diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000000..66b28b3485d --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,32 @@ +# +# An auto defined `clippy` feature was introduced, +# but it was found to clash with user defined features, +# so was renamed to `cargo-clippy`. +# +# If you want standard clippy run: +# RUSTFLAGS= cargo clippy +[target.'cfg(feature = "cargo-clippy")'] +rustflags = [ + "-Aclippy::all", + "-Dclippy::correctness", + "-Aclippy::if-same-then-else", + "-Aclippy::clone-double-ref", + "-Dclippy::complexity", + "-Aclippy::zero-prefixed-literal", # 00_1000_000 + "-Aclippy::type_complexity", # raison d'etre + "-Aclippy::nonminimal-bool", # maybe + "-Aclippy::borrowed-box", # Reasonable to fix this one + "-Aclippy::too-many-arguments", # (Turning this on would lead to) + "-Aclippy::unnecessary_cast", # Types may change + "-Aclippy::identity-op", # One case where we do 0 + + "-Aclippy::useless_conversion", # Types may change + "-Aclippy::unit_arg", # styalistic. + "-Aclippy::option-map-unit-fn", # styalistic + "-Aclippy::bind_instead_of_map", # styalistic + "-Aclippy::erasing_op", # E.g. 0 * DOLLARS + "-Aclippy::eq_op", # In tests we test equality. + "-Aclippy::while_immutable_condition", # false positives + "-Aclippy::needless_option_as_deref", # false positives + "-Aclippy::derivable_impls", # false positives + "-Aclippy::stable_sort_primitive", # prefer stable sort +] diff --git a/.github/pr-custom-review.yml b/.github/pr-custom-review.yml index f8c887c5f4a..fc26ee677f0 100644 --- a/.github/pr-custom-review.yml +++ b/.github/pr-custom-review.yml @@ -6,7 +6,7 @@ action-review-team: ci rules: - name: Runtime files check_type: changed_files - condition: ^parachains/runtimes/assets/(statemine|statemint)/src/[^/]+\.rs$|^parachains/runtimes/bridge-hubs/(bridge-hub-kusama|bridge-hub-polkadot)/src/[^/]+\.rs$|^parachains/runtimes/collectives/collectives-polkadot/src/[^/]+\.rs$|^parachains/common/src/[^/]+\.rs$ + condition: ^parachains/runtimes/assets/(asset-hub-kusama|asset-hub-polkadot)/src/[^/]+\.rs$|^parachains/runtimes/bridge-hubs/(bridge-hub-kusama|bridge-hub-polkadot)/src/[^/]+\.rs$|^parachains/runtimes/collectives/collectives-polkadot/src/[^/]+\.rs$|^parachains/common/src/[^/]+\.rs$ all_distinct: - min_approvals: 1 teams: @@ -19,12 +19,20 @@ rules: check_type: changed_files condition: include: .* - # excluding files from 'Runtime files' and 'CI files' rules - exclude: ^parachains/runtimes/assets/(statemine|statemint)/src/[^/]+\.rs$|^parachains/runtimes/bridge-hubs/(bridge-hub-kusama|bridge-hub-polkadot)/src/[^/]+\.rs$|^parachains/runtimes/collectives/collectives-polkadot/src/[^/]+\.rs$|^parachains/common/src/[^/]+\.rs$|^\.gitlab-ci\.yml|^scripts/ci/.*|^\.github/.* + # excluding files from 'Runtime files' and 'CI files' rules and `Bridges subtree files` + exclude: ^parachains/runtimes/assets/(asset-hub-kusama|asset-hub-polkadot)/src/[^/]+\.rs$|^parachains/runtimes/bridge-hubs/(bridge-hub-kusama|bridge-hub-polkadot)/src/[^/]+\.rs$|^parachains/runtimes/collectives/collectives-polkadot/src/[^/]+\.rs$|^parachains/common/src/[^/]+\.rs$|^\.gitlab-ci\.yml|^scripts/ci/.*|^\.github/.* min_approvals: 2 teams: - core-devs + # if there are any changes in the bridges subtree (in case of backport changes back to bridges repo) + - name: Bridges subtree files + check_type: changed_files + condition: ^bridges/.* + min_approvals: 1 + teams: + - bridges-core + - name: CI files check_type: changed_files condition: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a5ad2bd555e..c67f5bb97ad 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,7 +23,7 @@ jobs: run: rustup show - name: Rust cache - uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # v2.2.1 + uses: Swatinem/rust-cache@988c164c3d0e93c4dbab36aaf5bbeb77425b2894 # v2.4.0 - name: Build rustdocs run: SKIP_WASM_BUILD=1 cargo doc --all --no-deps @@ -32,7 +32,7 @@ jobs: run: echo "" > ./target/doc/index.html - name: Deploy documentation - uses: peaceiris/actions-gh-pages@de7ea6f8efb354206b205ef54722213d99067935 # v3.9.0 + uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3.9.3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_branch: gh-pages diff --git a/.github/workflows/fmt-check.yml b/.github/workflows/fmt-check.yml index 6c7a5f3f910..498e42527e3 100644 --- a/.github/workflows/fmt-check.yml +++ b/.github/workflows/fmt-check.yml @@ -13,28 +13,10 @@ jobs: matrix: os: ["ubuntu-latest"] runs-on: ${{ matrix.os }} + container: + image: paritytech/ci-linux:production steps: - - name: Install Rust nightly toolchain - uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.7 - with: - profile: minimal - toolchain: nightly - override: true - components: clippy, rustfmt - - - name: Cache Dependencies & Build Outputs - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 - name: Cargo fmt - uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # v1.0.3 - with: - command: fmt - args: --all -- --check + run: cargo +nightly fmt --all -- --check diff --git a/.github/workflows/release-20_extrinsic-ordering-check-from-bin.yml b/.github/workflows/release-20_extrinsic-ordering-check-from-bin.yml index 5a7d695ec98..2f4552b928f 100644 --- a/.github/workflows/release-20_extrinsic-ordering-check-from-bin.yml +++ b/.github/workflows/release-20_extrinsic-ordering-check-from-bin.yml @@ -14,7 +14,7 @@ on: required: true chain: description: The name of the chain under test. Usually, you would pass a local chain - default: statemine-local + default: asset-hub-kusama-local required: true jobs: diff --git a/.github/workflows/release-21_extrinsic-ordering-check-from-two.yml b/.github/workflows/release-21_extrinsic-ordering-check-from-two.yml index 7fde56ef1b2..79fa11b3f9c 100644 --- a/.github/workflows/release-21_extrinsic-ordering-check-from-two.yml +++ b/.github/workflows/release-21_extrinsic-ordering-check-from-two.yml @@ -28,14 +28,14 @@ jobs: fail-fast: false matrix: include: - - runtime: statemine - local: statemine-local + - runtime: asset-hub-kusama + local: asset-hub-kusama-local + relay: kusama-local + - runtime: asset-hub-polkadot + local: asset-hub-polkadot-local relay: polkadot-local - - runtime: statemint - local: statemint-local - relay: polkadot-local - - runtime: westmint - local: westmint-local + - runtime: asset-hub-westend + local: asset-hub-westend-local relay: polkadot-local - runtime: contracts-rococo local: contracts-rococo-local diff --git a/.github/workflows/release-30_create-draft.yml b/.github/workflows/release-30_create-draft.yml index 2ff64018252..b79f1948c16 100644 --- a/.github/workflows/release-30_create-draft.yml +++ b/.github/workflows/release-30_create-draft.yml @@ -45,11 +45,11 @@ jobs: matrix: include: - category: assets - runtime: statemine + runtime: asset-hub-kusama - category: assets - runtime: statemint + runtime: asset-hub-polkadot - category: assets - runtime: westmint + runtime: asset-hub-westend - category: bridge-hubs runtime: bridge-hub-polkadot - category: bridge-hubs @@ -126,7 +126,7 @@ jobs: path: cumulus ref: ${{ github.event.inputs.ref2 }} - - uses: ruby/setup-ruby@6cecb48364174b0952995175c55f9bf5527e6682 # v1.147.0 + - uses: ruby/setup-ruby@8a45918450651f5e4784b6031db26f4b9f76b251 # v1.150.0 with: ruby-version: 3.0.0 @@ -223,11 +223,11 @@ jobs: matrix: include: - category: assets - runtime: statemine + runtime: asset-hub-kusama - category: assets - runtime: statemint + runtime: asset-hub-polkadot - category: assets - runtime: westmint + runtime: asset-hub-westend - category: bridge-hubs runtime: bridge-hub-polkadot - category: bridge-hubs @@ -253,7 +253,7 @@ jobs: - name: Download artifacts uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 - - uses: ruby/setup-ruby@6cecb48364174b0952995175c55f9bf5527e6682 # v1.147.0 + - uses: ruby/setup-ruby@8a45918450651f5e4784b6031db26f4b9f76b251 # v1.150.0 with: ruby-version: 3.0.0 diff --git a/.github/workflows/srtool.yml b/.github/workflows/srtool.yml index 3ac4ff8be55..b717a12ce86 100644 --- a/.github/workflows/srtool.yml +++ b/.github/workflows/srtool.yml @@ -32,11 +32,11 @@ jobs: matrix: include: - category: assets - runtime: statemine + runtime: asset-hub-kusama - category: assets - runtime: statemint + runtime: asset-hub-polkadot - category: assets - runtime: westmint + runtime: asset-hub-westend - category: bridge-hubs runtime: bridge-hub-polkadot - category: bridge-hubs diff --git a/.gitignore b/.gitignore index 58abcc32cc5..225be857745 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,4 @@ polkadot_argument_parsing **/chains/ *.iml .env -bin **/._* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7166ace649f..7e7d2f252e2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ variables: CI_IMAGE: "paritytech/ci-linux:production" DOCKER_OS: "debian:stretch" ARCH: "x86_64" - ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.3.43" + ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.3.55" BUILDAH_IMAGE: "quay.io/buildah/stable:v1.29" BUILDAH_COMMAND: "buildah --storage-driver overlay2" diff --git a/BRIDGES.md b/BRIDGES.md new file mode 100644 index 00000000000..8766de92c17 --- /dev/null +++ b/BRIDGES.md @@ -0,0 +1,91 @@ +# Using Parity Bridges Common dependency (`git subtree`). + +In `./bridges` sub-directory you can find a `git subtree` imported version of: +[parity-bridges-common](https://github.com/paritytech/parity-bridges-common/) repository. + +(For regular Cumulus contributor 1. is relevant) \ +(For Cumulus maintainer 1. and 2. are relevant) \ +(For Bridges team 1. and 2. and 3. are relevant) + +# 1. How to fix broken Bridges code? + +To fix Bridges code simply create a commit in current (`Cumulus`) repo. Best if +the commit is isolated to changes in `./bridges` sub-directory, because it makes +it easier to import that change back to upstream repo. + +(Any changes to `bridges` subtree require Bridges team approve and they should manage backport to Bridges repo) + + +# 2. How to pull latest Bridges code to the `bridges` subtree +(in practice) + +The `bridges` repo has a stabilized branch `polkadot-staging` dedicated for releasing. + +``` +cd + +# this will update new git branches from bridges repo +# there could be unresolved conflicts, but dont worry, +# lots of them are caused because of removed unneeded files with patch step, +BRANCH=polkadot-staging ./scripts/bridges_update_subtree.sh fetch + +# so, after fetch and before solving conflicts just run patch, +# this will remove unneeded files and checks if subtree modules compiles +./scripts/bridges_update_subtree.sh patch + +# if there are conflicts, this could help, +# this removes locally deleted files at least (move changes to git stash for commit) +./scripts/bridges_update_subtree.sh merge + +# (optional) when conflicts resolved, you can check build again - should pass +# also important: this updates global Cargo.lock +./scripts/bridges_update_subtree.sh patch + +# add changes to the commit, first command `fetch` starts merge, +# so after all conflicts are solved and patch passes and compiles, +# then we need to finish merge with: +git merge --continue +```` + +# 3. How to pull latest Bridges code or contribute back? +(in theory) + +Note that it's totally fine to ping the **Bridges Team** to do that for you. The point +of adding the code as `git subtree` is to **reduce maintenance cost** for Cumulus/Polkadot +developers. + +If you still would like to either update the code to match latest code from the repo +or create an upstream PR read below. The following commands should be run in the +current (`polkadot`) repo. + +1. Add Bridges repo as a local remote: +``` +$ git remote add -f bridges git@github.com:paritytech/parity-bridges-common.git +``` + +If you plan to contribute back, consider forking the repository on Github and adding +your personal fork as a remote as well. +``` +$ git remote add -f my-bridges git@github.com:tomusdrw/parity-bridges-common.git +``` + +2. To update Bridges: +``` +$ git fetch bridges polkadot-staging +$ git subtree pull --prefix=bridges bridges polkadot-staging --squash +```` + +We use `--squash` to avoid adding individual commits and rather squashing them +all into one. + +3. Clean unneeded files here: +``` +./bridges/scripts/verify-pallets-build.sh --ignore-git-state --no-revert +``` + +4. Contributing back to Bridges (creating upstream PR) +``` +$ git subtree push --prefix=bridges my-bridges polkadot-staging +``` +This command will push changes to your personal fork of Bridges repo, from where +you can simply create a PR to the main repo. diff --git a/Cargo.lock b/Cargo.lock index 9a6ff16e387..12a740f3e36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,22 +12,13 @@ dependencies = [ "regex", ] -[[package]] -name = "addr2line" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" -dependencies = [ - "gimli 0.26.1", -] - [[package]] name = "addr2line" version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli 0.27.0", + "gimli", ] [[package]] @@ -42,7 +33,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -51,10 +42,20 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", ] +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array 0.14.7", +] + [[package]] name = "aes" version = "0.6.0" @@ -79,17 +80,14 @@ dependencies = [ ] [[package]] -name = "aes-gcm" -version = "0.8.0" +name = "aes" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5278b5fabbb9bd46e24aa69b2fdea62c99088e0a950a9be40e3e0101298f88da" +checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" dependencies = [ - "aead 0.3.2", - "aes 0.6.0", - "cipher 0.2.5", - "ctr 0.6.0", - "ghash 0.3.1", - "subtle", + "cfg-if", + "cipher 0.4.4", + "cpufeatures", ] [[package]] @@ -106,6 +104,20 @@ dependencies = [ "subtle", ] +[[package]] +name = "aes-gcm" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "209b47e8954a928e1d72e86eca7000ebb6655fe1436d33eefc2201cad027e237" +dependencies = [ + "aead 0.5.2", + "aes 0.8.2", + "cipher 0.4.4", + "ctr 0.9.2", + "ghash 0.5.0", + "subtle", +] + [[package]] name = "aes-soft" version = "0.6.4" @@ -132,37 +144,61 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", "once_cell", "version_check", ] [[package]] name = "ahash" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom 0.2.8", + "getrandom 0.2.9", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.18" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" dependencies = [ "memchr", ] [[package]] name = "always-assert" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf688625d06217d5b1bb0ea9d9c44a1635fd0ee3534466388d18203174f4d11" +checksum = "4436e0292ab1bb631b42973c61205e704475fe8126af845c8d923c0996328127" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] [[package]] name = "anes" @@ -181,11 +217,11 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ - "anstyle 1.0.0", + "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", @@ -194,12 +230,6 @@ dependencies = [ "utf8parse", ] -[[package]] -name = "anstyle" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba0b55c2201aa802adb684e7963ce2c3191675629e7df899774331e3ac747cf" - [[package]] name = "anstyle" version = "1.0.0" @@ -226,25 +256,25 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ - "anstyle 1.0.0", + "anstyle", "windows-sys 0.48.0", ] [[package]] name = "anyhow" -version = "1.0.69" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "approx" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "072df7202e63b127ab55acfe16ce97013d5b97bf160489336d3f1840fd78e99e" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" dependencies = [ "num-traits", ] @@ -263,15 +293,15 @@ checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" [[package]] name = "array-bytes" -version = "6.0.0" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22f72e9d6fac4bc80778ea470b20197b88d28c292bb7d60c3fb099280003cd19" +checksum = "d9b1c5a481ec30a5abd8dfbd94ab5cf1bb4e9a66be7f1b3b322f2f1170c200fd" [[package]] name = "arrayref" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" @@ -298,14 +328,14 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.21", ] [[package]] name = "asn1-rs" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf6690c370453db30743b373a60ba498fc0d6d83b11f4abfd87a84a075db5dd4" +checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" dependencies = [ "asn1-rs-derive 0.4.0", "asn1-rs-impl", @@ -314,7 +344,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.21", ] [[package]] @@ -352,33 +382,314 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "asn1_der" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22d1f4b888c298a027c99dc9048015fac177587de20fc30232a057dfbe24a21" - [[package]] name = "assert_cmd" version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" dependencies = [ - "anstyle 1.0.0", - "bstr 1.1.0", + "anstyle", + "bstr", "doc-comment", - "predicates 3.0.1", + "predicates 3.0.3", "predicates-core", "predicates-tree", "wait-timeout", ] -[[package]] -name = "assert_matches" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" - +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + +[[package]] +name = "asset-hub-kusama-integration-tests" +version = "1.0.0" +dependencies = [ + "asset-hub-kusama-runtime", + "frame-support", + "frame-system", + "integration-tests-common", + "pallet-assets", + "pallet-balances", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "penpal-runtime", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime", + "polkadot-runtime-parachains", + "sp-core", + "sp-runtime", + "sp-weights", + "xcm", + "xcm-emulator", + "xcm-executor", +] + +[[package]] +name = "asset-hub-kusama-runtime" +version = "0.9.420" +dependencies = [ + "asset-test-utils", + "assets-common", + "cumulus-pallet-aura-ext", + "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-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "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-message-queue", + "pallet-multisig", + "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", + "pallet-xcm-benchmarks", + "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-integration-tests" +version = "1.0.0" +dependencies = [ + "asset-hub-polkadot-runtime", + "frame-support", + "frame-system", + "integration-tests-common", + "pallet-assets", + "pallet-balances", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "penpal-runtime", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime", + "polkadot-runtime-parachains", + "sp-core", + "sp-runtime", + "sp-weights", + "xcm", + "xcm-emulator", + "xcm-executor", +] + +[[package]] +name = "asset-hub-polkadot-runtime" +version = "0.9.420" +dependencies = [ + "asset-test-utils", + "assets-common", + "cumulus-pallet-aura-ext", + "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-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-message-queue", + "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", + "pallet-xcm-benchmarks", + "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-integration-tests" +version = "1.0.0" +dependencies = [ + "asset-hub-westend-runtime", + "frame-support", + "frame-system", + "integration-tests-common", + "pallet-assets", + "pallet-balances", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "penpal-runtime", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime", + "polkadot-runtime-parachains", + "sp-core", + "sp-runtime", + "sp-weights", + "westend-runtime", + "xcm", + "xcm-emulator", + "xcm-executor", +] + +[[package]] +name = "asset-hub-westend-runtime" +version = "0.9.420" +dependencies = [ + "asset-test-utils", + "assets-common", + "cumulus-pallet-aura-ext", + "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-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-message-queue", + "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", + "pallet-xcm-benchmarks", + "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", + "substrate-wasm-builder", + "westend-runtime-constants", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "asset-test-utils" version = "1.0.0" @@ -399,6 +710,7 @@ dependencies = [ "pallet-xcm", "parachain-info", "parachains-common", + "parachains-runtimes-test-utils", "parity-scale-codec", "polkadot-parachain", "sp-consensus-aura", @@ -436,35 +748,36 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" dependencies = [ - "concurrent-queue 2.1.0", + "concurrent-queue", "event-listener", "futures-core", ] [[package]] name = "async-io" -version = "1.6.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ - "concurrent-queue 1.2.2", + "async-lock", + "autocfg", + "cfg-if", + "concurrent-queue", "futures-lite", - "libc", "log", - "once_cell", "parking", "polling", + "rustix 0.37.19", "slab", "socket2", "waker-fn", - "winapi", ] [[package]] name = "async-lock" -version = "2.4.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a8ea61bf9947a1007c5cada31e647dbc77b103c679858150003ba697ea798b" +checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" dependencies = [ "event-listener", ] @@ -477,7 +790,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -488,7 +801,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -506,9 +819,9 @@ dependencies = [ [[package]] name = "atomic-waker" -version = "1.0.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" +checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" [[package]] name = "atty" @@ -533,20 +846,20 @@ version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" dependencies = [ - "addr2line 0.19.0", + "addr2line", "cc", "cfg-if", "libc", "miniz_oxide 0.6.2", - "object 0.30.0", + "object", "rustc-demangle", ] [[package]] name = "base-x" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" +checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" [[package]] name = "base16ct" @@ -562,21 +875,27 @@ checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "base64ct" -version = "1.5.2" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2b2456fd614d856680dcd9fcc660a51a820fa09daef2e49772b56a193c8474" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "beef" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bed554bd50246729a1ec158d08aa3235d1b69d94ad120ebe187e28894787e736" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" dependencies = [ "serde", ] @@ -584,7 +903,7 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "hash-db", "log", @@ -601,9 +920,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.64.0" +version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ "bitflags", "cexpr", @@ -611,12 +930,13 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", + "prettyplease 0.2.6", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -639,11 +959,11 @@ dependencies = [ [[package]] name = "blake2" -version = "0.10.4" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -654,32 +974,32 @@ checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", "arrayvec 0.7.2", - "constant_time_eq 0.2.4", + "constant_time_eq", ] [[package]] name = "blake2s_simd" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db539cc2b5f6003621f1cd9ef92d7ded8ea5232c7de0f9faa2de251cd98730d4" +checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", "arrayvec 0.7.2", - "constant_time_eq 0.1.5", + "constant_time_eq", ] [[package]] name = "blake3" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f" +checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" dependencies = [ "arrayref", "arrayvec 0.7.2", "cc", "cfg-if", - "constant_time_eq 0.1.5", - "digest 0.10.6", + "constant_time_eq", + "digest 0.10.7", ] [[package]] @@ -700,16 +1020,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] name = "block-buffer" -version = "0.10.0" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -739,9 +1059,9 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "bounded-collections" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a071c348a5ef6da1d3a87166b408170b46002382b1dda83992b5c2208cefb370" +checksum = "07fbd1d11282a1eb134d3c3b7cf8ce213b5161c6e5f73fb1b98618482c606b64" dependencies = [ "log", "parity-scale-codec", @@ -758,6 +1078,192 @@ dependencies = [ "thiserror", ] +[[package]] +name = "bp-bridge-hub-cumulus" +version = "0.1.0" +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" +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" +dependencies = [ + "bp-bridge-hub-cumulus", + "bp-messages", + "bp-runtime", + "frame-support", + "sp-api", + "sp-std", +] + +[[package]] +name = "bp-header-chain" +version = "0.1.0" +dependencies = [ + "bp-runtime", + "bp-test-utils", + "finality-grandpa", + "frame-support", + "hex", + "hex-literal 0.4.1", + "parity-scale-codec", + "scale-info", + "serde", + "sp-consensus-grandpa", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "bp-messages" +version = "0.1.0" +dependencies = [ + "bp-header-chain", + "bp-runtime", + "frame-support", + "hex", + "hex-literal 0.4.1", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-std", +] + +[[package]] +name = "bp-parachains" +version = "0.1.0" +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" +dependencies = [ + "bp-messages", + "bp-runtime", + "frame-support", + "frame-system", + "hex", + "parity-scale-codec", + "parity-util-mem", + "scale-info", + "serde", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "bp-relayers" +version = "0.1.0" +dependencies = [ + "bp-messages", + "bp-runtime", + "frame-support", + "hex", + "hex-literal 0.4.1", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "bp-rococo" +version = "0.1.0" +dependencies = [ + "bp-header-chain", + "bp-polkadot-core", + "bp-runtime", + "frame-support", + "sp-api", +] + +[[package]] +name = "bp-runtime" +version = "0.1.0" +dependencies = [ + "frame-support", + "frame-system", + "hash-db", + "hex-literal 0.4.1", + "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" +dependencies = [ + "bp-header-chain", + "bp-parachains", + "bp-polkadot-core", + "bp-runtime", + "ed25519-dalek", + "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" +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" @@ -888,7 +1394,17 @@ dependencies = [ name = "bridge-hub-rococo-runtime" version = "0.1.0" 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-hub-test-utils", + "bridge-runtime-common", "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", "cumulus-pallet-session-benchmarking", @@ -909,6 +1425,10 @@ dependencies = [ "pallet-aura", "pallet-authorship", "pallet-balances", + "pallet-bridge-grandpa", + "pallet-bridge-messages", + "pallet-bridge-parachains", + "pallet-bridge-relayers", "pallet-collator-selection", "pallet-message-queue", "pallet-multisig", @@ -935,23 +1455,98 @@ dependencies = [ "sp-core", "sp-inherents", "sp-io", + "sp-keyring", "sp-offchain", "sp-runtime", - "sp-session", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "static_assertions", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "bridge-hub-test-utils" +version = "0.1.0" +dependencies = [ + "assert_matches", + "asset-test-utils", + "bp-bridge-hub-rococo", + "bp-bridge-hub-wococo", + "bp-header-chain", + "bp-messages", + "bp-parachains", + "bp-polkadot-core", + "bp-relayers", + "bp-runtime", + "bp-test-utils", + "bridge-runtime-common", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-bridge-grandpa", + "pallet-bridge-messages", + "pallet-bridge-parachains", + "pallet-bridge-relayers", + "pallet-collator-selection", + "pallet-session", + "pallet-utility", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parachain-info", + "parachains-runtimes-test-utils", + "parity-scale-codec", + "sp-core", + "sp-io", + "sp-keyring", + "sp-runtime", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "bridge-runtime-common" +version = "0.1.0" +dependencies = [ + "bp-header-chain", + "bp-messages", + "bp-parachains", + "bp-polkadot-core", + "bp-relayers", + "bp-runtime", + "bp-test-utils", + "frame-support", + "frame-system", + "hash-db", + "log", + "pallet-balances", + "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-transaction-pool", - "sp-version", - "substrate-wasm-builder", + "sp-trie", + "static_assertions", "xcm", "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "bridge-hub-test-utils" -version = "0.1.0" -dependencies = [ - "asset-test-utils", ] [[package]] @@ -962,18 +1557,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "memchr", -] - -[[package]] -name = "bstr" -version = "1.1.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b" +checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" dependencies = [ "memchr", "once_cell", @@ -992,15 +1578,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.8.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "byte-slice-cast" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byte-tools" @@ -1010,9 +1596,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c041d3eab048880cb0b86b256447da3f18859a163c3b8d8893f4e6368abe6393" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" [[package]] name = "byteorder" @@ -1037,17 +1623,11 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "cache-padded" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" - [[package]] name = "camino" -version = "1.1.2" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77df041dc383319cc661b428b6961a005db4d6808d5e12536931b1ca9556055" +checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" dependencies = [ "serde", ] @@ -1069,12 +1649,21 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.16", + "semver 1.0.17", "serde", "serde_json", "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" @@ -1083,9 +1672,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" dependencies = [ "jobserver", ] @@ -1112,9 +1701,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.10.3" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +checksum = "c8790cf1286da485c72cf5fc7aeba308438800036ec67d89425924c4807268c9" dependencies = [ "smallvec", ] @@ -1158,22 +1747,24 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.19" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ - "libc", - "num-integer", + "android-tzdata", + "iana-time-zone", + "js-sys", "num-traits", - "time 0.1.44", + "time 0.1.45", + "wasm-bindgen", "winapi", ] [[package]] name = "ciborium" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" dependencies = [ "ciborium-io", "ciborium-ll", @@ -1182,15 +1773,15 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" [[package]] name = "ciborium-ll" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" dependencies = [ "ciborium-io", "half", @@ -1204,7 +1795,7 @@ checksum = "f6ed9c8b2d17acb8110c46f1da5bf4a696d745e1474a16db0cd2b49cd0249bf2" dependencies = [ "core2", "multibase", - "multihash", + "multihash 0.16.3", "serde", "unsigned-varint", ] @@ -1215,7 +1806,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -1224,7 +1815,17 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", ] [[package]] @@ -1238,9 +1839,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.3.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa66045b9cb23c2e9c1520732030608b02ee07e5cfaa5a521ec15ded7fa24c90" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" dependencies = [ "glob", "libc", @@ -1249,21 +1850,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" -dependencies = [ - "bitflags", - "clap_lex 0.2.2", - "indexmap", - "textwrap", -] - -[[package]] -name = "clap" -version = "4.2.3" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f9152d70e42172fdb87de2efd7327160beee37886027cf86f30a233d5b30b4" +checksum = "b4ed2379f8603fa2b7509891660e802b88c70a79a6427a70abb5968054de2c28" dependencies = [ "clap_builder", "clap_derive", @@ -1272,49 +1861,40 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.2.3" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e067b220911598876eb55d52725ddcc201ffe3f0904018195973bc5b012ea2ca" +checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" dependencies = [ "anstream", - "anstyle 1.0.0", + "anstyle", "bitflags", - "clap_lex 0.4.1", + "clap_lex", "strsim", ] [[package]] name = "clap_derive" -version = "4.2.0" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" +checksum = "59e9ef9a08ee1c0e1f2e162121665ac45ac3783b0f897db7244ae75ad9a8f65b" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.15", -] - -[[package]] -name = "clap_lex" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5538cd660450ebeb4234cfecf8f2284b844ffc4c50531e66d584ad5b91293613" -dependencies = [ - "os_str_bytes", + "syn 2.0.18", ] [[package]] name = "clap_lex" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "coarsetime" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "454038500439e141804c655b4cd1bc6a70bcb95cd2bc9463af5661b6956f0e46" +checksum = "a90d114103adbc625300f346d4d09dfb4ab1c4a8df6868435dd903392ecf4354" dependencies = [ "libc", "once_cell", @@ -1429,31 +2009,41 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "6.0.0" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121d8a5b0346092c18a4b2fd6f620d7a06f0eb7ac0a45860939a0884bc579c56" +checksum = "7e959d788268e3bf9d35ace83e81b124190378e4c91c9067524675e33394b8ba" dependencies = [ "strum", "strum_macros", "unicode-width", ] +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + [[package]] name = "concurrent-queue" -version = "1.2.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" dependencies = [ - "cache-padded", + "crossbeam-utils", ] [[package]] -name = "concurrent-queue" -version = "2.1.0" +name = "console" +version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" +checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" dependencies = [ - "crossbeam-utils", + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.45.0", ] [[package]] @@ -1464,15 +2054,9 @@ checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "constant_time_eq" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ad85c1f65dc7b37604eb0e89748faf0b9653065f2a8ef69f96a687ec1e9279" +checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" [[package]] name = "contracts-rococo-runtime" @@ -1545,9 +2129,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core-foundation" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" dependencies = [ "core-foundation-sys", "libc", @@ -1555,9 +2139,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "core2" @@ -1589,43 +2173,36 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.1" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] -[[package]] -name = "cpuid-bool" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" - [[package]] name = "cranelift-bforest" -version = "0.93.1" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7379abaacee0f14abf3204a7606118f0465785252169d186337bcb75030815a" +checksum = "1277fbfa94bc82c8ec4af2ded3e639d49ca5f7f3c7eeab2c66accd135ece4e70" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.93.1" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9489fa336927df749631f1008007ced2871068544f40a202ce6d93fbf2366a7b" +checksum = "c6e8c31ad3b2270e9aeec38723888fe1b0ace3bea2b06b3f749ccf46661d3220" dependencies = [ - "arrayvec 0.7.2", "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-entity", "cranelift-isle", - "gimli 0.26.1", - "hashbrown 0.12.3", + "gimli", + "hashbrown 0.13.2", "log", "regalloc2", "smallvec", @@ -1634,33 +2211,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.93.1" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05bbb67da91ec721ed57cef2f7c5ef7728e1cd9bde9ffd3ef8601022e73e3239" +checksum = "c8ac5ac30d62b2d66f12651f6b606dbdfd9c2cfd0908de6b387560a277c5c9da" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.93.1" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418ecb2f36032f6665dc1a5e2060a143dbab41d83b784882e97710e890a7a16d" +checksum = "dd82b8b376247834b59ed9bdc0ddeb50f517452827d4a11bccf5937b213748b8" [[package]] name = "cranelift-entity" -version = "0.93.1" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cf583f7b093f291005f9fb1323e2c37f6ee4c7909e39ce016b2e8360d461705" +checksum = "40099d38061b37e505e63f89bab52199037a72b931ad4868d9089ff7268660b0" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.93.1" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b66bf9e916f57fbbd0f7703ec6286f4624866bf45000111627c70d272c8dda1" +checksum = "64a25d9d0a0ae3079c463c34115ec59507b4707175454f0eee0891e83e30e82d" dependencies = [ "cranelift-codegen", "log", @@ -1670,15 +2247,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.93.1" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "649782a39ce99798dd6b4029e2bb318a2fbeaade1b4fa25330763c10c65bc358" +checksum = "80de6a7d0486e4acbd5f9f87ec49912bf4c8fb6aea00087b989685460d4469ba" [[package]] name = "cranelift-native" -version = "0.93.1" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "937e021e089c51f9749d09e7ad1c4f255c2f8686cb8c3df63a34b3ec9921bc41" +checksum = "bb6b03e0e03801c4b3fd8ce0758a94750c07a44e7944cc0ffbf0d3f2e7c79b00" dependencies = [ "cranelift-codegen", "libc", @@ -1687,9 +2264,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.93.1" +version = "0.95.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d850cf6775477747c9dfda9ae23355dd70512ffebc70cf82b85a5b111ae668b5" +checksum = "ff3220489a3d928ad91e59dd7aeaa8b3de18afb554a6211213673a71c90737ac" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1703,44 +2280,44 @@ dependencies = [ [[package]] name = "crc" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53757d12b596c16c78b83458d732a5d1a17ab3f53f2f7412f6fb57cc8a140ab3" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" dependencies = [ "crc-catalog", ] [[package]] name = "crc-catalog" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d0165d2900ae6778e36e80bbc4da3b5eefccee9ba939761f9c2882a5d9af3ff" +checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" [[package]] name = "crc32fast" -version = "1.3.0" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ "cfg-if", ] [[package]] name = "criterion" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" dependencies = [ "anes", - "atty", "cast", "ciborium", - "clap 3.2.22", + "clap", "criterion-plot", "futures", + "is-terminal", "itertools", - "lazy_static", "num-traits", + "once_cell", "oorandom", "plotters", "rayon", @@ -1765,9 +2342,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.1" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -1775,9 +2352,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -1786,22 +2363,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.5" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ + "autocfg", "cfg-if", "crossbeam-utils", - "lazy_static", - "memoffset 0.6.5", + "memoffset 0.8.0", "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" dependencies = [ "cfg-if", "crossbeam-utils", @@ -1828,7 +2405,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", "subtle", "zeroize", @@ -1836,11 +2413,11 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2538c4e68e52548bacb3e83ac549f903d44f011ac9d5abb5e132e67d0808f7" +checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", "subtle", "zeroize", @@ -1848,11 +2425,12 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.3" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", + "rand_core 0.6.4", "typenum", ] @@ -1862,17 +2440,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.6", - "subtle", -] - -[[package]] -name = "crypto-mac" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" -dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -1882,33 +2450,33 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] [[package]] name = "ctr" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" +checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" dependencies = [ - "cipher 0.2.5", + "cipher 0.3.0", ] [[package]] name = "ctr" -version = "0.8.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ - "cipher 0.3.0", + "cipher 0.4.4", ] [[package]] name = "cumulus-client-cli" version = "0.1.0" dependencies = [ - "clap 4.2.3", + "clap", "parity-scale-codec", "sc-chain-spec", "sc-cli", @@ -1952,10 +2520,17 @@ name = "cumulus-client-consensus-aura" version = "0.1.0" dependencies = [ "async-trait", + "cumulus-client-collator", "cumulus-client-consensus-common", + "cumulus-client-consensus-proposer", "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-relay-chain-interface", "futures", "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-overseer", + "polkadot-primitives", "sc-client-api", "sc-consensus", "sc-consensus-aura", @@ -1971,6 +2546,8 @@ dependencies = [ "sp-inherents", "sp-keystore", "sp-runtime", + "sp-state-machine", + "sp-timestamp", "substrate-prometheus-endpoint", "tracing", ] @@ -1995,12 +2572,28 @@ dependencies = [ "schnellru", "sp-blockchain", "sp-consensus", + "sp-core", "sp-runtime", "sp-tracing", "sp-trie", + "substrate-prometheus-endpoint", "tracing", ] +[[package]] +name = "cumulus-client-consensus-proposer" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "cumulus-primitives-parachain-inherent", + "sp-consensus", + "sp-inherents", + "sp-runtime", + "sp-state-machine", + "thiserror", +] + [[package]] name = "cumulus-client-consensus-relay-chain" version = "0.1.0" @@ -2180,7 +2773,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -2388,7 +2981,7 @@ dependencies = [ name = "cumulus-relay-chain-minimal-node" version = "0.1.0" dependencies = [ - "array-bytes 6.0.0", + "array-bytes 6.1.0", "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", @@ -2497,8 +3090,8 @@ dependencies = [ name = "cumulus-test-relay-validation-worker-provider" version = "0.1.0" dependencies = [ - "polkadot-node-core-pvf-worker", - "toml 0.7.3", + "polkadot-node-core-pvf", + "toml 0.7.4", ] [[package]] @@ -2538,7 +3131,7 @@ name = "cumulus-test-service" version = "0.1.0" dependencies = [ "async-trait", - "clap 4.2.3", + "clap", "criterion", "cumulus-client-cli", "cumulus-client-consensus-common", @@ -2632,16 +3225,16 @@ dependencies = [ "cfg-if", "fiat-crypto", "packed_simd_2", - "platforms 3.0.2", + "platforms", "subtle", "zeroize", ] [[package]] name = "cxx" -version = "1.0.80" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" +checksum = "109308c20e8445959c2792e81871054c6a17e6976489a93d2769641a2ba5839c" dependencies = [ "cc", "cxxbridge-flags", @@ -2651,9 +3244,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.80" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" +checksum = "daf4c6755cdf10798b97510e0e2b3edb9573032bd9379de8fffa59d68165494f" dependencies = [ "cc", "codespan-reporting", @@ -2661,31 +3254,31 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "cxxbridge-flags" -version = "1.0.80" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" +checksum = "882074421238e84fe3b4c65d0081de34e5b323bf64555d3e61991f76eb64a7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.80" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" +checksum = "4a076022ece33e7686fb76513518e219cca4fce5750a8ae6d1ce6c0f48fd1af9" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "darling" -version = "0.14.2" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ "darling_core", "darling_macro", @@ -2693,9 +3286,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.2" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", @@ -2707,9 +3300,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.14.2" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core", "quote", @@ -2718,15 +3311,15 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" [[package]] name = "data-encoding-macro" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86927b7cd2fe88fa698b87404b287ab98d1a0063a34071d92e575b72d3029aca" +checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -2734,9 +3327,9 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db" +checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" dependencies = [ "data-encoding", "syn 1.0.109", @@ -2744,9 +3337,9 @@ dependencies = [ [[package]] name = "der" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dd2ae565c0a381dde7fade45fce95984c568bdcb4700a4fdbe3175e0380b2f" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" dependencies = [ "const-oid", "pem-rfc7468", @@ -2755,9 +3348,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.1" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc906908ea6458456e5eaa160a9c08543ec3d1e6f71e2235cedd660cb65f9df0" +checksum = "56acb310e15652100da43d130af8d97b509e95af61aab1c5a7939ef24337ee17" dependencies = [ "const-oid", "zeroize", @@ -2779,11 +3372,11 @@ dependencies = [ [[package]] name = "der-parser" -version = "8.1.0" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d4bc9b0db0a0df9ae64634ac5bdefb7afcb534e182275ca0beadbe486701c1" +checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" dependencies = [ - "asn1-rs 0.5.1", + "asn1-rs 0.5.2", "displaydoc", "nom", "num-bigint", @@ -2878,16 +3471,17 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.0", + "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] @@ -2913,9 +3507,9 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", @@ -2935,13 +3529,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -2950,6 +3544,33 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "docify" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18b972b74c30cbe838fc6a07665132ff94f257350e26fd01d80bc59ee7fcf129" +dependencies = [ + "docify_macros", +] + +[[package]] +name = "docify_macros" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c93004d1011191c56df9e853dca42f2012e7488638bcd5078935f5ce43e06cf3" +dependencies = [ + "common-path", + "derive-syn-parse", + "lazy_static", + "prettyplease 0.2.6", + "proc-macro2", + "quote", + "regex", + "syn 2.0.18", + "termcolor", + "walkdir", +] + [[package]] name = "downcast" version = "0.11.0" @@ -2964,9 +3585,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.2" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5caaa75cbd2b960ff1e5392d2cfb1f44717fffe12fc1f32b7b5d1267f99732a6" +checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" [[package]] name = "dyn-clonable" @@ -3001,7 +3622,7 @@ version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ - "der 0.6.0", + "der 0.6.1", "elliptic-curve 0.12.3", "rfc6979 0.3.1", "signature 1.6.4", @@ -3009,14 +3630,16 @@ dependencies = [ [[package]] name = "ecdsa" -version = "0.16.1" +version = "0.16.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1b0a1222f8072619e8a6b667a854020a03d363738303203c09468b3424a420a" +checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" dependencies = [ - "der 0.7.1", - "elliptic-curve 0.13.2", + "der 0.7.6", + "digest 0.10.7", + "elliptic-curve 0.13.5", "rfc6979 0.4.0", - "signature 2.0.0", + "signature 2.1.0", + "spki 0.7.2", ] [[package]] @@ -3038,7 +3661,7 @@ dependencies = [ "ed25519", "rand 0.7.3", "serde", - "sha2 0.9.8", + "sha2 0.9.9", "zeroize", ] @@ -3052,15 +3675,15 @@ dependencies = [ "hashbrown 0.12.3", "hex", "rand_core 0.6.4", - "sha2 0.9.8", + "sha2 0.9.9", "zeroize", ] [[package]] name = "either" -version = "1.6.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" @@ -3070,10 +3693,10 @@ checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ "base16ct 0.1.1", "crypto-bigint 0.4.9", - "der 0.6.0", - "digest 0.10.6", + "der 0.6.1", + "digest 0.10.7", "ff 0.12.1", - "generic-array 0.14.6", + "generic-array 0.14.7", "group 0.12.1", "hkdf", "pem-rfc7468", @@ -3086,23 +3709,29 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.2" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea5a92946e8614bb585254898bb7dd1ddad241ace60c52149e3765e34cc039d" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" dependencies = [ "base16ct 0.2.0", - "crypto-bigint 0.5.1", - "digest 0.10.6", + "crypto-bigint 0.5.2", + "digest 0.10.7", "ff 0.13.0", - "generic-array 0.14.6", + "generic-array 0.14.7", "group 0.13.0", - "pkcs8 0.10.1", + "pkcs8 0.10.2", "rand_core 0.6.4", - "sec1 0.7.1", + "sec1 0.7.2", "subtle", "zeroize", ] +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "enum-as-inner" version = "0.5.1" @@ -3132,28 +3761,28 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "enumn" -version = "0.1.5" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038b1afa59052df211f9efd58f8b1d84c242935ede1c3dbaed26b018a9e06ae2" +checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "env_logger" -version = "0.7.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" dependencies = [ "atty", - "humantime 1.3.0", + "humantime", "log", "regex", "termcolor", @@ -3161,12 +3790,12 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" dependencies = [ - "atty", - "humantime 2.1.0", + "humantime", + "is-terminal", "log", "regex", "termcolor", @@ -3180,41 +3809,57 @@ checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" [[package]] name = "errno" -version = "0.2.8" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] -name = "errno" -version = "0.3.0" +name = "errno-dragonfly" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" dependencies = [ - "errno-dragonfly", + "cc", "libc", - "windows-sys 0.45.0", ] [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "ethbloom" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" dependencies = [ - "cc", - "libc", + "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.1" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "exit-future" @@ -3272,7 +3917,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -3289,9 +3934,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] @@ -3358,24 +4003,24 @@ checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" [[package]] name = "file-per-thread-logger" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fdbe0d94371f9ce939b555dd342d0686cc4c0cadbcd4b61d70af5ff97eb4126" +checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" dependencies = [ - "env_logger 0.7.1", + "env_logger 0.10.0", "log", ] [[package]] name = "filetime" -version = "0.2.16" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0408e2626025178a6a7f7ffc05a25bc47103229f19c113755de7bf63816290c" +checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.10", - "winapi", + "redox_syscall 0.2.16", + "windows-sys 0.48.0", ] [[package]] @@ -3408,21 +4053,19 @@ dependencies = [ [[package]] name = "fixedbitset" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "398ea4fabe40b9b0d885340a2a991a44c8a645624075ad966d21f88688e2b69e" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.22" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ - "cfg-if", "crc32fast", - "libc", "libz-sys", - "miniz_oxide 0.4.4", + "miniz_oxide 0.7.1", ] [[package]] @@ -3443,7 +4086,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", ] @@ -3466,7 +4109,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "frame-support-procedural", @@ -3491,12 +4134,12 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "Inflector", "array-bytes 4.2.0", "chrono", - "clap 4.2.3", + "clap", "comfy-table", "frame-benchmarking", "frame-support", @@ -3538,18 +4181,18 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -3566,7 +4209,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "frame-system", @@ -3595,10 +4238,11 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-recursion", "futures", + "indicatif", "jsonrpsee", "log", "parity-scale-codec", @@ -3606,14 +4250,16 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", + "spinners", "substrate-rpc-client", "tokio", + "tokio-retry", ] [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "bitflags", "environmental", @@ -3622,6 +4268,7 @@ dependencies = [ "impl-trait-for-tuples", "k256", "log", + "macro_magic", "once_cell", "parity-scale-codec", "paste", @@ -3632,6 +4279,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-core-hashing-proc-macro", + "sp-debug-derive", "sp-inherents", "sp-io", "sp-runtime", @@ -3646,46 +4294,48 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "Inflector", "cfg-expr", "derive-syn-parse", "frame-support-procedural-tools", "itertools", + "macro_magic", "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ + "cfg-if", "frame-support", "log", "parity-scale-codec", @@ -3702,7 +4352,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -3717,7 +4367,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "sp-api", @@ -3726,7 +4376,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "parity-scale-codec", @@ -3737,9 +4387,9 @@ dependencies = [ [[package]] name = "fs-err" -version = "2.6.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ebd3504ad6116843b8375ad70df74e7bfe83cac77a1f3fe73200c844d43bfe0" +checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" [[package]] name = "fs2" @@ -3753,21 +4403,14 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea55201cc351fdb478217c0fb641b59813da9b4efe4c414a9d8f989a657d149" +checksum = "7672706608ecb74ab2e055c68327ffc25ae4cac1e12349204fd5fb0f3487cce2" dependencies = [ - "libc", - "rustix 0.35.13", - "winapi", + "rustix 0.37.19", + "windows-sys 0.48.0", ] -[[package]] -name = "fs_extra" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" - [[package]] name = "funty" version = "2.0.0" @@ -3825,9 +4468,9 @@ checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-lite" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ "fastrand", "futures-core", @@ -3846,7 +4489,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -3856,7 +4499,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" dependencies = [ "futures-io", - "rustls 0.20.7", + "rustls 0.20.8", "webpki 0.22.0", ] @@ -3916,9 +4559,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -3948,9 +4591,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", @@ -3959,60 +4602,89 @@ dependencies = [ [[package]] name = "ghash" -version = "0.3.1" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" +checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" dependencies = [ "opaque-debug 0.3.0", - "polyval 0.4.5", + "polyval 0.5.3", ] [[package]] name = "ghash" -version = "0.4.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" dependencies = [ "opaque-debug 0.3.0", - "polyval 0.5.3", + "polyval 0.6.0", ] [[package]] name = "gimli" -version = "0.26.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" dependencies = [ "fallible-iterator", "indexmap", "stable_deref_trait", ] -[[package]] -name = "gimli" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793" - [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10463d9ff00a2a068db14231982f5132edebad0d7660cd956a1c30292dbcbfbd" +checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "aho-corasick", - "bstr 0.2.17", + "aho-corasick 0.7.20", + "bstr", "fnv", "log", "regex", ] +[[package]] +name = "glutton-runtime" +version = "1.0.0" +dependencies = [ + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcm", + "cumulus-primitives-core", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-try-runtime", + "pallet-glutton", + "pallet-sudo", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-block-builder", + "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 = "group" version = "0.12.1" @@ -4037,9 +4709,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b91535aa35fea1523ad1b86cb6b53c28e0ae566ba4a460f4457e936cad7c6f" +checksum = "d357c7ae988e7d2182f7d7871d0b963962420b0678b0997ce7de72001aeab782" dependencies = [ "bytes", "fnv", @@ -4062,16 +4734,16 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "handlebars" -version = "4.2.2" +version = "4.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d6a30320f094710245150395bc763ad23128d6a1ebbad7594dc4164b62c56b" +checksum = "83c3372087601b532857d332f5957cbae686da52bb7810bf038c3e3c3cc2fa0d" dependencies = [ "log", "pest", "pest_derive", - "quick-error 2.0.1", "serde", "serde_json", + "thiserror", ] [[package]] @@ -4104,14 +4776,14 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.2", + "ahash 0.8.3", ] [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" @@ -4122,6 +4794,15 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.3.1" @@ -4165,16 +4846,6 @@ dependencies = [ "digest 0.9.0", ] -[[package]] -name = "hmac" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" -dependencies = [ - "crypto-mac 0.10.1", - "digest 0.9.0", -] - [[package]] name = "hmac" version = "0.11.0" @@ -4191,7 +4862,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -4201,7 +4872,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", - "generic-array 0.14.6", + "generic-array 0.14.7", "hmac 0.8.1", ] @@ -4218,13 +4889,13 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", - "itoa 1.0.4", + "itoa", ] [[package]] @@ -4246,9 +4917,9 @@ checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" [[package]] name = "httparse" -version = "1.5.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" @@ -4256,15 +4927,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error 1.2.3", -] - [[package]] name = "humantime" version = "2.1.0" @@ -4273,9 +4935,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.16" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -4286,7 +4948,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 0.4.8", + "itoa", "pin-project-lite 0.2.9", "socket2", "tokio", @@ -4297,20 +4959,43 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.23.0" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" +checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" dependencies = [ "http", "hyper", "log", - "rustls 0.20.7", + "rustls 0.20.8", "rustls-native-certs", "tokio", "tokio-rustls", "webpki-roots", ] +[[package]] +name = "iana-time-zone" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows 0.48.0", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -4350,9 +5035,9 @@ dependencies = [ [[package]] name = "if-watch" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba7abdbb86e485125dad06c2691e1e393bf3b08c7b743b43aa162a00fd39062e" +checksum = "a9465340214b296cd17a0009acdb890d6160010b8adf8f78a00d0d7ab270f79f" dependencies = [ "async-io", "core-foundation", @@ -4364,7 +5049,7 @@ dependencies = [ "rtnetlink", "system-configuration", "tokio", - "windows", + "windows 0.34.0", ] [[package]] @@ -4376,6 +5061,15 @@ dependencies = [ "parity-scale-codec", ] +[[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" @@ -4398,9 +5092,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", @@ -4413,6 +5107,28 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" +[[package]] +name = "indicatif" +version = "0.17.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db45317f37ef454e6519b6c3ed7d377e5f23346f0823f86e65ca36912d1d0ef8" +dependencies = [ + "console", + "instant", + "number_prefix", + "portable-atomic", + "unicode-width", +] + +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array 0.14.7", +] + [[package]] name = "instant" version = "0.1.12" @@ -4424,9 +5140,9 @@ dependencies = [ [[package]] name = "integer-encoding" -version = "3.0.2" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90c11140ffea82edce8dcd74137ce9324ec24b3cf0175fc9d7e29164da9915b8" +checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" [[package]] name = "integer-sqrt" @@ -4437,6 +5153,50 @@ dependencies = [ "num-traits", ] +[[package]] +name = "integration-tests-common" +version = "1.0.0" +dependencies = [ + "asset-hub-kusama-runtime", + "asset-hub-polkadot-runtime", + "asset-hub-westend-runtime", + "bridge-hub-kusama-runtime", + "bridge-hub-polkadot-runtime", + "collectives-polkadot-runtime", + "cumulus-primitives-core", + "frame-support", + "frame-system", + "kusama-runtime", + "kusama-runtime-constants", + "pallet-assets", + "pallet-balances", + "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", + "sc-consensus-grandpa", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-core", + "sp-runtime", + "sp-weights", + "westend-runtime", + "westend-runtime-constants", + "xcm", + "xcm-emulator", + "xcm-executor", +] + [[package]] name = "interceptor" version = "0.8.2" @@ -4458,18 +5218,13 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" - -[[package]] -name = "io-lifetimes" -version = "1.0.2" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e394faa0efb47f9f227f1cd89978f854542b318a6f64fa695489c9c993056656" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ + "hermit-abi 0.3.1", "libc", - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] @@ -4480,9 +5235,9 @@ checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" [[package]] name = "ipconfig" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723519edce41262b05d4143ceb95050e4c614f483e78e9fd9e39a8275a84ad98" +checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" dependencies = [ "socket2", "widestring", @@ -4492,9 +5247,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.7.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11b0d96e660696543b251e58030cf9787df56da39dab19ad60eae7353040917e" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "is-terminal" @@ -4503,46 +5258,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", - "io-lifetimes 1.0.2", - "rustix 0.37.3", + "io-lifetimes", + "rustix 0.37.19", "windows-sys 0.48.0", ] [[package]] name = "itertools" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] [[package]] name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - -[[package]] -name = "itoa" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jobserver" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.55" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" dependencies = [ "wasm-bindgen", ] @@ -4693,27 +5442,30 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955890845095ccf31ef83ad41a05aabb4d8cc23dc3cac5a9f5c89cf26dd0da75" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", - "ecdsa 0.16.1", - "elliptic-curve 0.13.2", + "ecdsa 0.16.7", + "elliptic-curve 0.13.5", "once_cell", - "sha2 0.10.2", + "sha2 0.10.6", ] [[package]] name = "keccak" -version = "0.1.0" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] [[package]] name = "kusama-runtime" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bitvec", "frame-benchmarking", @@ -4746,6 +5498,7 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-membership", + "pallet-message-queue", "pallet-multisig", "pallet-nis", "pallet-nomination-pools", @@ -4811,7 +5564,7 @@ dependencies = [ [[package]] name = "kusama-runtime-constants" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "frame-support", "polkadot-primitives", @@ -4843,9 +5596,9 @@ dependencies = [ [[package]] name = "kvdb-rocksdb" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7a749456510c45f795e8b04a6a3e0976d0139213ecbf465843830ad55e2217" +checksum = "b644c70b92285f66bfc2032922a79000ea30af7bc2ab31902992a5dcb9b434f6" dependencies = [ "kvdb", "num_cpus", @@ -4869,15 +5622,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "libloading" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ "cfg-if", "winapi", @@ -4891,28 +5644,30 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] name = "libm" -version = "0.2.1" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "libp2p" -version = "0.50.0" +version = "0.51.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e0a0d2f693675f49ded13c5d510c48b78069e23cbd9108d7ccd59f6dc568819" +checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.8", + "getrandom 0.2.9", "instant", + "libp2p-allow-block-list", + "libp2p-connection-limits", "libp2p-core", "libp2p-dns", "libp2p-identify", + "libp2p-identity", "libp2p-kad", "libp2p-mdns", "libp2p-metrics", - "libp2p-mplex", "libp2p-noise", "libp2p-ping", "libp2p-quic", @@ -4924,50 +5679,66 @@ dependencies = [ "libp2p-websocket", "libp2p-yamux", "multiaddr", - "parking_lot 0.12.1", "pin-project", - "smallvec", +] + +[[package]] +name = "libp2p-allow-block-list" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + +[[package]] +name = "libp2p-connection-limits" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", ] [[package]] name = "libp2p-core" -version = "0.38.0" +version = "0.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a8fcd392ff67af6cc3f03b1426c41f7f26b6b9aff2dc632c1c56dd649e571f" +checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" dependencies = [ - "asn1_der", - "bs58", - "ed25519-dalek", "either", "fnv", "futures", "futures-timer", "instant", + "libp2p-identity", "log", "multiaddr", - "multihash", + "multihash 0.17.0", "multistream-select", "once_cell", "parking_lot 0.12.1", "pin-project", - "prost", - "prost-build", + "quick-protobuf", "rand 0.8.5", "rw-stream-sink", - "sec1 0.3.0", - "sha2 0.10.2", "smallvec", "thiserror", "unsigned-varint", "void", - "zeroize", ] [[package]] name = "libp2p-dns" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e42a271c1b49f789b92f7fc87749fa79ce5c7bdc88cbdfacb818a4bca47fec5" +checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" dependencies = [ "futures", "libp2p-core", @@ -4979,30 +5750,49 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.41.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c052d0026f4817b44869bfb6810f4e1112f43aec8553f2cb38881c524b563abf" +checksum = "5455f472243e63b9c497ff320ded0314254a9eb751799a39c283c6f20b793f3c" dependencies = [ "asynchronous-codec", + "either", "futures", "futures-timer", "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", - "lru 0.8.1", - "prost", - "prost-build", - "prost-codec", - "smallvec", + "lru 0.10.0", + "quick-protobuf", + "quick-protobuf-codec", + "smallvec", + "thiserror", + "void", +] + +[[package]] +name = "libp2p-identity" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +dependencies = [ + "bs58", + "ed25519-dalek", + "log", + "multiaddr", + "multihash 0.17.0", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.6", "thiserror", - "void", + "zeroize", ] [[package]] name = "libp2p-kad" -version = "0.42.1" +version = "0.43.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2766dcd2be8c87d5e1f35487deb22d765f49c6ae1251b3633efe3b25698bd3d2" +checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" dependencies = [ "arrayvec 0.7.2", "asynchronous-codec", @@ -5013,12 +5803,12 @@ dependencies = [ "futures-timer", "instant", "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", - "prost", - "prost-build", + "quick-protobuf", "rand 0.8.5", - "sha2 0.10.2", + "sha2 0.10.6", "smallvec", "thiserror", "uint", @@ -5028,14 +5818,15 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.42.0" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f378264aade9872d6ccd315c0accc18be3a35d15fc1b9c36e5b6f983b62b5b" +checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" dependencies = [ "data-encoding", "futures", "if-watch", "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", @@ -5048,9 +5839,9 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad8a64f29da86005c86a4d2728b8a0719e9b192f4092b609fd8790acb9dec55" +checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" dependencies = [ "libp2p-core", "libp2p-identify", @@ -5060,40 +5851,22 @@ dependencies = [ "prometheus-client", ] -[[package]] -name = "libp2p-mplex" -version = "0.38.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03805b44107aa013e7cbbfa5627b31c36cbedfdfb00603c0311998882bc4bace" -dependencies = [ - "asynchronous-codec", - "bytes", - "futures", - "libp2p-core", - "log", - "nohash-hasher", - "parking_lot 0.12.1", - "rand 0.8.5", - "smallvec", - "unsigned-varint", -] - [[package]] name = "libp2p-noise" -version = "0.41.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a978cb57efe82e892ec6f348a536bfbd9fee677adbe5689d7a93ad3a9bffbf2e" +checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" dependencies = [ "bytes", "curve25519-dalek 3.2.0", "futures", "libp2p-core", + "libp2p-identity", "log", "once_cell", - "prost", - "prost-build", + "quick-protobuf", "rand 0.8.5", - "sha2 0.10.2", + "sha2 0.10.6", "snow", "static_assertions", "thiserror", @@ -5103,10 +5876,11 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.41.0" +version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "929fcace45a112536e22b3dcfd4db538723ef9c3cb79f672b98be2cc8e25f37f" +checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" dependencies = [ + "either", "futures", "futures-timer", "instant", @@ -5119,48 +5893,47 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.7.0-alpha" +version = "0.7.0-alpha.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01e7c867e95c8130667b24409d236d37598270e6da69b3baf54213ba31ffca59" +checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" dependencies = [ "bytes", "futures", "futures-timer", "if-watch", "libp2p-core", + "libp2p-identity", "libp2p-tls", "log", "parking_lot 0.12.1", "quinn-proto", "rand 0.8.5", - "rustls 0.20.7", + "rustls 0.20.8", "thiserror", "tokio", ] [[package]] name = "libp2p-request-response" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3236168796727bfcf4927f766393415361e2c644b08bedb6a6b13d957c9a4884" +checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" dependencies = [ "async-trait", - "bytes", "futures", "instant", "libp2p-core", + "libp2p-identity", "libp2p-swarm", - "log", "rand 0.8.5", "smallvec", - "unsigned-varint", ] [[package]] name = "libp2p-swarm" -version = "0.41.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a35472fe3276b3855c00f1c032ea8413615e030256429ad5349cdf67c6e1a0" +checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" dependencies = [ "either", "fnv", @@ -5168,21 +5941,20 @@ dependencies = [ "futures-timer", "instant", "libp2p-core", + "libp2p-identity", "libp2p-swarm-derive", "log", - "pin-project", "rand 0.8.5", "smallvec", - "thiserror", "tokio", "void", ] [[package]] name = "libp2p-swarm-derive" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d527d5827582abd44a6d80c07ff8b50b4ee238a8979e05998474179e79dc400" +checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" dependencies = [ "heck", "quote", @@ -5191,9 +5963,9 @@ dependencies = [ [[package]] name = "libp2p-tcp" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b257baf6df8f2df39678b86c578961d48cc8b68642a12f0f763f56c8e5858d" +checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" dependencies = [ "futures", "futures-timer", @@ -5207,16 +5979,17 @@ dependencies = [ [[package]] name = "libp2p-tls" -version = "0.1.0-alpha" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7905ce0d040576634e8a3229a7587cc8beab83f79db6023800f1792895defa8" +checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" dependencies = [ "futures", "futures-rustls", "libp2p-core", + "libp2p-identity", "rcgen 0.10.0", "ring", - "rustls 0.20.7", + "rustls 0.20.8", "thiserror", "webpki 0.22.0", "x509-parser 0.14.0", @@ -5225,9 +5998,9 @@ dependencies = [ [[package]] name = "libp2p-wasm-ext" -version = "0.38.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bb1a35299860e0d4b3c02a3e74e3b293ad35ae0cee8a056363b0c862d082069" +checksum = "77dff9d32353a5887adb86c8afc1de1a94d9e8c3bc6df8b2201d7cdf5c848f43" dependencies = [ "futures", "js-sys", @@ -5239,9 +6012,9 @@ dependencies = [ [[package]] name = "libp2p-webrtc" -version = "0.4.0-alpha" +version = "0.4.0-alpha.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb6cd86dd68cba72308ea05de1cebf3ba0ae6e187c40548167955d4e3970f6a" +checksum = "dba48592edbc2f60b4bc7c10d65445b0c3964c07df26fdf493b6880d33be36f8" dependencies = [ "async-trait", "asynchronous-codec", @@ -5251,12 +6024,12 @@ dependencies = [ "hex", "if-watch", "libp2p-core", + "libp2p-identity", "libp2p-noise", "log", - "multihash", - "prost", - "prost-build", - "prost-codec", + "multihash 0.17.0", + "quick-protobuf", + "quick-protobuf-codec", "rand 0.8.5", "rcgen 0.9.3", "serde", @@ -5270,9 +6043,9 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.40.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d705506030d5c0aaf2882437c70dab437605f21c5f9811978f694e6917a3b54" +checksum = "111273f7b3d3510524c752e8b7a5314b7f7a1fee7e68161c01a7d72cbb06db9f" dependencies = [ "either", "futures", @@ -5289,23 +6062,22 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.42.0" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f63594a0aa818642d9d4915c791945053877253f08a3626f13416b5cd928a29" +checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" dependencies = [ "futures", "libp2p-core", "log", - "parking_lot 0.12.1", "thiserror", "yamux", ] [[package]] name = "librocksdb-sys" -version = "0.10.0+7.9.2" +version = "0.11.0+8.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fe4d5874f5ff2bc616e55e8c6086d478fcda13faf9495768a4aa1c22042d30b" +checksum = "d3386f101bcb4bd252d8e9d2fb41ec3b0862a15a62b478c355b2982efa469e3e" dependencies = [ "bindgen", "bzip2-sys", @@ -5318,12 +6090,12 @@ dependencies = [ [[package]] name = "libsecp256k1" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0452aac8bab02242429380e9b2f94ea20cea2b37e2c1777a1358799bbe97f37" +checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" dependencies = [ "arrayref", - "base64", + "base64 0.13.1", "digest 0.9.0", "hmac-drbg", "libsecp256k1-core", @@ -5331,7 +6103,7 @@ dependencies = [ "libsecp256k1-gen-genmult", "rand 0.8.5", "serde", - "sha2 0.9.8", + "sha2 0.9.9", "typenum", ] @@ -5366,9 +6138,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.3" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" +checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" dependencies = [ "cc", "pkg-config", @@ -5377,18 +6149,18 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" dependencies = [ "cc", ] [[package]] name = "linked-hash-map" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linked_hash_set" @@ -5410,39 +6182,31 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.0.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" - -[[package]] -name = "linux-raw-sys" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "linux-raw-sys" -version = "0.3.0" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd550e73688e6d578f0ac2119e32b797a327631a42f9433e59d02e139c8df60d" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "lock_api" -version = "0.4.6" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ + "autocfg", "scopeguard", ] [[package]] name = "log" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" [[package]] name = "lru" @@ -5462,6 +6226,15 @@ dependencies = [ "hashbrown 0.13.2", ] +[[package]] +name = "lru" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e" +dependencies = [ + "hashbrown 0.13.2", +] + [[package]] name = "lru-cache" version = "0.1.2" @@ -5500,6 +6273,53 @@ dependencies = [ "libc", ] +[[package]] +name = "macro_magic" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e7c1b5ffe892e88b288611ccf55f9c4f4e43214aea6f7f80f0c2c53c85e68e" +dependencies = [ + "macro_magic_core", + "macro_magic_macros", + "quote", + "syn 2.0.18", +] + +[[package]] +name = "macro_magic_core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e812c59de90e5d50405131c676dad7d239de39ccc975620c72d467c70138851" +dependencies = [ + "derive-syn-parse", + "macro_magic_core_macros", + "proc-macro2", + "quote", + "syn 2.0.18", +] + +[[package]] +name = "macro_magic_core_macros" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b1906fa06ee8c02b24595e121be94e0036cb64f9dce5e587edd1e823c87c94" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.18", +] + +[[package]] +name = "macro_magic_macros" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49e8939ee52e99672a887d8ee13776d0f54262c058ce7e911185fed8e43e3a59" +dependencies = [ + "macro_magic_core", + "quote", + "syn 2.0.18", +] + [[package]] name = "maplit" version = "1.0.2" @@ -5523,48 +6343,49 @@ dependencies = [ [[package]] name = "matches" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matrixmultiply" -version = "0.3.2" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" dependencies = [ + "autocfg", "rawpointer", ] [[package]] name = "md-5" -version = "0.10.4" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b48670c893079d3c2ed79114e3644b7004df1c361a4e0ad52e2e6940d07c3d" +checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memfd" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" +checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.36.7", + "rustix 0.37.19", ] [[package]] name = "memmap2" -version = "0.5.0" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4647a11b578fead29cdbb34d4adef8dd3dc35b876c9c6d5240d83f205abfe96e" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" dependencies = [ "libc", ] @@ -5587,6 +6408,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + [[package]] name = "memory-db" version = "0.32.0" @@ -5596,12 +6426,6 @@ dependencies = [ "hash-db", ] -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - [[package]] name = "merlin" version = "2.0.1" @@ -5633,39 +6457,37 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.4.4" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", - "autocfg", ] [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] [[package]] name = "mio" -version = "0.8.4" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", - "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.36.1", + "windows-sys 0.48.0", ] [[package]] name = "mmr-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "futures", "log", @@ -5684,7 +6506,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "anyhow", "jsonrpsee", @@ -5699,24 +6521,24 @@ dependencies = [ [[package]] name = "mockall" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e4a1c770583dac7ab5e2f6c139153b783a53a1bbee9729613f193e59828326" +checksum = "4c84490118f2ee2d74570d114f3d0493cbf02790df303d2707606c3e14e07c96" dependencies = [ "cfg-if", "downcast", "fragile", "lazy_static", "mockall_derive", - "predicates 2.1.1", + "predicates 2.1.5", "predicates-tree", ] [[package]] name = "mockall_derive" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "832663583d5fa284ca8810bf7015e46c9fff9622d3cf34bd1eea5003fec06dd0" +checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" dependencies = [ "cfg-if", "proc-macro2", @@ -5726,15 +6548,16 @@ dependencies = [ [[package]] name = "multiaddr" -version = "0.16.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aebdb21e90f81d13ed01dc84123320838e53963c2ca94b60b305d3fa64f31e" +checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" dependencies = [ "arrayref", "byteorder", "data-encoding", + "log", "multibase", - "multihash", + "multihash 0.17.0", "percent-encoding", "serde", "static_assertions", @@ -5755,21 +6578,34 @@ dependencies = [ [[package]] name = "multihash" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3db354f401db558759dfc1e568d010a5d4146f4d3f637be1275ec4a3cf09689" +checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" dependencies = [ "blake2b_simd", "blake2s_simd", "blake3", "core2", - "digest 0.10.6", + "digest 0.10.7", "multihash-derive", - "sha2 0.10.2", + "sha2 0.10.6", "sha3", "unsigned-varint", ] +[[package]] +name = "multihash" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" +dependencies = [ + "core2", + "digest 0.10.7", + "multihash-derive", + "sha2 0.10.6", + "unsigned-varint", +] + [[package]] name = "multihash-derive" version = "0.8.0" @@ -5806,9 +6642,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6515c882ebfddccaa73ead7320ca28036c4bc84c9bcca3cc0cbba8efe89223a" +checksum = "d68d47bba83f9e2006d117a9a33af1524e655516b8919caac694427a6fb1e511" dependencies = [ "approx", "matrixmultiply", @@ -5874,9 +6710,9 @@ dependencies = [ [[package]] name = "netlink-packet-utils" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25af9cf0dc55498b7bd94a1508af7a78706aa0ab715a73c5169273e03c84845e" +checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" dependencies = [ "anyhow", "byteorder", @@ -5901,9 +6737,9 @@ dependencies = [ [[package]] name = "netlink-sys" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92b654097027250401127914afb37cb1f311df6610a9891ff07a757e94199027" +checksum = "6471bf08e7ac0135876a9581bf3217ef0333c191c128d34878079f42ee150411" dependencies = [ "bytes", "futures", @@ -5914,9 +6750,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ "bitflags", "cfg-if", @@ -5946,13 +6782,12 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" [[package]] name = "nom" -version = "7.1.0" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", - "version_check", ] [[package]] @@ -5974,28 +6809,28 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" dependencies = [ "num-traits", ] [[package]] name = "num-format" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b862ff8df690cf089058c98b183676a7ed0f974cc08b426800093227cbff3b" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ "arrayvec 0.7.2", - "itoa 1.0.4", + "itoa", ] [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", "num-traits", @@ -6024,32 +6859,29 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi 0.1.19", + "hermit-abi 0.2.6", "libc", ] [[package]] -name = "object" -version = "0.29.0" +name = "number_prefix" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" -dependencies = [ - "crc32fast", - "hashbrown 0.12.3", - "indexmap", - "memchr", -] +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.30.0" +version = "0.30.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239da7f290cfa979f43f85a8efeee9a8a76d0827c356d37f9d3d7254d6b537fb" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" dependencies = [ + "crc32fast", + "hashbrown 0.13.2", + "indexmap", "memchr", ] @@ -6068,14 +6900,14 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" dependencies = [ - "asn1-rs 0.5.1", + "asn1-rs 0.5.2", ] [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b" [[package]] name = "oorandom" @@ -6097,9 +6929,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl-probe" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "orchestra" @@ -6142,12 +6974,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "os_str_bytes" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" - [[package]] name = "p256" version = "0.11.1" @@ -6156,7 +6982,7 @@ checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" dependencies = [ "ecdsa 0.14.8", "elliptic-curve 0.12.3", - "sha2 0.10.2", + "sha2 0.10.6", ] [[package]] @@ -6167,7 +6993,7 @@ checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" dependencies = [ "ecdsa 0.14.8", "elliptic-curve 0.12.3", - "sha2 0.10.2", + "sha2 0.10.6", ] [[package]] @@ -6183,7 +7009,7 @@ dependencies = [ [[package]] name = "pallet-alliance" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", "frame-benchmarking", @@ -6204,7 +7030,7 @@ dependencies = [ [[package]] name = "pallet-asset-tx-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6222,7 +7048,7 @@ dependencies = [ [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6237,7 +7063,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "frame-system", @@ -6253,7 +7079,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "frame-system", @@ -6269,7 +7095,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "frame-system", @@ -6283,117 +7109,205 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-consensus-babe", + "sp-core", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-bags-list" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-tracing", +] + +[[package]] +name = "pallet-balances" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "log", - "pallet-authorship", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-beefy" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" +dependencies = [ + "frame-support", + "frame-system", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "scale-info", + "serde", + "sp-consensus-beefy", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-beefy-mmr" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" +dependencies = [ + "array-bytes 4.2.0", + "binary-merkle-tree", + "frame-support", + "frame-system", + "log", + "pallet-beefy", + "pallet-mmr", "pallet-session", - "pallet-timestamp", "parity-scale-codec", "scale-info", - "sp-application-crypto", - "sp-consensus-babe", + "serde", + "sp-api", + "sp-consensus-beefy", "sp-core", "sp-io", "sp-runtime", - "sp-session", - "sp-staking", "sp-std", ] [[package]] -name = "pallet-bags-list" +name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", - "frame-election-provider-support", "frame-support", "frame-system", "log", - "pallet-balances", + "pallet-treasury", "parity-scale-codec", "scale-info", "sp-core", "sp-io", "sp-runtime", "sp-std", - "sp-tracing", ] [[package]] -name = "pallet-balances" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +name = "pallet-bridge-grandpa" +version = "0.1.0" 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-core", + "sp-io", "sp-runtime", "sp-std", + "sp-trie", ] [[package]] -name = "pallet-beefy" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +name = "pallet-bridge-messages" +version = "0.1.0" dependencies = [ + "bp-messages", + "bp-runtime", + "bp-test-utils", + "frame-benchmarking", "frame-support", "frame-system", - "pallet-authorship", - "pallet-session", + "log", + "num-traits", + "pallet-balances", "parity-scale-codec", "scale-info", - "serde", - "sp-consensus-beefy", + "sp-core", + "sp-io", "sp-runtime", - "sp-session", - "sp-staking", "sp-std", ] [[package]] -name = "pallet-beefy-mmr" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +name = "pallet-bridge-parachains" +version = "0.1.0" dependencies = [ - "array-bytes 4.2.0", - "binary-merkle-tree", + "bp-header-chain", + "bp-parachains", + "bp-polkadot-core", + "bp-runtime", + "bp-test-utils", + "frame-benchmarking", "frame-support", "frame-system", "log", - "pallet-beefy", - "pallet-mmr", - "pallet-session", + "pallet-bridge-grandpa", "parity-scale-codec", "scale-info", - "serde", - "sp-api", - "sp-consensus-beefy", "sp-core", "sp-io", "sp-runtime", "sp-std", + "sp-trie", ] [[package]] -name = "pallet-bounties" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +name = "pallet-bridge-relayers" +version = "0.1.0" dependencies = [ + "bp-messages", + "bp-relayers", + "bp-runtime", "frame-benchmarking", "frame-support", "frame-system", "log", - "pallet-treasury", + "pallet-balances", + "pallet-bridge-messages", "parity-scale-codec", "scale-info", + "sp-arithmetic", "sp-core", "sp-io", "sp-runtime", @@ -6403,7 +7317,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6447,7 +7361,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6464,7 +7378,7 @@ dependencies = [ [[package]] name = "pallet-contracts" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "bitflags", "environmental", @@ -6487,14 +7401,14 @@ dependencies = [ "sp-runtime", "sp-std", "wasm-instrument 0.4.0", - "wasmi 0.28.0", + "wasmi", "wasmparser-nostd", ] [[package]] name = "pallet-contracts-primitives" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "24.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "bitflags", "parity-scale-codec", @@ -6507,17 +7421,17 @@ dependencies = [ [[package]] name = "pallet-contracts-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "assert_matches", "frame-benchmarking", @@ -6534,7 +7448,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6552,7 +7466,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6575,7 +7489,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6588,7 +7502,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6606,8 +7520,9 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ + "docify", "frame-benchmarking", "frame-election-provider-support", "frame-support", @@ -6621,10 +7536,28 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-glutton" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" +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" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6647,7 +7580,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "enumflags2", "frame-benchmarking", @@ -6663,7 +7596,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6683,7 +7616,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6700,7 +7633,7 @@ dependencies = [ [[package]] name = "pallet-insecure-randomness-collective-flip" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "frame-system", @@ -6714,7 +7647,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6731,7 +7664,7 @@ dependencies = [ [[package]] name = "pallet-message-queue" version = "7.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#9b43d8f891b1e53be2aa55687632ac6b17800cf8" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6750,7 +7683,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6767,7 +7700,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6780,10 +7713,27 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-nft-fractionalization" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" +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=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "enumflags2", "frame-benchmarking", @@ -6801,7 +7751,7 @@ dependencies = [ [[package]] name = "pallet-nfts-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "pallet-nfts", @@ -6812,7 +7762,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6828,7 +7778,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "frame-system", @@ -6845,7 +7795,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6865,7 +7815,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "pallet-nomination-pools", "parity-scale-codec", @@ -6876,7 +7826,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "frame-system", @@ -6893,7 +7843,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6914,10 +7864,25 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-parachain-template" +version = "0.1.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", +] + [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6934,7 +7899,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6949,7 +7914,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6967,7 +7932,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6982,7 +7947,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "assert_matches", "frame-benchmarking", @@ -7001,7 +7966,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -7018,7 +7983,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "frame-system", @@ -7039,7 +8004,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -7055,7 +8020,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "frame-system", @@ -7069,7 +8034,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -7092,18 +8057,18 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "log", "sp-arithmetic", @@ -7112,7 +8077,7 @@ dependencies = [ [[package]] name = "pallet-staking-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "sp-api", @@ -7121,7 +8086,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -7138,36 +8103,22 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-template" -version = "0.1.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", "scale-info", - "serde", - "sp-core", "sp-io", "sp-runtime", + "sp-std", ] [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -7185,7 +8136,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -7204,7 +8155,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-support", "frame-system", @@ -7220,7 +8171,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -7236,7 +8187,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -7248,7 +8199,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -7265,7 +8216,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -7280,7 +8231,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -7296,7 +8247,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -7311,7 +8262,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-benchmarking", "frame-support", @@ -7326,7 +8277,7 @@ dependencies = [ [[package]] name = "pallet-xcm" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bounded-collections", "frame-benchmarking", @@ -7347,7 +8298,7 @@ dependencies = [ [[package]] name = "pallet-xcm-benchmarks" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "frame-benchmarking", "frame-support", @@ -7378,7 +8329,7 @@ dependencies = [ name = "parachain-template-node" version = "0.1.0" dependencies = [ - "clap 4.2.3", + "clap", "color-print", "cumulus-client-cli", "cumulus-client-consensus-aura", @@ -7454,9 +8405,9 @@ dependencies = [ "pallet-balances", "pallet-collator-selection", "pallet-message-queue", + "pallet-parachain-template", "pallet-session", "pallet-sudo", - "pallet-template", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", @@ -7513,11 +8464,43 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "parachains-runtimes-test-utils" +version = "1.0.0" +dependencies = [ + "assets-common", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-test-relay-sproof-builder", + "frame-support", + "frame-system", + "hex-literal 0.3.4", + "pallet-assets", + "pallet-balances", + "pallet-collator-selection", + "pallet-session", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-parachain", + "sp-consensus-aura", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "substrate-wasm-builder", + "xcm", + "xcm-executor", +] + [[package]] name = "parity-db" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00bfb81cf5c90a222db2fb7b3a7cbf8cc7f38dfb6647aca4d98edf8281f56ed5" +checksum = "4890dcb9556136a4ec2b0c51fa4a08c8b733b829506af8fff2e853f3a065985b" dependencies = [ "blake2", "crc32fast", @@ -7535,9 +8518,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" +checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -7566,6 +8549,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" @@ -7574,9 +8586,9 @@ checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" [[package]] name = "parking" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" [[package]] name = "parking_lot" @@ -7586,7 +8598,7 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core 0.8.5", + "parking_lot_core 0.8.6", ] [[package]] @@ -7596,36 +8608,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.1", + "parking_lot_core 0.9.7", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" dependencies = [ "cfg-if", "instant", "libc", - "redox_syscall 0.2.10", + "redox_syscall 0.2.16", "smallvec", "winapi", ] [[package]] name = "parking_lot_core" -version = "0.9.1" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.10", + "redox_syscall 0.2.16", "smallvec", - "windows-sys 0.32.0", + "windows-sys 0.45.0", ] +[[package]] +name = "partial_sort" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" + [[package]] name = "paste" version = "1.0.12" @@ -7647,7 +8665,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -7658,11 +8676,11 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "pem" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c64931a1a212348ec4f3b4362585eca7159d0d09cbdf4a7f74f02173596fd4" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" dependencies = [ - "base64", + "base64 0.13.1", ] [[package]] @@ -7741,18 +8759,19 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.1.3" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" dependencies = [ + "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.1.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" +checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" dependencies = [ "pest", "pest_generator", @@ -7760,33 +8779,33 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.1.3" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" +checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "pest_meta" -version = "2.1.3" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" +checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" dependencies = [ - "maplit", + "once_cell", "pest", - "sha-1 0.8.2", + "sha2 0.10.6", ] [[package]] name = "petgraph" -version = "0.6.0" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a13a2fa9d0b63e5f22328828741e523766fff0ee9e779316902290dff3f824f" +checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", "indexmap", @@ -7794,22 +8813,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] @@ -7836,31 +8855,25 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" dependencies = [ - "der 0.6.0", + "der 0.6.1", "spki 0.6.0", ] [[package]] name = "pkcs8" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d2820d87d2b008616e5c27212dd9e0e694fb4c6b522de06094106813328cb49" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.1", - "spki 0.7.0", + "der 0.7.6", + "spki 0.7.2", ] [[package]] name = "pkg-config" -version = "0.3.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" - -[[package]] -name = "platforms" -version = "2.0.0" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "platforms" @@ -7870,9 +8883,9 @@ checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" [[package]] name = "plotters" -version = "0.3.1" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" +checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97" dependencies = [ "num-traits", "plotters-backend", @@ -7883,15 +8896,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" +checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142" [[package]] name = "plotters-svg" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" +checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" dependencies = [ "plotters-backend", ] @@ -7899,7 +8912,7 @@ dependencies = [ [[package]] name = "polkadot-approval-distribution" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "futures", "polkadot-node-jaeger", @@ -7915,7 +8928,7 @@ dependencies = [ [[package]] name = "polkadot-availability-bitfield-distribution" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "futures", "polkadot-node-network-protocol", @@ -7929,7 +8942,7 @@ dependencies = [ [[package]] name = "polkadot-availability-distribution" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "derive_more", "fatality", @@ -7952,7 +8965,7 @@ dependencies = [ [[package]] name = "polkadot-availability-recovery" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "fatality", "futures", @@ -7973,14 +8986,15 @@ dependencies = [ [[package]] name = "polkadot-cli" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ - "clap 4.2.3", + "clap", "frame-benchmarking-cli", "futures", "log", "polkadot-client", - "polkadot-node-core-pvf-worker", + "polkadot-node-core-pvf-execute-worker", + "polkadot-node-core-pvf-prepare-worker", "polkadot-node-metrics", "polkadot-performance-test", "polkadot-service", @@ -8002,7 +9016,7 @@ dependencies = [ [[package]] name = "polkadot-client" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "async-trait", "frame-benchmarking", @@ -8045,7 +9059,7 @@ dependencies = [ [[package]] name = "polkadot-collator-protocol" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "always-assert", "bitvec", @@ -8067,7 +9081,7 @@ dependencies = [ [[package]] name = "polkadot-core-primitives" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "parity-scale-codec", "scale-info", @@ -8079,7 +9093,7 @@ dependencies = [ [[package]] name = "polkadot-dispute-distribution" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "derive_more", "fatality", @@ -8104,7 +9118,7 @@ dependencies = [ [[package]] name = "polkadot-erasure-coding" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "parity-scale-codec", "polkadot-node-primitives", @@ -8118,7 +9132,7 @@ dependencies = [ [[package]] name = "polkadot-gossip-support" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "futures", "futures-timer", @@ -8138,7 +9152,7 @@ dependencies = [ [[package]] name = "polkadot-network-bridge" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "always-assert", "async-trait", @@ -8161,7 +9175,7 @@ dependencies = [ [[package]] name = "polkadot-node-collation-generation" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "futures", "parity-scale-codec", @@ -8179,7 +9193,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-approval-voting" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bitvec", "derive_more", @@ -8208,7 +9222,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-av-store" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bitvec", "futures", @@ -8229,7 +9243,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-backing" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bitvec", "fatality", @@ -8248,7 +9262,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-bitfield-signing" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "futures", "polkadot-node-subsystem", @@ -8263,7 +9277,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-candidate-validation" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "async-trait", "futures", @@ -8283,7 +9297,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-api" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "futures", "polkadot-node-metrics", @@ -8298,7 +9312,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-selection" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "futures", "futures-timer", @@ -8315,7 +9329,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-dispute-coordinator" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "fatality", "futures", @@ -8334,7 +9348,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-parachains-inherent" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "async-trait", "futures", @@ -8351,7 +9365,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-provisioner" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bitvec", "fatality", @@ -8369,7 +9383,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "always-assert", "futures", @@ -8378,6 +9392,9 @@ dependencies = [ "parity-scale-codec", "pin-project", "polkadot-core-primitives", + "polkadot-node-core-pvf-common", + "polkadot-node-core-pvf-execute-worker", + "polkadot-node-core-pvf-prepare-worker", "polkadot-node-metrics", "polkadot-node-primitives", "polkadot-parachain", @@ -8389,6 +9406,7 @@ dependencies = [ "sp-tracing", "sp-wasm-interface", "substrate-build-script-utils", + "tempfile", "tokio", "tracing-gum", ] @@ -8396,7 +9414,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-checker" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "futures", "polkadot-node-primitives", @@ -8404,35 +9422,72 @@ dependencies = [ "polkadot-node-subsystem-util", "polkadot-overseer", "polkadot-primitives", - "sp-keystore", - "thiserror", + "sp-keystore", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-pvf-common" +version = "0.9.41" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" +dependencies = [ + "cpu-time", + "futures", + "libc", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "sc-executor", + "sc-executor-common", + "sc-executor-wasmtime", + "sp-core", + "sp-externalities", + "sp-io", + "sp-tracing", + "substrate-build-script-utils", + "tokio", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-pvf-execute-worker" +version = "0.9.41" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" +dependencies = [ + "cpu-time", + "futures", + "parity-scale-codec", + "polkadot-node-core-pvf-common", + "polkadot-parachain", + "polkadot-primitives", + "rayon", + "sp-core", + "sp-maybe-compressed-blob", + "sp-tracing", + "tikv-jemalloc-ctl", + "tokio", "tracing-gum", ] [[package]] -name = "polkadot-node-core-pvf-worker" +name = "polkadot-node-core-pvf-prepare-worker" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ - "assert_matches", - "cpu-time", "futures", "libc", "parity-scale-codec", - "polkadot-node-core-pvf", + "polkadot-node-core-pvf-common", "polkadot-parachain", "polkadot-primitives", "rayon", "sc-executor", "sc-executor-common", "sc-executor-wasmtime", - "sp-core", - "sp-externalities", "sp-io", "sp-maybe-compressed-blob", "sp-tracing", - "substrate-build-script-utils", - "tempfile", "tikv-jemalloc-ctl", "tokio", "tracing-gum", @@ -8441,7 +9496,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-runtime-api" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "futures", "lru 0.9.0", @@ -8456,7 +9511,7 @@ dependencies = [ [[package]] name = "polkadot-node-jaeger" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "lazy_static", "log", @@ -8474,7 +9529,7 @@ dependencies = [ [[package]] name = "polkadot-node-metrics" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bs58", "futures", @@ -8493,8 +9548,9 @@ dependencies = [ [[package]] name = "polkadot-node-network-protocol" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ + "async-channel", "async-trait", "derive_more", "fatality", @@ -8515,7 +9571,7 @@ dependencies = [ [[package]] name = "polkadot-node-primitives" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bounded-vec", "futures", @@ -8537,7 +9593,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "polkadot-node-jaeger", "polkadot-node-subsystem-types", @@ -8547,7 +9603,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-test-helpers" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "async-trait", "futures", @@ -8565,7 +9621,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-types" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "async-trait", "derive_more", @@ -8588,7 +9644,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-util" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "async-trait", "derive_more", @@ -8621,7 +9677,7 @@ dependencies = [ [[package]] name = "polkadot-overseer" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "async-trait", "futures", @@ -8644,7 +9700,7 @@ dependencies = [ [[package]] name = "polkadot-parachain" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bounded-collections", "derive_more", @@ -8660,14 +9716,17 @@ dependencies = [ [[package]] name = "polkadot-parachain-bin" -version = "0.9.400" +version = "0.9.420" dependencies = [ "assert_cmd", + "asset-hub-kusama-runtime", + "asset-hub-polkadot-runtime", + "asset-hub-westend-runtime", "async-trait", "bridge-hub-kusama-runtime", "bridge-hub-polkadot-runtime", "bridge-hub-rococo-runtime", - "clap 4.2.3", + "clap", "collectives-polkadot-runtime", "color-print", "contracts-rococo-runtime", @@ -8682,6 +9741,7 @@ dependencies = [ "frame-benchmarking", "frame-benchmarking-cli", "futures", + "glutton-runtime", "hex-literal 0.4.1", "jsonrpsee", "log", @@ -8711,6 +9771,7 @@ dependencies = [ "sc-transaction-pool-api", "seedling-runtime", "serde", + "serde_json", "shell-runtime", "sp-api", "sp-block-builder", @@ -8721,12 +9782,9 @@ dependencies = [ "sp-keystore", "sp-offchain", "sp-runtime", - "sp-serializer", "sp-session", "sp-timestamp", "sp-transaction-pool", - "statemine-runtime", - "statemint-runtime", "substrate-build-script-utils", "substrate-frame-rpc-system", "substrate-prometheus-endpoint", @@ -8735,20 +9793,19 @@ dependencies = [ "tokio", "try-runtime-cli", "wait-timeout", - "westmint-runtime", "xcm", ] [[package]] name = "polkadot-performance-test" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ - "env_logger 0.9.0", + "env_logger 0.9.3", "kusama-runtime", "log", "polkadot-erasure-coding", - "polkadot-node-core-pvf-worker", + "polkadot-node-core-pvf-prepare-worker", "polkadot-node-primitives", "polkadot-primitives", "quote", @@ -8760,7 +9817,7 @@ dependencies = [ [[package]] name = "polkadot-primitives" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bitvec", "hex-literal 0.4.1", @@ -8786,7 +9843,7 @@ dependencies = [ [[package]] name = "polkadot-rpc" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "jsonrpsee", "mmr-rpc", @@ -8818,7 +9875,7 @@ dependencies = [ [[package]] name = "polkadot-runtime" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bitvec", "frame-benchmarking", @@ -8850,6 +9907,7 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-membership", + "pallet-message-queue", "pallet-multisig", "pallet-nomination-pools", "pallet-nomination-pools-benchmarking", @@ -8912,7 +9970,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-common" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bitvec", "frame-benchmarking", @@ -8958,7 +10016,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-constants" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "frame-support", "polkadot-primitives", @@ -8972,7 +10030,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-metrics" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bs58", "parity-scale-codec", @@ -8984,7 +10042,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-parachains" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bitflags", "bitvec", @@ -8997,6 +10055,7 @@ dependencies = [ "pallet-authorship", "pallet-babe", "pallet-balances", + "pallet-message-queue", "pallet-session", "pallet-staking", "pallet-timestamp", @@ -9028,7 +10087,7 @@ dependencies = [ [[package]] name = "polkadot-service" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "async-trait", "frame-benchmarking-cli", @@ -9138,7 +10197,7 @@ dependencies = [ [[package]] name = "polkadot-statement-distribution" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "arrayvec 0.5.2", "fatality", @@ -9159,7 +10218,7 @@ dependencies = [ [[package]] name = "polkadot-statement-table" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "parity-scale-codec", "polkadot-primitives", @@ -9169,7 +10228,7 @@ dependencies = [ [[package]] name = "polkadot-test-client" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "parity-scale-codec", "polkadot-node-subsystem", @@ -9194,7 +10253,7 @@ dependencies = [ [[package]] name = "polkadot-test-runtime" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bitvec", "frame-election-provider-support", @@ -9255,7 +10314,7 @@ dependencies = [ [[package]] name = "polkadot-test-service" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "frame-benchmarking", "frame-system", @@ -9307,15 +10366,18 @@ dependencies = [ [[package]] name = "polling" -version = "2.2.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ + "autocfg", + "bitflags", "cfg-if", + "concurrent-queue", "libc", "log", - "wepoll-ffi", - "winapi", + "pin-project-lite 0.2.9", + "windows-sys 0.48.0", ] [[package]] @@ -9326,32 +10388,39 @@ checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" dependencies = [ "cpufeatures", "opaque-debug 0.3.0", - "universal-hash", + "universal-hash 0.4.1", ] [[package]] name = "polyval" -version = "0.4.5" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" +checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" dependencies = [ - "cpuid-bool", + "cfg-if", + "cpufeatures", "opaque-debug 0.3.0", - "universal-hash", + "universal-hash 0.4.1", ] [[package]] name = "polyval" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6" dependencies = [ "cfg-if", "cpufeatures", "opaque-debug 0.3.0", - "universal-hash", + "universal-hash 0.5.1", ] +[[package]] +name = "portable-atomic" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "767eb9f07d4a5ebcb39bbf2d452058a93c011373abf6832e24194a1c3f004794" + [[package]] name = "portpicker" version = "0.1.1" @@ -9363,15 +10432,15 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "predicates" -version = "2.1.1" +version = "2.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5aab5be6e4732b473071984b3164dbbfb7a3674d30ea5ff44410b6bcd960c3c" +checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" dependencies = [ "difflib", "float-cmp", @@ -9383,11 +10452,11 @@ dependencies = [ [[package]] name = "predicates" -version = "3.0.1" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba7d6ead3e3966038f68caa9fc1f860185d95a793180bbcfe0d0da47b3961ed" +checksum = "09963355b9f467184c04017ced4a2ba2d75cbcb4e7462690d388233253d4b1a9" dependencies = [ - "anstyle 0.3.4", + "anstyle", "difflib", "itertools", "predicates-core", @@ -9401,22 +10470,43 @@ checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" [[package]] name = "predicates-tree" -version = "1.0.4" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" dependencies = [ "predicates-core", "termtree", ] +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "prettyplease" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b69d39aab54d069e7f2fe8cb970493e7834601ca2d8c65fd7bbd183578080d1" +dependencies = [ + "proc-macro2", + "syn 2.0.18", +] + [[package]] name = "primitive-types" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cfd65aea0c5fa0bfcc7c9e7ca828c921ef778f43d325325ec84bda371bfa75a" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ "fixed-hash", "impl-codec", + "impl-rlp", "impl-serde", "scale-info", "uint", @@ -9474,55 +10564,55 @@ dependencies = [ [[package]] name = "proc-macro-warning" -version = "0.3.1" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" +checksum = "70550716265d1ec349c41f70dd4f964b4fd88394efe4405f0c1da679c4799a07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" dependencies = [ "unicode-ident", ] [[package]] name = "prometheus" -version = "0.13.0" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f64969ffd5dd8f39bd57a68ac53c163a095ed9d0fb707146da1b27025a3504" +checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" dependencies = [ "cfg-if", "fnv", "lazy_static", "memchr", - "parking_lot 0.11.2", + "parking_lot 0.12.1", "thiserror", ] [[package]] name = "prometheus-client" -version = "0.18.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83cd1b99916654a69008fd66b4f9397fbe08e6e51dfe23d4417acf5d3b8cb87c" +checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" dependencies = [ "dtoa", - "itoa 1.0.4", + "itoa", "parking_lot 0.12.1", - "prometheus-client-derive-text-encode", + "prometheus-client-derive-encode", ] [[package]] -name = "prometheus-client-derive-text-encode" -version = "0.3.0" +name = "prometheus-client-derive-encode" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a455fbcb954c1a7decf3c586e860fd7889cddf4b8e164be736dbac95a953cd" +checksum = "72b6a5217beb0ad503ee7fa752d451c905113d70721b937126158f3106a48cc1" dependencies = [ "proc-macro2", "quote", @@ -9531,9 +10621,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.0" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "399c3c31cdec40583bb68f0b18403400d01ec4289c383aa047560439952c4dd7" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", "prost-derive", @@ -9541,9 +10631,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.11.1" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f835c582e6bd972ba8347313300219fed5bfa52caf175298d860b61ff6069bb" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" dependencies = [ "bytes", "heck", @@ -9552,31 +10642,20 @@ dependencies = [ "log", "multimap", "petgraph", + "prettyplease 0.1.25", "prost", "prost-types", "regex", + "syn 1.0.109", "tempfile", "which", ] -[[package]] -name = "prost-codec" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc34979ff898b6e141106178981ce2596c387ea6e62533facfc61a37fc879c0" -dependencies = [ - "asynchronous-codec", - "bytes", - "prost", - "thiserror", - "unsigned-varint", -] - [[package]] name = "prost-derive" -version = "0.11.0" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7345d5f0e08c0536d7ac7229952590239e77abf0a0100a1b1d890add6ea96364" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", @@ -9587,19 +10666,18 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.11.1" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dfaa718ad76a44b3415e6c4d53b17c8f99160dcb3a99b10470fce8ad43f6e3e" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "bytes", "prost", ] [[package]] name = "psm" -version = "0.1.16" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd136ff4382c4753fc061cb9e4712ab2af263376b95bbd5bd8cd50c020b78e69" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" dependencies = [ "cc", ] @@ -9611,10 +10689,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] -name = "quick-error" -version = "2.0.1" +name = "quick-protobuf" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" +checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" +dependencies = [ + "byteorder", +] + +[[package]] +name = "quick-protobuf-codec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +dependencies = [ + "asynchronous-codec", + "bytes", + "quick-protobuf", + "thiserror", + "unsigned-varint", +] [[package]] name = "quicksink" @@ -9629,15 +10723,15 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4ced82a24bb281af338b9e8f94429b6eca01b4e66d899f40031f074e74c9" +checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" dependencies = [ "bytes", "rand 0.8.5", "ring", "rustc-hash", - "rustls 0.20.7", + "rustls 0.20.8", "slab", "thiserror", "tinyvec", @@ -9647,9 +10741,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] @@ -9719,7 +10813,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", ] [[package]] @@ -9776,7 +10870,7 @@ checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", "ring", - "time 0.3.17", + "time 0.3.21", "x509-parser 0.13.2", "yasna", ] @@ -9789,15 +10883,15 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.17", + "time 0.3.21", "yasna", ] [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] @@ -9813,12 +10907,13 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.8", - "redox_syscall 0.2.10", + "getrandom 0.2.9", + "redox_syscall 0.2.16", + "thiserror", ] [[package]] @@ -9836,29 +10931,29 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.6" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da" +checksum = "f43faa91b1c8b36841ee70e97188a869d37ae21759da6846d4be66de5bf7b12c" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.6" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2" +checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "regalloc2" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" +checksum = "80535183cae11b149d618fbd3c37e38d7cda589d82d7769e196ca9a9042d7621" dependencies = [ "fxhash", "log", @@ -9868,13 +10963,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390" dependencies = [ - "aho-corasick", + "aho-corasick 1.0.1", "memchr", - "regex-syntax", + "regex-syntax 0.7.2", ] [[package]] @@ -9883,26 +10978,20 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.29", ] [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] -name = "region" -version = "3.0.0" +name = "regex-syntax" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" -dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", -] +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" [[package]] name = "resolv-conf" @@ -9911,7 +11000,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" dependencies = [ "hostname", - "quick-error 1.2.3", + "quick-error", ] [[package]] @@ -9950,11 +11039,21 @@ dependencies = [ "winapi", ] +[[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.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "015439787fce1e75d55f279078d33ff14b4af5d93d995e8838ee4631301c8a99" +checksum = "bb6f170a4041d50a0ce04b0d2e14916d6ca863ea2e422689a5b694395d299ffe" dependencies = [ "libc", "librocksdb-sys", @@ -10011,7 +11110,7 @@ dependencies = [ [[package]] name = "rococo-runtime" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "binary-merkle-tree", "frame-benchmarking", @@ -10039,6 +11138,7 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-membership", + "pallet-message-queue", "pallet-mmr", "pallet-multisig", "pallet-nis", @@ -10097,7 +11197,7 @@ dependencies = [ [[package]] name = "rococo-runtime-constants" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "frame-support", "polkadot-primitives", @@ -10110,11 +11210,12 @@ dependencies = [ [[package]] name = "rpassword" -version = "7.0.0" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b763cb66df1c928432cc35053f8bd4cec3335d8559fc16010017d16b3c1680" +checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" dependencies = [ "libc", + "rtoolbox", "winapi", ] @@ -10139,11 +11240,21 @@ dependencies = [ "log", "netlink-packet-route", "netlink-proto", - "nix 0.24.2", + "nix 0.24.3", "thiserror", "tokio", ] +[[package]] +name = "rtoolbox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "rtp" version = "0.6.8" @@ -10160,9 +11271,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -10191,7 +11302,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.16", + "semver 1.0.17", ] [[package]] @@ -10205,44 +11316,30 @@ dependencies = [ [[package]] name = "rustix" -version = "0.35.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" -dependencies = [ - "bitflags", - "errno 0.2.8", - "io-lifetimes 0.7.5", - "libc", - "linux-raw-sys 0.0.46", - "windows-sys 0.42.0", -] - -[[package]] -name = "rustix" -version = "0.36.7" +version = "0.36.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03" +checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62" dependencies = [ "bitflags", - "errno 0.2.8", - "io-lifetimes 1.0.2", + "errno", + "io-lifetimes", "libc", - "linux-raw-sys 0.1.3", - "windows-sys 0.42.0", + "linux-raw-sys 0.1.4", + "windows-sys 0.45.0", ] [[package]] name = "rustix" -version = "0.37.3" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b24138615de35e32031d041a09032ef3487a616d901ca4db224e7d557efae2" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags", - "errno 0.3.0", - "io-lifetimes 1.0.2", + "errno", + "io-lifetimes", "libc", - "linux-raw-sys 0.3.0", - "windows-sys 0.45.0", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", ] [[package]] @@ -10251,7 +11348,7 @@ version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" dependencies = [ - "base64", + "base64 0.13.1", "log", "ring", "sct 0.6.1", @@ -10260,9 +11357,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.7" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "539a2bfe908f471bfa933876bd1eb6a19cf2176d375f82ef7f99530a40e48c2c" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", "ring", @@ -10272,9 +11369,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca9ebdfa27d3fc180e42879037b5338ab1c040c06affd00d8338598e7800943" +checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -10284,11 +11381,11 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "0.2.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" dependencies = [ - "base64", + "base64 0.21.2", ] [[package]] @@ -10310,9 +11407,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.6" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "safe-mix" @@ -10344,7 +11441,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "log", "sp-core", @@ -10355,7 +11452,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "futures", @@ -10363,6 +11460,7 @@ dependencies = [ "ip_network", "libp2p", "log", + "multihash 0.17.0", "parity-scale-codec", "prost", "prost-build", @@ -10383,7 +11481,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "futures", "futures-timer", @@ -10406,7 +11504,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -10421,7 +11519,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -10440,25 +11538,25 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", "chrono", - "clap 4.2.3", + "clap", "fdlimit", "futures", - "libp2p", + "libp2p-identity", "log", "names", "parity-scale-codec", @@ -10491,7 +11589,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "fnv", "futures", @@ -10510,6 +11608,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "sp-state-machine", + "sp-statement-store", "sp-storage", "substrate-prometheus-endpoint", ] @@ -10517,7 +11616,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "hash-db", "kvdb", @@ -10543,12 +11642,12 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "futures", "futures-timer", - "libp2p", + "libp2p-identity", "log", "mockall", "parking_lot 0.12.1", @@ -10568,7 +11667,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "futures", @@ -10597,7 +11696,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "fork-tree", @@ -10633,7 +11732,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "futures", "jsonrpsee", @@ -10655,9 +11754,10 @@ dependencies = [ [[package]] name = "sc-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", + "async-channel", "async-trait", "fnv", "futures", @@ -10690,7 +11790,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "futures", "jsonrpsee", @@ -10709,7 +11809,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "fork-tree", "parity-scale-codec", @@ -10722,9 +11822,9 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ - "ahash 0.8.2", + "ahash 0.8.3", "array-bytes 4.2.0", "async-trait", "dyn-clone", @@ -10762,7 +11862,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "finality-grandpa", "futures", @@ -10782,7 +11882,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "futures", @@ -10805,13 +11905,12 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ - "lru 0.8.1", + "lru 0.10.0", "parity-scale-codec", "parking_lot 0.12.1", "sc-executor-common", - "sc-executor-wasmi", "sc-executor-wasmtime", "sp-api", "sp-core", @@ -10823,46 +11922,31 @@ dependencies = [ "sp-version", "sp-wasm-interface", "tracing", - "wasmi 0.13.2", ] [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", "sp-wasm-interface", "thiserror", "wasm-instrument 0.3.0", - "wasmi 0.13.2", -] - -[[package]] -name = "sc-executor-wasmi" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" -dependencies = [ - "log", - "sc-allocator", - "sc-executor-common", - "sp-runtime-interface", - "sp-wasm-interface", - "wasmi 0.13.2", ] [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "anyhow", "cfg-if", "libc", "log", "once_cell", - "rustix 0.36.7", + "rustix 0.36.14", "sc-allocator", "sc-executor-common", "sp-runtime-interface", @@ -10873,7 +11957,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "ansi_term", "futures", @@ -10889,10 +11973,9 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", - "async-trait", "parking_lot 0.12.1", "serde_json", "sp-application-crypto", @@ -10904,7 +11987,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", "async-channel", @@ -10919,17 +12002,17 @@ dependencies = [ "libp2p", "linked_hash_set", "log", - "lru 0.8.1", + "lru 0.10.0", "mockall", "parity-scale-codec", "parking_lot 0.12.1", + "partial_sort", "pin-project", "rand 0.8.5", "sc-block-builder", "sc-client-api", "sc-consensus", "sc-network-common", - "sc-peerset", "sc-utils", "serde", "serde_json", @@ -10943,17 +12026,19 @@ dependencies = [ "substrate-prometheus-endpoint", "thiserror", "unsigned-varint", + "wasm-timer", "zeroize", ] [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ + "async-channel", "cid", "futures", - "libp2p", + "libp2p-identity", "log", "prost", "prost-build", @@ -10969,7 +12054,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -10977,11 +12062,10 @@ dependencies = [ "bytes", "futures", "futures-timer", - "libp2p", + "libp2p-identity", "parity-scale-codec", "prost-build", "sc-consensus", - "sc-peerset", "sc-utils", "serde", "smallvec", @@ -10997,17 +12081,16 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ - "ahash 0.8.2", + "ahash 0.8.3", "futures", "futures-timer", "libp2p", "log", - "lru 0.8.1", + "lru 0.10.0", "sc-network", "sc-network-common", - "sc-peerset", "sp-runtime", "substrate-prometheus-endpoint", "tracing", @@ -11016,11 +12099,12 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", + "async-channel", "futures", - "libp2p", + "libp2p-identity", "log", "parity-scale-codec", "prost", @@ -11028,7 +12112,6 @@ dependencies = [ "sc-client-api", "sc-network", "sc-network-common", - "sc-peerset", "sp-blockchain", "sp-core", "sp-runtime", @@ -11038,16 +12121,17 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", + "async-channel", "async-trait", "fork-tree", "futures", "futures-timer", "libp2p", "log", - "lru 0.8.1", + "lru 0.10.0", "mockall", "parity-scale-codec", "prost", @@ -11056,7 +12140,6 @@ dependencies = [ "sc-consensus", "sc-network", "sc-network-common", - "sc-peerset", "sc-utils", "smallvec", "sp-arithmetic", @@ -11072,17 +12155,15 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", "futures", "libp2p", "log", "parity-scale-codec", - "pin-project", "sc-network", "sc-network-common", - "sc-peerset", "sc-utils", "sp-consensus", "sp-runtime", @@ -11092,7 +12173,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", "bytes", @@ -11110,7 +12191,6 @@ dependencies = [ "sc-client-api", "sc-network", "sc-network-common", - "sc-peerset", "sc-utils", "sp-api", "sp-core", @@ -11120,23 +12200,10 @@ dependencies = [ "tracing", ] -[[package]] -name = "sc-peerset" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" -dependencies = [ - "futures", - "libp2p", - "log", - "sc-utils", - "serde_json", - "wasm-timer", -] - [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -11145,7 +12212,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "futures", "jsonrpsee", @@ -11168,6 +12235,7 @@ dependencies = [ "sp-rpc", "sp-runtime", "sp-session", + "sp-statement-store", "sp-version", "tokio", ] @@ -11175,7 +12243,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -11194,7 +12262,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "http", "jsonrpsee", @@ -11209,7 +12277,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", "futures", @@ -11235,7 +12303,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "directories", @@ -11301,7 +12369,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "log", "parity-scale-codec", @@ -11312,9 +12380,9 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ - "clap 4.2.3", + "clap", "fs4", "futures", "log", @@ -11328,7 +12396,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -11347,7 +12415,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "futures", "libc", @@ -11366,7 +12434,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "chrono", "futures", @@ -11385,7 +12453,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "ansi_term", "atty", @@ -11416,25 +12484,24 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "futures", "futures-timer", "linked-hash-map", "log", - "num-traits", "parity-scale-codec", "parking_lot 0.12.1", "sc-client-api", @@ -11454,13 +12521,15 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "futures", "log", + "parity-scale-codec", "serde", "sp-blockchain", + "sp-core", "sp-runtime", "thiserror", ] @@ -11468,7 +12537,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-channel", "futures", @@ -11482,9 +12551,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.5.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cfdffd972d76b22f3d7f81c8be34b2296afd3a25e0a547bd9abe340a4dbbe97" +checksum = "b569c32c806ec3abdf3b5869fb8bf1e0d275a7c1c9b0b05603d9464632649edf" dependencies = [ "bitvec", "cfg-if", @@ -11496,9 +12565,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61fa974aea2d63dd18a4ec3a49d59af9f34178c73a4f56d2f18205628d00681e" +checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -11508,12 +12577,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.19" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" dependencies = [ - "lazy_static", - "winapi", + "windows-sys 0.42.0", ] [[package]] @@ -11522,7 +12590,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" dependencies = [ - "ahash 0.8.2", + "ahash 0.8.3", "cfg-if", "hashbrown 0.13.2", ] @@ -11553,9 +12621,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sct" @@ -11596,8 +12664,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ "base16ct 0.1.1", - "der 0.6.0", - "generic-array 0.14.6", + "der 0.6.1", + "generic-array 0.14.7", "pkcs8 0.9.0", "subtle", "zeroize", @@ -11605,32 +12673,32 @@ dependencies = [ [[package]] name = "sec1" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48518a2b5775ba8ca5b46596aae011caa431e6ce7e4a67ead66d92f08884220e" +checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" dependencies = [ "base16ct 0.2.0", - "der 0.7.1", - "generic-array 0.14.6", - "pkcs8 0.10.1", + "der 0.7.6", + "generic-array 0.14.7", + "pkcs8 0.10.2", "subtle", "zeroize", ] [[package]] name = "secp256k1" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9512ffd81e3a3503ed401f79c33168b9148c75038956039166cd750eaa037c3" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" dependencies = [ "secp256k1-sys", ] [[package]] name = "secp256k1-sys" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7058dc8eaf3f2810d7828680320acda0b25a288f6d288e19278e249bbf74226b" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" dependencies = [ "cc", ] @@ -11646,9 +12714,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.4.2" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" +checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ "bitflags", "core-foundation", @@ -11659,9 +12727,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.4.2" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" +checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" dependencies = [ "core-foundation-sys", "libc", @@ -11716,9 +12784,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" dependencies = [ "serde", ] @@ -11731,22 +12799,22 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.160" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -11755,32 +12823,20 @@ version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ - "itoa 1.0.4", + "itoa", "ryu", "serde", ] [[package]] name = "serde_spanned" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +checksum = "93107647184f6027e3b7dcb2e11034cf95ffa1e3a682c67951963ac69c1c007d" dependencies = [ "serde", ] -[[package]] -name = "sha-1" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - [[package]] name = "sha-1" version = "0.9.8" @@ -11794,6 +12850,17 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "sha2" version = "0.8.2" @@ -11808,9 +12875,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", "cfg-if", @@ -11821,22 +12888,22 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.2" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] name = "sha3" -version = "0.10.0" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f935e31cf406e8c0e96c2815a5516181b7004ae8c5f296293221e9b1e356bd" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "keccak", ] @@ -11888,9 +12955,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] @@ -11901,25 +12968,25 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "rand_core 0.6.4", ] [[package]] name = "signature" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fe458c98333f9c8152221191a77e2a44e8325d0193484af2e9421a53019e57d" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "rand_core 0.6.4", ] [[package]] name = "simba" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50582927ed6f77e4ac020c057f37a268fc6aebc29225050365aacbb9deeeddc4" +checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" dependencies = [ "approx", "num-complex", @@ -11936,20 +13003,23 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.5" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] [[package]] name = "slice-group-by" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "slot-range-helper" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "enumn", "parity-scale-codec", @@ -11975,9 +13045,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "snap" -version = "1.0.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45456094d1983e2ee2a18fdfebce3189fa451699d0502cb8e3b49dba5ba41451" +checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "snow" @@ -11992,7 +13062,7 @@ dependencies = [ "rand_core 0.6.4", "ring", "rustc_version 0.4.0", - "sha2 0.10.2", + "sha2 0.10.6", "subtle", ] @@ -12012,7 +13082,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ - "base64", + "base64 0.13.1", "bytes", "flate2", "futures", @@ -12020,13 +13090,13 @@ dependencies = [ "httparse", "log", "rand 0.8.5", - "sha-1 0.9.8", + "sha-1", ] [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "hash-db", "log", @@ -12046,7 +13116,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "Inflector", "blake2", @@ -12054,13 +13124,13 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "sp-application-crypto" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "23.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "scale-info", @@ -12072,8 +13142,8 @@ dependencies = [ [[package]] name = "sp-arithmetic" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "16.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "integer-sqrt", "num-traits", @@ -12087,7 +13157,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "scale-info", @@ -12100,7 +13170,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "sp-api", @@ -12112,11 +13182,11 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "futures", "log", - "lru 0.8.1", + "lru 0.10.0", "parity-scale-codec", "parking_lot 0.12.1", "sp-api", @@ -12130,7 +13200,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "futures", @@ -12145,7 +13215,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "parity-scale-codec", @@ -12163,7 +13233,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "parity-scale-codec", @@ -12184,7 +13254,7 @@ dependencies = [ [[package]] name = "sp-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "lazy_static", "parity-scale-codec", @@ -12203,7 +13273,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "finality-grandpa", "log", @@ -12221,7 +13291,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "scale-info", @@ -12232,8 +13302,8 @@ dependencies = [ [[package]] name = "sp-core" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "21.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", "bitflags", @@ -12276,13 +13346,13 @@ dependencies = [ [[package]] name = "sp-core-hashing" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "9.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "blake2b_simd", "byteorder", - "digest 0.10.6", - "sha2 0.10.2", + "digest 0.10.7", + "sha2 0.10.6", "sha3", "sp-std", "twox-hash", @@ -12290,19 +13360,19 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "9.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "proc-macro2", "quote", "sp-core-hashing", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -12310,18 +13380,18 @@ dependencies = [ [[package]] name = "sp-debug-derive" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "8.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "sp-externalities" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "0.19.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "environmental", "parity-scale-codec", @@ -12332,7 +13402,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -12346,8 +13416,8 @@ dependencies = [ [[package]] name = "sp-io" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "23.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "bytes", "ed25519", @@ -12372,8 +13442,8 @@ dependencies = [ [[package]] name = "sp-keyring" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "24.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "lazy_static", "sp-core", @@ -12383,8 +13453,8 @@ dependencies = [ [[package]] name = "sp-keystore" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "0.27.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "futures", "parity-scale-codec", @@ -12398,7 +13468,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "thiserror", "zstd 0.12.3+zstd.1.5.2", @@ -12407,7 +13477,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -12418,7 +13488,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -12436,7 +13506,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "scale-info", @@ -12450,7 +13520,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "sp-api", "sp-core", @@ -12459,8 +13529,8 @@ dependencies = [ [[package]] name = "sp-panic-handler" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "8.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "backtrace", "lazy_static", @@ -12470,7 +13540,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "rustc-hash", "serde", @@ -12479,8 +13549,8 @@ dependencies = [ [[package]] name = "sp-runtime" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "24.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "either", "hash256-std-hasher", @@ -12501,8 +13571,8 @@ dependencies = [ [[package]] name = "sp-runtime-interface" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "17.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -12519,29 +13589,20 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "11.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "Inflector", "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.15", -] - -[[package]] -name = "sp-serializer" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" -dependencies = [ - "serde", - "serde_json", + "syn 2.0.18", ] [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "scale-info", @@ -12555,10 +13616,11 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "scale-info", + "serde", "sp-core", "sp-runtime", "sp-std", @@ -12566,8 +13628,8 @@ dependencies = [ [[package]] name = "sp-state-machine" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "0.28.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "hash-db", "log", @@ -12584,15 +13646,33 @@ dependencies = [ "tracing", ] +[[package]] +name = "sp-statement-store" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" +dependencies = [ + "log", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-externalities", + "sp-runtime", + "sp-runtime-interface", + "sp-std", + "thiserror", +] + [[package]] name = "sp-std" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "8.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" [[package]] name = "sp-storage" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "13.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "impl-serde", "parity-scale-codec", @@ -12605,7 +13685,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "futures-timer", @@ -12619,8 +13699,8 @@ dependencies = [ [[package]] name = "sp-tracing" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "10.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "sp-std", @@ -12632,7 +13712,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "sp-api", "sp-runtime", @@ -12641,7 +13721,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "log", @@ -12656,10 +13736,10 @@ dependencies = [ [[package]] name = "sp-trie" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "22.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ - "ahash 0.8.2", + "ahash 0.8.3", "hash-db", "hashbrown 0.13.2", "lazy_static", @@ -12679,8 +13759,8 @@ dependencies = [ [[package]] name = "sp-version" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "22.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "impl-serde", "parity-scale-codec", @@ -12696,33 +13776,32 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "8.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "sp-wasm-interface" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "14.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "anyhow", "impl-trait-for-tuples", "log", "parity-scale-codec", "sp-std", - "wasmi 0.13.2", "wasmtime", ] [[package]] name = "sp-weights" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +version = "20.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "parity-scale-codec", "scale-info", @@ -12742,9 +13821,20 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "spin" -version = "0.9.4" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "spinners" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" +dependencies = [ + "lazy_static", + "maplit", + "strum", +] [[package]] name = "spki" @@ -12753,24 +13843,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" dependencies = [ "base64ct", - "der 0.6.0", + "der 0.6.1", ] [[package]] name = "spki" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0445c905640145c7ea8c1993555957f65e7c46d0535b91ba501bc9bfc85522f" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", - "der 0.7.1", + "der 0.7.6", ] [[package]] name = "ss58-registry" -version = "1.34.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37a9821878e1f13aba383aa40a86fb1b33c7265774ec91e32563cb1dd1577496" +checksum = "eb47a8ad42e5fc72d5b1eb104a5546937eaf39843499948bb666d6e93c62423b" dependencies = [ "Inflector", "num-format", @@ -12787,143 +13877,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "statemine-runtime" -version = "2.0.0" -dependencies = [ - "asset-test-utils", - "assets-common", - "cumulus-pallet-aura-ext", - "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-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "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-message-queue", - "pallet-multisig", - "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", - "pallet-xcm-benchmarks", - "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 = "statemint-runtime" -version = "1.0.0" -dependencies = [ - "asset-test-utils", - "assets-common", - "cumulus-pallet-aura-ext", - "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-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-message-queue", - "pallet-multisig", - "pallet-proxy", - "pallet-session", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-uniques", - "pallet-utility", - "pallet-xcm", - "pallet-xcm-benchmarks", - "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 = "static_assertions" version = "1.1.0" @@ -12952,7 +13905,7 @@ dependencies = [ "cfg_aliases", "libc", "parking_lot 0.11.2", - "parking_lot_core 0.8.5", + "parking_lot_core 0.8.6", "static_init_macro 1.0.2", "winapi", ] @@ -13000,9 +13953,9 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.24.0" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ "heck", "proc-macro2", @@ -13017,7 +13970,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7e94b1ec00bad60e6410e058b52f1c66de3dc5fe4d62d09b3e52bb7d3b73e25" dependencies = [ - "base64", + "base64 0.13.1", "crc", "lazy_static", "md-5", @@ -13039,22 +13992,22 @@ dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", "schnorrkel", - "sha2 0.9.8", + "sha2 0.9.9", "zeroize", ] [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ - "platforms 2.0.0", + "platforms", ] [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -13073,7 +14026,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "hyper", "log", @@ -13085,7 +14038,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", "jsonrpsee", @@ -13098,7 +14051,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "jsonrpsee", "log", @@ -13117,7 +14070,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -13143,7 +14096,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "futures", "substrate-test-utils-derive", @@ -13153,27 +14106,28 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "ansi_term", "build-helper", "cargo_metadata", "filetime", + "parity-wasm", "sp-maybe-compressed-blob", "strum", "tempfile", - "toml 0.7.3", + "toml 0.7.4", "walkdir", "wasm-opt", ] @@ -13206,9 +14160,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" dependencies = [ "proc-macro2", "quote", @@ -13229,9 +14183,9 @@ dependencies = [ [[package]] name = "system-configuration" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75182f12f490e953596550b65ee31bda7c8e043d9386174b353bda50838c3fd" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags", "core-foundation", @@ -13256,9 +14210,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.5" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tempfile" @@ -13269,29 +14223,29 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.3", + "rustix 0.37.19", "windows-sys 0.45.0", ] [[package]] name = "termcolor" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] [[package]] name = "termtree" -version = "0.2.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "test-runtime-constants" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "frame-support", "polkadot-primitives", @@ -13302,12 +14256,6 @@ dependencies = [ "sp-weights", ] -[[package]] -name = "textwrap" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" - [[package]] name = "thiserror" version = "1.0.40" @@ -13325,7 +14273,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -13336,10 +14284,11 @@ checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ + "cfg-if", "once_cell", ] @@ -13378,20 +14327,19 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.2+5.3.0-patched" +version = "0.5.3+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec45c14da997d0925c7835883e4d5c181f196fa142f8c19d7643d1e9af2592c3" +checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" dependencies = [ "cc", - "fs_extra", "libc", ] [[package]] name = "time" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", "wasi 0.10.0+wasi-snapshot-preview1", @@ -13400,11 +14348,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" dependencies = [ - "itoa 1.0.4", + "itoa", "serde", "time-core", "time-macros", @@ -13412,15 +14360,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.6" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" dependencies = [ "time-core", ] @@ -13437,13 +14385,22 @@ dependencies = [ "pbkdf2 0.11.0", "rand 0.8.5", "rustc-hash", - "sha2 0.10.2", + "sha2 0.10.6", "thiserror", "unicode-normalization", "wasm-bindgen", "zeroize", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -13456,24 +14413,24 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.27.0" +version = "1.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" dependencies = [ "autocfg", "bytes", @@ -13485,36 +14442,47 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", +] + +[[package]] +name = "tokio-retry" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" +dependencies = [ + "pin-project", + "rand 0.8.5", + "tokio", ] [[package]] name = "tokio-rustls" -version = "0.23.2" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ - "rustls 0.20.7", + "rustls 0.20.8", "tokio", "webpki 0.22.0", ] [[package]] name = "tokio-stream" -version = "0.1.9" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df54d54117d6fdc4e4fea40fe1e4e566b3505700e148a6827e59b34b0d2600d9" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", "pin-project-lite 0.2.9", @@ -13524,9 +14492,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.1" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0edfdeb067411dba2044da6d1cb2df793dd35add7888d73c16e3381ded401764" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -13539,18 +14507,18 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", ] [[package]] name = "toml" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" +checksum = "d6135d499e69981f9ff0ef2167955a5333c35e36f6937d382974566b3d5b94ec" dependencies = [ "serde", "serde_spanned", @@ -13560,18 +14528,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.7" +version = "0.19.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc18466501acd8ac6a3f615dd29a3438f8ca6bb3b19537138b3106e575621274" +checksum = "2380d56e8670370eee6566b0bfd4265f65b3f432e8c6d85623f728d4fa31f739" dependencies = [ "indexmap", "serde", @@ -13593,9 +14561,9 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.3.5" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" +checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658" dependencies = [ "bitflags", "bytes", @@ -13617,9 +14585,9 @@ checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" [[package]] name = "tower-service" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" @@ -13636,20 +14604,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", "valuable", @@ -13668,7 +14636,7 @@ dependencies = [ [[package]] name = "tracing-gum" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "polkadot-node-jaeger", "polkadot-primitives", @@ -13679,13 +14647,13 @@ dependencies = [ [[package]] name = "tracing-gum-proc-macro" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "expander 2.0.0", "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -13701,9 +14669,9 @@ dependencies = [ [[package]] name = "tracing-serde" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" dependencies = [ "serde", "tracing-core", @@ -13734,9 +14702,9 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.27.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d75c77ea43f2ad8ea9d9c58de49dfc9c3995bdef32b503df7883ff054e7f1" +checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" dependencies = [ "hash-db", "hashbrown 0.13.2", @@ -13802,17 +14770,17 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#d5d63e9b7f624de321032a033675387a73a66646" +source = "git+https://github.com/paritytech/substrate?branch=master#689da495a0c0c0c2466fe90a9ea187ce56760f2d" dependencies = [ "async-trait", - "clap 4.2.3", + "clap", "frame-remote-externalities", "frame-try-runtime", "hex", @@ -13845,9 +14813,9 @@ dependencies = [ [[package]] name = "tt-call" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" +checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" [[package]] name = "turn" @@ -13856,7 +14824,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" dependencies = [ "async-trait", - "base64", + "base64 0.13.1", "futures", "log", "md-5", @@ -13875,28 +14843,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", - "digest 0.10.6", + "digest 0.10.7", "rand 0.8.5", "static_assertions", ] [[package]] name = "typenum" -version = "1.14.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" [[package]] name = "uint" -version = "0.9.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ "byteorder", "crunchy", @@ -13906,36 +14874,36 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.7" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.0" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] [[package]] name = "unicode-width" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "unicode-xid" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "universal-hash" @@ -13943,7 +14911,17 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", + "subtle", +] + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", "subtle", ] @@ -13984,11 +14962,11 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.2.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" +checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", ] [[package]] @@ -14041,12 +15019,11 @@ checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -14080,9 +15057,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.78" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -14090,24 +15067,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.78" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.28" +version = "0.4.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" +checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" dependencies = [ "cfg-if", "js-sys", @@ -14117,9 +15094,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.78" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -14127,22 +15104,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.78" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.18", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.78" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "wasm-instrument" @@ -14164,9 +15141,9 @@ dependencies = [ [[package]] name = "wasm-opt" -version = "0.111.0" +version = "0.112.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a303793cbc01fb96551badfc7367db6007396bba6bac97936b3c8b6f7fdb41" +checksum = "87fef6d0d508f08334e0ab0e6877feb4c0ecb3956bcf2cb950699b22fedf3e9c" dependencies = [ "anyhow", "libc", @@ -14180,9 +15157,9 @@ dependencies = [ [[package]] name = "wasm-opt-cxx-sys" -version = "0.111.0" +version = "0.112.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c9deb56f8a9f2ec177b3bd642a8205621835944ed5da55f2388ef216aca5a4" +checksum = "bc816bbc1596c8f2e8127e137a760c798023ef3d378f2ae51f0f1840e2dfa445" dependencies = [ "anyhow", "cxx", @@ -14192,15 +15169,14 @@ dependencies = [ [[package]] name = "wasm-opt-sys" -version = "0.111.0" +version = "0.112.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4432e28b542738a9776cedf92e8a99d8991c7b4667ee2c7ccddfb479dd2856a7" +checksum = "40199e4f68ef1071b3c6d0bd8026a12b481865d4b9e49c156932ea9a6234dd14" dependencies = [ "anyhow", "cc", "cxx", "cxx-build", - "regex", ] [[package]] @@ -14218,58 +15194,24 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wasmi" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" -dependencies = [ - "parity-wasm", - "wasmi-validation", - "wasmi_core 0.2.1", -] - [[package]] name = "wasmi" version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e61a7006b0fdf24f6bbe8dcfdad5ca1b350de80061fb2827f31c82fbbb9565a" dependencies = [ - "spin 0.9.4", + "spin 0.9.8", "wasmi_arena", - "wasmi_core 0.12.0", + "wasmi_core", "wasmparser-nostd", ] -[[package]] -name = "wasmi-validation" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" -dependencies = [ - "parity-wasm", -] - [[package]] name = "wasmi_arena" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "401c1f35e413fac1846d4843745589d9ec678977ab35a384db8ae7830525d468" -[[package]] -name = "wasmi_core" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" -dependencies = [ - "downcast-rs", - "libm 0.2.1", - "memory_units", - "num-rational", - "num-traits", - "region", -] - [[package]] name = "wasmi_core" version = "0.12.0" @@ -14277,16 +15219,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624e6333e861ef49095d2d678b76ebf30b06bf37effca845be7e5b87c90071b7" dependencies = [ "downcast-rs", - "libm 0.2.1", + "libm 0.2.7", "num-traits", "paste", ] [[package]] name = "wasmparser" -version = "0.100.0" +version = "0.102.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b20236ab624147dfbb62cf12a19aaf66af0e41b8398838b66e997d07d269d4" +checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" dependencies = [ "indexmap", "url", @@ -14303,9 +15245,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "6.0.1" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e89f9819523447330ffd70367ef4a18d8c832e24e8150fe054d1d912841632" +checksum = "f907fdead3153cb9bfb7a93bbd5b62629472dc06dee83605358c64c52ed3dda9" dependencies = [ "anyhow", "bincode", @@ -14313,7 +15255,7 @@ dependencies = [ "indexmap", "libc", "log", - "object 0.29.0", + "object", "once_cell", "paste", "psm", @@ -14326,43 +15268,43 @@ dependencies = [ "wasmtime-environ", "wasmtime-jit", "wasmtime-runtime", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-asm-macros" -version = "6.0.1" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd3a5e46c198032da934469f3a6e48649d1f9142438e4fd4617b68a35644b8a" +checksum = "d3b9daa7c14cd4fa3edbf69de994408d5f4b7b0959ac13fa69d465f6597f810d" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "6.0.1" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b389ae9b678b9c3851091a4804f4182d688d27aff7abc9aa37fa7be37d8ecffa" +checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", - "base64", + "base64 0.21.2", "bincode", "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.7", + "rustix 0.36.14", "serde", - "sha2 0.10.2", - "toml 0.5.10", - "windows-sys 0.42.0", + "sha2 0.10.6", + "toml 0.5.11", + "windows-sys 0.45.0", "zstd 0.11.2+zstd.1.5.2", ] [[package]] name = "wasmtime-cranelift" -version = "6.0.1" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b2c92a08c0db6efffd88fdc97d7aa9c7c63b03edb0971dbca745469f820e8c" +checksum = "b1cefde0cce8cb700b1b21b6298a3837dba46521affd7b8c38a9ee2c869eee04" dependencies = [ "anyhow", "cranelift-codegen", @@ -14370,27 +15312,43 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli 0.26.1", + "gimli", "log", - "object 0.29.0", + "object", "target-lexicon", "thiserror", "wasmparser", + "wasmtime-cranelift-shared", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-cranelift-shared" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd041e382ef5aea1b9fc78442394f1a4f6d676ce457e7076ca4cb3f397882f8b" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-native", + "gimli", + "object", + "target-lexicon", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "6.0.1" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a6db9fc52985ba06ca601f2ff0ff1f526c5d724c7ac267b47326304b0c97883" +checksum = "a990198cee4197423045235bf89d3359e69bd2ea031005f4c2d901125955c949" dependencies = [ "anyhow", "cranelift-entity", - "gimli 0.26.1", + "gimli", "indexmap", "log", - "object 0.29.0", + "object", "serde", "target-lexicon", "thiserror", @@ -14400,18 +15358,18 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "6.0.1" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b77e3a52cd84d0f7f18554afa8060cfe564ccac61e3b0802d3fd4084772fa5f6" +checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" dependencies = [ - "addr2line 0.17.0", + "addr2line", "anyhow", "bincode", "cfg-if", "cpp_demangle", - "gimli 0.26.1", + "gimli", "log", - "object 0.29.0", + "object", "rustc-demangle", "serde", "target-lexicon", @@ -14419,36 +15377,36 @@ dependencies = [ "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-jit-debug" -version = "6.0.1" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0245e8a9347017c7185a72e215218a802ff561545c242953c11ba00fccc930f" +checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ - "object 0.29.0", + "object", "once_cell", - "rustix 0.36.7", + "rustix 0.36.14", ] [[package]] name = "wasmtime-jit-icache-coherence" -version = "6.0.1" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67d412e9340ab1c83867051d8d1d7c90aa8c9afc91da086088068e2734e25064" +checksum = "aecae978b13f7f67efb23bd827373ace4578f2137ec110bbf6a4a7cde4121bbd" dependencies = [ "cfg-if", "libc", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-runtime" -version = "6.0.1" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d594e791b5fdd4dbaf8cf7ae62f2e4ff85018ce90f483ca6f42947688e48827d" +checksum = "658cf6f325232b6760e202e5255d823da5e348fdea827eff0a2a22319000b441" dependencies = [ "anyhow", "cc", @@ -14458,21 +15416,21 @@ dependencies = [ "log", "mach", "memfd", - "memoffset 0.6.5", + "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.7", + "rustix 0.36.14", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "wasmtime-types" -version = "6.0.1" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6688d6f96d4dbc1f89fab626c56c1778936d122b5f4ae7a57c2eb42b8d982e2" +checksum = "a4f6fffd2a1011887d57f07654dd112791e872e3ff4a2e626aee8059ee17f06f" dependencies = [ "cranelift-entity", "serde", @@ -14482,9 +15440,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.55" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" dependencies = [ "js-sys", "wasm-bindgen", @@ -14512,9 +15470,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.2" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ "webpki 0.22.0", ] @@ -14542,10 +15500,10 @@ dependencies = [ "sdp", "serde", "serde_json", - "sha2 0.10.2", + "sha2 0.10.6", "stun", "thiserror", - "time 0.3.17", + "time 0.3.21", "tokio", "turn", "url", @@ -14577,22 +15535,22 @@ dependencies = [ [[package]] name = "webrtc-dtls" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7021987ae0a2ed6c8cd33f68e98e49bb6e74ffe9543310267b48a1bbe3900e5f" +checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" dependencies = [ "aes 0.6.0", - "aes-gcm 0.8.0", + "aes-gcm 0.10.2", "async-trait", "bincode", "block-modes", "byteorder", "ccm", "curve25519-dalek 3.2.0", - "der-parser 8.1.0", + "der-parser 8.2.0", "elliptic-curve 0.12.3", "hkdf", - "hmac 0.10.1", + "hmac 0.12.1", "log", "oid-registry 0.6.1", "p256", @@ -14604,8 +15562,8 @@ dependencies = [ "rustls 0.19.1", "sec1 0.3.0", "serde", - "sha-1 0.9.8", - "sha2 0.9.8", + "sha1", + "sha2 0.10.6", "signature 1.6.4", "subtle", "thiserror", @@ -14618,9 +15576,9 @@ dependencies = [ [[package]] name = "webrtc-ice" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "494483fbb2f5492620871fdc78b084aed8807377f6e3fe88b2e49f0a9c9c41d7" +checksum = "465a03cc11e9a7d7b4f9f99870558fe37a102b65b93f8045392fef7c67b39e80" dependencies = [ "arc-swap", "async-trait", @@ -14655,18 +15613,15 @@ dependencies = [ [[package]] name = "webrtc-media" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a3c157a040324e5049bcbd644ffc9079e6738fa2cfab2bcff64e5cc4c00d7" +checksum = "f72e1650a8ae006017d1a5280efb49e2610c19ccc3c0905b03b648aee9554991" dependencies = [ "byteorder", "bytes", - "derive_builder", - "displaydoc", "rand 0.8.5", "rtp", "thiserror", - "webrtc-util", ] [[package]] @@ -14703,7 +15658,7 @@ dependencies = [ "log", "rtcp", "rtp", - "sha-1 0.9.8", + "sha-1", "subtle", "thiserror", "tokio", @@ -14724,26 +15679,17 @@ dependencies = [ "lazy_static", "libc", "log", - "nix 0.24.2", + "nix 0.24.3", "rand 0.8.5", "thiserror", "tokio", "winapi", ] -[[package]] -name = "wepoll-ffi" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" -dependencies = [ - "cc", -] - [[package]] name = "westend-runtime" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bitvec", "frame-benchmarking", @@ -14772,6 +15718,7 @@ dependencies = [ "pallet-im-online", "pallet-indices", "pallet-membership", + "pallet-message-queue", "pallet-multisig", "pallet-nomination-pools", "pallet-nomination-pools-benchmarking", @@ -14835,7 +15782,7 @@ dependencies = [ [[package]] name = "westend-runtime-constants" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "frame-support", "polkadot-primitives", @@ -14846,90 +15793,22 @@ dependencies = [ "sp-weights", ] -[[package]] -name = "westmint-runtime" -version = "1.0.0" -dependencies = [ - "asset-test-utils", - "assets-common", - "cumulus-pallet-aura-ext", - "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-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-message-queue", - "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", - "pallet-xcm-benchmarks", - "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", - "substrate-wasm-builder", - "westend-runtime-constants", - "xcm", - "xcm-builder", - "xcm-executor", -] - [[package]] name = "which" -version = "4.2.2" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea187a8ef279bc014ec368c27a920da2024d2a711109bfbe3440585d5cf27ad9" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" dependencies = [ "either", - "lazy_static", "libc", + "once_cell", ] [[package]] name = "wide" -version = "0.7.6" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feff0a412894d67223777b6cc8d68c0dab06d52d95e9890d5f2d47f10dd9366c" +checksum = "5cd0496a71f3cc6bc4bf0ed91346426a5099e93d89807e663162dc5a1069ff65" dependencies = [ "bytemuck", "safe_arch", @@ -14986,29 +15865,12 @@ dependencies = [ ] [[package]] -name = "windows-sys" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" -dependencies = [ - "windows_aarch64_msvc 0.32.0", - "windows_i686_gnu 0.32.0", - "windows_i686_msvc 0.32.0", - "windows_x86_64_gnu 0.32.0", - "windows_x86_64_msvc 0.32.0", -] - -[[package]] -name = "windows-sys" -version = "0.36.1" +name = "windows" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", + "windows-targets 0.48.0", ] [[package]] @@ -15086,24 +15948,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" -[[package]] -name = "windows_aarch64_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" - [[package]] name = "windows_aarch64_msvc" version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" -[[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -15116,24 +15966,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" -[[package]] -name = "windows_i686_gnu" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" - [[package]] name = "windows_i686_gnu" version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" -[[package]] -name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -15146,24 +15984,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" -[[package]] -name = "windows_i686_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" - [[package]] name = "windows_i686_msvc" version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -15176,24 +16002,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" -[[package]] -name = "windows_x86_64_gnu" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" - [[package]] name = "windows_x86_64_gnu" version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -15218,24 +16032,12 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" -[[package]] -name = "windows_x86_64_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" - [[package]] name = "windows_x86_64_msvc" version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -15250,27 +16052,27 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.3.6" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d020b441f92996c80d94ae9166e8501e59c7bb56121189dc9eab3bd8216966" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.7.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ "winapi", ] [[package]] name = "wyz" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" dependencies = [ "tap", ] @@ -15304,7 +16106,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fb9bace5b5589ffead1afb76e43e34cff39cd0f3ce7e170ae0c29e53b88eb1c" dependencies = [ "asn1-rs 0.3.1", - "base64", + "base64 0.13.1", "data-encoding", "der-parser 7.0.0", "lazy_static", @@ -15313,7 +16115,7 @@ dependencies = [ "ring", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.21", ] [[package]] @@ -15322,22 +16124,22 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" dependencies = [ - "asn1-rs 0.5.1", - "base64", + "asn1-rs 0.5.2", + "base64 0.13.1", "data-encoding", - "der-parser 8.1.0", + "der-parser 8.2.0", "lazy_static", "nom", "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.17", + "time 0.3.21", ] [[package]] name = "xcm" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "bounded-collections", "derivative", @@ -15353,7 +16155,7 @@ dependencies = [ [[package]] name = "xcm-builder" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "frame-support", "frame-system", @@ -15367,6 +16169,39 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "sp-weights", + "xcm", + "xcm-executor", +] + +[[package]] +name = "xcm-emulator" +version = "0.1.0" +dependencies = [ + "casey", + "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", "xcm-executor", ] @@ -15374,7 +16209,7 @@ dependencies = [ [[package]] name = "xcm-executor" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "environmental", "frame-benchmarking", @@ -15394,12 +16229,12 @@ dependencies = [ [[package]] name = "xcm-procedural" version = "0.9.41" -source = "git+https://github.com/paritytech/polkadot?branch=master#929936478a2ef63ad8718e3e8abc4c85a4a0fb50" +source = "git+https://github.com/paritytech/polkadot?branch=master#d67d47f4bc330988dad0a97f5a537a4413ee90e7" dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.18", ] [[package]] @@ -15418,32 +16253,31 @@ dependencies = [ [[package]] name = "yasna" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aed2e7a52e3744ab4d0c05c20aa065258e84c49fd4226f5191b2ed29712710b4" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.17", + "time 0.3.21", ] [[package]] name = "zeroize" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.3.2" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", - "synstructure", + "syn 2.0.18", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index eebd7d51d4e..f2fe232c7b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,9 +2,15 @@ resolver = "2" members = [ + "bridges/bin/runtime-common", + "bridges/modules/grandpa", + "bridges/modules/messages", + "bridges/modules/parachains", + "bridges/modules/relayers", "client/cli", "client/consensus/aura", "client/consensus/common", + "client/consensus/proposer", "client/consensus/relay-chain", "client/network", "client/pov-recovery", @@ -35,20 +41,26 @@ members = [ "parachains/runtimes/starters/shell", "parachains/runtimes/starters/seedling", "parachains/runtimes/assets/common", - "parachains/runtimes/assets/statemint", - "parachains/runtimes/assets/statemine", - "parachains/runtimes/assets/westmint", + "parachains/runtimes/assets/asset-hub-polkadot", + "parachains/runtimes/assets/asset-hub-kusama", + "parachains/runtimes/assets/asset-hub-westend", "parachains/runtimes/bridge-hubs/bridge-hub-rococo", "parachains/runtimes/bridge-hubs/bridge-hub-kusama", "parachains/runtimes/bridge-hubs/bridge-hub-polkadot", "parachains/runtimes/collectives/collectives-polkadot", "parachains/runtimes/contracts/contracts-rococo", + "parachains/runtimes/glutton/glutton-kusama", "parachains/runtimes/testing/penpal", + "parachains/integration-tests/emulated/common", + "parachains/integration-tests/emulated/assets/asset-hub-kusama", + "parachains/integration-tests/emulated/assets/asset-hub-polkadot", + "parachains/integration-tests/emulated/assets/asset-hub-westend", "test/client", "test/relay-sproof-builder", "test/relay-validation-worker-provider", "test/runtime", "test/service", + "xcm/xcm-emulator", ] [profile.release] @@ -59,4 +71,3 @@ opt-level = 3 inherits = "release" lto = true codegen-units = 1 - diff --git a/README.md b/README.md index d1828eafce1..b9ebebfe3a7 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A set of tools for writing [Substrate](https://substrate.io/)-based [Polkadot](https://wiki.polkadot.network/en/) [parachains](https://wiki.polkadot.network/docs/en/learn-parachains). Refer to the included [overview](docs/overview.md) for architectural details, and the -[Connect to relay and parachain tutorials](https://docs.substrate.io/tutorials/connect-relay-and-parachains/) for a +[Connect to a relay chain how-to guide](https://docs.substrate.io/reference/how-to-guides/parachains/connect-to-a-relay-chain/) for a guided walk-through of using these tools. It's easy to write blockchains using Substrate, and the overhead of writing parachains' @@ -167,29 +167,27 @@ cargo build --release --bin polkadot-parachain ![image](https://user-images.githubusercontent.com/2915325/99548884-1be13580-2987-11eb-9a8b-20be658d34f9.png) -## Statemint 🪙 +## Asset Hub 🪙 -This repository also contains the Statemint runtime (as well as the canary runtime Statemine and the -test runtime Westmint). -Statemint is a system parachain providing an asset store for the Polkadot ecosystem. +This repository also contains the Asset Hub runtimes. Asset Hub is a system parachain providing an +asset store for the Polkadot ecosystem. ### Build & Launch a Node -To run a Statemine or Westmint node (Statemint is not deployed, yet) you will need to compile the -`polkadot-parachain` binary: +To run an Asset Hub node, you will need to compile the `polkadot-parachain` binary: ```bash -cargo build --release --locked -p polkadot-parachain +cargo build --release --locked --bin polkadot-parachain ``` Once the executable is built, launch the parachain node via: ```bash -CHAIN=westmint # or statemine +CHAIN=asset-hub-westend # or asset-hub-kusama ./target/release/polkadot-parachain --chain $CHAIN ``` -Refer to the [setup instructions](#local-setup) to run a local network for development. +Refer to the [setup instructions](#manual-setup) to run a local network for development. ## Contracts 📝 @@ -219,7 +217,7 @@ eventually be included by the relay chain for a parachain. To run a Rococo collator you will need to compile the following binary: ```bash -cargo build --release --locked -p polkadot-parachain +cargo build --release --locked --bin polkadot-parachain ``` Otherwise you can compile it with @@ -228,7 +226,7 @@ Otherwise you can compile it with ```bash docker run --rm -it -w /shellhere/cumulus \ -v $(pwd):/shellhere/cumulus \ - paritytech/ci-linux:production cargo build --release --locked -p polkadot-parachain + paritytech/ci-linux:production cargo build --release --locked --bin polkadot-parachain sudo chown -R $(id -u):$(id -g) target/ ``` @@ -244,7 +242,7 @@ Once the executable is built, launch collators for each parachain (repeat once e ### Parachains -* [Statemint](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-statemint-rpc.polkadot.io#/explorer) +* [Asset Hub](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-statemint-rpc.polkadot.io#/explorer) * [Contracts on Rococo](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-contracts-rpc.polkadot.io#/explorer) * [RILT](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo.kilt.io#/explorer) diff --git a/bridges/.gitignore b/bridges/.gitignore new file mode 100644 index 00000000000..5d10cfa41a4 --- /dev/null +++ b/bridges/.gitignore @@ -0,0 +1,26 @@ +**/target/ +**/.env +**/.env2 +**/rust-toolchain +hfuzz_target +hfuzz_workspace +**/Cargo.lock + +**/*.rs.bk + +*.o +*.so +*.rlib +*.dll +.gdb_history + +*.exe + +.DS_Store + +.cargo +.idea +.vscode +*.iml +*.swp +*.swo diff --git a/bridges/CODE_OF_CONDUCT.md b/bridges/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..70541fb72fa --- /dev/null +++ b/bridges/CODE_OF_CONDUCT.md @@ -0,0 +1,80 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers +pledge to making participation in our project and our community a harassment-free experience for +everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity +and expression, level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit + permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +### Facilitation, Not Strongarming + +We recognise that this software is merely a tool for users to create and maintain their blockchain +of preference. We see that blockchains are naturally community platforms with users being the +ultimate decision makers. We assert that good software will maximise user agency by facilitate +user-expression on the network. As such: + +- This project will strive to give users as much choice as is both reasonable and possible over what + protocol they adhere to; but +- use of the project's technical forums, commenting systems, pull requests and issue trackers as a + means to express individual protocol preferences is forbidden. + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are +expected to take appropriate and fair corrective action in response to any instances of unacceptable +behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, +code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or +to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is +representing the project or its community. Examples of representing a project or community include +using an official project e-mail address, posting via an official social media account, or acting as +an appointed representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting +the project team at admin@parity.io. All complaints will be reviewed and investigated and will +result in a response that is deemed necessary and appropriate to the circumstances. The project team +is obligated to maintain confidentiality with regard to the reporter of an incident. Further +details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face +temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/bridges/LICENSE b/bridges/LICENSE new file mode 100644 index 00000000000..733c072369c --- /dev/null +++ b/bridges/LICENSE @@ -0,0 +1,675 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + diff --git a/bridges/README.md b/bridges/README.md new file mode 100644 index 00000000000..2f8c5ca9abb --- /dev/null +++ b/bridges/README.md @@ -0,0 +1,259 @@ +# Parity Bridges Common + +This is a collection of components for building bridges. + +These components include Substrate pallets for syncing headers, passing arbitrary messages, as well +as libraries for building relayers to provide cross-chain communication capabilities. + +Three bridge nodes are also available. The nodes can be used to run test networks which bridge other +Substrate chains. + +🚧 The bridges are currently under construction - a hardhat is recommended beyond this point 🚧 + +## Contents + +- [Installation](#installation) +- [High-Level Architecture](#high-level-architecture) +- [Project Layout](#project-layout) +- [Running the Bridge](#running-the-bridge) +- [How to send a message](#how-to-send-a-message) +- [Community](#community) + +## Installation + +To get up and running you need both stable and nightly Rust. Rust nightly is used to build the Web +Assembly (WASM) runtime for the node. You can configure the WASM support as so: + +```bash +rustup install nightly +rustup target add wasm32-unknown-unknown --toolchain nightly +``` + +Once this is configured you can build and test the repo as follows: + +``` +git clone https://github.com/paritytech/parity-bridges-common.git +cd parity-bridges-common +cargo build --all +cargo test --all +``` + +Also you can build the repo with +[Parity CI Docker image](https://github.com/paritytech/scripts/tree/master/dockerfiles/bridges-ci): + +```bash +docker pull paritytech/bridges-ci:production +mkdir ~/cache +chown 1000:1000 ~/cache #processes in the container runs as "nonroot" user with UID 1000 +docker run --rm -it -w /shellhere/parity-bridges-common \ + -v /home/$(whoami)/cache/:/cache/ \ + -v "$(pwd)":/shellhere/parity-bridges-common \ + -e CARGO_HOME=/cache/cargo/ \ + -e SCCACHE_DIR=/cache/sccache/ \ + -e CARGO_TARGET_DIR=/cache/target/ paritytech/bridges-ci:production cargo build --all +#artifacts can be found in ~/cache/target +``` + +If you want to reproduce other steps of CI process you can use the following +[guide](https://github.com/paritytech/scripts#reproduce-ci-locally). + +If you need more information about setting up your development environment [Substrate's +Installation page](https://docs.substrate.io/main-docs/install/) is a good +resource. + +## High-Level Architecture + +This repo has support for bridging foreign chains together using a combination of Substrate pallets +and external processes called relayers. A bridge chain is one that is able to follow the consensus +of a foreign chain independently. For example, consider the case below where we want to bridge two +Substrate based chains. + +``` ++---------------+ +---------------+ +| | | | +| Rialto | | Millau | +| | | | ++-------+-------+ +-------+-------+ + ^ ^ + | +---------------+ | + | | | | + +-----> | Bridge Relay | <-------+ + | | + +---------------+ +``` + +The Millau chain must be able to accept Rialto headers and verify their integrity. It does this by +using a runtime module designed to track GRANDPA finality. Since two blockchains can't interact +directly they need an external service, called a relayer, to communicate. The relayer will subscribe +to new Rialto headers via RPC and submit them to the Millau chain for verification. + +Take a look at [Bridge High Level Documentation](./docs/high-level-overview.md) for more in-depth +description of the bridge interaction. + +## Project Layout + +Here's an overview of how the project is laid out. The main bits are the `bin`, which is the actual +"blockchain", the `modules` which are used to build the blockchain's logic (a.k.a the runtime) and +the `relays` which are used to pass messages between chains. + +``` +├── bin // Node and Runtime for the various Substrate chains +│ └── ... +├── deployments // Useful tools for deploying test networks +│ └── ... +├── modules // Substrate Runtime Modules (a.k.a Pallets) +│ ├── beefy // On-Chain BEEFY Light Client (in progress) +│ ├── grandpa // On-Chain GRANDPA Light Client +│ ├── messages // Cross Chain Message Passing +│ ├── parachains // On-Chain Parachains Light Client +│ ├── relayers // Relayer rewards registry +│ └── ... +├── primitives // Code shared between modules, runtimes, and relays +│ └── ... +├── relays // Application for sending finality proofs and messages between chains +│ └── ... +└── scripts // Useful development and maintenance scripts +``` + +## Running the Bridge + +To run the Bridge you need to be able to connect the bridge relay node to the RPC interface of nodes +on each side of the bridge (source and target chain). + +There are 2 ways to run the bridge, described below: + +- building & running from source: with this option, you'll be able to run the bridge between two standalone +chains that are running GRANDPA finality gadget to achieve finality; + +- running a Docker Compose setup: this is a recommended option, where you'll see bridges with parachains, +complex relays and more. + +### Using the Source + +First you'll need to build the bridge nodes and relay. This can be done as follows: + +```bash +# In `parity-bridges-common` folder +cargo build -p rialto-bridge-node +cargo build -p millau-bridge-node +cargo build -p substrate-relay +``` + +### Running a Dev network + +We will launch a dev network to demonstrate how to relay a message between two Substrate based +chains (named Rialto and Millau). + +To do this we will need two nodes, two relayers which will relay headers, and two relayers which +will relay messages. + +#### Running from local scripts + +To run a simple dev network you can use the scripts located in the +[`deployments/local-scripts` folder](./deployments/local-scripts). + +First, we must run the two Substrate nodes. + +```bash +# In `parity-bridges-common` folder +./deployments/local-scripts/run-rialto-node.sh +./deployments/local-scripts/run-millau-node.sh +``` + +After the nodes are up we can run the header relayers. + +```bash +./deployments/local-scripts/relay-millau-to-rialto.sh +./deployments/local-scripts/relay-rialto-to-millau.sh +``` + +At this point you should see the relayer submitting headers from the Millau Substrate chain to the +Rialto Substrate chain. + +``` +# Header Relayer Logs +[Millau_to_Rialto_Sync] [date] DEBUG bridge Going to submit finality proof of Millau header #147 to Rialto +[...] [date] INFO bridge Synced 147 of 147 headers +[...] [date] DEBUG bridge Going to submit finality proof of Millau header #148 to Rialto +[...] [date] INFO bridge Synced 148 of 149 headers +``` + +Finally, we can run the message relayers. + +```bash +./deployments/local-scripts/relay-messages-millau-to-rialto.sh +./deployments/local-scripts/relay-messages-rialto-to-millau.sh +``` + +You will also see the message lane relayers listening for new messages. + +``` +# Message Relayer Logs +[Millau_to_Rialto_MessageLane_00000000] [date] DEBUG bridge Asking Millau::ReceivingConfirmationsDelivery about best message nonces +[...] [date] INFO bridge Synced Some(2) of Some(3) nonces in Millau::MessagesDelivery -> Rialto::MessagesDelivery race +[...] [date] DEBUG bridge Asking Millau::MessagesDelivery about message nonces +[...] [date] DEBUG bridge Received best nonces from Millau::ReceivingConfirmationsDelivery: TargetClientNonces { latest_nonce: 0, nonces_data: () } +[...] [date] DEBUG bridge Asking Millau::ReceivingConfirmationsDelivery about finalized message nonces +[...] [date] DEBUG bridge Received finalized nonces from Millau::ReceivingConfirmationsDelivery: TargetClientNonces { latest_nonce: 0, nonces_data: () } +[...] [date] DEBUG bridge Received nonces from Millau::MessagesDelivery: SourceClientNonces { new_nonces: {}, confirmed_nonce: Some(0) } +[...] [date] DEBUG bridge Asking Millau node about its state +[...] [date] DEBUG bridge Received state from Millau node: ClientState { best_self: HeaderId(1593, 0xacac***), best_finalized_self: HeaderId(1590, 0x0be81d...), best_finalized_peer_at_best_self: HeaderId(0, 0xdcdd89...) } +``` + +To send a message see the ["How to send a message" section](#how-to-send-a-message). + +### How to send a message + +In this section we'll show you how to quickly send a bridge message. The message is just an encoded XCM +`Trap(43)` message. + +```bash +# In `parity-bridges-common` folder +./scripts/send-message-from-millau-rialto.sh +``` + +After sending a message you will see the following logs showing a message was successfully sent: + +``` +INFO bridge Sending message to Rialto. Size: 11. +TRACE bridge Sent transaction to Millau node: 0x5e68... +``` + +And at the Rialto node logs you'll something like this: + +``` +... runtime::bridge-messages: Received messages: total=1, valid=1. Weight used: Weight(ref_time: 1215065371, proof_size: 48559)/Weight(ref_time: 1215065371, proof_size: 54703). +``` + +It means that the message has been delivered and dispatched. Message may be dispatched with an +error, though - the goal of our test bridge is to ensure that messages are successfully delivered +and all involved components are working. + +## Full Network Docker Compose Setup + +For a more sophisticated deployment which includes bidirectional header sync, message passing, +monitoring dashboards, etc. see the [Deployments README](./deployments/README.md). + +You should note that you can find images for all the bridge components published on +[Docker Hub](https://hub.docker.com/u/paritytech). + +To run a Rialto node for example, you can use the following command: + +```bash +docker run -p 30333:30333 -p 9933:9933 -p 9944:9944 \ + -it paritytech/rialto-bridge-node --dev --tmp \ + --rpc-cors=all --unsafe-rpc-external +``` + +## Community + +Main hangout for the community is [Element](https://element.io/) (formerly Riot). Element is a chat +server like, for example, Discord. Most discussions around Polkadot and Substrate happen +in various Element "rooms" (channels). So, joining Element might be a good idea, anyway. + +If you are interested in information exchange and development of Polkadot related bridges please +feel free to join the [Polkadot Bridges](https://app.element.io/#/room/#bridges:web3.foundation) +Element channel. + +The [Substrate Technical](https://app.element.io/#/room/#substrate-technical:matrix.org) Element +channel is most suited for discussions regarding Substrate itself. diff --git a/bridges/SECURITY.md b/bridges/SECURITY.md new file mode 100644 index 00000000000..65f2f3bff05 --- /dev/null +++ b/bridges/SECURITY.md @@ -0,0 +1,14 @@ +# Security Policy + +Thanks for helping make the Parity ecosystem more secure. Security is one of our first priorities. + +## Reporting a vulnerability + +If you find something that can be treated as a security vulnerability, please do not use the issue tracker or discuss it in the public forum as it can cause more damage, rather than giving real help to the ecosystem. + +Security vulnerabilities should be reported by the [contact form](https://security-submission.parity.io/). + +If you think that your report might be eligible for the Bug Bounty Program, please mark this during the submission. Please check up-to-date [Parity Bug Bounty Program rules](https://www.parity.io/bug-bounty) to find out the information about our Bug Bounty Program. + +**Warning**: This is an unified SECURITY.md file for Paritytech GitHub Organization. The presence of this file does not mean that this repository is covered by the Bug Bounty program. Please always check the Bug Bounty Program scope for information. + diff --git a/bridges/bin/runtime-common/Cargo.toml b/bridges/bin/runtime-common/Cargo.toml new file mode 100644 index 00000000000..8fe89de962e --- /dev/null +++ b/bridges/bin/runtime-common/Cargo.toml @@ -0,0 +1,88 @@ +[package] +name = "bridge-runtime-common" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +repository = "https://github.com/paritytech/parity-bridges-common/" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } +hash-db = { version = "0.16.0", default-features = false } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } +static_assertions = { version = "1.1", optional = true } + +# Bridge dependencies + +bp-header-chain = { path = "../../primitives/header-chain", default-features = false } +bp-messages = { path = "../../primitives/messages", default-features = false } +bp-parachains = { path = "../../primitives/parachains", default-features = false } +bp-polkadot-core = { path = "../../primitives/polkadot-core", default-features = false } +bp-relayers = { path = "../../primitives/relayers", default-features = false } +bp-runtime = { path = "../../primitives/runtime", default-features = false } +pallet-bridge-grandpa = { path = "../../modules/grandpa", default-features = false } +pallet-bridge-messages = { path = "../../modules/messages", default-features = false } +pallet-bridge-parachains = { path = "../../modules/parachains", default-features = false } +pallet-bridge-relayers = { path = "../../modules/relayers", default-features = false } + +# Substrate dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +# Polkadot dependencies +xcm = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false } +xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false } + +[dev-dependencies] +bp-test-utils = { path = "../../primitives/test-utils" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } + +[features] +default = ["std"] +std = [ + "bp-header-chain/std", + "bp-messages/std", + "bp-parachains/std", + "bp-polkadot-core/std", + "bp-runtime/std", + "codec/std", + "frame-support/std", + "frame-system/std", + "hash-db/std", + "log/std", + "pallet-bridge-grandpa/std", + "pallet-bridge-messages/std", + "pallet-bridge-parachains/std", + "pallet-bridge-relayers/std", + "pallet-transaction-payment/std", + "pallet-utility/std", + "scale-info/std", + "sp-api/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "sp-trie/std", + "xcm/std", + "xcm-builder/std", +] +runtime-benchmarks = [ + "pallet-bridge-grandpa/runtime-benchmarks", + "pallet-bridge-messages/runtime-benchmarks", + "pallet-bridge-parachains/runtime-benchmarks", + "pallet-bridge-relayers/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", +] +integrity-test = [ + "static_assertions", +] diff --git a/bridges/bin/runtime-common/src/integrity.rs b/bridges/bin/runtime-common/src/integrity.rs new file mode 100644 index 00000000000..aa698b0b95e --- /dev/null +++ b/bridges/bin/runtime-common/src/integrity.rs @@ -0,0 +1,361 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Integrity tests for chain constants and pallets configuration. +//! +//! Most of the tests in this module assume that the bridge is using standard (see `crate::messages` +//! module for details) configuration. + +use crate::{messages, messages::MessageBridge}; + +use bp_messages::{InboundLaneData, MessageNonce}; +use bp_runtime::{Chain, ChainId}; +use codec::Encode; +use frame_support::{storage::generator::StorageValue, traits::Get, weights::Weight}; +use frame_system::limits; +use pallet_bridge_messages::WeightInfoExt as _; +use sp_runtime::traits::SignedExtension; + +/// Macro that ensures that the runtime configuration and chain primitives crate are sharing +/// the same types (index, block number, hash, hasher, account id and header). +#[macro_export] +macro_rules! assert_chain_types( + ( runtime: $r:path, this_chain: $this:path ) => { + { + // if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard + // configuration is used), or something has broke existing configuration (meaning that all bridged chains + // and relays will stop functioning) + use frame_system::Config as SystemConfig; + use static_assertions::assert_type_eq_all; + + assert_type_eq_all!(<$r as SystemConfig>::Index, bp_runtime::IndexOf<$this>); + assert_type_eq_all!(<$r as SystemConfig>::BlockNumber, bp_runtime::BlockNumberOf<$this>); + assert_type_eq_all!(<$r as SystemConfig>::Hash, bp_runtime::HashOf<$this>); + assert_type_eq_all!(<$r as SystemConfig>::Hashing, bp_runtime::HasherOf<$this>); + assert_type_eq_all!(<$r as SystemConfig>::AccountId, bp_runtime::AccountIdOf<$this>); + assert_type_eq_all!(<$r as SystemConfig>::Header, bp_runtime::HeaderOf<$this>); + } + } +); + +/// Macro that ensures that the bridge GRANDPA pallet is configured properly to bridge with given +/// chain. +#[macro_export] +macro_rules! assert_bridge_grandpa_pallet_types( + ( runtime: $r:path, with_bridged_chain_grandpa_instance: $i:path, bridged_chain: $bridged:path ) => { + { + // if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard + // configuration is used), or something has broke existing configuration (meaning that all bridged chains + // and relays will stop functioning) + use pallet_bridge_grandpa::Config as GrandpaConfig; + use static_assertions::assert_type_eq_all; + + assert_type_eq_all!(<$r as GrandpaConfig<$i>>::BridgedChain, $bridged); + } + } +); + +/// Macro that ensures that the bridge messages pallet is configured properly to bridge using given +/// configuration. +#[macro_export] +macro_rules! assert_bridge_messages_pallet_types( + ( + runtime: $r:path, + with_bridged_chain_messages_instance: $i:path, + bridge: $bridge:path + ) => { + { + // if one of asserts fail, then either bridge isn't configured properly (or alternatively - non-standard + // configuration is used), or something has broke existing configuration (meaning that all bridged chains + // and relays will stop functioning) + use $crate::messages::{ + source::{FromThisChainMessagePayload, TargetHeaderChainAdapter}, + target::{FromBridgedChainMessagePayload, SourceHeaderChainAdapter}, + AccountIdOf, BalanceOf, BridgedChain, ThisChain, + }; + use pallet_bridge_messages::Config as MessagesConfig; + use static_assertions::assert_type_eq_all; + + assert_type_eq_all!(<$r as MessagesConfig<$i>>::OutboundPayload, FromThisChainMessagePayload); + + assert_type_eq_all!(<$r as MessagesConfig<$i>>::InboundRelayer, AccountIdOf>); + + assert_type_eq_all!(<$r as MessagesConfig<$i>>::TargetHeaderChain, TargetHeaderChainAdapter<$bridge>); + assert_type_eq_all!(<$r as MessagesConfig<$i>>::SourceHeaderChain, SourceHeaderChainAdapter<$bridge>); + } + } +); + +/// Macro that combines four other macro calls - `assert_chain_types`, `assert_bridge_types`, +/// `assert_bridge_grandpa_pallet_types` and `assert_bridge_messages_pallet_types`. It may be used +/// at the chain that is implementing complete standard messages bridge (i.e. with bridge GRANDPA +/// and messages pallets deployed). +#[macro_export] +macro_rules! assert_complete_bridge_types( + ( + runtime: $r:path, + with_bridged_chain_grandpa_instance: $gi:path, + with_bridged_chain_messages_instance: $mi:path, + bridge: $bridge:path, + this_chain: $this:path, + bridged_chain: $bridged:path, + ) => { + $crate::assert_chain_types!(runtime: $r, this_chain: $this); + $crate::assert_bridge_grandpa_pallet_types!( + runtime: $r, + with_bridged_chain_grandpa_instance: $gi, + bridged_chain: $bridged + ); + $crate::assert_bridge_messages_pallet_types!( + runtime: $r, + with_bridged_chain_messages_instance: $mi, + bridge: $bridge + ); + } +); + +/// Parameters for asserting chain-related constants. +#[derive(Debug)] +pub struct AssertChainConstants { + /// Block length limits of the chain. + pub block_length: limits::BlockLength, + /// Block weight limits of the chain. + pub block_weights: limits::BlockWeights, +} + +/// Test that our hardcoded, chain-related constants, are matching chain runtime configuration. +/// +/// In particular, this test ensures that: +/// +/// 1) block weight limits are matching; +/// 2) block size limits are matching. +pub fn assert_chain_constants(params: AssertChainConstants) +where + R: frame_system::Config, +{ + // we don't check runtime version here, because in our case we'll be building relay from one + // repo and runtime will live in another repo, along with outdated relay version. To avoid + // unneeded commits, let's not raise an error in case of version mismatch. + + // if one of following assert fails, it means that we may need to upgrade bridged chain and + // relay to use updated constants. If constants are now smaller than before, it may lead to + // undeliverable messages. + + // `BlockLength` struct is not implementing `PartialEq`, so we compare encoded values here. + assert_eq!( + R::BlockLength::get().encode(), + params.block_length.encode(), + "BlockLength from runtime ({:?}) differ from hardcoded: {:?}", + R::BlockLength::get(), + params.block_length, + ); + // `BlockWeights` struct is not implementing `PartialEq`, so we compare encoded values here + assert_eq!( + R::BlockWeights::get().encode(), + params.block_weights.encode(), + "BlockWeights from runtime ({:?}) differ from hardcoded: {:?}", + R::BlockWeights::get(), + params.block_weights, + ); +} + +/// Test that the constants, used in GRANDPA pallet configuration are valid. +pub fn assert_bridge_grandpa_pallet_constants() +where + R: pallet_bridge_grandpa::Config, + GI: 'static, +{ + assert!( + R::HeadersToKeep::get() > 0, + "HeadersToKeep ({}) must be larger than zero", + R::HeadersToKeep::get(), + ); +} + +/// Parameters for asserting messages pallet constants. +#[derive(Debug)] +pub struct AssertBridgeMessagesPalletConstants { + /// Maximal number of unrewarded relayer entries in a confirmation transaction at the bridged + /// chain. + pub max_unrewarded_relayers_in_bridged_confirmation_tx: MessageNonce, + /// Maximal number of unconfirmed messages in a confirmation transaction at the bridged chain. + pub max_unconfirmed_messages_in_bridged_confirmation_tx: MessageNonce, + /// Identifier of the bridged chain. + pub bridged_chain_id: ChainId, +} + +/// Test that the constants, used in messages pallet configuration are valid. +pub fn assert_bridge_messages_pallet_constants(params: AssertBridgeMessagesPalletConstants) +where + R: pallet_bridge_messages::Config, + MI: 'static, +{ + assert!( + !R::ActiveOutboundLanes::get().is_empty(), + "ActiveOutboundLanes ({:?}) must not be empty", + R::ActiveOutboundLanes::get(), + ); + assert!( + R::MaxUnrewardedRelayerEntriesAtInboundLane::get() <= params.max_unrewarded_relayers_in_bridged_confirmation_tx, + "MaxUnrewardedRelayerEntriesAtInboundLane ({}) must be <= than the hardcoded value for bridged chain: {}", + R::MaxUnrewardedRelayerEntriesAtInboundLane::get(), + params.max_unrewarded_relayers_in_bridged_confirmation_tx, + ); + assert!( + R::MaxUnconfirmedMessagesAtInboundLane::get() <= params.max_unconfirmed_messages_in_bridged_confirmation_tx, + "MaxUnrewardedRelayerEntriesAtInboundLane ({}) must be <= than the hardcoded value for bridged chain: {}", + R::MaxUnconfirmedMessagesAtInboundLane::get(), + params.max_unconfirmed_messages_in_bridged_confirmation_tx, + ); + assert_eq!(R::BridgedChainId::get(), params.bridged_chain_id); +} + +/// Parameters for asserting bridge pallet names. +#[derive(Debug)] +pub struct AssertBridgePalletNames<'a> { + /// Name of the messages pallet, deployed at the bridged chain and used to bridge with this + /// chain. + pub with_this_chain_messages_pallet_name: &'a str, + /// Name of the GRANDPA pallet, deployed at this chain and used to bridge with the bridged + /// chain. + pub with_bridged_chain_grandpa_pallet_name: &'a str, + /// Name of the messages pallet, deployed at this chain and used to bridge with the bridged + /// chain. + pub with_bridged_chain_messages_pallet_name: &'a str, +} + +/// Tests that bridge pallet names used in `construct_runtime!()` macro call are matching constants +/// from chain primitives crates. +pub fn assert_bridge_pallet_names(params: AssertBridgePalletNames) +where + B: MessageBridge, + R: pallet_bridge_grandpa::Config + pallet_bridge_messages::Config, + GI: 'static, + MI: 'static, +{ + assert_eq!(B::BRIDGED_MESSAGES_PALLET_NAME, params.with_this_chain_messages_pallet_name); + assert_eq!( + pallet_bridge_grandpa::PalletOwner::::storage_value_final_key().to_vec(), + bp_runtime::storage_value_key(params.with_bridged_chain_grandpa_pallet_name, "PalletOwner",).0, + ); + assert_eq!( + pallet_bridge_messages::PalletOwner::::storage_value_final_key().to_vec(), + bp_runtime::storage_value_key( + params.with_bridged_chain_messages_pallet_name, + "PalletOwner", + ) + .0, + ); +} + +/// Parameters for asserting complete standard messages bridge. +#[derive(Debug)] +pub struct AssertCompleteBridgeConstants<'a> { + /// Parameters to assert this chain constants. + pub this_chain_constants: AssertChainConstants, + /// Parameters to assert messages pallet constants. + pub messages_pallet_constants: AssertBridgeMessagesPalletConstants, + /// Parameters to assert pallet names constants. + pub pallet_names: AssertBridgePalletNames<'a>, +} + +/// All bridge-related constants tests for the complete standard messages bridge (i.e. with bridge +/// GRANDPA and messages pallets deployed). +pub fn assert_complete_bridge_constants(params: AssertCompleteBridgeConstants) +where + R: frame_system::Config + + pallet_bridge_grandpa::Config + + pallet_bridge_messages::Config, + GI: 'static, + MI: 'static, + B: MessageBridge, +{ + assert_chain_constants::(params.this_chain_constants); + assert_bridge_grandpa_pallet_constants::(); + assert_bridge_messages_pallet_constants::(params.messages_pallet_constants); + assert_bridge_pallet_names::(params.pallet_names); +} + +/// Check that the message lane weights are correct. +pub fn check_message_lane_weights< + C: Chain, + T: frame_system::Config + pallet_bridge_messages::Config, + MessagesPalletInstance: 'static, +>( + bridged_chain_extra_storage_proof_size: u32, + this_chain_max_unrewarded_relayers: MessageNonce, + this_chain_max_unconfirmed_messages: MessageNonce, + // whether `RefundBridgedParachainMessages` extension is deployed at runtime and is used for + // refunding this bridge transactions? + // + // in other words: pass true for all known production chains + runtime_includes_refund_extension: bool, +) { + type Weights = >::WeightInfo; + + // check basic weight assumptions + pallet_bridge_messages::ensure_weights_are_correct::>(); + + // check that weights allow us to receive messages + let max_incoming_message_proof_size = bridged_chain_extra_storage_proof_size + .saturating_add(messages::target::maximal_incoming_message_size(C::max_extrinsic_size())); + pallet_bridge_messages::ensure_able_to_receive_message::>( + C::max_extrinsic_size(), + C::max_extrinsic_weight(), + max_incoming_message_proof_size, + messages::target::maximal_incoming_message_dispatch_weight(C::max_extrinsic_weight()), + ); + + // check that weights allow us to receive delivery confirmations + let max_incoming_inbound_lane_data_proof_size = + InboundLaneData::<()>::encoded_size_hint_u32(this_chain_max_unrewarded_relayers as _); + pallet_bridge_messages::ensure_able_to_receive_confirmation::>( + C::max_extrinsic_size(), + C::max_extrinsic_weight(), + max_incoming_inbound_lane_data_proof_size, + this_chain_max_unrewarded_relayers, + this_chain_max_unconfirmed_messages, + ); + + // check that extra weights of delivery/confirmation transactions include the weight + // of `RefundBridgedParachainMessages` operations. This signed extension assumes the worst case + // (i.e. slashing if delivery transaction was invalid) and refunds some weight if + // assumption was wrong (i.e. if we did refund instead of slashing). This check + // ensures the extension will not refund weight when it doesn't need to (i.e. if pallet + // weights do not account weights of refund extension). + if runtime_includes_refund_extension { + assert_ne!( + Weights::::receive_messages_proof_overhead_from_runtime(), + Weight::zero() + ); + assert_ne!( + Weights::::receive_messages_delivery_proof_overhead_from_runtime(), + Weight::zero() + ); + } +} + +/// Check that the `AdditionalSigned` type of a wrapped runtime is the same as the one of the +/// corresponding actual runtime. +/// +/// This method doesn't perform any `assert`. If the condition is not true it will generate a +/// compile-time error. +pub fn check_additional_signed() +where + SignedExt: SignedExtension, + IndirectSignedExt: SignedExtension, +{ +} diff --git a/bridges/bin/runtime-common/src/lib.rs b/bridges/bin/runtime-common/src/lib.rs new file mode 100644 index 00000000000..546d4388471 --- /dev/null +++ b/bridges/bin/runtime-common/src/lib.rs @@ -0,0 +1,259 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Common types/functions that may be used by runtimes of all bridged chains. + +#![cfg_attr(not(feature = "std"), no_std)] + +use crate::messages_call_ext::MessagesCallSubType; +use pallet_bridge_grandpa::CallSubType as GrandpaCallSubType; +use pallet_bridge_parachains::CallSubType as ParachainsCallSubtype; +use sp_runtime::transaction_validity::TransactionValidity; +use xcm::v3::NetworkId; + +pub mod messages; +pub mod messages_api; +pub mod messages_benchmarking; +pub mod messages_call_ext; +pub mod messages_generation; +pub mod messages_xcm_extension; +pub mod parachains_benchmarking; +pub mod priority_calculator; +pub mod refund_relayer_extension; + +mod mock; + +#[cfg(feature = "integrity-test")] +pub mod integrity; + +const LOG_TARGET_BRIDGE_DISPATCH: &str = "runtime::bridge-dispatch"; + +/// A duplication of the `FilterCall` trait. +/// +/// We need this trait in order to be able to implement it for the messages pallet, +/// since the implementation is done outside of the pallet crate. +pub trait BridgeRuntimeFilterCall { + /// Checks if a runtime call is valid. + fn validate(call: &Call) -> TransactionValidity; +} + +impl BridgeRuntimeFilterCall for pallet_bridge_grandpa::Pallet +where + T: pallet_bridge_grandpa::Config, + T::RuntimeCall: GrandpaCallSubType, +{ + fn validate(call: &T::RuntimeCall) -> TransactionValidity { + GrandpaCallSubType::::check_obsolete_submit_finality_proof(call) + } +} + +impl BridgeRuntimeFilterCall + for pallet_bridge_parachains::Pallet +where + T: pallet_bridge_parachains::Config, + T::RuntimeCall: ParachainsCallSubtype, +{ + fn validate(call: &T::RuntimeCall) -> TransactionValidity { + ParachainsCallSubtype::::check_obsolete_submit_parachain_heads(call) + } +} + +impl, I: 'static> BridgeRuntimeFilterCall + for pallet_bridge_messages::Pallet +where + T::RuntimeCall: MessagesCallSubType, +{ + /// Validate messages in order to avoid "mining" messages delivery and delivery confirmation + /// transactions, that are delivering outdated messages/confirmations. Without this validation, + /// even honest relayers may lose their funds if there are multiple relays running and + /// submitting the same messages/confirmations. + fn validate(call: &T::RuntimeCall) -> TransactionValidity { + call.check_obsolete_call() + } +} + +/// Declares a runtime-specific `BridgeRejectObsoleteHeadersAndMessages` signed extension. +/// +/// ## Example +/// +/// ```nocompile +/// generate_bridge_reject_obsolete_headers_and_messages!{ +/// Call, AccountId +/// BridgeRialtoGrandpa, BridgeWestendGrandpa, +/// BridgeRialtoParachains +/// } +/// ``` +/// +/// The goal of this extension is to avoid "mining" transactions that provide outdated bridged +/// headers and messages. Without that extension, even honest relayers may lose their funds if +/// there are multiple relays running and submitting the same information. +#[macro_export] +macro_rules! generate_bridge_reject_obsolete_headers_and_messages { + ($call:ty, $account_id:ty, $($filter_call:ty),*) => { + #[derive(Clone, codec::Decode, Default, codec::Encode, Eq, PartialEq, frame_support::RuntimeDebug, scale_info::TypeInfo)] + pub struct BridgeRejectObsoleteHeadersAndMessages; + impl sp_runtime::traits::SignedExtension for BridgeRejectObsoleteHeadersAndMessages { + const IDENTIFIER: &'static str = "BridgeRejectObsoleteHeadersAndMessages"; + type AccountId = $account_id; + type Call = $call; + type AdditionalSigned = (); + type Pre = (); + + fn additional_signed(&self) -> sp_std::result::Result< + (), + sp_runtime::transaction_validity::TransactionValidityError, + > { + Ok(()) + } + + fn validate( + &self, + _who: &Self::AccountId, + call: &Self::Call, + _info: &sp_runtime::traits::DispatchInfoOf, + _len: usize, + ) -> sp_runtime::transaction_validity::TransactionValidity { + let valid = sp_runtime::transaction_validity::ValidTransaction::default(); + $( + let valid = valid + .combine_with(<$filter_call as $crate::BridgeRuntimeFilterCall<$call>>::validate(call)?); + )* + Ok(valid) + } + + fn pre_dispatch( + self, + who: &Self::AccountId, + call: &Self::Call, + info: &sp_runtime::traits::DispatchInfoOf, + len: usize, + ) -> Result { + self.validate(who, call, info, len).map(drop) + } + } + }; +} + +/// A mapping over `NetworkId`. +/// Since `NetworkId` doesn't include `Millau`, `Rialto` and `RialtoParachain`, we create some +/// synthetic associations between these chains and `NetworkId` chains. +pub enum CustomNetworkId { + /// The Millau network ID, associated with Kusama. + Millau, + /// The Rialto network ID, associated with Polkadot. + Rialto, + /// The RialtoParachain network ID, associated with Westend. + RialtoParachain, +} + +impl TryFrom for CustomNetworkId { + type Error = (); + + fn try_from(chain: bp_runtime::ChainId) -> Result { + Ok(match chain { + bp_runtime::MILLAU_CHAIN_ID => Self::Millau, + bp_runtime::RIALTO_CHAIN_ID => Self::Rialto, + bp_runtime::RIALTO_PARACHAIN_CHAIN_ID => Self::RialtoParachain, + _ => return Err(()), + }) + } +} + +impl CustomNetworkId { + /// Converts self to XCM' network id. + pub const fn as_network_id(&self) -> NetworkId { + match *self { + CustomNetworkId::Millau => NetworkId::Kusama, + CustomNetworkId::Rialto => NetworkId::Polkadot, + CustomNetworkId::RialtoParachain => NetworkId::Westend, + } + } +} + +#[cfg(test)] +mod tests { + use crate::BridgeRuntimeFilterCall; + use frame_support::{assert_err, assert_ok}; + use sp_runtime::{ + traits::SignedExtension, + transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction}, + }; + + pub struct MockCall { + data: u32, + } + + impl sp_runtime::traits::Dispatchable for MockCall { + type RuntimeOrigin = (); + type Config = (); + type Info = (); + type PostInfo = (); + + fn dispatch( + self, + _origin: Self::RuntimeOrigin, + ) -> sp_runtime::DispatchResultWithInfo { + unimplemented!() + } + } + + struct FirstFilterCall; + impl BridgeRuntimeFilterCall for FirstFilterCall { + fn validate(call: &MockCall) -> TransactionValidity { + if call.data <= 1 { + return InvalidTransaction::Custom(1).into() + } + + Ok(ValidTransaction { priority: 1, ..Default::default() }) + } + } + + struct SecondFilterCall; + impl BridgeRuntimeFilterCall for SecondFilterCall { + fn validate(call: &MockCall) -> TransactionValidity { + if call.data <= 2 { + return InvalidTransaction::Custom(2).into() + } + + Ok(ValidTransaction { priority: 2, ..Default::default() }) + } + } + + #[test] + fn test() { + generate_bridge_reject_obsolete_headers_and_messages!( + MockCall, + (), + FirstFilterCall, + SecondFilterCall + ); + + assert_err!( + BridgeRejectObsoleteHeadersAndMessages.validate(&(), &MockCall { data: 1 }, &(), 0), + InvalidTransaction::Custom(1) + ); + + assert_err!( + BridgeRejectObsoleteHeadersAndMessages.validate(&(), &MockCall { data: 2 }, &(), 0), + InvalidTransaction::Custom(2) + ); + + assert_ok!( + BridgeRejectObsoleteHeadersAndMessages.validate(&(), &MockCall { data: 3 }, &(), 0), + ValidTransaction { priority: 3, ..Default::default() } + ) + } +} diff --git a/bridges/bin/runtime-common/src/messages.rs b/bridges/bin/runtime-common/src/messages.rs new file mode 100644 index 00000000000..e6c7deb98a2 --- /dev/null +++ b/bridges/bin/runtime-common/src/messages.rs @@ -0,0 +1,745 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Types that allow runtime to act as a source/target endpoint of message lanes. +//! +//! Messages are assumed to be encoded `Call`s of the target chain. Call-dispatch +//! pallet is used to dispatch incoming messages. Message identified by a tuple +//! of to elements - message lane id and message nonce. + +pub use bp_runtime::{RangeInclusiveExt, UnderlyingChainOf, UnderlyingChainProvider}; + +use bp_header_chain::HeaderChain; +use bp_messages::{ + source_chain::{LaneMessageVerifier, TargetHeaderChain}, + target_chain::{ProvedLaneMessages, ProvedMessages, SourceHeaderChain}, + InboundLaneData, LaneId, Message, MessageKey, MessageNonce, MessagePayload, OutboundLaneData, + VerificationError, +}; +use bp_runtime::{Chain, RawStorageProof, Size, StorageProofChecker}; +use codec::{Decode, Encode}; +use frame_support::{traits::Get, weights::Weight, RuntimeDebug}; +use hash_db::Hasher; +use scale_info::TypeInfo; +use sp_std::{convert::TryFrom, marker::PhantomData, vec::Vec}; + +/// Bidirectional message bridge. +pub trait MessageBridge { + /// Name of the paired messages pallet instance at the Bridged chain. + /// + /// Should be the name that is used in the `construct_runtime!()` macro. + const BRIDGED_MESSAGES_PALLET_NAME: &'static str; + + /// This chain in context of message bridge. + type ThisChain: ThisChainWithMessages; + /// Bridged chain in context of message bridge. + type BridgedChain: BridgedChainWithMessages; + /// Bridged header chain. + type BridgedHeaderChain: HeaderChain>; +} + +/// This chain that has `pallet-bridge-messages` module. +pub trait ThisChainWithMessages: UnderlyingChainProvider { + /// Call origin on the chain. + type RuntimeOrigin; +} + +/// Bridged chain that has `pallet-bridge-messages` module. +pub trait BridgedChainWithMessages: UnderlyingChainProvider {} + +/// This chain in context of message bridge. +pub type ThisChain = ::ThisChain; +/// Bridged chain in context of message bridge. +pub type BridgedChain = ::BridgedChain; +/// Hash used on the chain. +pub type HashOf = bp_runtime::HashOf<::Chain>; +/// Hasher used on the chain. +pub type HasherOf = bp_runtime::HasherOf>; +/// Account id used on the chain. +pub type AccountIdOf = bp_runtime::AccountIdOf>; +/// Type of balances that is used on the chain. +pub type BalanceOf = bp_runtime::BalanceOf>; +/// Type of origin that is used on the chain. +pub type OriginOf = ::RuntimeOrigin; + +/// Sub-module that is declaring types required for processing This -> Bridged chain messages. +pub mod source { + use super::*; + + /// Message payload for This -> Bridged chain messages. + pub type FromThisChainMessagePayload = crate::messages_xcm_extension::XcmAsPlainPayload; + + /// Maximal size of outbound message payload. + pub struct FromThisChainMaximalOutboundPayloadSize(PhantomData); + + impl Get for FromThisChainMaximalOutboundPayloadSize { + fn get() -> u32 { + maximal_message_size::() + } + } + + /// Messages delivery proof from bridged chain: + /// + /// - hash of finalized header; + /// - storage proof of inbound lane state; + /// - lane id. + #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] + pub struct FromBridgedChainMessagesDeliveryProof { + /// Hash of the bridge header the proof is for. + pub bridged_header_hash: BridgedHeaderHash, + /// Storage trie proof generated for [`Self::bridged_header_hash`]. + pub storage_proof: RawStorageProof, + /// Lane id of which messages were delivered and the proof is for. + pub lane: LaneId, + } + + impl Size for FromBridgedChainMessagesDeliveryProof { + fn size(&self) -> u32 { + u32::try_from( + self.storage_proof + .iter() + .fold(0usize, |sum, node| sum.saturating_add(node.len())), + ) + .unwrap_or(u32::MAX) + } + } + + /// 'Parsed' message delivery proof - inbound lane id and its state. + pub type ParsedMessagesDeliveryProofFromBridgedChain = + (LaneId, InboundLaneData>>); + + /// Message verifier that is doing all basic checks. + /// + /// This verifier assumes following: + /// + /// - all message lanes are equivalent, so all checks are the same; + /// + /// Following checks are made: + /// + /// - message is rejected if its lane is currently blocked; + /// - message is rejected if there are too many pending (undelivered) messages at the outbound + /// lane; + /// - check that the sender has rights to dispatch the call on target chain using provided + /// dispatch origin; + /// - check that the sender has paid enough funds for both message delivery and dispatch. + #[derive(RuntimeDebug)] + pub struct FromThisChainMessageVerifier(PhantomData); + + impl LaneMessageVerifier>, FromThisChainMessagePayload> + for FromThisChainMessageVerifier + where + B: MessageBridge, + // matches requirements from the `frame_system::Config::Origin` + OriginOf>: Clone + + Into>>, OriginOf>>>, + AccountIdOf>: PartialEq + Clone, + { + fn verify_message( + _submitter: &OriginOf>, + _lane: &LaneId, + _lane_outbound_data: &OutboundLaneData, + _payload: &FromThisChainMessagePayload, + ) -> Result<(), VerificationError> { + // IMPORTANT: any error that is returned here is fatal for the bridge, because + // this code is executed at the bridge hub and message sender actually lives + // at some sibling parachain. So we are failing **after** the message has been + // sent and we can't report it back to sender (unless error report mechanism is + // embedded into message and its dispatcher). + + Ok(()) + } + } + + /// Return maximal message size of This -> Bridged chain message. + pub fn maximal_message_size() -> u32 { + super::target::maximal_incoming_message_size( + UnderlyingChainOf::>::max_extrinsic_size(), + ) + } + + /// `TargetHeaderChain` implementation that is using default types and perform default checks. + pub struct TargetHeaderChainAdapter(PhantomData); + + impl TargetHeaderChain>> + for TargetHeaderChainAdapter + { + type MessagesDeliveryProof = FromBridgedChainMessagesDeliveryProof>>; + + fn verify_message(payload: &FromThisChainMessagePayload) -> Result<(), VerificationError> { + verify_chain_message::(payload) + } + + fn verify_messages_delivery_proof( + proof: Self::MessagesDeliveryProof, + ) -> Result<(LaneId, InboundLaneData>>), VerificationError> { + verify_messages_delivery_proof::(proof) + } + } + + /// Do basic Bridged-chain specific verification of This -> Bridged chain message. + /// + /// Ok result from this function means that the delivery transaction with this message + /// may be 'mined' by the target chain. But the lane may have its own checks (e.g. fee + /// check) that would reject message (see `FromThisChainMessageVerifier`). + pub fn verify_chain_message( + payload: &FromThisChainMessagePayload, + ) -> Result<(), VerificationError> { + // IMPORTANT: any error that is returned here is fatal for the bridge, because + // this code is executed at the bridge hub and message sender actually lives + // at some sibling parachain. So we are failing **after** the message has been + // sent and we can't report it back to sender (unless error report mechanism is + // embedded into message and its dispatcher). + + // apart from maximal message size check (see below), we should also check the message + // dispatch weight here. But we assume that the bridged chain will just push the message + // to some queue (XCMP, UMP, DMP), so the weight is constant and fits the block. + + // The maximal size of extrinsic at Substrate-based chain depends on the + // `frame_system::Config::MaximumBlockLength` and + // `frame_system::Config::AvailableBlockRatio` constants. This check is here to be sure that + // the lane won't stuck because message is too large to fit into delivery transaction. + // + // **IMPORTANT NOTE**: the delivery transaction contains storage proof of the message, not + // the message itself. The proof is always larger than the message. But unless chain state + // is enormously large, it should be several dozens/hundreds of bytes. The delivery + // transaction also contains signatures and signed extensions. Because of this, we reserve + // 1/3 of the the maximal extrinsic size for this data. + if payload.len() > maximal_message_size::() as usize { + return Err(VerificationError::MessageTooLarge) + } + + Ok(()) + } + + /// Verify proof of This -> Bridged chain messages delivery. + /// + /// This function is used when Bridged chain is directly using GRANDPA finality. For Bridged + /// parachains, please use the `verify_messages_delivery_proof_from_parachain`. + pub fn verify_messages_delivery_proof( + proof: FromBridgedChainMessagesDeliveryProof>>, + ) -> Result, VerificationError> { + let FromBridgedChainMessagesDeliveryProof { bridged_header_hash, storage_proof, lane } = + proof; + let mut storage = + B::BridgedHeaderChain::storage_proof_checker(bridged_header_hash, storage_proof) + .map_err(VerificationError::HeaderChain)?; + // Messages delivery proof is just proof of single storage key read => any error + // is fatal. + let storage_inbound_lane_data_key = bp_messages::storage_keys::inbound_lane_data_key( + B::BRIDGED_MESSAGES_PALLET_NAME, + &lane, + ); + let inbound_lane_data = storage + .read_and_decode_mandatory_value(storage_inbound_lane_data_key.0.as_ref()) + .map_err(VerificationError::InboundLaneStorage)?; + + // check that the storage proof doesn't have any untouched trie nodes + storage.ensure_no_unused_nodes().map_err(VerificationError::StorageProof)?; + + Ok((lane, inbound_lane_data)) + } +} + +/// Sub-module that is declaring types required for processing Bridged -> This chain messages. +pub mod target { + use super::*; + + /// Decoded Bridged -> This message payload. + pub type FromBridgedChainMessagePayload = crate::messages_xcm_extension::XcmAsPlainPayload; + + /// Messages proof from bridged chain: + /// + /// - hash of finalized header; + /// - storage proof of messages and (optionally) outbound lane state; + /// - lane id; + /// - nonces (inclusive range) of messages which are included in this proof. + #[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] + pub struct FromBridgedChainMessagesProof { + /// Hash of the finalized bridged header the proof is for. + pub bridged_header_hash: BridgedHeaderHash, + /// A storage trie proof of messages being delivered. + pub storage_proof: RawStorageProof, + /// Messages in this proof are sent over this lane. + pub lane: LaneId, + /// Nonce of the first message being delivered. + pub nonces_start: MessageNonce, + /// Nonce of the last message being delivered. + pub nonces_end: MessageNonce, + } + + impl Size for FromBridgedChainMessagesProof { + fn size(&self) -> u32 { + u32::try_from( + self.storage_proof + .iter() + .fold(0usize, |sum, node| sum.saturating_add(node.len())), + ) + .unwrap_or(u32::MAX) + } + } + + /// Return maximal dispatch weight of the message we're able to receive. + pub fn maximal_incoming_message_dispatch_weight(maximal_extrinsic_weight: Weight) -> Weight { + maximal_extrinsic_weight / 2 + } + + /// Return maximal message size given maximal extrinsic size. + pub fn maximal_incoming_message_size(maximal_extrinsic_size: u32) -> u32 { + maximal_extrinsic_size / 3 * 2 + } + + /// `SourceHeaderChain` implementation that is using default types and perform default checks. + pub struct SourceHeaderChainAdapter(PhantomData); + + impl SourceHeaderChain for SourceHeaderChainAdapter { + type MessagesProof = FromBridgedChainMessagesProof>>; + + fn verify_messages_proof( + proof: Self::MessagesProof, + messages_count: u32, + ) -> Result, VerificationError> { + verify_messages_proof::(proof, messages_count) + } + } + + /// Verify proof of Bridged -> This chain messages. + /// + /// This function is used when Bridged chain is directly using GRANDPA finality. For Bridged + /// parachains, please use the `verify_messages_proof_from_parachain`. + /// + /// The `messages_count` argument verification (sane limits) is supposed to be made + /// outside of this function. This function only verifies that the proof declares exactly + /// `messages_count` messages. + pub fn verify_messages_proof( + proof: FromBridgedChainMessagesProof>>, + messages_count: u32, + ) -> Result, VerificationError> { + let FromBridgedChainMessagesProof { + bridged_header_hash, + storage_proof, + lane, + nonces_start, + nonces_end, + } = proof; + let storage = + B::BridgedHeaderChain::storage_proof_checker(bridged_header_hash, storage_proof) + .map_err(VerificationError::HeaderChain)?; + let mut parser = StorageProofCheckerAdapter::<_, B> { storage, _dummy: Default::default() }; + let nonces_range = nonces_start..=nonces_end; + + // receiving proofs where end < begin is ok (if proof includes outbound lane state) + let messages_in_the_proof = nonces_range.checked_len().unwrap_or(0); + if messages_in_the_proof != MessageNonce::from(messages_count) { + return Err(VerificationError::MessagesCountMismatch) + } + + // Read messages first. All messages that are claimed to be in the proof must + // be in the proof. So any error in `read_value`, or even missing value is fatal. + // + // Mind that we allow proofs with no messages if outbound lane state is proved. + let mut messages = Vec::with_capacity(messages_in_the_proof as _); + for nonce in nonces_range { + let message_key = MessageKey { lane_id: lane, nonce }; + let message_payload = parser.read_and_decode_message_payload(&message_key)?; + messages.push(Message { key: message_key, payload: message_payload }); + } + + // Now let's check if proof contains outbound lane state proof. It is optional, so + // we simply ignore `read_value` errors and missing value. + let proved_lane_messages = ProvedLaneMessages { + lane_state: parser.read_and_decode_outbound_lane_data(&lane)?, + messages, + }; + + // Now we may actually check if the proof is empty or not. + if proved_lane_messages.lane_state.is_none() && proved_lane_messages.messages.is_empty() { + return Err(VerificationError::EmptyMessageProof) + } + + // check that the storage proof doesn't have any untouched trie nodes + parser + .storage + .ensure_no_unused_nodes() + .map_err(VerificationError::StorageProof)?; + + // We only support single lane messages in this generated_schema + let mut proved_messages = ProvedMessages::new(); + proved_messages.insert(lane, proved_lane_messages); + + Ok(proved_messages) + } + + struct StorageProofCheckerAdapter { + storage: StorageProofChecker, + _dummy: sp_std::marker::PhantomData, + } + + impl StorageProofCheckerAdapter { + fn read_and_decode_outbound_lane_data( + &mut self, + lane_id: &LaneId, + ) -> Result, VerificationError> { + let storage_outbound_lane_data_key = bp_messages::storage_keys::outbound_lane_data_key( + B::BRIDGED_MESSAGES_PALLET_NAME, + lane_id, + ); + + self.storage + .read_and_decode_opt_value(storage_outbound_lane_data_key.0.as_ref()) + .map_err(VerificationError::OutboundLaneStorage) + } + + fn read_and_decode_message_payload( + &mut self, + message_key: &MessageKey, + ) -> Result { + let storage_message_key = bp_messages::storage_keys::message_key( + B::BRIDGED_MESSAGES_PALLET_NAME, + &message_key.lane_id, + message_key.nonce, + ); + self.storage + .read_and_decode_mandatory_value(storage_message_key.0.as_ref()) + .map_err(VerificationError::MessageStorage) + } + } +} + +/// The `BridgeMessagesCall` used by a chain. +pub type BridgeMessagesCallOf = bp_messages::BridgeMessagesCall< + bp_runtime::AccountIdOf, + target::FromBridgedChainMessagesProof>, + source::FromBridgedChainMessagesDeliveryProof>, +>; + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + messages_generation::{ + encode_all_messages, encode_lane_data, prepare_messages_storage_proof, + }, + mock::*, + }; + use bp_header_chain::{HeaderChainError, StoredHeaderDataBuilder}; + use bp_runtime::{HeaderId, StorageProofError}; + use codec::Encode; + use sp_core::H256; + use sp_runtime::traits::Header as _; + + #[test] + fn verify_chain_message_rejects_message_with_too_large_declared_weight() { + assert!(source::verify_chain_message::(&vec![ + 42; + BRIDGED_CHAIN_MAX_EXTRINSIC_WEIGHT - + 1 + ]) + .is_err()); + } + + #[test] + fn verify_chain_message_rejects_message_too_large_message() { + assert!(source::verify_chain_message::(&vec![ + 0; + source::maximal_message_size::() + as usize + 1 + ],) + .is_err()); + } + + #[test] + fn verify_chain_message_accepts_maximal_message() { + assert_eq!( + source::verify_chain_message::(&vec![ + 0; + source::maximal_message_size::() + as _ + ],), + Ok(()), + ); + } + + fn using_messages_proof( + nonces_end: MessageNonce, + outbound_lane_data: Option, + encode_message: impl Fn(MessageNonce, &MessagePayload) -> Option>, + encode_outbound_lane_data: impl Fn(&OutboundLaneData) -> Vec, + test: impl Fn(target::FromBridgedChainMessagesProof) -> R, + ) -> R { + let (state_root, storage_proof) = prepare_messages_storage_proof::( + TEST_LANE_ID, + 1..=nonces_end, + outbound_lane_data, + bp_runtime::StorageProofSize::Minimal(0), + vec![42], + encode_message, + encode_outbound_lane_data, + ); + + sp_io::TestExternalities::new(Default::default()).execute_with(move || { + let bridged_header = BridgedChainHeader::new( + 0, + Default::default(), + state_root, + Default::default(), + Default::default(), + ); + let bridged_header_hash = bridged_header.hash(); + + pallet_bridge_grandpa::BestFinalized::::put(HeaderId( + 0, + bridged_header_hash, + )); + pallet_bridge_grandpa::ImportedHeaders::::insert( + bridged_header_hash, + bridged_header.build(), + ); + test(target::FromBridgedChainMessagesProof { + bridged_header_hash, + storage_proof, + lane: TEST_LANE_ID, + nonces_start: 1, + nonces_end, + }) + }) + } + + #[test] + fn messages_proof_is_rejected_if_declared_less_than_actual_number_of_messages() { + assert_eq!( + using_messages_proof(10, None, encode_all_messages, encode_lane_data, |proof| { + target::verify_messages_proof::(proof, 5) + }), + Err(VerificationError::MessagesCountMismatch), + ); + } + + #[test] + fn messages_proof_is_rejected_if_declared_more_than_actual_number_of_messages() { + assert_eq!( + using_messages_proof(10, None, encode_all_messages, encode_lane_data, |proof| { + target::verify_messages_proof::(proof, 15) + }), + Err(VerificationError::MessagesCountMismatch), + ); + } + + #[test] + fn message_proof_is_rejected_if_header_is_missing_from_the_chain() { + assert_eq!( + using_messages_proof(10, None, encode_all_messages, encode_lane_data, |proof| { + let bridged_header_hash = + pallet_bridge_grandpa::BestFinalized::::get().unwrap().1; + pallet_bridge_grandpa::ImportedHeaders::::remove(bridged_header_hash); + target::verify_messages_proof::(proof, 10) + }), + Err(VerificationError::HeaderChain(HeaderChainError::UnknownHeader)), + ); + } + + #[test] + fn message_proof_is_rejected_if_header_state_root_mismatches() { + assert_eq!( + using_messages_proof(10, None, encode_all_messages, encode_lane_data, |proof| { + let bridged_header_hash = + pallet_bridge_grandpa::BestFinalized::::get().unwrap().1; + pallet_bridge_grandpa::ImportedHeaders::::insert( + bridged_header_hash, + BridgedChainHeader::new( + 0, + Default::default(), + Default::default(), + Default::default(), + Default::default(), + ) + .build(), + ); + target::verify_messages_proof::(proof, 10) + }), + Err(VerificationError::HeaderChain(HeaderChainError::StorageProof( + StorageProofError::StorageRootMismatch + ))), + ); + } + + #[test] + fn message_proof_is_rejected_if_it_has_duplicate_trie_nodes() { + assert_eq!( + using_messages_proof(10, None, encode_all_messages, encode_lane_data, |mut proof| { + let node = proof.storage_proof.pop().unwrap(); + proof.storage_proof.push(node.clone()); + proof.storage_proof.push(node); + target::verify_messages_proof::(proof, 10) + },), + Err(VerificationError::HeaderChain(HeaderChainError::StorageProof( + StorageProofError::DuplicateNodesInProof + ))), + ); + } + + #[test] + fn message_proof_is_rejected_if_it_has_unused_trie_nodes() { + assert_eq!( + using_messages_proof(10, None, encode_all_messages, encode_lane_data, |mut proof| { + proof.storage_proof.push(vec![42]); + target::verify_messages_proof::(proof, 10) + },), + Err(VerificationError::StorageProof(StorageProofError::UnusedNodesInTheProof)), + ); + } + + #[test] + fn message_proof_is_rejected_if_required_message_is_missing() { + matches!( + using_messages_proof( + 10, + None, + |n, m| if n != 5 { Some(m.encode()) } else { None }, + encode_lane_data, + |proof| target::verify_messages_proof::(proof, 10) + ), + Err(VerificationError::MessageStorage(StorageProofError::StorageValueEmpty)), + ); + } + + #[test] + fn message_proof_is_rejected_if_message_decode_fails() { + matches!( + using_messages_proof( + 10, + None, + |n, m| { + let mut m = m.encode(); + if n == 5 { + m = vec![42] + } + Some(m) + }, + encode_lane_data, + |proof| target::verify_messages_proof::(proof, 10), + ), + Err(VerificationError::MessageStorage(StorageProofError::StorageValueDecodeFailed(_))), + ); + } + + #[test] + fn message_proof_is_rejected_if_outbound_lane_state_decode_fails() { + matches!( + using_messages_proof( + 10, + Some(OutboundLaneData { + oldest_unpruned_nonce: 1, + latest_received_nonce: 1, + latest_generated_nonce: 1, + }), + encode_all_messages, + |d| { + let mut d = d.encode(); + d.truncate(1); + d + }, + |proof| target::verify_messages_proof::(proof, 10), + ), + Err(VerificationError::OutboundLaneStorage( + StorageProofError::StorageValueDecodeFailed(_) + )), + ); + } + + #[test] + fn message_proof_is_rejected_if_it_is_empty() { + assert_eq!( + using_messages_proof(0, None, encode_all_messages, encode_lane_data, |proof| { + target::verify_messages_proof::(proof, 0) + },), + Err(VerificationError::EmptyMessageProof), + ); + } + + #[test] + fn non_empty_message_proof_without_messages_is_accepted() { + assert_eq!( + using_messages_proof( + 0, + Some(OutboundLaneData { + oldest_unpruned_nonce: 1, + latest_received_nonce: 1, + latest_generated_nonce: 1, + }), + encode_all_messages, + encode_lane_data, + |proof| target::verify_messages_proof::(proof, 0), + ), + Ok(vec![( + TEST_LANE_ID, + ProvedLaneMessages { + lane_state: Some(OutboundLaneData { + oldest_unpruned_nonce: 1, + latest_received_nonce: 1, + latest_generated_nonce: 1, + }), + messages: Vec::new(), + }, + )] + .into_iter() + .collect()), + ); + } + + #[test] + fn non_empty_message_proof_is_accepted() { + assert_eq!( + using_messages_proof( + 1, + Some(OutboundLaneData { + oldest_unpruned_nonce: 1, + latest_received_nonce: 1, + latest_generated_nonce: 1, + }), + encode_all_messages, + encode_lane_data, + |proof| target::verify_messages_proof::(proof, 1), + ), + Ok(vec![( + TEST_LANE_ID, + ProvedLaneMessages { + lane_state: Some(OutboundLaneData { + oldest_unpruned_nonce: 1, + latest_received_nonce: 1, + latest_generated_nonce: 1, + }), + messages: vec![Message { + key: MessageKey { lane_id: TEST_LANE_ID, nonce: 1 }, + payload: vec![42], + }], + }, + )] + .into_iter() + .collect()), + ); + } + + #[test] + fn verify_messages_proof_does_not_panic_if_messages_count_mismatches() { + assert_eq!( + using_messages_proof(1, None, encode_all_messages, encode_lane_data, |mut proof| { + proof.nonces_end = u64::MAX; + target::verify_messages_proof::(proof, u32::MAX) + },), + Err(VerificationError::MessagesCountMismatch), + ); + } +} diff --git a/bridges/bin/runtime-common/src/messages_api.rs b/bridges/bin/runtime-common/src/messages_api.rs new file mode 100644 index 00000000000..199e062fe98 --- /dev/null +++ b/bridges/bin/runtime-common/src/messages_api.rs @@ -0,0 +1,66 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Helpers for implementing various message-related runtime API mthods. + +use bp_messages::{ + InboundMessageDetails, LaneId, MessageNonce, MessagePayload, OutboundMessageDetails, +}; +use sp_std::vec::Vec; + +/// Implementation of the `To*OutboundLaneApi::message_details`. +pub fn outbound_message_details( + lane: LaneId, + begin: MessageNonce, + end: MessageNonce, +) -> Vec +where + Runtime: pallet_bridge_messages::Config, + MessagesPalletInstance: 'static, +{ + (begin..=end) + .filter_map(|nonce| { + let message_data = + pallet_bridge_messages::Pallet::::outbound_message_data(lane, nonce)?; + Some(OutboundMessageDetails { + nonce, + // dispatch message weight is always zero at the source chain, since we're paying for + // dispatch at the target chain + dispatch_weight: frame_support::weights::Weight::zero(), + size: message_data.len() as _, + }) + }) + .collect() +} + +/// Implementation of the `To*InboundLaneApi::message_details`. +pub fn inbound_message_details( + lane: LaneId, + messages: Vec<(MessagePayload, OutboundMessageDetails)>, +) -> Vec +where + Runtime: pallet_bridge_messages::Config, + MessagesPalletInstance: 'static, +{ + messages + .into_iter() + .map(|(payload, details)| { + pallet_bridge_messages::Pallet::::inbound_message_data( + lane, payload, details, + ) + }) + .collect() +} diff --git a/bridges/bin/runtime-common/src/messages_benchmarking.rs b/bridges/bin/runtime-common/src/messages_benchmarking.rs new file mode 100644 index 00000000000..b067523c305 --- /dev/null +++ b/bridges/bin/runtime-common/src/messages_benchmarking.rs @@ -0,0 +1,293 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Everything required to run benchmarks of messages module, based on +//! `bridge_runtime_common::messages` implementation. + +#![cfg(feature = "runtime-benchmarks")] + +use crate::{ + messages::{ + source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, + AccountIdOf, BridgedChain, HashOf, HasherOf, MessageBridge, ThisChain, + }, + messages_generation::{ + encode_all_messages, encode_lane_data, grow_trie_leaf_value, prepare_messages_storage_proof, + }, +}; + +use bp_messages::storage_keys; +use bp_polkadot_core::parachains::ParaHash; +use bp_runtime::{ + record_all_trie_keys, Chain, Parachain, RawStorageProof, StorageProofSize, UnderlyingChainOf, +}; +use codec::Encode; +use frame_support::weights::Weight; +use pallet_bridge_messages::benchmarking::{MessageDeliveryProofParams, MessageProofParams}; +use sp_runtime::traits::{Header, Zero}; +use sp_std::prelude::*; +use sp_trie::{trie_types::TrieDBMutBuilderV1, LayoutV1, MemoryDB, TrieMut}; +use xcm::v3::prelude::*; + +/// Prepare inbound bridge message according to given message proof parameters. +fn prepare_inbound_message( + params: &MessageProofParams, + destination: InteriorMultiLocation, +) -> Vec { + // we only care about **this** message size when message proof needs to be `Minimal` + let expected_size = match params.size { + StorageProofSize::Minimal(size) => size as usize, + _ => 0, + }; + + // if we don't need a correct message, then we may just return some random blob + if !params.is_successful_dispatch_expected { + return vec![0u8; expected_size] + } + + // else let's prepare successful message. For XCM bridge hubs, it is the message that + // will be pushed further to some XCM queue (XCMP/UMP) + let location = xcm::VersionedInteriorMultiLocation::V3(destination); + let location_encoded_size = location.encoded_size(); + + // we don't need to be super-precise with `expected_size` here + let xcm_size = expected_size.saturating_sub(location_encoded_size); + let xcm = xcm::VersionedXcm::<()>::V3(vec![Instruction::ClearOrigin; xcm_size].into()); + + // this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor + // or public fields, so just tuple + // (double encoding, because `.encode()` is called on original Xcm BLOB when it is pushed + // to the storage) + (location, xcm).encode().encode() +} + +/// Prepare proof of messages for the `receive_messages_proof` call. +/// +/// In addition to returning valid messages proof, environment is prepared to verify this message +/// proof. +/// +/// This method is intended to be used when benchmarking pallet, linked to the chain that +/// uses GRANDPA finality. For parachains, please use the `prepare_message_proof_from_parachain` +/// function. +pub fn prepare_message_proof_from_grandpa_chain( + params: MessageProofParams, + message_destination: InteriorMultiLocation, +) -> (FromBridgedChainMessagesProof>>, Weight) +where + R: pallet_bridge_grandpa::Config>>, + FI: 'static, + B: MessageBridge, +{ + // prepare storage proof + let (state_root, storage_proof) = prepare_messages_storage_proof::( + params.lane, + params.message_nonces.clone(), + params.outbound_lane_data.clone(), + params.size, + prepare_inbound_message(¶ms, message_destination), + encode_all_messages, + encode_lane_data, + ); + + // update runtime storage + let (_, bridged_header_hash) = insert_header_to_grandpa_pallet::(state_root); + + ( + FromBridgedChainMessagesProof { + bridged_header_hash, + storage_proof, + lane: params.lane, + nonces_start: *params.message_nonces.start(), + nonces_end: *params.message_nonces.end(), + }, + Weight::MAX / 1000, + ) +} + +/// Prepare proof of messages for the `receive_messages_proof` call. +/// +/// In addition to returning valid messages proof, environment is prepared to verify this message +/// proof. +/// +/// This method is intended to be used when benchmarking pallet, linked to the chain that +/// uses parachain finality. For GRANDPA chains, please use the +/// `prepare_message_proof_from_grandpa_chain` function. +pub fn prepare_message_proof_from_parachain( + params: MessageProofParams, + message_destination: InteriorMultiLocation, +) -> (FromBridgedChainMessagesProof>>, Weight) +where + R: pallet_bridge_parachains::Config, + PI: 'static, + B: MessageBridge, + UnderlyingChainOf>: Chain + Parachain, +{ + // prepare storage proof + let (state_root, storage_proof) = prepare_messages_storage_proof::( + params.lane, + params.message_nonces.clone(), + params.outbound_lane_data.clone(), + params.size, + prepare_inbound_message(¶ms, message_destination), + encode_all_messages, + encode_lane_data, + ); + + // update runtime storage + let (_, bridged_header_hash) = + insert_header_to_parachains_pallet::>>(state_root); + + ( + FromBridgedChainMessagesProof { + bridged_header_hash, + storage_proof, + lane: params.lane, + nonces_start: *params.message_nonces.start(), + nonces_end: *params.message_nonces.end(), + }, + Weight::MAX / 1000, + ) +} + +/// Prepare proof of messages delivery for the `receive_messages_delivery_proof` call. +/// +/// This method is intended to be used when benchmarking pallet, linked to the chain that +/// uses GRANDPA finality. For parachains, please use the +/// `prepare_message_delivery_proof_from_parachain` function. +pub fn prepare_message_delivery_proof_from_grandpa_chain( + params: MessageDeliveryProofParams>>, +) -> FromBridgedChainMessagesDeliveryProof>> +where + R: pallet_bridge_grandpa::Config>>, + FI: 'static, + B: MessageBridge, +{ + // prepare storage proof + let lane = params.lane; + let (state_root, storage_proof) = prepare_message_delivery_proof::(params); + + // update runtime storage + let (_, bridged_header_hash) = insert_header_to_grandpa_pallet::(state_root); + + FromBridgedChainMessagesDeliveryProof { + bridged_header_hash: bridged_header_hash.into(), + storage_proof, + lane, + } +} + +/// Prepare proof of messages delivery for the `receive_messages_delivery_proof` call. +/// +/// This method is intended to be used when benchmarking pallet, linked to the chain that +/// uses parachain finality. For GRANDPA chains, please use the +/// `prepare_message_delivery_proof_from_grandpa_chain` function. +pub fn prepare_message_delivery_proof_from_parachain( + params: MessageDeliveryProofParams>>, +) -> FromBridgedChainMessagesDeliveryProof>> +where + R: pallet_bridge_parachains::Config, + PI: 'static, + B: MessageBridge, + UnderlyingChainOf>: Chain + Parachain, +{ + // prepare storage proof + let lane = params.lane; + let (state_root, storage_proof) = prepare_message_delivery_proof::(params); + + // update runtime storage + let (_, bridged_header_hash) = + insert_header_to_parachains_pallet::>>(state_root); + + FromBridgedChainMessagesDeliveryProof { + bridged_header_hash: bridged_header_hash.into(), + storage_proof, + lane, + } +} + +/// Prepare in-memory message delivery proof, without inserting anything to the runtime storage. +fn prepare_message_delivery_proof( + params: MessageDeliveryProofParams>>, +) -> (HashOf>, RawStorageProof) +where + B: MessageBridge, +{ + // prepare Bridged chain storage with inbound lane state + let storage_key = + storage_keys::inbound_lane_data_key(B::BRIDGED_MESSAGES_PALLET_NAME, ¶ms.lane).0; + let mut root = Default::default(); + let mut mdb = MemoryDB::default(); + { + let mut trie = + TrieDBMutBuilderV1::>>::new(&mut mdb, &mut root).build(); + let inbound_lane_data = + grow_trie_leaf_value(params.inbound_lane_data.encode(), params.size); + trie.insert(&storage_key, &inbound_lane_data) + .map_err(|_| "TrieMut::insert has failed") + .expect("TrieMut::insert should not fail in benchmarks"); + } + + // generate storage proof to be delivered to This chain + let storage_proof = record_all_trie_keys::>>, _>(&mdb, &root) + .map_err(|_| "record_all_trie_keys has failed") + .expect("record_all_trie_keys should not fail in benchmarks"); + + (root, storage_proof) +} + +/// Insert header to the bridge GRANDPA pallet. +pub(crate) fn insert_header_to_grandpa_pallet( + state_root: bp_runtime::HashOf, +) -> (bp_runtime::BlockNumberOf, bp_runtime::HashOf) +where + R: pallet_bridge_grandpa::Config, + GI: 'static, + R::BridgedChain: bp_runtime::Chain, +{ + let bridged_block_number = Zero::zero(); + let bridged_header = bp_runtime::HeaderOf::::new( + bridged_block_number, + Default::default(), + state_root, + Default::default(), + Default::default(), + ); + let bridged_header_hash = bridged_header.hash(); + pallet_bridge_grandpa::initialize_for_benchmarks::(bridged_header); + (bridged_block_number, bridged_header_hash) +} + +/// Insert header to the bridge parachains pallet. +pub(crate) fn insert_header_to_parachains_pallet( + state_root: bp_runtime::HashOf, +) -> (bp_runtime::BlockNumberOf, bp_runtime::HashOf) +where + R: pallet_bridge_parachains::Config, + PI: 'static, + PC: Chain + Parachain, +{ + let bridged_block_number = Zero::zero(); + let bridged_header = bp_runtime::HeaderOf::::new( + bridged_block_number, + Default::default(), + state_root, + Default::default(), + Default::default(), + ); + let bridged_header_hash = bridged_header.hash(); + pallet_bridge_parachains::initialize_for_benchmarks::(bridged_header); + (bridged_block_number, bridged_header_hash) +} diff --git a/bridges/bin/runtime-common/src/messages_call_ext.rs b/bridges/bin/runtime-common/src/messages_call_ext.rs new file mode 100644 index 00000000000..8b4a50a0f30 --- /dev/null +++ b/bridges/bin/runtime-common/src/messages_call_ext.rs @@ -0,0 +1,644 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +use crate::messages::{ + source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, +}; +use bp_messages::{InboundLaneData, LaneId, MessageNonce}; +use frame_support::{ + dispatch::CallableCallFor, + traits::{Get, IsSubType}, + RuntimeDebug, +}; +use pallet_bridge_messages::{Config, Pallet}; +use sp_runtime::transaction_validity::TransactionValidity; +use sp_std::ops::RangeInclusive; + +/// Generic info about a messages delivery/confirmation proof. +#[derive(PartialEq, RuntimeDebug)] +pub struct BaseMessagesProofInfo { + /// Message lane, used by the call. + pub lane_id: LaneId, + /// Nonces of messages, included in the call. + /// + /// For delivery transaction, it is nonces of bundled messages. For confirmation + /// transaction, it is nonces that are to be confirmed during the call. + pub bundled_range: RangeInclusive, + /// Nonce of the best message, stored by this chain before the call is dispatched. + /// + /// For delivery transaction, it is the nonce of best delivered message before the call. + /// For confirmation transaction, it is the nonce of best confirmed message before the call. + pub best_stored_nonce: MessageNonce, +} + +impl BaseMessagesProofInfo { + /// Returns true if `bundled_range` continues the `0..=best_stored_nonce` range. + fn appends_to_stored_nonce(&self) -> bool { + Some(*self.bundled_range.start()) == self.best_stored_nonce.checked_add(1) + } +} + +/// Occupation state of the unrewarded relayers vector. +#[derive(PartialEq, RuntimeDebug)] +#[cfg_attr(test, derive(Default))] +pub struct UnrewardedRelayerOccupation { + /// The number of remaining unoccupied entries for new relayers. + pub free_relayer_slots: MessageNonce, + /// The number of messages that we are ready to accept. + pub free_message_slots: MessageNonce, +} + +/// Info about a `ReceiveMessagesProof` call which tries to update a single lane. +#[derive(PartialEq, RuntimeDebug)] +pub struct ReceiveMessagesProofInfo { + /// Base messages proof info + pub base: BaseMessagesProofInfo, + /// State of unrewarded relayers vector. + pub unrewarded_relayers: UnrewardedRelayerOccupation, +} + +impl ReceiveMessagesProofInfo { + /// Returns true if: + /// + /// - either inbound lane is ready to accept bundled messages; + /// + /// - or there are no bundled messages, but the inbound lane is blocked by too many unconfirmed + /// messages and/or unrewarded relayers. + fn is_obsolete(&self) -> bool { + // transactions with zero bundled nonces are not allowed, unless they're message + // delivery transactions, which brings reward confirmations required to unblock + // the lane + if self.base.bundled_range.is_empty() { + let empty_transactions_allowed = + // we allow empty transactions when we can't accept delivery from new relayers + self.unrewarded_relayers.free_relayer_slots == 0 || + // or if we can't accept new messages at all + self.unrewarded_relayers.free_message_slots == 0; + + return !empty_transactions_allowed + } + + // otherwise we require bundled messages to continue stored range + !self.base.appends_to_stored_nonce() + } +} + +/// Info about a `ReceiveMessagesDeliveryProof` call which tries to update a single lane. +#[derive(PartialEq, RuntimeDebug)] +pub struct ReceiveMessagesDeliveryProofInfo(pub BaseMessagesProofInfo); + +impl ReceiveMessagesDeliveryProofInfo { + /// Returns true if outbound lane is ready to accept confirmations of bundled messages. + fn is_obsolete(&self) -> bool { + self.0.bundled_range.is_empty() || !self.0.appends_to_stored_nonce() + } +} + +/// Info about a `ReceiveMessagesProof` or a `ReceiveMessagesDeliveryProof` call +/// which tries to update a single lane. +#[derive(PartialEq, RuntimeDebug)] +pub enum CallInfo { + ReceiveMessagesProof(ReceiveMessagesProofInfo), + ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo), +} + +impl CallInfo { + /// Returns range of messages, bundled with the call. + pub fn bundled_messages(&self) -> RangeInclusive { + match *self { + Self::ReceiveMessagesProof(ref info) => info.base.bundled_range.clone(), + Self::ReceiveMessagesDeliveryProof(ref info) => info.0.bundled_range.clone(), + } + } +} + +/// Helper struct that provides methods for working with a call supported by `CallInfo`. +pub struct CallHelper, I: 'static> { + pub _phantom_data: sp_std::marker::PhantomData<(T, I)>, +} + +impl, I: 'static> CallHelper { + /// Returns true if: + /// + /// - call is `receive_messages_proof` and all messages have been delivered; + /// + /// - call is `receive_messages_delivery_proof` and all messages confirmations have been + /// received. + pub fn was_successful(info: &CallInfo) -> bool { + match info { + CallInfo::ReceiveMessagesProof(info) => { + let inbound_lane_data = + pallet_bridge_messages::InboundLanes::::get(info.base.lane_id); + if info.base.bundled_range.is_empty() { + let post_occupation = + unrewarded_relayers_occupation::(&inbound_lane_data); + // we don't care about `free_relayer_slots` here - it is checked in + // `is_obsolete` and every relayer has delivered at least one message, + // so if relayer slots are released, then message slots are also + // released + return post_occupation.free_message_slots > + info.unrewarded_relayers.free_message_slots + } + + inbound_lane_data.last_delivered_nonce() == *info.base.bundled_range.end() + }, + CallInfo::ReceiveMessagesDeliveryProof(info) => { + let outbound_lane_data = + pallet_bridge_messages::OutboundLanes::::get(info.0.lane_id); + outbound_lane_data.latest_received_nonce == *info.0.bundled_range.end() + }, + } + } +} + +/// Trait representing a call that is a sub type of `pallet_bridge_messages::Call`. +pub trait MessagesCallSubType, I: 'static>: + IsSubType, T>> +{ + /// Create a new instance of `ReceiveMessagesProofInfo` from a `ReceiveMessagesProof` call. + fn receive_messages_proof_info(&self) -> Option; + + /// Create a new instance of `ReceiveMessagesDeliveryProofInfo` from + /// a `ReceiveMessagesDeliveryProof` call. + fn receive_messages_delivery_proof_info(&self) -> Option; + + /// Create a new instance of `CallInfo` from a `ReceiveMessagesProof` + /// or a `ReceiveMessagesDeliveryProof` call. + fn call_info(&self) -> Option; + + /// Create a new instance of `CallInfo` from a `ReceiveMessagesProof` + /// or a `ReceiveMessagesDeliveryProof` call, if the call is for the provided lane. + fn call_info_for(&self, lane_id: LaneId) -> Option; + + /// Check that a `ReceiveMessagesProof` or a `ReceiveMessagesDeliveryProof` call is trying + /// to deliver/confirm at least some messages that are better than the ones we know of. + fn check_obsolete_call(&self) -> TransactionValidity; +} + +impl< + BridgedHeaderHash, + SourceHeaderChain: bp_messages::target_chain::SourceHeaderChain< + MessagesProof = FromBridgedChainMessagesProof, + >, + TargetHeaderChain: bp_messages::source_chain::TargetHeaderChain< + >::OutboundPayload, + ::AccountId, + MessagesDeliveryProof = FromBridgedChainMessagesDeliveryProof, + >, + Call: IsSubType, T>>, + T: frame_system::Config + + Config, + I: 'static, + > MessagesCallSubType for T::RuntimeCall +{ + fn receive_messages_proof_info(&self) -> Option { + if let Some(pallet_bridge_messages::Call::::receive_messages_proof { + ref proof, + .. + }) = self.is_sub_type() + { + let inbound_lane_data = pallet_bridge_messages::InboundLanes::::get(proof.lane); + + return Some(ReceiveMessagesProofInfo { + base: BaseMessagesProofInfo { + lane_id: proof.lane, + // we want all messages in this range to be new for us. Otherwise transaction + // will be considered obsolete. + bundled_range: proof.nonces_start..=proof.nonces_end, + best_stored_nonce: inbound_lane_data.last_delivered_nonce(), + }, + unrewarded_relayers: unrewarded_relayers_occupation::(&inbound_lane_data), + }) + } + + None + } + + fn receive_messages_delivery_proof_info(&self) -> Option { + if let Some(pallet_bridge_messages::Call::::receive_messages_delivery_proof { + ref proof, + ref relayers_state, + .. + }) = self.is_sub_type() + { + let outbound_lane_data = pallet_bridge_messages::OutboundLanes::::get(proof.lane); + + return Some(ReceiveMessagesDeliveryProofInfo(BaseMessagesProofInfo { + lane_id: proof.lane, + // there's a time frame between message delivery, message confirmation and reward + // confirmation. Because of that, we can't assume that our state has been confirmed + // to the bridged chain. So we are accepting any proof that brings new + // confirmations. + bundled_range: outbound_lane_data.latest_received_nonce + 1..= + relayers_state.last_delivered_nonce, + best_stored_nonce: outbound_lane_data.latest_received_nonce, + })) + } + + None + } + + fn call_info(&self) -> Option { + if let Some(info) = self.receive_messages_proof_info() { + return Some(CallInfo::ReceiveMessagesProof(info)) + } + + if let Some(info) = self.receive_messages_delivery_proof_info() { + return Some(CallInfo::ReceiveMessagesDeliveryProof(info)) + } + + None + } + + fn call_info_for(&self, lane_id: LaneId) -> Option { + self.call_info().filter(|info| { + let actual_lane_id = match info { + CallInfo::ReceiveMessagesProof(info) => info.base.lane_id, + CallInfo::ReceiveMessagesDeliveryProof(info) => info.0.lane_id, + }; + actual_lane_id == lane_id + }) + } + + fn check_obsolete_call(&self) -> TransactionValidity { + match self.call_info() { + Some(CallInfo::ReceiveMessagesProof(proof_info)) if proof_info.is_obsolete() => { + log::trace!( + target: pallet_bridge_messages::LOG_TARGET, + "Rejecting obsolete messages delivery transaction: {:?}", + proof_info + ); + + return sp_runtime::transaction_validity::InvalidTransaction::Stale.into() + }, + Some(CallInfo::ReceiveMessagesDeliveryProof(proof_info)) + if proof_info.is_obsolete() => + { + log::trace!( + target: pallet_bridge_messages::LOG_TARGET, + "Rejecting obsolete messages confirmation transaction: {:?}", + proof_info, + ); + + return sp_runtime::transaction_validity::InvalidTransaction::Stale.into() + }, + _ => {}, + } + + Ok(sp_runtime::transaction_validity::ValidTransaction::default()) + } +} + +/// Returns occupation state of unrewarded relayers vector. +fn unrewarded_relayers_occupation, I: 'static>( + inbound_lane_data: &InboundLaneData, +) -> UnrewardedRelayerOccupation { + UnrewardedRelayerOccupation { + free_relayer_slots: T::MaxUnrewardedRelayerEntriesAtInboundLane::get() + .saturating_sub(inbound_lane_data.relayers.len() as MessageNonce), + free_message_slots: { + let unconfirmed_messages = inbound_lane_data + .last_delivered_nonce() + .saturating_sub(inbound_lane_data.last_confirmed_nonce); + T::MaxUnconfirmedMessagesAtInboundLane::get().saturating_sub(unconfirmed_messages) + }, + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + messages::{ + source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, + }, + messages_call_ext::MessagesCallSubType, + mock::{ + MaxUnconfirmedMessagesAtInboundLane, MaxUnrewardedRelayerEntriesAtInboundLane, + TestRuntime, ThisChainRuntimeCall, + }, + }; + use bp_messages::{DeliveredMessages, UnrewardedRelayer, UnrewardedRelayersState}; + use sp_std::ops::RangeInclusive; + + fn fill_unrewarded_relayers() { + let mut inbound_lane_state = + pallet_bridge_messages::InboundLanes::::get(LaneId([0, 0, 0, 0])); + for n in 0..MaxUnrewardedRelayerEntriesAtInboundLane::get() { + inbound_lane_state.relayers.push_back(UnrewardedRelayer { + relayer: Default::default(), + messages: DeliveredMessages { begin: n + 1, end: n + 1 }, + }); + } + pallet_bridge_messages::InboundLanes::::insert( + LaneId([0, 0, 0, 0]), + inbound_lane_state, + ); + } + + fn fill_unrewarded_messages() { + let mut inbound_lane_state = + pallet_bridge_messages::InboundLanes::::get(LaneId([0, 0, 0, 0])); + inbound_lane_state.relayers.push_back(UnrewardedRelayer { + relayer: Default::default(), + messages: DeliveredMessages { + begin: 1, + end: MaxUnconfirmedMessagesAtInboundLane::get(), + }, + }); + pallet_bridge_messages::InboundLanes::::insert( + LaneId([0, 0, 0, 0]), + inbound_lane_state, + ); + } + + fn deliver_message_10() { + pallet_bridge_messages::InboundLanes::::insert( + LaneId([0, 0, 0, 0]), + bp_messages::InboundLaneData { relayers: Default::default(), last_confirmed_nonce: 10 }, + ); + } + + fn validate_message_delivery( + nonces_start: bp_messages::MessageNonce, + nonces_end: bp_messages::MessageNonce, + ) -> bool { + ThisChainRuntimeCall::BridgeMessages( + pallet_bridge_messages::Call::::receive_messages_proof { + relayer_id_at_bridged_chain: 42, + messages_count: nonces_end.checked_sub(nonces_start).map(|x| x + 1).unwrap_or(0) + as u32, + dispatch_weight: frame_support::weights::Weight::zero(), + proof: FromBridgedChainMessagesProof { + bridged_header_hash: Default::default(), + storage_proof: vec![], + lane: LaneId([0, 0, 0, 0]), + nonces_start, + nonces_end, + }, + }, + ) + .check_obsolete_call() + .is_ok() + } + + #[test] + fn extension_rejects_obsolete_messages() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + // when current best delivered is message#10 and we're trying to deliver messages 8..=9 + // => tx is rejected + deliver_message_10(); + assert!(!validate_message_delivery(8, 9)); + }); + } + + #[test] + fn extension_rejects_same_message() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + // when current best delivered is message#10 and we're trying to import messages 10..=10 + // => tx is rejected + deliver_message_10(); + assert!(!validate_message_delivery(8, 10)); + }); + } + + #[test] + fn extension_rejects_call_with_some_obsolete_messages() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + // when current best delivered is message#10 and we're trying to deliver messages + // 10..=15 => tx is rejected + deliver_message_10(); + assert!(!validate_message_delivery(10, 15)); + }); + } + + #[test] + fn extension_rejects_call_with_future_messages() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + // when current best delivered is message#10 and we're trying to deliver messages + // 13..=15 => tx is rejected + deliver_message_10(); + assert!(!validate_message_delivery(13, 15)); + }); + } + + #[test] + fn extension_rejects_empty_delivery_with_rewards_confirmations_if_there_are_free_relayer_and_message_slots( + ) { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + deliver_message_10(); + assert!(!validate_message_delivery(10, 9)); + }); + } + + #[test] + fn extension_accepts_empty_delivery_with_rewards_confirmations_if_there_are_no_free_relayer_slots( + ) { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + deliver_message_10(); + fill_unrewarded_relayers(); + assert!(validate_message_delivery(10, 9)); + }); + } + + #[test] + fn extension_accepts_empty_delivery_with_rewards_confirmations_if_there_are_no_free_message_slots( + ) { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + fill_unrewarded_messages(); + assert!(validate_message_delivery( + MaxUnconfirmedMessagesAtInboundLane::get(), + MaxUnconfirmedMessagesAtInboundLane::get() - 1 + )); + }); + } + + #[test] + fn extension_accepts_new_messages() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + // when current best delivered is message#10 and we're trying to deliver message 11..=15 + // => tx is accepted + deliver_message_10(); + assert!(validate_message_delivery(11, 15)); + }); + } + + fn confirm_message_10() { + pallet_bridge_messages::OutboundLanes::::insert( + LaneId([0, 0, 0, 0]), + bp_messages::OutboundLaneData { + oldest_unpruned_nonce: 0, + latest_received_nonce: 10, + latest_generated_nonce: 10, + }, + ); + } + + fn validate_message_confirmation(last_delivered_nonce: bp_messages::MessageNonce) -> bool { + ThisChainRuntimeCall::BridgeMessages( + pallet_bridge_messages::Call::::receive_messages_delivery_proof { + proof: FromBridgedChainMessagesDeliveryProof { + bridged_header_hash: Default::default(), + storage_proof: Vec::new(), + lane: LaneId([0, 0, 0, 0]), + }, + relayers_state: UnrewardedRelayersState { + last_delivered_nonce, + ..Default::default() + }, + }, + ) + .check_obsolete_call() + .is_ok() + } + + #[test] + fn extension_rejects_obsolete_confirmations() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + // when current best confirmed is message#10 and we're trying to confirm message#5 => tx + // is rejected + confirm_message_10(); + assert!(!validate_message_confirmation(5)); + }); + } + + #[test] + fn extension_rejects_same_confirmation() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + // when current best confirmed is message#10 and we're trying to confirm message#10 => + // tx is rejected + confirm_message_10(); + assert!(!validate_message_confirmation(10)); + }); + } + + #[test] + fn extension_rejects_empty_confirmation_even_if_there_are_no_free_unrewarded_entries() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + confirm_message_10(); + fill_unrewarded_relayers(); + assert!(!validate_message_confirmation(10)); + }); + } + + #[test] + fn extension_accepts_new_confirmation() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + // when current best confirmed is message#10 and we're trying to confirm message#15 => + // tx is accepted + confirm_message_10(); + assert!(validate_message_confirmation(15)); + }); + } + + fn was_message_delivery_successful( + bundled_range: RangeInclusive, + is_empty: bool, + ) -> bool { + CallHelper::::was_successful(&CallInfo::ReceiveMessagesProof( + ReceiveMessagesProofInfo { + base: BaseMessagesProofInfo { + lane_id: LaneId([0, 0, 0, 0]), + bundled_range, + best_stored_nonce: 0, // doesn't matter for `was_successful` + }, + unrewarded_relayers: UnrewardedRelayerOccupation { + free_relayer_slots: 0, // doesn't matter for `was_successful` + free_message_slots: if is_empty { + 0 + } else { + MaxUnconfirmedMessagesAtInboundLane::get() + }, + }, + }, + )) + } + + #[test] + #[allow(clippy::reversed_empty_ranges)] + fn was_successful_returns_false_for_failed_reward_confirmation_transaction() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + fill_unrewarded_messages(); + assert!(!was_message_delivery_successful(10..=9, true)); + }); + } + + #[test] + #[allow(clippy::reversed_empty_ranges)] + fn was_successful_returns_true_for_successful_reward_confirmation_transaction() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + assert!(was_message_delivery_successful(10..=9, true)); + }); + } + + #[test] + fn was_successful_returns_false_for_failed_delivery() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + deliver_message_10(); + assert!(!was_message_delivery_successful(10..=12, false)); + }); + } + + #[test] + fn was_successful_returns_false_for_partially_successful_delivery() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + deliver_message_10(); + assert!(!was_message_delivery_successful(9..=12, false)); + }); + } + + #[test] + fn was_successful_returns_true_for_successful_delivery() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + deliver_message_10(); + assert!(was_message_delivery_successful(9..=10, false)); + }); + } + + fn was_message_confirmation_successful(bundled_range: RangeInclusive) -> bool { + CallHelper::::was_successful(&CallInfo::ReceiveMessagesDeliveryProof( + ReceiveMessagesDeliveryProofInfo(BaseMessagesProofInfo { + lane_id: LaneId([0, 0, 0, 0]), + bundled_range, + best_stored_nonce: 0, // doesn't matter for `was_successful` + }), + )) + } + + #[test] + fn was_successful_returns_false_for_failed_confirmation() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + confirm_message_10(); + assert!(!was_message_confirmation_successful(10..=12)); + }); + } + + #[test] + fn was_successful_returns_false_for_partially_successful_confirmation() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + confirm_message_10(); + assert!(!was_message_confirmation_successful(9..=12)); + }); + } + + #[test] + fn was_successful_returns_true_for_successful_confirmation() { + sp_io::TestExternalities::new(Default::default()).execute_with(|| { + confirm_message_10(); + assert!(was_message_confirmation_successful(9..=10)); + }); + } +} diff --git a/bridges/bin/runtime-common/src/messages_generation.rs b/bridges/bin/runtime-common/src/messages_generation.rs new file mode 100644 index 00000000000..8dbf3abd683 --- /dev/null +++ b/bridges/bin/runtime-common/src/messages_generation.rs @@ -0,0 +1,117 @@ +// Copyright 2019-2022 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Helpers for generating message storage proofs, that are used by tests and by benchmarks. + +use crate::messages::{BridgedChain, HashOf, HasherOf, MessageBridge}; + +use bp_messages::{ + storage_keys, LaneId, MessageKey, MessageNonce, MessagePayload, OutboundLaneData, +}; +use bp_runtime::{record_all_trie_keys, RawStorageProof, StorageProofSize}; +use codec::Encode; +use sp_std::{ops::RangeInclusive, prelude::*}; +use sp_trie::{trie_types::TrieDBMutBuilderV1, LayoutV1, MemoryDB, TrieMut}; + +/// Simple and correct message data encode function. +pub fn encode_all_messages(_: MessageNonce, m: &MessagePayload) -> Option> { + Some(m.encode()) +} + +/// Simple and correct outbound lane data encode function. +pub fn encode_lane_data(d: &OutboundLaneData) -> Vec { + d.encode() +} + +/// Prepare storage proof of given messages. +/// +/// Returns state trie root and nodes with prepared messages. +pub fn prepare_messages_storage_proof( + lane: LaneId, + message_nonces: RangeInclusive, + outbound_lane_data: Option, + size: StorageProofSize, + message_payload: MessagePayload, + encode_message: impl Fn(MessageNonce, &MessagePayload) -> Option>, + encode_outbound_lane_data: impl Fn(&OutboundLaneData) -> Vec, +) -> (HashOf>, RawStorageProof) +where + B: MessageBridge, + HashOf>: Copy + Default, +{ + // prepare Bridged chain storage with messages and (optionally) outbound lane state + let message_count = message_nonces.end().saturating_sub(*message_nonces.start()) + 1; + let mut storage_keys = Vec::with_capacity(message_count as usize + 1); + let mut root = Default::default(); + let mut mdb = MemoryDB::default(); + { + let mut trie = + TrieDBMutBuilderV1::>>::new(&mut mdb, &mut root).build(); + + // insert messages + for (i, nonce) in message_nonces.into_iter().enumerate() { + let message_key = MessageKey { lane_id: lane, nonce }; + let message_payload = match encode_message(nonce, &message_payload) { + Some(message_payload) => + if i == 0 { + grow_trie_leaf_value(message_payload, size) + } else { + message_payload + }, + None => continue, + }; + let storage_key = storage_keys::message_key( + B::BRIDGED_MESSAGES_PALLET_NAME, + &message_key.lane_id, + message_key.nonce, + ) + .0; + trie.insert(&storage_key, &message_payload) + .map_err(|_| "TrieMut::insert has failed") + .expect("TrieMut::insert should not fail in benchmarks"); + storage_keys.push(storage_key); + } + + // insert outbound lane state + if let Some(outbound_lane_data) = outbound_lane_data.as_ref().map(encode_outbound_lane_data) + { + let storage_key = + storage_keys::outbound_lane_data_key(B::BRIDGED_MESSAGES_PALLET_NAME, &lane).0; + trie.insert(&storage_key, &outbound_lane_data) + .map_err(|_| "TrieMut::insert has failed") + .expect("TrieMut::insert should not fail in benchmarks"); + storage_keys.push(storage_key); + } + } + + // generate storage proof to be delivered to This chain + let storage_proof = record_all_trie_keys::>>, _>(&mdb, &root) + .map_err(|_| "record_all_trie_keys has failed") + .expect("record_all_trie_keys should not fail in benchmarks"); + (root, storage_proof) +} + +/// Add extra data to the trie leaf value so that it'll be of given size. +pub fn grow_trie_leaf_value(mut value: Vec, size: StorageProofSize) -> Vec { + match size { + StorageProofSize::Minimal(_) => (), + StorageProofSize::HasLargeLeaf(size) if size as usize > value.len() => { + value.extend(sp_std::iter::repeat(42u8).take(size as usize - value.len())); + }, + StorageProofSize::HasLargeLeaf(_) => (), + } + value +} diff --git a/bridges/bin/runtime-common/src/messages_xcm_extension.rs b/bridges/bin/runtime-common/src/messages_xcm_extension.rs new file mode 100644 index 00000000000..96fdf1d5018 --- /dev/null +++ b/bridges/bin/runtime-common/src/messages_xcm_extension.rs @@ -0,0 +1,152 @@ +// Copyright 2023 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Module provides utilities for easier XCM handling, e.g: +//! `XcmExecutor` -> `MessageSender` -> `OutboundMessageQueue` +//! | +//! `Relayer` +//! | +//! `XcmRouter` <- `MessageDispatch` <- `InboundMessageQueue` + +use bp_messages::{ + source_chain::MessagesBridge, + target_chain::{DispatchMessage, MessageDispatch}, + LaneId, +}; +use bp_runtime::messages::MessageDispatchResult; +use codec::{Decode, Encode}; +use frame_support::{dispatch::Weight, CloneNoBound, EqNoBound, PartialEqNoBound}; +use pallet_bridge_messages::WeightInfoExt as MessagesPalletWeights; +use scale_info::TypeInfo; +use sp_runtime::SaturatedConversion; +use xcm_builder::{DispatchBlob, DispatchBlobError, HaulBlob, HaulBlobError}; + +/// Plain "XCM" payload, which we transfer through bridge +pub type XcmAsPlainPayload = sp_std::prelude::Vec; + +/// Message dispatch result type for single message +#[derive(CloneNoBound, EqNoBound, PartialEqNoBound, Encode, Decode, Debug, TypeInfo)] +pub enum XcmBlobMessageDispatchResult { + InvalidPayload, + Dispatched, + NotDispatched(#[codec(skip)] Option), +} + +/// [`XcmBlobMessageDispatch`] is responsible for dispatching received messages +pub struct XcmBlobMessageDispatch { + _marker: sp_std::marker::PhantomData<(DispatchBlob, Weights)>, +} + +impl MessageDispatch + for XcmBlobMessageDispatch +{ + type DispatchPayload = XcmAsPlainPayload; + type DispatchLevelResult = XcmBlobMessageDispatchResult; + + fn dispatch_weight(message: &mut DispatchMessage) -> Weight { + match message.data.payload { + Ok(ref payload) => { + let payload_size = payload.encoded_size().saturated_into(); + Weights::message_dispatch_weight(payload_size) + }, + Err(_) => Weight::zero(), + } + } + + fn dispatch( + message: DispatchMessage, + ) -> MessageDispatchResult { + let payload = match message.data.payload { + Ok(payload) => payload, + Err(e) => { + log::error!( + target: crate::LOG_TARGET_BRIDGE_DISPATCH, + "[XcmBlobMessageDispatch] payload error: {:?} - message_nonce: {:?}", + e, + message.key.nonce + ); + return MessageDispatchResult { + unspent_weight: Weight::zero(), + dispatch_level_result: XcmBlobMessageDispatchResult::InvalidPayload, + } + }, + }; + let dispatch_level_result = match BlobDispatcher::dispatch_blob(payload) { + Ok(_) => { + log::debug!( + target: crate::LOG_TARGET_BRIDGE_DISPATCH, + "[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob was ok - message_nonce: {:?}", + message.key.nonce + ); + XcmBlobMessageDispatchResult::Dispatched + }, + Err(e) => { + log::error!( + target: crate::LOG_TARGET_BRIDGE_DISPATCH, + "[XcmBlobMessageDispatch] DispatchBlob::dispatch_blob failed, error: {:?} - message_nonce: {:?}", + e, message.key.nonce + ); + XcmBlobMessageDispatchResult::NotDispatched(Some(e)) + }, + }; + MessageDispatchResult { unspent_weight: Weight::zero(), dispatch_level_result } + } +} + +/// [`XcmBlobHauler`] is responsible for sending messages to the bridge "point-to-point link" from +/// one side, where on the other it can be dispatched by [`XcmBlobMessageDispatch`]. +pub trait XcmBlobHauler { + /// Runtime message sender adapter. + type MessageSender: MessagesBridge; + + /// Runtime message sender origin, which is used by [`Self::MessageSender`]. + type MessageSenderOrigin; + /// Our location within the Consensus Universe. + fn message_sender_origin() -> Self::MessageSenderOrigin; + + /// Return message lane (as "point-to-point link") used to deliver XCM messages. + fn xcm_lane() -> LaneId; +} + +/// XCM bridge adapter which connects [`XcmBlobHauler`] with [`XcmBlobHauler::MessageSender`] and +/// makes sure that XCM blob is sent to the [`pallet_bridge_messages`] queue to be relayed. +pub struct XcmBlobHaulerAdapter(sp_std::marker::PhantomData); +impl> HaulBlob + for XcmBlobHaulerAdapter +{ + fn haul_blob(blob: sp_std::prelude::Vec) -> Result<(), HaulBlobError> { + let lane = H::xcm_lane(); + H::MessageSender::send_message(H::message_sender_origin(), lane, blob) + .map(|artifacts| (lane, artifacts.nonce).using_encoded(sp_io::hashing::blake2_256)) + .map(|result| { + log::info!( + target: crate::LOG_TARGET_BRIDGE_DISPATCH, + "haul_blob result - ok: {:?} on lane: {:?}", + result, + lane + ) + }) + .map_err(|error| { + log::error!( + target: crate::LOG_TARGET_BRIDGE_DISPATCH, + "haul_blob result - error: {:?} on lane: {:?}", + error, + lane + ); + HaulBlobError::Transport("MessageSenderError") + }) + } +} diff --git a/bridges/bin/runtime-common/src/mock.rs b/bridges/bin/runtime-common/src/mock.rs new file mode 100644 index 00000000000..4542ad39b62 --- /dev/null +++ b/bridges/bin/runtime-common/src/mock.rs @@ -0,0 +1,424 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! A mock runtime for testing different stuff in the crate. We've been using Millau +//! runtime for that before, but it has two drawbacks: +//! +//! - circular dependencies between this crate and Millau runtime; +//! +//! - we can't use (e.g. as git subtree or by copying) this crate in repo without Millau. + +#![cfg(test)] + +use crate::messages::{ + source::{ + FromThisChainMaximalOutboundPayloadSize, FromThisChainMessagePayload, + FromThisChainMessageVerifier, TargetHeaderChainAdapter, + }, + target::{FromBridgedChainMessagePayload, SourceHeaderChainAdapter}, + BridgedChainWithMessages, HashOf, MessageBridge, ThisChainWithMessages, +}; + +use bp_header_chain::{ChainWithGrandpa, HeaderChain}; +use bp_messages::{target_chain::ForbidInboundMessages, LaneId, MessageNonce}; +use bp_parachains::SingleParaStoredHeaderDataBuilder; +use bp_relayers::PayRewardFromAccount; +use bp_runtime::{Chain, ChainId, Parachain, UnderlyingChainProvider}; +use codec::{Decode, Encode}; +use frame_support::{ + parameter_types, + weights::{ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight}, +}; +use pallet_transaction_payment::Multiplier; +use sp_runtime::{ + testing::H256, + traits::{BlakeTwo256, ConstU32, ConstU64, ConstU8, IdentityLookup}, + FixedPointNumber, Perquintill, +}; + +/// Account identifier at `ThisChain`. +pub type ThisChainAccountId = u64; +/// Balance at `ThisChain`. +pub type ThisChainBalance = u64; +/// Block number at `ThisChain`. +pub type ThisChainBlockNumber = u32; +/// Hash at `ThisChain`. +pub type ThisChainHash = H256; +/// Hasher at `ThisChain`. +pub type ThisChainHasher = BlakeTwo256; +/// Runtime call at `ThisChain`. +pub type ThisChainRuntimeCall = RuntimeCall; +/// Runtime call origin at `ThisChain`. +pub type ThisChainCallOrigin = RuntimeOrigin; +/// Header of `ThisChain`. +pub type ThisChainHeader = sp_runtime::generic::Header; +/// Block of `ThisChain`. +pub type ThisChainBlock = frame_system::mocking::MockBlock; +/// Unchecked extrinsic of `ThisChain`. +pub type ThisChainUncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + +/// Account identifier at the `BridgedChain`. +pub type BridgedChainAccountId = u128; +/// Balance at the `BridgedChain`. +pub type BridgedChainBalance = u128; +/// Block number at the `BridgedChain`. +pub type BridgedChainBlockNumber = u32; +/// Hash at the `BridgedChain`. +pub type BridgedChainHash = H256; +/// Hasher at the `BridgedChain`. +pub type BridgedChainHasher = BlakeTwo256; +/// Header of the `BridgedChain`. +pub type BridgedChainHeader = + sp_runtime::generic::Header; + +/// Rewards payment procedure. +pub type TestPaymentProcedure = PayRewardFromAccount; +/// Stake that we are using in tests. +pub type TestStake = ConstU64<5_000>; +/// Stake and slash mechanism to use in tests. +pub type TestStakeAndSlash = pallet_bridge_relayers::StakeAndSlashNamed< + ThisChainAccountId, + ThisChainBlockNumber, + Balances, + ReserveId, + TestStake, + ConstU32<8>, +>; + +/// Message lane used in tests. +pub const TEST_LANE_ID: LaneId = LaneId([0, 0, 0, 0]); +/// Bridged chain id used in tests. +pub const TEST_BRIDGED_CHAIN_ID: ChainId = *b"brdg"; +/// Maximal extrinsic weight at the `BridgedChain`. +pub const BRIDGED_CHAIN_MAX_EXTRINSIC_WEIGHT: usize = 2048; +/// Maximal extrinsic size at the `BridgedChain`. +pub const BRIDGED_CHAIN_MAX_EXTRINSIC_SIZE: u32 = 1024; + +frame_support::construct_runtime! { + pub enum TestRuntime where + Block = ThisChainBlock, + NodeBlock = ThisChainBlock, + UncheckedExtrinsic = ThisChainUncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Utility: pallet_utility, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, + BridgeRelayers: pallet_bridge_relayers::{Pallet, Call, Storage, Event}, + BridgeGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage, Event}, + BridgeParachains: pallet_bridge_parachains::{Pallet, Call, Storage, Event}, + BridgeMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event, Config}, + } +} + +crate::generate_bridge_reject_obsolete_headers_and_messages! { + ThisChainRuntimeCall, ThisChainAccountId, + BridgeGrandpa, BridgeParachains, BridgeMessages +} + +parameter_types! { + pub const ActiveOutboundLanes: &'static [LaneId] = &[TEST_LANE_ID]; + pub const BridgedChainId: ChainId = TEST_BRIDGED_CHAIN_ID; + pub const BridgedParasPalletName: &'static str = "Paras"; + pub const ExistentialDeposit: ThisChainBalance = 500; + pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { read: 1, write: 2 }; + pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); + pub const TransactionBaseFee: ThisChainBalance = 0; + pub const TransactionByteFee: ThisChainBalance = 1; + pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(3, 100_000); + pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128); + pub MaximumMultiplier: Multiplier = sp_runtime::traits::Bounded::max_value(); + pub const MaxUnrewardedRelayerEntriesAtInboundLane: MessageNonce = 16; + pub const MaxUnconfirmedMessagesAtInboundLane: MessageNonce = 1_000; + pub const ReserveId: [u8; 8] = *b"brdgrlrs"; +} + +impl frame_system::Config for TestRuntime { + type RuntimeOrigin = RuntimeOrigin; + type Index = u64; + type RuntimeCall = RuntimeCall; + type BlockNumber = ThisChainBlockNumber; + type Hash = ThisChainHash; + type Hashing = ThisChainHasher; + type AccountId = ThisChainAccountId; + type Lookup = IdentityLookup; + type Header = ThisChainHeader; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = ConstU32<250>; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type BaseCallFilter = frame_support::traits::Everything; + type SystemWeightInfo = (); + type BlockWeights = (); + type BlockLength = (); + type DbWeight = DbWeight; + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +impl pallet_utility::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type PalletsOrigin = OriginCaller; + type WeightInfo = (); +} + +impl pallet_balances::Config for TestRuntime { + type Balance = ThisChainBalance; + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = (); + type MaxLocks = ConstU32<50>; + type MaxReserves = ConstU32<50>; + type ReserveIdentifier = [u8; 8]; + type RuntimeHoldReason = RuntimeHoldReason; + type FreezeIdentifier = (); + type MaxHolds = ConstU32<0>; + type MaxFreezes = ConstU32<0>; +} + +impl pallet_transaction_payment::Config for TestRuntime { + type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; + type OperationalFeeMultiplier = ConstU8<5>; + type WeightToFee = IdentityFee; + type LengthToFee = ConstantMultiplier; + type FeeMultiplierUpdate = pallet_transaction_payment::TargetedFeeAdjustment< + TestRuntime, + TargetBlockFullness, + AdjustmentVariable, + MinimumMultiplier, + MaximumMultiplier, + >; + type RuntimeEvent = RuntimeEvent; +} + +impl pallet_bridge_grandpa::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type BridgedChain = BridgedUnderlyingChain; + type MaxFreeMandatoryHeadersPerBlock = ConstU32<4>; + type HeadersToKeep = ConstU32<8>; + type WeightInfo = pallet_bridge_grandpa::weights::BridgeWeight; +} + +impl pallet_bridge_parachains::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type BridgesGrandpaPalletInstance = (); + type ParasPalletName = BridgedParasPalletName; + type ParaStoredHeaderDataBuilder = + SingleParaStoredHeaderDataBuilder; + type HeadsToKeep = ConstU32<8>; + type MaxParaHeadDataSize = ConstU32<1024>; + type WeightInfo = pallet_bridge_parachains::weights::BridgeWeight; +} + +impl pallet_bridge_messages::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_bridge_messages::weights::BridgeWeight; + type ActiveOutboundLanes = ActiveOutboundLanes; + type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane; + type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane; + + type MaximalOutboundPayloadSize = FromThisChainMaximalOutboundPayloadSize; + type OutboundPayload = FromThisChainMessagePayload; + + type InboundPayload = FromBridgedChainMessagePayload; + type InboundRelayer = BridgedChainAccountId; + type DeliveryPayments = (); + + type TargetHeaderChain = TargetHeaderChainAdapter; + type LaneMessageVerifier = FromThisChainMessageVerifier; + type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter< + TestRuntime, + (), + ConstU64<100_000>, + >; + + type SourceHeaderChain = SourceHeaderChainAdapter; + type MessageDispatch = ForbidInboundMessages<(), FromBridgedChainMessagePayload>; + type BridgedChainId = BridgedChainId; +} + +impl pallet_bridge_relayers::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type Reward = ThisChainBalance; + type PaymentProcedure = TestPaymentProcedure; + type StakeAndSlash = TestStakeAndSlash; + type WeightInfo = (); +} + +/// Bridge that is deployed on `ThisChain` and allows sending/receiving messages to/from +/// `BridgedChain`. +#[derive(Debug, PartialEq, Eq)] +pub struct OnThisChainBridge; + +impl MessageBridge for OnThisChainBridge { + const BRIDGED_MESSAGES_PALLET_NAME: &'static str = ""; + + type ThisChain = ThisChain; + type BridgedChain = BridgedChain; + type BridgedHeaderChain = pallet_bridge_grandpa::GrandpaChainHeaders; +} + +/// Bridge that is deployed on `BridgedChain` and allows sending/receiving messages to/from +/// `ThisChain`. +#[derive(Debug, PartialEq, Eq)] +pub struct OnBridgedChainBridge; + +impl MessageBridge for OnBridgedChainBridge { + const BRIDGED_MESSAGES_PALLET_NAME: &'static str = ""; + + type ThisChain = BridgedChain; + type BridgedChain = ThisChain; + type BridgedHeaderChain = ThisHeaderChain; +} + +/// Dummy implementation of `HeaderChain` for `ThisChain` at the `BridgedChain`. +pub struct ThisHeaderChain; + +impl HeaderChain for ThisHeaderChain { + fn finalized_header_state_root(_hash: HashOf) -> Option> { + unreachable!() + } +} + +/// Call origin at `BridgedChain`. +#[derive(Clone, Debug)] +pub struct BridgedChainOrigin; + +impl From + for Result, BridgedChainOrigin> +{ + fn from( + _origin: BridgedChainOrigin, + ) -> Result, BridgedChainOrigin> { + unreachable!() + } +} + +/// Underlying chain of `ThisChain`. +pub struct ThisUnderlyingChain; + +impl Chain for ThisUnderlyingChain { + type BlockNumber = ThisChainBlockNumber; + type Hash = ThisChainHash; + type Hasher = ThisChainHasher; + type Header = ThisChainHeader; + type AccountId = ThisChainAccountId; + type Balance = ThisChainBalance; + type Index = u32; + type Signature = sp_runtime::MultiSignature; + + fn max_extrinsic_size() -> u32 { + BRIDGED_CHAIN_MAX_EXTRINSIC_SIZE + } + + fn max_extrinsic_weight() -> Weight { + Weight::zero() + } +} + +/// The chain where we are in tests. +pub struct ThisChain; + +impl UnderlyingChainProvider for ThisChain { + type Chain = ThisUnderlyingChain; +} + +impl ThisChainWithMessages for ThisChain { + type RuntimeOrigin = ThisChainCallOrigin; +} + +impl BridgedChainWithMessages for ThisChain {} + +/// Underlying chain of `BridgedChain`. +pub struct BridgedUnderlyingChain; +/// Some parachain under `BridgedChain` consensus. +pub struct BridgedUnderlyingParachain; +/// Runtime call of the `BridgedChain`. +#[derive(Decode, Encode)] +pub struct BridgedChainCall; + +impl Chain for BridgedUnderlyingChain { + type BlockNumber = BridgedChainBlockNumber; + type Hash = BridgedChainHash; + type Hasher = BridgedChainHasher; + type Header = BridgedChainHeader; + type AccountId = BridgedChainAccountId; + type Balance = BridgedChainBalance; + type Index = u32; + type Signature = sp_runtime::MultiSignature; + + fn max_extrinsic_size() -> u32 { + BRIDGED_CHAIN_MAX_EXTRINSIC_SIZE + } + fn max_extrinsic_weight() -> Weight { + Weight::zero() + } +} + +impl ChainWithGrandpa for BridgedUnderlyingChain { + const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = ""; + const MAX_AUTHORITIES_COUNT: u32 = 16; + const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 8; + const MAX_HEADER_SIZE: u32 = 256; + const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 64; +} + +impl Chain for BridgedUnderlyingParachain { + type BlockNumber = BridgedChainBlockNumber; + type Hash = BridgedChainHash; + type Hasher = BridgedChainHasher; + type Header = BridgedChainHeader; + type AccountId = BridgedChainAccountId; + type Balance = BridgedChainBalance; + type Index = u32; + type Signature = sp_runtime::MultiSignature; + + fn max_extrinsic_size() -> u32 { + BRIDGED_CHAIN_MAX_EXTRINSIC_SIZE + } + fn max_extrinsic_weight() -> Weight { + Weight::zero() + } +} + +impl Parachain for BridgedUnderlyingParachain { + const PARACHAIN_ID: u32 = 42; +} + +/// The other, bridged chain, used in tests. +pub struct BridgedChain; + +impl UnderlyingChainProvider for BridgedChain { + type Chain = BridgedUnderlyingChain; +} + +impl ThisChainWithMessages for BridgedChain { + type RuntimeOrigin = BridgedChainOrigin; +} + +impl BridgedChainWithMessages for BridgedChain {} + +/// Run test within test externalities. +pub fn run_test(test: impl FnOnce()) { + sp_io::TestExternalities::new(Default::default()).execute_with(test) +} diff --git a/bridges/bin/runtime-common/src/parachains_benchmarking.rs b/bridges/bin/runtime-common/src/parachains_benchmarking.rs new file mode 100644 index 00000000000..aad53673c3a --- /dev/null +++ b/bridges/bin/runtime-common/src/parachains_benchmarking.rs @@ -0,0 +1,88 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Everything required to run benchmarks of parachains finality module. + +#![cfg(feature = "runtime-benchmarks")] + +use crate::{ + messages_benchmarking::insert_header_to_grandpa_pallet, + messages_generation::grow_trie_leaf_value, +}; + +use bp_parachains::parachain_head_storage_key_at_source; +use bp_polkadot_core::parachains::{ParaHash, ParaHead, ParaHeadsProof, ParaId}; +use bp_runtime::{record_all_trie_keys, StorageProofSize}; +use codec::Encode; +use frame_support::traits::Get; +use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumber}; +use sp_std::prelude::*; +use sp_trie::{trie_types::TrieDBMutBuilderV1, LayoutV1, MemoryDB, TrieMut}; + +/// Prepare proof of messages for the `receive_messages_proof` call. +/// +/// In addition to returning valid messages proof, environment is prepared to verify this message +/// proof. +pub fn prepare_parachain_heads_proof( + parachains: &[ParaId], + parachain_head_size: u32, + size: StorageProofSize, +) -> (RelayBlockNumber, RelayBlockHash, ParaHeadsProof, Vec<(ParaId, ParaHash)>) +where + R: pallet_bridge_parachains::Config + + pallet_bridge_grandpa::Config, + PI: 'static, + >::BridgedChain: + bp_runtime::Chain, +{ + let parachain_head = ParaHead(vec![0u8; parachain_head_size as usize]); + + // insert all heads to the trie + let mut parachain_heads = Vec::with_capacity(parachains.len()); + let mut storage_keys = Vec::with_capacity(parachains.len()); + let mut state_root = Default::default(); + let mut mdb = MemoryDB::default(); + { + let mut trie = + TrieDBMutBuilderV1::::new(&mut mdb, &mut state_root).build(); + + // insert parachain heads + for (i, parachain) in parachains.into_iter().enumerate() { + let storage_key = + parachain_head_storage_key_at_source(R::ParasPalletName::get(), *parachain); + let leaf_data = if i == 0 { + grow_trie_leaf_value(parachain_head.encode(), size) + } else { + parachain_head.encode() + }; + trie.insert(&storage_key.0, &leaf_data) + .map_err(|_| "TrieMut::insert has failed") + .expect("TrieMut::insert should not fail in benchmarks"); + storage_keys.push(storage_key); + parachain_heads.push((*parachain, parachain_head.hash())) + } + } + + // generate heads storage proof + let proof = record_all_trie_keys::, _>(&mdb, &state_root) + .map_err(|_| "record_all_trie_keys has failed") + .expect("record_all_trie_keys should not fail in benchmarks"); + + let (relay_block_number, relay_block_hash) = + insert_header_to_grandpa_pallet::(state_root); + + (relay_block_number, relay_block_hash, ParaHeadsProof(proof), parachain_heads) +} diff --git a/bridges/bin/runtime-common/src/priority_calculator.rs b/bridges/bin/runtime-common/src/priority_calculator.rs new file mode 100644 index 00000000000..590de05fb1c --- /dev/null +++ b/bridges/bin/runtime-common/src/priority_calculator.rs @@ -0,0 +1,201 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Bridge transaction priority calculator. +//! +//! We want to prioritize message delivery transactions with more messages over +//! transactions with less messages. That's because we reject delivery transactions +//! if it contains already delivered message. And if some transaction delivers +//! single message with nonce `N`, then the transaction with nonces `N..=N+100` will +//! be rejected. This can lower bridge throughput down to one message per block. + +use bp_messages::MessageNonce; +use frame_support::traits::Get; +use sp_runtime::transaction_validity::TransactionPriority; + +// reexport everything from `integrity_tests` module +pub use integrity_tests::*; + +/// Compute priority boost for message delivery transaction that delivers +/// given number of messages. +pub fn compute_priority_boost( + messages: MessageNonce, +) -> TransactionPriority +where + PriorityBoostPerMessage: Get, +{ + // we don't want any boost for transaction with single message => minus one + PriorityBoostPerMessage::get().saturating_mul(messages - 1) +} + +#[cfg(not(feature = "integrity-test"))] +mod integrity_tests {} + +#[cfg(feature = "integrity-test")] +mod integrity_tests { + use super::compute_priority_boost; + + use bp_messages::MessageNonce; + use bp_runtime::PreComputedSize; + use frame_support::{ + dispatch::{DispatchClass, DispatchInfo, Dispatchable, Pays, PostDispatchInfo}, + traits::Get, + }; + use pallet_bridge_messages::WeightInfoExt; + use pallet_transaction_payment::OnChargeTransaction; + use sp_runtime::{ + traits::{UniqueSaturatedInto, Zero}, + transaction_validity::TransactionPriority, + FixedPointOperand, SaturatedConversion, Saturating, + }; + + type BalanceOf = + <::OnChargeTransaction as OnChargeTransaction< + T, + >>::Balance; + + /// Ensures that the value of `PriorityBoostPerMessage` matches the value of + /// `tip_boost_per_message`. + /// + /// We want two transactions, `TX1` with `N` messages and `TX2` with `N+1` messages, have almost + /// the same priority if we'll add `tip_boost_per_message` tip to the `TX1`. We want to be sure + /// that if we add plain `PriorityBoostPerMessage` priority to `TX1`, the priority will be close + /// to `TX2` as well. + pub fn ensure_priority_boost_is_sane( + tip_boost_per_message: BalanceOf, + ) where + Runtime: + pallet_transaction_payment::Config + pallet_bridge_messages::Config, + MessagesInstance: 'static, + PriorityBoostPerMessage: Get, + Runtime::RuntimeCall: Dispatchable, + BalanceOf: Send + Sync + FixedPointOperand, + { + let priority_boost_per_message = PriorityBoostPerMessage::get(); + let maximal_messages_in_delivery_transaction = + Runtime::MaxUnconfirmedMessagesAtInboundLane::get(); + for messages in 1..=maximal_messages_in_delivery_transaction { + let base_priority = estimate_message_delivery_transaction_priority::< + Runtime, + MessagesInstance, + >(messages, Zero::zero()); + let priority_boost = compute_priority_boost::(messages); + let priority_with_boost = base_priority + priority_boost; + + let tip = tip_boost_per_message.saturating_mul((messages - 1).unique_saturated_into()); + let priority_with_tip = + estimate_message_delivery_transaction_priority::(1, tip); + + const ERROR_MARGIN: TransactionPriority = 5; // 5% + if priority_with_boost.abs_diff(priority_with_tip).saturating_mul(100) / + priority_with_tip > + ERROR_MARGIN + { + panic!( + "The PriorityBoostPerMessage value ({}) must be fixed to: {}", + priority_boost_per_message, + compute_priority_boost_per_message::( + tip_boost_per_message + ), + ); + } + } + } + + /// Compute priority boost that we give to message delivery transaction for additional message. + #[cfg(feature = "integrity-test")] + fn compute_priority_boost_per_message( + tip_boost_per_message: BalanceOf, + ) -> TransactionPriority + where + Runtime: + pallet_transaction_payment::Config + pallet_bridge_messages::Config, + MessagesInstance: 'static, + Runtime::RuntimeCall: Dispatchable, + BalanceOf: Send + Sync + FixedPointOperand, + { + // esimate priority of transaction that delivers one message and has large tip + let maximal_messages_in_delivery_transaction = + Runtime::MaxUnconfirmedMessagesAtInboundLane::get(); + let small_with_tip_priority = + estimate_message_delivery_transaction_priority::( + 1, + tip_boost_per_message + .saturating_mul(maximal_messages_in_delivery_transaction.saturated_into()), + ); + // estimate priority of transaction that delivers maximal number of messages, but has no tip + let large_without_tip_priority = estimate_message_delivery_transaction_priority::< + Runtime, + MessagesInstance, + >(maximal_messages_in_delivery_transaction, Zero::zero()); + + small_with_tip_priority + .saturating_sub(large_without_tip_priority) + .saturating_div(maximal_messages_in_delivery_transaction - 1) + } + + /// Estimate message delivery transaction priority. + #[cfg(feature = "integrity-test")] + fn estimate_message_delivery_transaction_priority( + messages: MessageNonce, + tip: BalanceOf, + ) -> TransactionPriority + where + Runtime: + pallet_transaction_payment::Config + pallet_bridge_messages::Config, + MessagesInstance: 'static, + Runtime::RuntimeCall: Dispatchable, + BalanceOf: Send + Sync + FixedPointOperand, + { + // just an estimation of extra transaction bytes that are added to every transaction + // (including signature, signed extensions extra and etc + in our case it includes + // all call arguments extept the proof itself) + let base_tx_size = 512; + // let's say we are relaying similar small messages and for every message we add more trie + // nodes to the proof (x0.5 because we expect some nodes to be reused) + let estimated_message_size = 512; + // let's say all our messages have the same dispatch weight + let estimated_message_dispatch_weight = + Runtime::WeightInfo::message_dispatch_weight(estimated_message_size); + // messages proof argument size is (for every message) messages size + some additional + // trie nodes. Some of them are reused by different messages, so let's take 2/3 of default + // "overhead" constant + let messages_proof_size = Runtime::WeightInfo::expected_extra_storage_proof_size() + .saturating_mul(2) + .saturating_div(3) + .saturating_add(estimated_message_size) + .saturating_mul(messages as _); + + // finally we are able to estimate transaction size and weight + let transaction_size = base_tx_size.saturating_add(messages_proof_size); + let transaction_weight = Runtime::WeightInfo::receive_messages_proof_weight( + &PreComputedSize(transaction_size as _), + messages as _, + estimated_message_dispatch_weight.saturating_mul(messages), + ); + + pallet_transaction_payment::ChargeTransactionPayment::::get_priority( + &DispatchInfo { + weight: transaction_weight, + class: DispatchClass::Normal, + pays_fee: Pays::Yes, + }, + transaction_size as _, + tip, + Zero::zero(), + ) + } +} diff --git a/bridges/bin/runtime-common/src/refund_relayer_extension.rs b/bridges/bin/runtime-common/src/refund_relayer_extension.rs new file mode 100644 index 00000000000..c5419837316 --- /dev/null +++ b/bridges/bin/runtime-common/src/refund_relayer_extension.rs @@ -0,0 +1,1741 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Signed extension that refunds relayer if he has delivered some new messages. +//! It also refunds transaction cost if the transaction is an `utility.batchAll()` +//! with calls that are: delivering new messsage and all necessary underlying headers +//! (parachain or relay chain). + +use crate::messages_call_ext::{ + CallHelper as MessagesCallHelper, CallInfo as MessagesCallInfo, MessagesCallSubType, +}; +use bp_messages::{LaneId, MessageNonce}; +use bp_relayers::{RewardsAccountOwner, RewardsAccountParams}; +use bp_runtime::{Parachain, ParachainIdOf, RangeInclusiveExt, StaticStrProvider}; +use codec::{Decode, Encode}; +use frame_support::{ + dispatch::{CallableCallFor, DispatchInfo, Dispatchable, PostDispatchInfo}, + traits::IsSubType, + weights::Weight, + CloneNoBound, DefaultNoBound, EqNoBound, PartialEqNoBound, RuntimeDebug, RuntimeDebugNoBound, +}; +use pallet_bridge_grandpa::{ + CallSubType as GrandpaCallSubType, SubmitFinalityProofHelper, SubmitFinalityProofInfo, +}; +use pallet_bridge_messages::Config as MessagesConfig; +use pallet_bridge_parachains::{ + BoundedBridgeGrandpaConfig, CallSubType as ParachainsCallSubType, Config as ParachainsConfig, + RelayBlockNumber, SubmitParachainHeadsHelper, SubmitParachainHeadsInfo, +}; +use pallet_bridge_relayers::{ + Config as RelayersConfig, Pallet as RelayersPallet, WeightInfoExt as _, +}; +use pallet_transaction_payment::{Config as TransactionPaymentConfig, OnChargeTransaction}; +use pallet_utility::{Call as UtilityCall, Config as UtilityConfig, Pallet as UtilityPallet}; +use scale_info::TypeInfo; +use sp_runtime::{ + traits::{DispatchInfoOf, Get, PostDispatchInfoOf, SignedExtension, Zero}, + transaction_validity::{ + TransactionPriority, TransactionValidity, TransactionValidityError, ValidTransactionBuilder, + }, + DispatchResult, FixedPointOperand, +}; +use sp_std::{marker::PhantomData, vec, vec::Vec}; + +type AccountIdOf = ::AccountId; +// without this typedef rustfmt fails with internal err +type BalanceOf = + <::OnChargeTransaction as OnChargeTransaction>::Balance; +type CallOf = ::RuntimeCall; + +/// Trait identifying a bridged parachain. A relayer might be refunded for delivering messages +/// coming from this parachain. +pub trait RefundableParachainId { + /// The instance of the bridge parachains pallet. + type Instance; + /// The parachain Id. + type Id: Get; +} + +/// Default implementation of `RefundableParachainId`. +pub struct DefaultRefundableParachainId(PhantomData<(Instance, Id)>); + +impl RefundableParachainId for DefaultRefundableParachainId +where + Id: Get, +{ + type Instance = Instance; + type Id = Id; +} + +/// Implementation of `RefundableParachainId` for `trait Parachain`. +pub struct RefundableParachain(PhantomData<(Instance, Para)>); + +impl RefundableParachainId for RefundableParachain +where + Para: Parachain, +{ + type Instance = Instance; + type Id = ParachainIdOf; +} + +/// Trait identifying a bridged messages lane. A relayer might be refunded for delivering messages +/// coming from this lane. +pub trait RefundableMessagesLaneId { + /// The instance of the bridge messages pallet. + type Instance; + /// The messages lane id. + type Id: Get; +} + +/// Default implementation of `RefundableMessagesLaneId`. +pub struct RefundableMessagesLane(PhantomData<(Instance, Id)>); + +impl RefundableMessagesLaneId for RefundableMessagesLane +where + Id: Get, +{ + type Instance = Instance; + type Id = Id; +} + +/// Refund calculator. +pub trait RefundCalculator { + // The underlying integer type in which the refund is calculated. + type Balance; + + /// Compute refund for given transaction. + fn compute_refund( + info: &DispatchInfo, + post_info: &PostDispatchInfo, + len: usize, + tip: Self::Balance, + ) -> Self::Balance; +} + +/// `RefundCalculator` implementation which refunds the actual transaction fee. +pub struct ActualFeeRefund(PhantomData); + +impl RefundCalculator for ActualFeeRefund +where + R: TransactionPaymentConfig, + CallOf: Dispatchable, + BalanceOf: FixedPointOperand, +{ + type Balance = BalanceOf; + + fn compute_refund( + info: &DispatchInfo, + post_info: &PostDispatchInfo, + len: usize, + tip: BalanceOf, + ) -> BalanceOf { + pallet_transaction_payment::Pallet::::compute_actual_fee(len as _, info, post_info, tip) + } +} + +/// Data that is crafted in `pre_dispatch` method and used at `post_dispatch`. +#[cfg_attr(test, derive(Debug, PartialEq))] +pub struct PreDispatchData { + /// Transaction submitter (relayer) account. + relayer: AccountId, + /// Type of the call. + call_info: CallInfo, +} + +/// Type of the call that the extension recognizes. +#[derive(RuntimeDebugNoBound, PartialEq)] +pub enum CallInfo { + /// Relay chain finality + parachain finality + message delivery/confirmation calls. + AllFinalityAndMsgs( + SubmitFinalityProofInfo, + SubmitParachainHeadsInfo, + MessagesCallInfo, + ), + /// Parachain finality + message delivery/confirmation calls. + ParachainFinalityAndMsgs(SubmitParachainHeadsInfo, MessagesCallInfo), + /// Standalone message delivery/confirmation call. + Msgs(MessagesCallInfo), +} + +impl CallInfo { + /// Returns true if call is a message delivery call (with optional finality calls). + fn is_receive_messages_proof_call(&self) -> bool { + match self.messages_call_info() { + MessagesCallInfo::ReceiveMessagesProof(_) => true, + MessagesCallInfo::ReceiveMessagesDeliveryProof(_) => false, + } + } + + /// Returns the pre-dispatch `finality_target` sent to the `SubmitFinalityProof` call. + fn submit_finality_proof_info(&self) -> Option> { + match *self { + Self::AllFinalityAndMsgs(info, _, _) => Some(info), + _ => None, + } + } + + /// Returns the pre-dispatch `SubmitParachainHeadsInfo`. + fn submit_parachain_heads_info(&self) -> Option<&SubmitParachainHeadsInfo> { + match self { + Self::AllFinalityAndMsgs(_, info, _) => Some(info), + Self::ParachainFinalityAndMsgs(info, _) => Some(info), + _ => None, + } + } + + /// Returns the pre-dispatch `ReceiveMessagesProofInfo`. + fn messages_call_info(&self) -> &MessagesCallInfo { + match self { + Self::AllFinalityAndMsgs(_, _, info) => info, + Self::ParachainFinalityAndMsgs(_, info) => info, + Self::Msgs(info) => info, + } + } +} + +/// The actions on relayer account that need to be performed because of his actions. +#[derive(RuntimeDebug, PartialEq)] +enum RelayerAccountAction { + /// Do nothing with relayer account. + None, + /// Reward the relayer. + Reward(AccountId, RewardsAccountParams, Reward), + /// Slash the relayer. + Slash(AccountId, RewardsAccountParams), +} + +/// Signed extension that refunds a relayer for new messages coming from a parachain. +/// +/// Also refunds relayer for successful finality delivery if it comes in batch (`utility.batchAll`) +/// with message delivery transaction. Batch may deliver either both relay chain header and +/// parachain head, or just parachain head. Corresponding headers must be used in messages +/// proof verification. +/// +/// Extension does not refund transaction tip due to security reasons. +#[derive( + DefaultNoBound, + CloneNoBound, + Decode, + Encode, + EqNoBound, + PartialEqNoBound, + RuntimeDebugNoBound, + TypeInfo, +)] +#[scale_info(skip_type_params(Runtime, Para, Msgs, Refund, Priority, Id))] +pub struct RefundBridgedParachainMessages( + PhantomData<( + // runtime with `frame-utility`, `pallet-bridge-grandpa`, `pallet-bridge-parachains`, + // `pallet-bridge-messages` and `pallet-bridge-relayers` pallets deployed + Runtime, + // implementation of `RefundableParachainId` trait, which specifies the instance of + // the used `pallet-bridge-parachains` pallet and the bridged parachain id + Para, + // implementation of `RefundableMessagesLaneId` trait, which specifies the instance of + // the used `pallet-bridge-messages` pallet and the lane within this pallet + Msgs, + // implementation of the `RefundCalculator` trait, that is used to compute refund that + // we give to relayer for his transaction + Refund, + // getter for per-message `TransactionPriority` boost that we give to message + // delivery transactions + Priority, + // the runtime-unique identifier of this signed extension + Id, + )>, +); + +impl + RefundBridgedParachainMessages +where + Self: 'static + Send + Sync, + Runtime: UtilityConfig> + + BoundedBridgeGrandpaConfig + + ParachainsConfig + + MessagesConfig + + RelayersConfig, + Para: RefundableParachainId, + Msgs: RefundableMessagesLaneId, + Refund: RefundCalculator, + Priority: Get, + Id: StaticStrProvider, + CallOf: Dispatchable + + IsSubType, Runtime>> + + GrandpaCallSubType + + ParachainsCallSubType + + MessagesCallSubType, +{ + fn expand_call<'a>(&self, call: &'a CallOf) -> Vec<&'a CallOf> { + match call.is_sub_type() { + Some(UtilityCall::::batch_all { ref calls }) if calls.len() <= 3 => + calls.iter().collect(), + Some(_) => vec![], + None => vec![call], + } + } + + fn parse_and_check_for_obsolete_call( + &self, + call: &CallOf, + ) -> Result, TransactionValidityError> { + let calls = self.expand_call(call); + let total_calls = calls.len(); + let mut calls = calls.into_iter().map(Self::check_obsolete_call).rev(); + + let msgs_call = calls.next().transpose()?.and_then(|c| c.call_info_for(Msgs::Id::get())); + let para_finality_call = calls + .next() + .transpose()? + .and_then(|c| c.submit_parachain_heads_info_for(Para::Id::get())); + let relay_finality_call = + calls.next().transpose()?.and_then(|c| c.submit_finality_proof_info()); + + Ok(match (total_calls, relay_finality_call, para_finality_call, msgs_call) { + (3, Some(relay_finality_call), Some(para_finality_call), Some(msgs_call)) => Some( + CallInfo::AllFinalityAndMsgs(relay_finality_call, para_finality_call, msgs_call), + ), + (2, None, Some(para_finality_call), Some(msgs_call)) => + Some(CallInfo::ParachainFinalityAndMsgs(para_finality_call, msgs_call)), + (1, None, None, Some(msgs_call)) => Some(CallInfo::Msgs(msgs_call)), + _ => None, + }) + } + + fn check_obsolete_call( + call: &CallOf, + ) -> Result<&CallOf, TransactionValidityError> { + call.check_obsolete_submit_finality_proof()?; + call.check_obsolete_submit_parachain_heads()?; + call.check_obsolete_call()?; + Ok(call) + } + + /// Given post-dispatch information, analyze the outcome of relayer call and return + /// actions that need to be performed on relayer account. + fn analyze_call_result( + pre: Option>>, + info: &DispatchInfo, + post_info: &PostDispatchInfo, + len: usize, + result: &DispatchResult, + ) -> RelayerAccountAction, Runtime::Reward> { + let mut extra_weight = Weight::zero(); + let mut extra_size = 0; + + // We don't refund anything for transactions that we don't support. + let (relayer, call_info) = match pre { + Some(Some(pre)) => (pre.relayer, pre.call_info), + _ => return RelayerAccountAction::None, + }; + + // now we know that the relayer either needs to be rewarded, or slashed + // => let's prepare the correspondent account that pays reward/receives slashed amount + let reward_account_params = RewardsAccountParams::new( + Msgs::Id::get(), + Runtime::BridgedChainId::get(), + if call_info.is_receive_messages_proof_call() { + RewardsAccountOwner::ThisChain + } else { + RewardsAccountOwner::BridgedChain + }, + ); + + // prepare return value for the case if the call has failed or it has not caused + // expected side effects (e.g. not all messages have been accepted) + // + // we are not checking if relayer is registered here - it happens during the slash attempt + // + // there are couple of edge cases here: + // + // - when the relayer becomes registered during message dispatch: this is unlikely + relayer + // should be ready for slashing after registration; + // + // - when relayer is registered after `validate` is called and priority is not boosted: + // relayer should be ready for slashing after registration. + let may_slash_relayer = + Self::bundled_messages_for_priority_boost(Some(&call_info)).is_some(); + let slash_relayer_if_delivery_result = may_slash_relayer + .then(|| RelayerAccountAction::Slash(relayer.clone(), reward_account_params)) + .unwrap_or(RelayerAccountAction::None); + + // We don't refund anything if the transaction has failed. + if let Err(e) = result { + log::trace!( + target: "runtime::bridge", + "{} from parachain {} via {:?}: relayer {:?} has submitted invalid messages transaction: {:?}", + Self::IDENTIFIER, + Para::Id::get(), + Msgs::Id::get(), + relayer, + e, + ); + return slash_relayer_if_delivery_result + } + + // check if relay chain state has been updated + if let Some(finality_proof_info) = call_info.submit_finality_proof_info() { + if !SubmitFinalityProofHelper::::was_successful( + finality_proof_info.block_number, + ) { + // we only refund relayer if all calls have updated chain state + log::trace!( + target: "runtime::bridge", + "{} from parachain {} via {:?}: relayer {:?} has submitted invalid relay chain finality proof", + Self::IDENTIFIER, + Para::Id::get(), + Msgs::Id::get(), + relayer, + ); + return slash_relayer_if_delivery_result; + } + + // there's a conflict between how bridge GRANDPA pallet works and a `utility.batchAll` + // transaction. If relay chain header is mandatory, the GRANDPA pallet returns + // `Pays::No`, because such transaction is mandatory for operating the bridge. But + // `utility.batchAll` transaction always requires payment. But in both cases we'll + // refund relayer - either explicitly here, or using `Pays::No` if he's choosing + // to submit dedicated transaction. + + // submitter has means to include extra weight/bytes in the `submit_finality_proof` + // call, so let's subtract extra weight/size to avoid refunding for this extra stuff + extra_weight = finality_proof_info.extra_weight; + extra_size = finality_proof_info.extra_size; + } + + // check if parachain state has been updated + if let Some(para_proof_info) = call_info.submit_parachain_heads_info() { + if !SubmitParachainHeadsHelper::::was_successful( + para_proof_info, + ) { + // we only refund relayer if all calls have updated chain state + log::trace!( + target: "runtime::bridge", + "{} from parachain {} via {:?}: relayer {:?} has submitted invalid parachain finality proof", + Self::IDENTIFIER, + Para::Id::get(), + Msgs::Id::get(), + relayer, + ); + return slash_relayer_if_delivery_result + } + } + + // Check if the `ReceiveMessagesProof` call delivered at least some of the messages that + // it contained. If this happens, we consider the transaction "helpful" and refund it. + let msgs_call_info = call_info.messages_call_info(); + if !MessagesCallHelper::::was_successful(msgs_call_info) { + log::trace!( + target: "runtime::bridge", + "{} from parachain {} via {:?}: relayer {:?} has submitted invalid messages call", + Self::IDENTIFIER, + Para::Id::get(), + Msgs::Id::get(), + relayer, + ); + return slash_relayer_if_delivery_result + } + + // regarding the tip - refund that happens here (at this side of the bridge) isn't the whole + // relayer compensation. He'll receive some amount at the other side of the bridge. It shall + // (in theory) cover the tip there. Otherwise, if we'll be compensating tip here, some + // malicious relayer may use huge tips, effectively depleting account that pay rewards. The + // cost of this attack is nothing. Hence we use zero as tip here. + let tip = Zero::zero(); + + // decrease post-dispatch weight/size using extra weight/size that we know now + let post_info_len = len.saturating_sub(extra_size as usize); + let mut post_info_weight = + post_info.actual_weight.unwrap_or(info.weight).saturating_sub(extra_weight); + + // let's also replace the weight of slashing relayer with the weight of rewarding relayer + if call_info.is_receive_messages_proof_call() { + post_info_weight = post_info_weight.saturating_sub( + ::WeightInfo::extra_weight_of_successful_receive_messages_proof_call(), + ); + } + + // compute the relayer refund + let mut post_info = *post_info; + post_info.actual_weight = Some(post_info_weight); + let refund = Refund::compute_refund(info, &post_info, post_info_len, tip); + + // we can finally reward relayer + RelayerAccountAction::Reward(relayer, reward_account_params, refund) + } + + /// Returns number of bundled messages `Some(_)`, if the given call info is a: + /// + /// - message delivery transaction; + /// + /// - with reasonable bundled messages that may be accepted by the messages pallet. + /// + /// This function is used to check whether the transaction priority should be + /// virtually boosted. The relayer registration (we only boost priority for registered + /// relayer transactions) must be checked outside. + fn bundled_messages_for_priority_boost(call_info: Option<&CallInfo>) -> Option { + // we only boost priority of message delivery transactions + let parsed_call = match call_info { + Some(parsed_call) if parsed_call.is_receive_messages_proof_call() => parsed_call, + _ => return None, + }; + + // compute total number of messages in transaction + let bundled_messages = + parsed_call.messages_call_info().bundled_messages().checked_len().unwrap_or(0); + + // a quick check to avoid invalid high-priority transactions + if bundled_messages > Runtime::MaxUnconfirmedMessagesAtInboundLane::get() { + return None + } + + Some(bundled_messages) + } +} + +impl SignedExtension + for RefundBridgedParachainMessages +where + Self: 'static + Send + Sync, + Runtime: UtilityConfig> + + BoundedBridgeGrandpaConfig + + ParachainsConfig + + MessagesConfig + + RelayersConfig, + Para: RefundableParachainId, + Msgs: RefundableMessagesLaneId, + Refund: RefundCalculator, + Priority: Get, + Id: StaticStrProvider, + CallOf: Dispatchable + + IsSubType, Runtime>> + + GrandpaCallSubType + + ParachainsCallSubType + + MessagesCallSubType, +{ + const IDENTIFIER: &'static str = Id::STR; + type AccountId = Runtime::AccountId; + type Call = CallOf; + type AdditionalSigned = (); + type Pre = Option>; + + fn additional_signed(&self) -> Result<(), TransactionValidityError> { + Ok(()) + } + + fn validate( + &self, + who: &Self::AccountId, + call: &Self::Call, + _info: &DispatchInfoOf, + _len: usize, + ) -> TransactionValidity { + // this is the only relevant line of code for the `pre_dispatch` + // + // we're not calling `validate` from `pre_dispatch` directly because of performance + // reasons, so if you're adding some code that may fail here, please check if it needs + // to be added to the `pre_dispatch` as well + let parsed_call = self.parse_and_check_for_obsolete_call(call)?; + + // the following code just plays with transaction priority and never returns an error + + // we only boost priority of presumably correct message delivery transactions + let bundled_messages = match Self::bundled_messages_for_priority_boost(parsed_call.as_ref()) + { + Some(bundled_messages) => bundled_messages, + None => return Ok(Default::default()), + }; + + // we only boost priority if relayer has staked required balance + if !RelayersPallet::::is_registration_active(who) { + return Ok(Default::default()) + } + + // compute priority boost + let priority_boost = + crate::priority_calculator::compute_priority_boost::(bundled_messages); + let valid_transaction = ValidTransactionBuilder::default().priority(priority_boost); + + log::trace!( + target: "runtime::bridge", + "{} from parachain {} via {:?} has boosted priority of message delivery transaction \ + of relayer {:?}: {} messages -> {} priority", + Self::IDENTIFIER, + Para::Id::get(), + Msgs::Id::get(), + who, + bundled_messages, + priority_boost, + ); + + valid_transaction.build() + } + + fn pre_dispatch( + self, + who: &Self::AccountId, + call: &Self::Call, + _info: &DispatchInfoOf, + _len: usize, + ) -> Result { + // this is a relevant piece of `validate` that we need here (in `pre_dispatch`) + let parsed_call = self.parse_and_check_for_obsolete_call(call)?; + + Ok(parsed_call.map(|call_info| { + log::trace!( + target: "runtime::bridge", + "{} from parachain {} via {:?} parsed bridge transaction in pre-dispatch: {:?}", + Self::IDENTIFIER, + Para::Id::get(), + Msgs::Id::get(), + call_info, + ); + PreDispatchData { relayer: who.clone(), call_info } + })) + } + + fn post_dispatch( + pre: Option, + info: &DispatchInfoOf, + post_info: &PostDispatchInfoOf, + len: usize, + result: &DispatchResult, + ) -> Result<(), TransactionValidityError> { + let call_result = Self::analyze_call_result(pre, info, post_info, len, result); + + match call_result { + RelayerAccountAction::None => (), + RelayerAccountAction::Reward(relayer, reward_account, reward) => { + RelayersPallet::::register_relayer_reward( + reward_account, + &relayer, + reward, + ); + + log::trace!( + target: "runtime::bridge", + "{} from parachain {} via {:?} has registered reward: {:?} for {:?}", + Self::IDENTIFIER, + Para::Id::get(), + Msgs::Id::get(), + reward, + relayer, + ); + }, + RelayerAccountAction::Slash(relayer, slash_account) => + RelayersPallet::::slash_and_deregister(&relayer, slash_account), + } + + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + messages::{ + source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, + }, + messages_call_ext::{ + BaseMessagesProofInfo, ReceiveMessagesDeliveryProofInfo, ReceiveMessagesProofInfo, + UnrewardedRelayerOccupation, + }, + mock::*, + }; + use bp_messages::{InboundLaneData, MessageNonce, OutboundLaneData, UnrewardedRelayersState}; + use bp_parachains::{BestParaHeadHash, ParaInfo}; + use bp_polkadot_core::parachains::{ParaHeadsProof, ParaId}; + use bp_runtime::HeaderId; + use bp_test_utils::{make_default_justification, test_keyring}; + use frame_support::{ + assert_storage_noop, parameter_types, + traits::{fungible::Mutate, ReservableCurrency}, + weights::Weight, + }; + use pallet_bridge_grandpa::{Call as GrandpaCall, StoredAuthoritySet}; + use pallet_bridge_messages::Call as MessagesCall; + use pallet_bridge_parachains::{Call as ParachainsCall, RelayBlockHash}; + use sp_runtime::{ + traits::{ConstU64, Header as HeaderT}, + transaction_validity::{InvalidTransaction, ValidTransaction}, + DispatchError, + }; + + parameter_types! { + TestParachain: u32 = 1000; + pub TestLaneId: LaneId = TEST_LANE_ID; + pub MsgProofsRewardsAccount: RewardsAccountParams = RewardsAccountParams::new( + TEST_LANE_ID, + TEST_BRIDGED_CHAIN_ID, + RewardsAccountOwner::ThisChain, + ); + pub MsgDeliveryProofsRewardsAccount: RewardsAccountParams = RewardsAccountParams::new( + TEST_LANE_ID, + TEST_BRIDGED_CHAIN_ID, + RewardsAccountOwner::BridgedChain, + ); + } + + bp_runtime::generate_static_str_provider!(TestExtension); + type TestExtension = RefundBridgedParachainMessages< + TestRuntime, + DefaultRefundableParachainId<(), TestParachain>, + RefundableMessagesLane<(), TestLaneId>, + ActualFeeRefund, + ConstU64<1>, + StrTestExtension, + >; + + fn initial_balance_of_relayer_account_at_this_chain() -> ThisChainBalance { + let test_stake: ThisChainBalance = TestStake::get(); + ExistentialDeposit::get().saturating_add(test_stake * 100) + } + + // in tests, the following accounts are equal (because of how `into_sub_account_truncating` + // works) + + fn delivery_rewards_account() -> ThisChainAccountId { + TestPaymentProcedure::rewards_account(MsgProofsRewardsAccount::get()) + } + + fn confirmation_rewards_account() -> ThisChainAccountId { + TestPaymentProcedure::rewards_account(MsgDeliveryProofsRewardsAccount::get()) + } + + fn relayer_account_at_this_chain() -> ThisChainAccountId { + 0 + } + + fn relayer_account_at_bridged_chain() -> BridgedChainAccountId { + 0 + } + + fn initialize_environment( + best_relay_header_number: RelayBlockNumber, + parachain_head_at_relay_header_number: RelayBlockNumber, + best_message: MessageNonce, + ) { + let authorities = test_keyring().into_iter().map(|(a, w)| (a.into(), w)).collect(); + let best_relay_header = HeaderId(best_relay_header_number, RelayBlockHash::default()); + pallet_bridge_grandpa::CurrentAuthoritySet::::put( + StoredAuthoritySet::try_new(authorities, 0).unwrap(), + ); + pallet_bridge_grandpa::BestFinalized::::put(best_relay_header); + + let para_id = ParaId(TestParachain::get()); + let para_info = ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: parachain_head_at_relay_header_number, + head_hash: [parachain_head_at_relay_header_number as u8; 32].into(), + }, + next_imported_hash_position: 0, + }; + pallet_bridge_parachains::ParasInfo::::insert(para_id, para_info); + + let lane_id = TestLaneId::get(); + let in_lane_data = + InboundLaneData { last_confirmed_nonce: best_message, ..Default::default() }; + pallet_bridge_messages::InboundLanes::::insert(lane_id, in_lane_data); + + let out_lane_data = + OutboundLaneData { latest_received_nonce: best_message, ..Default::default() }; + pallet_bridge_messages::OutboundLanes::::insert(lane_id, out_lane_data); + + Balances::mint_into(&delivery_rewards_account(), ExistentialDeposit::get()).unwrap(); + Balances::mint_into(&confirmation_rewards_account(), ExistentialDeposit::get()).unwrap(); + Balances::mint_into( + &relayer_account_at_this_chain(), + initial_balance_of_relayer_account_at_this_chain(), + ) + .unwrap(); + } + + fn submit_relay_header_call(relay_header_number: RelayBlockNumber) -> RuntimeCall { + let relay_header = BridgedChainHeader::new( + relay_header_number, + Default::default(), + Default::default(), + Default::default(), + Default::default(), + ); + let relay_justification = make_default_justification(&relay_header); + + RuntimeCall::BridgeGrandpa(GrandpaCall::submit_finality_proof { + finality_target: Box::new(relay_header), + justification: relay_justification, + }) + } + + fn submit_parachain_head_call( + parachain_head_at_relay_header_number: RelayBlockNumber, + ) -> RuntimeCall { + RuntimeCall::BridgeParachains(ParachainsCall::submit_parachain_heads { + at_relay_block: (parachain_head_at_relay_header_number, RelayBlockHash::default()), + parachains: vec![( + ParaId(TestParachain::get()), + [parachain_head_at_relay_header_number as u8; 32].into(), + )], + parachain_heads_proof: ParaHeadsProof(vec![]), + }) + } + + fn message_delivery_call(best_message: MessageNonce) -> RuntimeCall { + RuntimeCall::BridgeMessages(MessagesCall::receive_messages_proof { + relayer_id_at_bridged_chain: relayer_account_at_bridged_chain(), + proof: FromBridgedChainMessagesProof { + bridged_header_hash: Default::default(), + storage_proof: vec![], + lane: TestLaneId::get(), + nonces_start: pallet_bridge_messages::InboundLanes::::get( + TEST_LANE_ID, + ) + .last_delivered_nonce() + + 1, + nonces_end: best_message, + }, + messages_count: 1, + dispatch_weight: Weight::zero(), + }) + } + + fn message_confirmation_call(best_message: MessageNonce) -> RuntimeCall { + RuntimeCall::BridgeMessages(MessagesCall::receive_messages_delivery_proof { + proof: FromBridgedChainMessagesDeliveryProof { + bridged_header_hash: Default::default(), + storage_proof: vec![], + lane: TestLaneId::get(), + }, + relayers_state: UnrewardedRelayersState { + last_delivered_nonce: best_message, + ..Default::default() + }, + }) + } + + fn parachain_finality_and_delivery_batch_call( + parachain_head_at_relay_header_number: RelayBlockNumber, + best_message: MessageNonce, + ) -> RuntimeCall { + RuntimeCall::Utility(UtilityCall::batch_all { + calls: vec![ + submit_parachain_head_call(parachain_head_at_relay_header_number), + message_delivery_call(best_message), + ], + }) + } + + fn parachain_finality_and_confirmation_batch_call( + parachain_head_at_relay_header_number: RelayBlockNumber, + best_message: MessageNonce, + ) -> RuntimeCall { + RuntimeCall::Utility(UtilityCall::batch_all { + calls: vec![ + submit_parachain_head_call(parachain_head_at_relay_header_number), + message_confirmation_call(best_message), + ], + }) + } + + fn all_finality_and_delivery_batch_call( + relay_header_number: RelayBlockNumber, + parachain_head_at_relay_header_number: RelayBlockNumber, + best_message: MessageNonce, + ) -> RuntimeCall { + RuntimeCall::Utility(UtilityCall::batch_all { + calls: vec![ + submit_relay_header_call(relay_header_number), + submit_parachain_head_call(parachain_head_at_relay_header_number), + message_delivery_call(best_message), + ], + }) + } + + fn all_finality_and_confirmation_batch_call( + relay_header_number: RelayBlockNumber, + parachain_head_at_relay_header_number: RelayBlockNumber, + best_message: MessageNonce, + ) -> RuntimeCall { + RuntimeCall::Utility(UtilityCall::batch_all { + calls: vec![ + submit_relay_header_call(relay_header_number), + submit_parachain_head_call(parachain_head_at_relay_header_number), + message_confirmation_call(best_message), + ], + }) + } + + fn all_finality_pre_dispatch_data() -> PreDispatchData { + PreDispatchData { + relayer: relayer_account_at_this_chain(), + call_info: CallInfo::AllFinalityAndMsgs( + SubmitFinalityProofInfo { + block_number: 200, + extra_weight: Weight::zero(), + extra_size: 0, + }, + SubmitParachainHeadsInfo { + at_relay_block_number: 200, + para_id: ParaId(TestParachain::get()), + para_head_hash: [200u8; 32].into(), + }, + MessagesCallInfo::ReceiveMessagesProof(ReceiveMessagesProofInfo { + base: BaseMessagesProofInfo { + lane_id: TEST_LANE_ID, + bundled_range: 101..=200, + best_stored_nonce: 100, + }, + unrewarded_relayers: UnrewardedRelayerOccupation { + free_relayer_slots: MaxUnrewardedRelayerEntriesAtInboundLane::get(), + free_message_slots: MaxUnconfirmedMessagesAtInboundLane::get(), + }, + }), + ), + } + } + + fn all_finality_confirmation_pre_dispatch_data() -> PreDispatchData { + PreDispatchData { + relayer: relayer_account_at_this_chain(), + call_info: CallInfo::AllFinalityAndMsgs( + SubmitFinalityProofInfo { + block_number: 200, + extra_weight: Weight::zero(), + extra_size: 0, + }, + SubmitParachainHeadsInfo { + at_relay_block_number: 200, + para_id: ParaId(TestParachain::get()), + para_head_hash: [200u8; 32].into(), + }, + MessagesCallInfo::ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo( + BaseMessagesProofInfo { + lane_id: TEST_LANE_ID, + bundled_range: 101..=200, + best_stored_nonce: 100, + }, + )), + ), + } + } + + fn parachain_finality_pre_dispatch_data() -> PreDispatchData { + PreDispatchData { + relayer: relayer_account_at_this_chain(), + call_info: CallInfo::ParachainFinalityAndMsgs( + SubmitParachainHeadsInfo { + at_relay_block_number: 200, + para_id: ParaId(TestParachain::get()), + para_head_hash: [200u8; 32].into(), + }, + MessagesCallInfo::ReceiveMessagesProof(ReceiveMessagesProofInfo { + base: BaseMessagesProofInfo { + lane_id: TEST_LANE_ID, + bundled_range: 101..=200, + best_stored_nonce: 100, + }, + unrewarded_relayers: UnrewardedRelayerOccupation { + free_relayer_slots: MaxUnrewardedRelayerEntriesAtInboundLane::get(), + free_message_slots: MaxUnconfirmedMessagesAtInboundLane::get(), + }, + }), + ), + } + } + + fn parachain_finality_confirmation_pre_dispatch_data() -> PreDispatchData { + PreDispatchData { + relayer: relayer_account_at_this_chain(), + call_info: CallInfo::ParachainFinalityAndMsgs( + SubmitParachainHeadsInfo { + at_relay_block_number: 200, + para_id: ParaId(TestParachain::get()), + para_head_hash: [200u8; 32].into(), + }, + MessagesCallInfo::ReceiveMessagesDeliveryProof(ReceiveMessagesDeliveryProofInfo( + BaseMessagesProofInfo { + lane_id: TEST_LANE_ID, + bundled_range: 101..=200, + best_stored_nonce: 100, + }, + )), + ), + } + } + + fn delivery_pre_dispatch_data() -> PreDispatchData { + PreDispatchData { + relayer: relayer_account_at_this_chain(), + call_info: CallInfo::Msgs(MessagesCallInfo::ReceiveMessagesProof( + ReceiveMessagesProofInfo { + base: BaseMessagesProofInfo { + lane_id: TEST_LANE_ID, + bundled_range: 101..=200, + best_stored_nonce: 100, + }, + unrewarded_relayers: UnrewardedRelayerOccupation { + free_relayer_slots: MaxUnrewardedRelayerEntriesAtInboundLane::get(), + free_message_slots: MaxUnconfirmedMessagesAtInboundLane::get(), + }, + }, + )), + } + } + + fn confirmation_pre_dispatch_data() -> PreDispatchData { + PreDispatchData { + relayer: relayer_account_at_this_chain(), + call_info: CallInfo::Msgs(MessagesCallInfo::ReceiveMessagesDeliveryProof( + ReceiveMessagesDeliveryProofInfo(BaseMessagesProofInfo { + lane_id: TEST_LANE_ID, + bundled_range: 101..=200, + best_stored_nonce: 100, + }), + )), + } + } + + fn set_bundled_range_end( + mut pre_dispatch_data: PreDispatchData, + end: MessageNonce, + ) -> PreDispatchData { + let msg_info = match pre_dispatch_data.call_info { + CallInfo::AllFinalityAndMsgs(_, _, ref mut info) => info, + CallInfo::ParachainFinalityAndMsgs(_, ref mut info) => info, + CallInfo::Msgs(ref mut info) => info, + }; + + if let MessagesCallInfo::ReceiveMessagesProof(ref mut msg_info) = msg_info { + msg_info.base.bundled_range = *msg_info.base.bundled_range.start()..=end + } + + pre_dispatch_data + } + + fn run_validate(call: RuntimeCall) -> TransactionValidity { + let extension: TestExtension = RefundBridgedParachainMessages(PhantomData); + extension.validate(&relayer_account_at_this_chain(), &call, &DispatchInfo::default(), 0) + } + + fn run_validate_ignore_priority(call: RuntimeCall) -> TransactionValidity { + run_validate(call).map(|mut tx| { + tx.priority = 0; + tx + }) + } + + fn run_pre_dispatch( + call: RuntimeCall, + ) -> Result>, TransactionValidityError> { + let extension: TestExtension = RefundBridgedParachainMessages(PhantomData); + extension.pre_dispatch(&relayer_account_at_this_chain(), &call, &DispatchInfo::default(), 0) + } + + fn dispatch_info() -> DispatchInfo { + DispatchInfo { + weight: Weight::from_parts( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND, + 0, + ), + class: frame_support::dispatch::DispatchClass::Normal, + pays_fee: frame_support::dispatch::Pays::Yes, + } + } + + fn post_dispatch_info() -> PostDispatchInfo { + PostDispatchInfo { actual_weight: None, pays_fee: frame_support::dispatch::Pays::Yes } + } + + fn run_post_dispatch( + pre_dispatch_data: Option>, + dispatch_result: DispatchResult, + ) { + let post_dispatch_result = TestExtension::post_dispatch( + Some(pre_dispatch_data), + &dispatch_info(), + &post_dispatch_info(), + 1024, + &dispatch_result, + ); + assert_eq!(post_dispatch_result, Ok(())); + } + + fn expected_delivery_reward() -> ThisChainBalance { + let mut post_dispatch_info = post_dispatch_info(); + let extra_weight = ::WeightInfo::extra_weight_of_successful_receive_messages_proof_call(); + post_dispatch_info.actual_weight = + Some(dispatch_info().weight.saturating_sub(extra_weight)); + pallet_transaction_payment::Pallet::::compute_actual_fee( + 1024, + &dispatch_info(), + &post_dispatch_info, + Zero::zero(), + ) + } + + fn expected_confirmation_reward() -> ThisChainBalance { + pallet_transaction_payment::Pallet::::compute_actual_fee( + 1024, + &dispatch_info(), + &post_dispatch_info(), + Zero::zero(), + ) + } + + #[test] + fn validate_doesnt_boost_transaction_priority_if_relayer_is_not_registered() { + run_test(|| { + initialize_environment(100, 100, 100); + Balances::set_balance(&relayer_account_at_this_chain(), ExistentialDeposit::get()); + + // message delivery is failing + assert_eq!(run_validate(message_delivery_call(200)), Ok(Default::default()),); + assert_eq!( + run_validate(parachain_finality_and_delivery_batch_call(200, 200)), + Ok(Default::default()), + ); + assert_eq!( + run_validate(all_finality_and_delivery_batch_call(200, 200, 200)), + Ok(Default::default()), + ); + // message confirmation validation is passing + assert_eq!( + run_validate_ignore_priority(message_confirmation_call(200)), + Ok(Default::default()), + ); + assert_eq!( + run_validate_ignore_priority(parachain_finality_and_confirmation_batch_call( + 200, 200 + )), + Ok(Default::default()), + ); + assert_eq!( + run_validate_ignore_priority(all_finality_and_confirmation_batch_call( + 200, 200, 200 + )), + Ok(Default::default()), + ); + }); + } + + #[test] + fn validate_boosts_priority_of_message_delivery_transactons() { + run_test(|| { + initialize_environment(100, 100, 100); + + BridgeRelayers::register(RuntimeOrigin::signed(relayer_account_at_this_chain()), 1000) + .unwrap(); + + let priority_of_100_messages_delivery = + run_validate(message_delivery_call(200)).unwrap().priority; + let priority_of_200_messages_delivery = + run_validate(message_delivery_call(300)).unwrap().priority; + assert!( + priority_of_200_messages_delivery > priority_of_100_messages_delivery, + "Invalid priorities: {} for 200 messages vs {} for 100 messages", + priority_of_200_messages_delivery, + priority_of_100_messages_delivery, + ); + + let priority_of_100_messages_confirmation = + run_validate(message_confirmation_call(200)).unwrap().priority; + let priority_of_200_messages_confirmation = + run_validate(message_confirmation_call(300)).unwrap().priority; + assert_eq!( + priority_of_100_messages_confirmation, + priority_of_200_messages_confirmation + ); + }); + } + + #[test] + fn validate_does_not_boost_priority_of_message_delivery_transactons_with_too_many_messages() { + run_test(|| { + initialize_environment(100, 100, 100); + + BridgeRelayers::register(RuntimeOrigin::signed(relayer_account_at_this_chain()), 1000) + .unwrap(); + + let priority_of_max_messages_delivery = run_validate(message_delivery_call( + 100 + MaxUnconfirmedMessagesAtInboundLane::get(), + )) + .unwrap() + .priority; + let priority_of_more_than_max_messages_delivery = run_validate(message_delivery_call( + 100 + MaxUnconfirmedMessagesAtInboundLane::get() + 1, + )) + .unwrap() + .priority; + + assert!( + priority_of_max_messages_delivery > priority_of_more_than_max_messages_delivery, + "Invalid priorities: {} for MAX messages vs {} for MAX+1 messages", + priority_of_max_messages_delivery, + priority_of_more_than_max_messages_delivery, + ); + }); + } + + #[test] + fn validate_allows_non_obsolete_transactions() { + run_test(|| { + initialize_environment(100, 100, 100); + + assert_eq!( + run_validate_ignore_priority(message_delivery_call(200)), + Ok(ValidTransaction::default()), + ); + assert_eq!( + run_validate_ignore_priority(message_confirmation_call(200)), + Ok(ValidTransaction::default()), + ); + + assert_eq!( + run_validate_ignore_priority(parachain_finality_and_delivery_batch_call(200, 200)), + Ok(ValidTransaction::default()), + ); + assert_eq!( + run_validate_ignore_priority(parachain_finality_and_confirmation_batch_call( + 200, 200 + )), + Ok(ValidTransaction::default()), + ); + + assert_eq!( + run_validate_ignore_priority(all_finality_and_delivery_batch_call(200, 200, 200)), + Ok(ValidTransaction::default()), + ); + assert_eq!( + run_validate_ignore_priority(all_finality_and_confirmation_batch_call( + 200, 200, 200 + )), + Ok(ValidTransaction::default()), + ); + }); + } + + #[test] + fn ext_rejects_batch_with_obsolete_relay_chain_header() { + run_test(|| { + initialize_environment(100, 100, 100); + + assert_eq!( + run_pre_dispatch(all_finality_and_delivery_batch_call(100, 200, 200)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + + assert_eq!( + run_validate(all_finality_and_delivery_batch_call(100, 200, 200)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + }); + } + + #[test] + fn ext_rejects_batch_with_obsolete_parachain_head() { + run_test(|| { + initialize_environment(100, 100, 100); + + assert_eq!( + run_pre_dispatch(all_finality_and_delivery_batch_call(101, 100, 200)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + assert_eq!( + run_validate(all_finality_and_delivery_batch_call(101, 100, 200)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + + assert_eq!( + run_pre_dispatch(parachain_finality_and_delivery_batch_call(100, 200)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + assert_eq!( + run_validate(parachain_finality_and_delivery_batch_call(100, 200)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + }); + } + + #[test] + fn ext_rejects_batch_with_obsolete_messages() { + run_test(|| { + initialize_environment(100, 100, 100); + + assert_eq!( + run_pre_dispatch(all_finality_and_delivery_batch_call(200, 200, 100)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + assert_eq!( + run_pre_dispatch(all_finality_and_confirmation_batch_call(200, 200, 100)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + + assert_eq!( + run_validate(all_finality_and_delivery_batch_call(200, 200, 100)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + assert_eq!( + run_validate(all_finality_and_confirmation_batch_call(200, 200, 100)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + + assert_eq!( + run_pre_dispatch(parachain_finality_and_delivery_batch_call(200, 100)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + assert_eq!( + run_pre_dispatch(parachain_finality_and_confirmation_batch_call(200, 100)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + + assert_eq!( + run_validate(parachain_finality_and_delivery_batch_call(200, 100)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + assert_eq!( + run_validate(parachain_finality_and_confirmation_batch_call(200, 100)), + Err(TransactionValidityError::Invalid(InvalidTransaction::Stale)), + ); + }); + } + + #[test] + fn pre_dispatch_parses_batch_with_relay_chain_and_parachain_headers() { + run_test(|| { + initialize_environment(100, 100, 100); + + assert_eq!( + run_pre_dispatch(all_finality_and_delivery_batch_call(200, 200, 200)), + Ok(Some(all_finality_pre_dispatch_data())), + ); + assert_eq!( + run_pre_dispatch(all_finality_and_confirmation_batch_call(200, 200, 200)), + Ok(Some(all_finality_confirmation_pre_dispatch_data())), + ); + }); + } + + #[test] + fn pre_dispatch_parses_batch_with_parachain_header() { + run_test(|| { + initialize_environment(100, 100, 100); + + assert_eq!( + run_pre_dispatch(parachain_finality_and_delivery_batch_call(200, 200)), + Ok(Some(parachain_finality_pre_dispatch_data())), + ); + assert_eq!( + run_pre_dispatch(parachain_finality_and_confirmation_batch_call(200, 200)), + Ok(Some(parachain_finality_confirmation_pre_dispatch_data())), + ); + }); + } + + #[test] + fn pre_dispatch_fails_to_parse_batch_with_multiple_parachain_headers() { + run_test(|| { + initialize_environment(100, 100, 100); + + let call = RuntimeCall::Utility(UtilityCall::batch_all { + calls: vec![ + RuntimeCall::BridgeParachains(ParachainsCall::submit_parachain_heads { + at_relay_block: (100, RelayBlockHash::default()), + parachains: vec![ + (ParaId(TestParachain::get()), [1u8; 32].into()), + (ParaId(TestParachain::get() + 1), [1u8; 32].into()), + ], + parachain_heads_proof: ParaHeadsProof(vec![]), + }), + message_delivery_call(200), + ], + }); + + assert_eq!(run_pre_dispatch(call), Ok(None),); + }); + } + + #[test] + fn pre_dispatch_parses_message_transaction() { + run_test(|| { + initialize_environment(100, 100, 100); + + assert_eq!( + run_pre_dispatch(message_delivery_call(200)), + Ok(Some(delivery_pre_dispatch_data())), + ); + assert_eq!( + run_pre_dispatch(message_confirmation_call(200)), + Ok(Some(confirmation_pre_dispatch_data())), + ); + }); + } + + #[test] + fn post_dispatch_ignores_unknown_transaction() { + run_test(|| { + assert_storage_noop!(run_post_dispatch(None, Ok(()))); + }); + } + + #[test] + fn post_dispatch_ignores_failed_transaction() { + run_test(|| { + assert_storage_noop!(run_post_dispatch( + Some(all_finality_pre_dispatch_data()), + Err(DispatchError::BadOrigin) + )); + }); + } + + #[test] + fn post_dispatch_ignores_transaction_that_has_not_updated_relay_chain_state() { + run_test(|| { + initialize_environment(100, 200, 200); + + assert_storage_noop!(run_post_dispatch(Some(all_finality_pre_dispatch_data()), Ok(()))); + }); + } + + #[test] + fn post_dispatch_ignores_transaction_that_has_not_updated_parachain_state() { + run_test(|| { + initialize_environment(200, 100, 200); + + assert_storage_noop!(run_post_dispatch(Some(all_finality_pre_dispatch_data()), Ok(()))); + assert_storage_noop!(run_post_dispatch( + Some(parachain_finality_pre_dispatch_data()), + Ok(()) + )); + }); + } + + #[test] + fn post_dispatch_ignores_transaction_that_has_not_delivered_any_messages() { + run_test(|| { + initialize_environment(200, 200, 100); + + assert_storage_noop!(run_post_dispatch(Some(all_finality_pre_dispatch_data()), Ok(()))); + assert_storage_noop!(run_post_dispatch( + Some(parachain_finality_pre_dispatch_data()), + Ok(()) + )); + assert_storage_noop!(run_post_dispatch(Some(delivery_pre_dispatch_data()), Ok(()))); + + assert_storage_noop!(run_post_dispatch( + Some(all_finality_confirmation_pre_dispatch_data()), + Ok(()) + )); + assert_storage_noop!(run_post_dispatch( + Some(parachain_finality_confirmation_pre_dispatch_data()), + Ok(()) + )); + assert_storage_noop!(run_post_dispatch(Some(confirmation_pre_dispatch_data()), Ok(()))); + }); + } + + #[test] + fn post_dispatch_ignores_transaction_that_has_not_delivered_all_messages() { + run_test(|| { + initialize_environment(200, 200, 150); + + assert_storage_noop!(run_post_dispatch(Some(all_finality_pre_dispatch_data()), Ok(()))); + assert_storage_noop!(run_post_dispatch( + Some(parachain_finality_pre_dispatch_data()), + Ok(()) + )); + assert_storage_noop!(run_post_dispatch(Some(delivery_pre_dispatch_data()), Ok(()))); + + assert_storage_noop!(run_post_dispatch( + Some(all_finality_confirmation_pre_dispatch_data()), + Ok(()) + )); + assert_storage_noop!(run_post_dispatch( + Some(parachain_finality_confirmation_pre_dispatch_data()), + Ok(()) + )); + assert_storage_noop!(run_post_dispatch(Some(confirmation_pre_dispatch_data()), Ok(()))); + }); + } + + #[test] + fn post_dispatch_refunds_relayer_in_all_finality_batch_with_extra_weight() { + run_test(|| { + initialize_environment(200, 200, 200); + + let mut dispatch_info = dispatch_info(); + dispatch_info.weight = Weight::from_parts( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND * 2, + 0, + ); + + // without any size/weight refund: we expect regular reward + let pre_dispatch_data = all_finality_pre_dispatch_data(); + let regular_reward = expected_delivery_reward(); + run_post_dispatch(Some(pre_dispatch_data), Ok(())); + assert_eq!( + RelayersPallet::::relayer_reward( + relayer_account_at_this_chain(), + MsgProofsRewardsAccount::get() + ), + Some(regular_reward), + ); + + // now repeat the same with size+weight refund: we expect smaller reward + let mut pre_dispatch_data = all_finality_pre_dispatch_data(); + match pre_dispatch_data.call_info { + CallInfo::AllFinalityAndMsgs(ref mut info, ..) => { + info.extra_weight.set_ref_time( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND, + ); + info.extra_size = 32; + }, + _ => unreachable!(), + } + run_post_dispatch(Some(pre_dispatch_data), Ok(())); + let reward_after_two_calls = RelayersPallet::::relayer_reward( + relayer_account_at_this_chain(), + MsgProofsRewardsAccount::get(), + ) + .unwrap(); + assert!( + reward_after_two_calls < 2 * regular_reward, + "{} must be < 2 * {}", + reward_after_two_calls, + 2 * regular_reward, + ); + }); + } + + #[test] + fn post_dispatch_refunds_relayer_in_all_finality_batch() { + run_test(|| { + initialize_environment(200, 200, 200); + + run_post_dispatch(Some(all_finality_pre_dispatch_data()), Ok(())); + assert_eq!( + RelayersPallet::::relayer_reward( + relayer_account_at_this_chain(), + MsgProofsRewardsAccount::get() + ), + Some(expected_delivery_reward()), + ); + + run_post_dispatch(Some(all_finality_confirmation_pre_dispatch_data()), Ok(())); + assert_eq!( + RelayersPallet::::relayer_reward( + relayer_account_at_this_chain(), + MsgDeliveryProofsRewardsAccount::get() + ), + Some(expected_confirmation_reward()), + ); + }); + } + + #[test] + fn post_dispatch_refunds_relayer_in_parachain_finality_batch() { + run_test(|| { + initialize_environment(200, 200, 200); + + run_post_dispatch(Some(parachain_finality_pre_dispatch_data()), Ok(())); + assert_eq!( + RelayersPallet::::relayer_reward( + relayer_account_at_this_chain(), + MsgProofsRewardsAccount::get() + ), + Some(expected_delivery_reward()), + ); + + run_post_dispatch(Some(parachain_finality_confirmation_pre_dispatch_data()), Ok(())); + assert_eq!( + RelayersPallet::::relayer_reward( + relayer_account_at_this_chain(), + MsgDeliveryProofsRewardsAccount::get() + ), + Some(expected_confirmation_reward()), + ); + }); + } + + #[test] + fn post_dispatch_refunds_relayer_in_message_transaction() { + run_test(|| { + initialize_environment(200, 200, 200); + + run_post_dispatch(Some(delivery_pre_dispatch_data()), Ok(())); + assert_eq!( + RelayersPallet::::relayer_reward( + relayer_account_at_this_chain(), + MsgProofsRewardsAccount::get() + ), + Some(expected_delivery_reward()), + ); + + run_post_dispatch(Some(confirmation_pre_dispatch_data()), Ok(())); + assert_eq!( + RelayersPallet::::relayer_reward( + relayer_account_at_this_chain(), + MsgDeliveryProofsRewardsAccount::get() + ), + Some(expected_confirmation_reward()), + ); + }); + } + + #[test] + fn post_dispatch_slashing_relayer_stake() { + run_test(|| { + initialize_environment(200, 200, 100); + + let delivery_rewards_account_balance = + Balances::free_balance(delivery_rewards_account()); + + let test_stake: ThisChainBalance = TestStake::get(); + Balances::set_balance( + &relayer_account_at_this_chain(), + ExistentialDeposit::get() + test_stake * 10, + ); + + // slashing works for message delivery calls + BridgeRelayers::register(RuntimeOrigin::signed(relayer_account_at_this_chain()), 1000) + .unwrap(); + assert_eq!(Balances::reserved_balance(relayer_account_at_this_chain()), test_stake); + run_post_dispatch(Some(delivery_pre_dispatch_data()), Ok(())); + assert_eq!(Balances::reserved_balance(relayer_account_at_this_chain()), 0); + assert_eq!( + delivery_rewards_account_balance + test_stake, + Balances::free_balance(delivery_rewards_account()) + ); + + BridgeRelayers::register(RuntimeOrigin::signed(relayer_account_at_this_chain()), 1000) + .unwrap(); + assert_eq!(Balances::reserved_balance(relayer_account_at_this_chain()), test_stake); + run_post_dispatch(Some(parachain_finality_pre_dispatch_data()), Ok(())); + assert_eq!(Balances::reserved_balance(relayer_account_at_this_chain()), 0); + assert_eq!( + delivery_rewards_account_balance + test_stake * 2, + Balances::free_balance(delivery_rewards_account()) + ); + + BridgeRelayers::register(RuntimeOrigin::signed(relayer_account_at_this_chain()), 1000) + .unwrap(); + assert_eq!(Balances::reserved_balance(relayer_account_at_this_chain()), test_stake); + run_post_dispatch(Some(all_finality_pre_dispatch_data()), Ok(())); + assert_eq!(Balances::reserved_balance(relayer_account_at_this_chain()), 0); + assert_eq!( + delivery_rewards_account_balance + test_stake * 3, + Balances::free_balance(delivery_rewards_account()) + ); + + // reserve doesn't work for message confirmation calls + let confirmation_rewards_account_balance = + Balances::free_balance(confirmation_rewards_account()); + + Balances::reserve(&relayer_account_at_this_chain(), test_stake).unwrap(); + assert_eq!(Balances::reserved_balance(relayer_account_at_this_chain()), test_stake); + + assert_eq!( + confirmation_rewards_account_balance, + Balances::free_balance(confirmation_rewards_account()) + ); + run_post_dispatch(Some(confirmation_pre_dispatch_data()), Ok(())); + assert_eq!(Balances::reserved_balance(relayer_account_at_this_chain()), test_stake); + + run_post_dispatch(Some(parachain_finality_confirmation_pre_dispatch_data()), Ok(())); + assert_eq!(Balances::reserved_balance(relayer_account_at_this_chain()), test_stake); + + run_post_dispatch(Some(all_finality_confirmation_pre_dispatch_data()), Ok(())); + assert_eq!(Balances::reserved_balance(relayer_account_at_this_chain()), test_stake); + + // check that unreserve has happened, not slashing + assert_eq!( + delivery_rewards_account_balance + test_stake * 3, + Balances::free_balance(delivery_rewards_account()) + ); + assert_eq!( + confirmation_rewards_account_balance, + Balances::free_balance(confirmation_rewards_account()) + ); + }); + } + + fn run_analyze_call_result( + pre_dispatch_data: PreDispatchData, + dispatch_result: DispatchResult, + ) -> RelayerAccountAction { + TestExtension::analyze_call_result( + Some(Some(pre_dispatch_data)), + &dispatch_info(), + &post_dispatch_info(), + 1024, + &dispatch_result, + ) + } + + #[test] + fn analyze_call_result_shall_not_slash_for_transactions_with_too_many_messages() { + run_test(|| { + initialize_environment(100, 100, 100); + + // the `analyze_call_result` should return slash if number of bundled messages is + // within reasonable limits + assert_eq!( + run_analyze_call_result(all_finality_pre_dispatch_data(), Ok(())), + RelayerAccountAction::Slash( + relayer_account_at_this_chain(), + MsgProofsRewardsAccount::get() + ), + ); + assert_eq!( + run_analyze_call_result(parachain_finality_pre_dispatch_data(), Ok(())), + RelayerAccountAction::Slash( + relayer_account_at_this_chain(), + MsgProofsRewardsAccount::get() + ), + ); + assert_eq!( + run_analyze_call_result(delivery_pre_dispatch_data(), Ok(())), + RelayerAccountAction::Slash( + relayer_account_at_this_chain(), + MsgProofsRewardsAccount::get() + ), + ); + + // the `analyze_call_result` should not return slash if number of bundled messages is + // larger than the + assert_eq!( + run_analyze_call_result( + set_bundled_range_end(all_finality_pre_dispatch_data(), 1_000_000), + Ok(()) + ), + RelayerAccountAction::None, + ); + assert_eq!( + run_analyze_call_result( + set_bundled_range_end(parachain_finality_pre_dispatch_data(), 1_000_000), + Ok(()) + ), + RelayerAccountAction::None, + ); + assert_eq!( + run_analyze_call_result( + set_bundled_range_end(delivery_pre_dispatch_data(), 1_000_000), + Ok(()) + ), + RelayerAccountAction::None, + ); + }); + } +} diff --git a/bridges/docs/complex-relay.html b/bridges/docs/complex-relay.html new file mode 100644 index 00000000000..21524bfd049 --- /dev/null +++ b/bridges/docs/complex-relay.html @@ -0,0 +1,85 @@ + + + + + + Complex Relay + + +

Complex Relay

+

+ Both Source Chain and Target Chains have Bridge Messages pallets deployed. They also have required + finality pallets deployed - we don't care about finality type here - they can be either Bridge GRANDPA, + or Bridge Parachains finality pallets, or any combination of those.
+

+

+ There are 4-6 relayer subprocesses inside the Complex Relayer. They include two message relayers, + serving the lane in both directions and 2-4 Complex Relayers (depending on the finality type of Source + and Target Chains).
+

+

+ The following diagram shows the way the complex relayer serves the lane in single direction. Everything + below may be applied to the opposite direction if you'll swap the Source and Target Chains. +

+
+ sequenceDiagram + participant Source Chain + participant Complex Relayer + participant Target Chain + + Note right of Source Chain: Finalized: 480, Target Finalized: 50, Sent Messages: 42, Confirmed Messages: 42 + Note left of Target Chain: Finalized: 60, Source Finalized: 420, Received Messages: 42 + + Source Chain ->> Source Chain: someone Sends Message 43 + Source Chain ->> Source Chain: Import and Finalize Block 481 + + Source Chain ->> Complex Relayer: notes new outbound message 43 at Source Chain Block 481 + Note right of Complex Relayer: can't deliver message 43, Source Chain Block 481 is not relayed + Complex Relayer ->> Complex Relayer: asks on-demand Finality Relayer to relay Source Chain Block 481 + + Source Chain ->> Complex Relayer: Read Finality Proof of Block 481 + Complex Relayer ->> Target Chain: Submit Finality Proof of Block 481 + Target Chain ->> Target Chain: Import and Finalize Block 61 + Note left of Target Chain: Finalized: 61, Source Finalized: 481, Received Messages: 42 + + Source Chain ->> Complex Relayer: Read Proof of Message 43 at Block 481 + Complex Relayer ->> Target Chain: Submit Proof of Message 43 at Block 481 + Target Chain ->> Target Chain: Import and Finalize Block 62 + Note left of Target Chain: Finalized: 62, Source Finalized: 481, Received Messages: { rewarded: 42, messages-relayer-account: [43] } + + Target Chain ->> Complex Relayer: notes new unrewarded relayer at Target Chain Block 62 + Note right of Complex Relayer: can't relay delivery confirmations because Target Chain Block 62 is not relayed + Complex Relayer ->> Complex Relayer: asks on-demand Finality Relayer to relay Target Chain Block 62 + + Target Chain ->> Complex Relayer: Read Finality Proof of Block 62 + Complex Relayer ->> Source Chain: Submit Finality Proof of Block 62 + Source Chain ->> Source Chain: Import and Finalize Block 482 + Note right of Source Chain: Finalized: 482, Target Finalized: 62, Confirmed Messages: 42 + + Target Chain ->> Complex Relayer: Read Proof of Message 43 Delivery at Block 62 + Complex Relayer ->> Source Chain: Submit Proof of Message 43 Delivery at Block 612 + Source Chain ->> Source Chain: rewards messages-relayer-account for delivering message [43] + Source Chain ->> Source Chain: prune delivered message 43 from runtime storage + Note right of Source Chain: Finalized: 482, Target Finalized: 61, Confirmed Messages: 43 + + Source Chain ->> Source Chain: someone Sends Message 44 + Source Chain ->> Source Chain: Import and Finalize Block 483 + + Source Chain ->> Complex Relayer: notes new outbound message 44 at Source Chain Block 483 and new confirmed message 43 + Note right of Complex Relayer: can't deliver message 44, Source Chain Block 483 is not relayed + Complex Relayer ->> Complex Relayer: asks on-demand Finality Relayer to relay Source Chain Block 483 + + Source Chain ->> Complex Relayer: Read Finality Proof of Block 483 + Complex Relayer ->> Target Chain: Submit Finality Proof of Block 483 + Target Chain ->> Target Chain: Import and Finalize Block 63 + Note left of Target Chain: Finalized: 63, Source Finalized: 483, Received Messages: { rewarded: 42, messages-relayer-account: [43] } + + Source Chain ->> Complex Relayer: Read Proof of Message 44 and Proof of Message 43 reward at Block 483 + Complex Relayer ->> Target Chain: Submit Proof of Message 44 and Proof of Message 43 reward at Block 483 + Target Chain ->> Target Chain: Import and Finalize Block 64 + Note left of Target Chain: Finalized: 64, Source Finalized: 483, Received Messages: { rewarded: 43, messages-relayer-account: [44] }--> +
+ + + + diff --git a/bridges/docs/grandpa-finality-relay.html b/bridges/docs/grandpa-finality-relay.html new file mode 100644 index 00000000000..4136621b1a4 --- /dev/null +++ b/bridges/docs/grandpa-finality-relay.html @@ -0,0 +1,47 @@ + + + + + + GRANDPA Finality Relay + + +

GRANDPA Finality Relay

+

+ Source Chain is running GRANDPA Finality Gadget. Bridge GRANDPA finality pallet is deployed at + Target Chain runtime. Relayer is configured to relay Source Chain finality to Target Chain. +

+
+ sequenceDiagram + participant Source Chain + participant Relayer + participant Target Chain + Note left of Source Chain: Best: 500, Finalized: 480, Authorities Set Index: 42 + Note right of Target Chain: Uninitialized + + Source Chain ->> Relayer: Read Initialization Data + Relayer ->> Target Chain: Initialize Bridge GRANDPA Finality Pallet + Note right of Target Chain: Finalized: 480, Authorities Set Index: 42 + + Source Chain ->> Source Chain: Import Block 501 + Source Chain ->> Source Chain: Import Block 502 + Source Chain ->> Source Chain: Finalize Block 495 + Source Chain ->> Relayer: Read Finality Proof of Block 495 + Relayer ->> Target Chain: Finality Proof of Block 495 + Note right of Target Chain: Finalized: 495, Authorities Set Index: 42 + + Source Chain ->> Source Chain: Import Block 503 that changes Authorities Set to 43 + Source Chain ->> Source Chain: Finalize Block 500 + Note left of Relayer: Relayer Misses Finality Notification for Block 500 + + Source Chain ->> Source Chain: Import Block 504 + Source Chain ->> Source Chain: Finalize Mandatory Block 503 + Source Chain ->> Source Chain: Finalize Block 504 + Source Chain ->> Relayer: Read Finality Proof of Mandatory Block 503 + Relayer ->> Target Chain: Finality Proof of Block 503 + Note right of Target Chain: Finalized: 503, Authorities Set Index: 43 +
+ + + + diff --git a/bridges/docs/high-level-overview.md b/bridges/docs/high-level-overview.md new file mode 100644 index 00000000000..449224124af --- /dev/null +++ b/bridges/docs/high-level-overview.md @@ -0,0 +1,181 @@ +# High-Level Bridge Documentation + +This document gives a brief, abstract description of main components that may be found in this repository. +If you want to see how we're using them to build Rococo <> Wococo (Kusama <> Polkadot) bridge, please +refer to the [Polkadot <> Kusama Bridge](./polkadot-kusama-bridge-overview.md). + +## Purpose + +This repo contains all components required to build a trustless connection between standalone Substrate chains, +that are using GRANDPA finality, their parachains or any combination of those. On top of this connection, we +offer a messaging pallet that provides means to organize messages exchange. + +On top of that layered infrastructure, anyone may build their own bridge applications - e.g. [XCM messaging](./polkadot-kusama-bridge-overview.md), +[encoded calls messaging](https://github.com/paritytech/parity-bridges-common/releases/tag/encoded-calls-messaging) and so on. + +## Terminology + +Even though we support (and require) two-way bridging, the documentation will generally talk about +a one-sided interaction. That's to say, we will only talk about syncing finality proofs and messages +from a _source_ chain to a _target_ chain. This is because the two-sided interaction is really just the +one-sided interaction with the source and target chains switched. + +The bridge has both on-chain (pallets) and offchain (relayers) components. + +## On-chain components + +On-chain bridge components are pallets that are deployed at the chain runtime. Finality pallets require +deployment at the target chain, while messages pallet needs to be deployed at both, source +and target chains. + +### Bridge GRANDPA Finality Pallet + +A GRANDPA light client of the source chain built into the target chain's runtime. It provides a "source of truth" +about the source chain headers which have been finalized. This is useful for higher level applications. + +The pallet tracks current GRANDPA authorities set and only accepts finality proofs (GRANDPA justifications), +generated by the current authorities set. The GRANDPA protocol itself requires current authorities set to +generate explicit justification for the header that enacts next authorities set. Such headers and their finality +proofs are called mandatory in the pallet and relayer pays no fee for such headers submission. + +The pallet does not require all headers to be imported or provided. The relayer itself chooses which headers +he wants to submit (with the exception of mandatory headers). + +More: [pallet level documentation and code](../modules/grandpa/). + +### Bridge Parachains Finality Pallet + +Parachains are not supposed to have their own finality, so we can't use bridge GRANDPA pallet to verify their +finality proofs. Instead, they rely on their relay chain finality. The parachain header is considered final, +when it is accepted by the [`paras` pallet](https://github.com/paritytech/polkadot/tree/1a034bd6de0e76721d19aed02a538bcef0787260/runtime/parachains/src/paras) +at its relay chain. Obviously, the relay chain block, where it is accepted, must also be finalized by the relay +chain GRANDPA gadget. + +That said, the bridge parachains pallet accepts storage proof of one or several parachain heads, inserted to the +[`Heads`](https://github.com/paritytech/polkadot/blob/1a034bd6de0e76721d19aed02a538bcef0787260/runtime/parachains/src/paras/mod.rs#L642) +map of the [`paras` pallet](https://github.com/paritytech/polkadot/tree/1a034bd6de0e76721d19aed02a538bcef0787260/runtime/parachains/src/paras). +To verify this storage proof, the pallet uses relay chain header, imported earlier by the bridge GRANDPA pallet. + +The pallet may track multiple parachains at once and those parachains may use different primitives. So the +parachain header decoding never happens at the pallet level. For maintaining the headers order, the pallet +uses relay chain header number. + +More: [pallet level documentation and code](../modules/parachains/). + +### Bridge Messages Pallet + +The pallet is responsible for queuing messages at the source chain and receiving the messages proofs at the +target chain. The messages are sent to the particular _lane_, where they are guaranteed to be received in the +same order they are sent. The pallet supports many lanes. + +The lane has two ends. Outbound lane end is storing number of messages that have been sent and the number of +messages that have been received. Inbound lane end stores the number of messages that have been received and +also a map that maps messages to relayers that have delivered those messages to the target chain. + +The pallet has three main entrypoints: +- the `send_message` may be used by the other runtime pallets to send the messages; +- the `receive_messages_proof` is responsible for parsing the messages proof and handing messages over to the +dispatch code; +- the `receive_messages_delivery_proof` is responsible for parsing the messages delivery proof and rewarding +relayers that have delivered the message. + +Many things are abstracted by the pallet: +- the message itself may mean anything, the pallet doesn't care about its content; +- the message dispatch happens during delivery, but it is decoupled from the pallet code; +- the messages proof and messages delivery proof are verified outside of the pallet; +- the relayers incentivization scheme is defined outside of the pallet. + +Outside of the messaging pallet, we have a set of adapters, where messages and delivery proofs are regular +storage proofs. The proofs are generated at the bridged chain and require bridged chain finality. So messages +pallet, in this case, depends on one of the finality pallets. The messages are XCM messages and we are using +XCM executor to dispatch them on receival. You may find more info in [Polkadot <> Kusama Bridge](./polkadot-kusama-bridge-overview.md) +document. + +More: [pallet level documentation and code](../modules/messages/). + +### Bridge Relayers Pallet + +The pallet is quite simple. It just registers relayer rewards and has an entrypoint to collect them. When +the rewards are registered and the reward amount is configured outside of the pallet. + +More: [pallet level documentation and code](../modules/relayers/). + +## Offchain Components + +Offchain bridge components are separate processes, called relayers. Relayers are connected both to the +source chain and target chain nodes. Relayers are reading state of the source chain, compare it to the +state of the target chain and, if state at target chain needs to be updated, submits target chain +transaction. + +### GRANDPA Finality Relay + +The task of relay is to submit source chain GRANDPA justifications and their corresponding headers to +the Bridge GRANDPA Finality Pallet, deployed at the target chain. For that, the relay subscribes to +the source chain GRANDPA justifications stream and submits every new justification it sees to the +target chain GRANDPA light client. In addition, relay is searching for mandatory headers and +submits their justifications - without that the pallet will be unable to move forward. + +More: [GRANDPA Finality Relay Sequence Diagram](./grandpa-finality-relay.html), [pallet level documentation and code](../relays/finality/). + +### Parachains Finality Relay + +The relay connects to the source _relay_ chain and the target chain nodes. It doesn't need to connect to the +tracked parachain nodes. The relay looks at the [`Heads`](https://github.com/paritytech/polkadot/blob/1a034bd6de0e76721d19aed02a538bcef0787260/runtime/parachains/src/paras/mod.rs#L642) +map of the [`paras` pallet](https://github.com/paritytech/polkadot/tree/1a034bd6de0e76721d19aed02a538bcef0787260/runtime/parachains/src/paras) +in source chain, and compares the value with the best parachain head, stored in the bridge parachains pallet at +the target chain. If new parachain head appears at the relay chain block `B`, the relay process **waits** +until header `B` or one of its ancestors appears at the target chain. Once it is available, the storage +proof of the map entry is generated and is submitted to the target chain. + +As its on-chain component (which requires bridge GRANDPA pallet to be deployed nearby), the parachains +finality relay requires GRANDPA finality relay to be running in parallel. Without it, the header `B` or +any of its children's finality at source won't be relayed at target, and target chain +won't be able to verify generated storage proof. + +More: [Parachains Finality Relay Sequence Diagram](./parachains-finality-relay.html), [code](../relays/parachains/). + +### Messages Relay + +Messages relay is actually two relays that are running in a single process: messages delivery relay and +delivery confirmation relay. Even though they are more complex and have many caveats, the overall algorithm +is the same as in other relays. + +Message delivery relay connects to the source chain and looks at the outbound lane end, waiting until new +messages are queued there. Once they appear at the source block `B`, the relay start waiting for the block +`B` or its descendant appear at the target chain. Then the messages storage proof is generated and submitted +to the bridge messages pallet at the target chain. In addition, the transaction may include the storage proof +of the outbound lane state - that proves that relayer rewards have been paid and this data (map of relay +accounts to the delivered messages) may be pruned from the inbound lane state at the target chain. + +Delivery confirmation relay connects to the target chain and starts watching the inbound lane end. When new +messages are delivered to the target chain, the corresponding _source chain account_ is inserted to the +map in the inbound lane data. Relay detects that, say, at the target chain block `B` and waits until that +block or its descendant appears at the source chain. Once that happens, the relay crafts a storage proof of +that data and sends it to the messages pallet, deployed at the source chain. + +As you can see, the messages relay also requires finality relay to be operating in parallel. Since messages +relay submits transactions to both source and target chains, it requires both _source-to-target_ and +_target-to-source_ finality relays. They can be GRANDPA finality relays or GRANDPA+parachains finality relays, +depending on the type of connected chain. + +More: [Messages Relay Sequence Diagram](./messages-relay.html), [pallet level documentation and code](../relays/messages/). + +### Complex Relay + +Every relay transaction has its cost. The only transaction, that is "free" to relayer is when the mandatory +GRANDPA header is submitted. The relay that feeds the bridge with every relay chain and/or parachain head it +sees, will have to pay a (quite large) cost. And if no messages are sent through the bridge, that is just +waste of money. + +We have a special relay mode, called _complex relay_, where relay mostly sleeps and only submits transactions +that are required for the messages/confirmations delivery. This mode starts two message relays (in both +directions). All required finality relays are also started in a special _on-demand_ mode. In this mode they +do not submit any headers without special request. As always, the only exception is when GRANDPA finality +relay sees the mandatory header - it is submitted without such request. + +The message relays are watching their lanes and when, at some block `B`, they see new messages/confirmations +to be delivered, they are asking on-demand relays to relay this block `B`. On-demand relays does that and +then message relay may perform its job. If on-demand relay is a parachain finality relay, it also runs its +own on-demand GRANDPA relay, which is used to relay required relay chain headers. + +More: [Complex Relay Sequence Diagram](./complex-relay.html), [code](../relays/bin-substrate/src/cli/relay_headers_and_messages/). diff --git a/bridges/docs/messages-relay.html b/bridges/docs/messages-relay.html new file mode 100644 index 00000000000..c4dab9901e0 --- /dev/null +++ b/bridges/docs/messages-relay.html @@ -0,0 +1,78 @@ + + + + + + Messages Relay + + +

Messages Relay

+

+ Both Source Chain and Target Chains have Bridge Messages pallets deployed. They also have required + finality pallets deployed - we don't care about finality type here - they can be either Bridge GRANDPA, + or Bridge Parachains finality pallets, or any combination of those. +

+

+ Finality Relayer represents two actual relayers - one relays Source Chain Finality to Target Chain. + And another one relays Target Chain Finality to Source Chain. +

+
+ sequenceDiagram + participant Source Chain + participant Finality Relayer + participant Messages Relayer + participant Target Chain + + Note right of Source Chain: Finalized: 480, Target Finalized: 50, Sent Messages: 42, Confirmed Messages: 42 + Note left of Target Chain: Finalized: 60, Source Finalized: 420, Received Messages: 42 + + Source Chain ->> Source Chain: someone Sends Message 43 + Source Chain ->> Source Chain: Import and Finalize Block 481 + + Source Chain ->> Messages Relayer: notes new outbound message 43 at Source Chain Block 481 + Note right of Messages Relayer: can't deliver message 43, Source Chain Block 481 is not relayed + + Source Chain ->> Finality Relayer: Read Finality Proof of Block 481 + Finality Relayer ->> Target Chain: Submit Finality Proof of Block 481 + Target Chain ->> Target Chain: Import and Finalize Block 61 + Note left of Target Chain: Finalized: 61, Source Finalized: 481, Received Messages: 42 + + Source Chain ->> Messages Relayer: Read Proof of Message 43 at Block 481 + Messages Relayer ->> Target Chain: Submit Proof of Message 43 at Block 481 + Target Chain ->> Target Chain: Import and Finalize Block 62 + Note left of Target Chain: Finalized: 62, Source Finalized: 481, Received Messages: { rewarded: 42, messages-relayer-account: [43] } + + Target Chain ->> Messages Relayer: notes new unrewarded relayer at Target Chain Block 62 + Note right of Messages Relayer: can't relay delivery confirmations because Target Chain Block 62 is not relayed + + Target Chain ->> Finality Relayer: Read Finality Proof of Block 62 + Finality Relayer ->> Source Chain: Submit Finality Proof of Block 62 + Source Chain ->> Source Chain: Import and Finalize Block 482 + Note right of Source Chain: Finalized: 482, Target Finalized: 62, Confirmed Messages: 42 + + Target Chain ->> Messages Relayer: Read Proof of Message 43 Delivery at Block 62 + Messages Relayer ->> Source Chain: Submit Proof of Message 43 Delivery at Block 612 + Source Chain ->> Source Chain: rewards messages-relayer-account for delivering message [43] + Source Chain ->> Source Chain: prune delivered message 43 from runtime storage + Note right of Source Chain: Finalized: 482, Target Finalized: 61, Confirmed Messages: 43 + + Source Chain ->> Source Chain: someone Sends Message 44 + Source Chain ->> Source Chain: Import and Finalize Block 483 + + Source Chain ->> Messages Relayer: notes new outbound message 44 at Source Chain Block 483 and new confirmed message 43 + Note right of Messages Relayer: can't deliver message 44, Source Chain Block 483 is not relayed + + Source Chain ->> Finality Relayer: Read Finality Proof of Block 483 + Finality Relayer ->> Target Chain: Submit Finality Proof of Block 483 + Target Chain ->> Target Chain: Import and Finalize Block 63 + Note left of Target Chain: Finalized: 63, Source Finalized: 483, Received Messages: { rewarded: 42, messages-relayer-account: [43] } + + Source Chain ->> Messages Relayer: Read Proof of Message 44 and Proof of Message 43 reward at Block 483 + Messages Relayer ->> Target Chain: Submit Proof of Message 44 and Proof of Message 43 reward at Block 483 + Target Chain ->> Target Chain: Import and Finalize Block 64 + Note left of Target Chain: Finalized: 64, Source Finalized: 483, Received Messages: { rewarded: 43, messages-relayer-account: [44] } +
+ + + + diff --git a/bridges/docs/parachains-finality-relay.html b/bridges/docs/parachains-finality-relay.html new file mode 100644 index 00000000000..4fc1392b87d --- /dev/null +++ b/bridges/docs/parachains-finality-relay.html @@ -0,0 +1,55 @@ + + + + + + Parachains Finality Relay + + +

Parachains Finality Relay

+

+ Source Relay Chain is running GRANDPA Finality Gadget. Source Parachain is a parachain of the Source + Relay Chain. Bridge GRANDPA finality pallet is deployed at Target Chain runtime and is "connected" + to the Source Relay Chain. Bridge Parachains finality pallet is deployed at Target Chain and is + configured to track the Source Parachain. GRANDPA Relayer is configured to relay Source Relay Chain + finality to Target Chain. Parachains Relayer is configured to relay Source Parachain headers finality + to Target Chain. +

+
+ sequenceDiagram + participant Source Parachain + participant Source Relay Chain + participant GRANDPA Relayer + participant Parachains Relayer + participant Target Chain + + Note left of Source Parachain: Best: 125 + Note left of Source Relay Chain: Finalized: 500, Best Parachain at Finalized: 120 + Note right of Target Chain: Best Relay: 480, Best Parachain: 110 + + Source Parachain ->> Source Parachain: Import Block 126 + Source Parachain ->> Source Relay Chain: Receives the Parachain block 126 + + Source Relay Chain ->> Source Relay Chain: Import block 501 + Source Relay Chain ->> Source Relay Chain: Finalize block 501 + Note left of Source Relay Chain: Finalized: 501, Best Parachain at Finalized: 126 + + Source Relay Chain ->> Parachains Relayer: notes new Source Parachain Block 126 + Note left of Parachains Relayer: can't relay Source Parachain Block 126, because it requires at least Source Relay Block 501 at Target Chain + + Source Relay Chain ->> Source Relay Chain: Import block 502 + Source Relay Chain ->> Source Relay Chain: Finalize block 502 + + Source Relay Chain ->> GRANDPA Relayer: read GRANDPA Finality Proof of Block 502 + GRANDPA Relayer ->> Target Chain: submit GRANDPA Finality Proof of Block 502 + Note right of Target Chain: Best Relay: 502, Best Parachain: 110 + + Target Chain ->> Parachains Relayer: notes finalized Source Relay Block 502 at Target Chain + Source Relay Chain ->> Parachains Relayer: read Parachain Finality Proof at Relay Block 502 + Parachains Relayer ->> Target Chain: submit Parachain Finality Proof at Relay Block 502 + Note right of Target Chain: Best Relay: 502, Best Parachain: 126 +
+ + + + diff --git a/bridges/docs/polkadot-kusama-bridge-overview.md b/bridges/docs/polkadot-kusama-bridge-overview.md new file mode 100644 index 00000000000..b469720f65b --- /dev/null +++ b/bridges/docs/polkadot-kusama-bridge-overview.md @@ -0,0 +1,132 @@ +# Polkadot <> Kusama Bridge Overview + +This document describes how we use all components, described in the [High-Level Bridge Documentation](./high-level-overview.md), +to build the XCM bridge between Kusama and Polkadot. In this case, our components merely work as a XCM transport +(like XCMP/UMP/HRMP), between chains that are not a part of the same consensus system. + +The overall architecture may be seen in [this diagram](./polkadot-kusama-bridge.html). + +## Bridge Hubs + +All operations at relay chain are expensive. Ideally all non-mandatory transactions must happen on parachains. +That's why we are planning to have two parachains - Polkadot Bridge Hub under Polkadot consensus and Kusama +Bridge Hub under Kusama consensus. + +The Bridge Hub will have all required bridge pallets in its runtime. We hope that later, other teams will be able to +use our bridge hubs too and have their pallets there. + +The Bridge Hub will use the base token of the ecosystem - KSM at Kusama Bridge Hub and DOT at Polkadot Bridge Hub. +The runtime will have minimal set of non-bridge pallets, so there's not much you can do directly on bridge hubs. + +## Connecting Parachains + +You won't be able to directly use bridge hub transactions to send XCM messages over the bridge. Instead, you'll need +to use other parachains transactions, which will use HRMP to deliver messages to the Bridge Hub. The Bridge Hub will +just queue these messages in its outbound lane, which is dedicated to deliver messages between two parachains. + +Our first planned bridge will connect the Polkadot and Kusama Asset Hubs. A bridge between those two +parachains would allow Asset Hub Polkadot accounts to hold wrapped KSM tokens and Asset Hub Kusama +accounts to hold wrapped DOT tokens. + +For that bridge (pair of parachains under different consensus systems) we'll be using the lane 00000000. Later, +when other parachains will join the bridge, they will be using other lanes for their messages. + +## Running Relayers + +We are planning to run our own complex relayer for the lane 00000000. The relayer will relay Kusama/Polkadot GRANDPA +justifications to the bridge hubs at the other side. It'll also relay finalized Kusama Bridge Hub and Polkadot Bridge +Hub heads. This will only happen when messages will be queued at hubs. So most of time relayer will be idle. + +There's no any active relayer sets, or something like that. Anyone may start its own relayer and relay queued messages. +We are not against that and, as always, appreciate any community efforts. Of course, running relayer has the cost. +Apart from paying for the CPU and network, the relayer pays for transactions at both sides of the bridge. We have +a mechanism for rewarding relayers. + +### Compensating the Cost of Message Delivery Transactions + +One part of our rewarding scheme is that the cost of message delivery, for honest relayer, is zero. The honest relayer +is the relayer, which is following our rules: + +- we do not reward relayers for submitting GRANDPA finality transactions. The only exception is submitting mandatory + headers (headers which are changing the GRANDPA authorities set) - the cost of such transaction is zero. The relayer + will pay the full cost for submitting all other headers; + +- we do not reward relayers for submitting parachain finality transactions. The relayer will pay the full cost for + submitting parachain finality transactions; + +- we compensate the cost of message delivery transactions that have actually delivered the messages. So if your + transaction has claimed to deliver messages `[42, 43, 44]`, but, because of some reasons, has actually delivered + messages `[42, 43]`, the transaction will be free for relayer. If it has not delivered any messages, then + the relayer pays the full cost of the transaction; + +- we compensate the cost of message delivery and all required finality calls, if they are part of the same + [`frame_utility::batch_all`](https://github.com/paritytech/substrate/blob/891d6a5c870ab88521183facafc811a203bb6541/frame/utility/src/lib.rs#L326) + transaction. Of course, the calls inside the batch must be linked - e.g. the submitted parachain head must be used + to prove messages. Relay header must be used to prove parachain head finality. If one of calls fails, or if they + are not linked together, the relayer pays the full transaction cost. + +Please keep in mind that the fee of "zero-cost" transactions is still withdrawn from the relayer account. But the +compensation is registered in the `pallet_bridge_relayers::RelayerRewards` map at the target bridge hub. The relayer +may later claim all its rewards later, using the `pallet_bridge_relayers::claim_rewards` call. + +*A side note*: why we don't simply set the cost of useful transactions to zero? That's because the bridge has its cost. +If we won't take any fees, it would mean that the sender is not obliged to pay for its messages. And Bridge Hub +collators (and, maybe, "treasury") are not receiving any payment for including transactions. More about this later, +in the [Who is Rewarding Relayers](#who-is-rewarding-relayers) section. + +### Message Delivery Confirmation Rewards + +In addition to the "zero-cost" message delivery transactions, the relayer is also rewarded for: + +- delivering every message. The reward is registered during delivery confirmation transaction at the Source Bridge + Hub.; + +- submitting delivery confirmation transaction. The relayer may submit delivery confirmation that e.g. confirms + delivery of four messages, of which the only one (or zero) messages is actually delivered by this relayer. It + receives some fee for confirming messages, delivered by other relayers. + +Both rewards may be claimed using the `pallet_bridge_relayers::claim_rewards` call at the Source Bridge Hub. + +### Who is Rewarding Relayers + +Obviously, there should be someone who is paying relayer rewards. We want bridge transactions to have a cost, so we +can't use fees for rewards. Instead, the parachains using the bridge, use sovereign accounts on both sides +of the bridge to cover relayer rewards. + +Bridged Parachains will have sovereign accounts at bridge hubs. For example, the Kusama Asset Hub will +have an account at the Polkadot Bridge Hub. The Polkadot Asset Hub will have an account at the Kusama +Bridge Hub. The sovereign accounts are used as a source of funds when the relayer is calling the +`pallet_bridge_relayers::claim_rewards`. + +Since messages lane is only used by the pair of parachains, there's no collision between different bridges. E.g. +Kusama Asset Hub will only reward relayers that are delivering messages from Kusama Asset Hub. The Kusama Asset Hub sovereign account +is not used to cover rewards of bridging with some other Polkadot Parachain. + +### Multiple Relayers and Rewards + +Our goal is to incentivize running honest relayers. But we have no relayers sets, so at any time anyone may submit +message delivery transaction, hoping that the cost of this transaction will be compensated. So what if some message is +currently queued and two relayers are submitting two identical message delivery transactions at once? Without any +special means, the cost of first included transaction will be compensated and the cost of the other one won't. A honest, +but unlucky relayer will lose some money. In addition, we'll waste some portion of block size and weight, which +may be used by other useful transactions. + +To solve the problem, we have two signed extensions ([generate_bridge_reject_obsolete_headers_and_messages! {}](../bin/runtime-common/src/lib.rs) +and [RefundRelayerForMessagesFromParachain](../bin/runtime-common/src/refund_relayer_extension.rs)), that are +preventing bridge transactions with obsolete data from including into the block. We are rejecting following +transactions: + +- transactions, that are submitting the GRANDPA justification for the best finalized header, or one of its ancestors; + +- transactions, that are submitting the proof of the current best parachain head, or one of its ancestors; + +- transactions, that are delivering already delivered messages. If at least one of messages is not yet delivered, + the transaction is not rejected; + +- transactions, that are confirming delivery of already confirmed messages. If at least one of confirmations is new, + the transaction is not rejected; + +- [`frame_utility::batch_all`](https://github.com/paritytech/substrate/blob/891d6a5c870ab88521183facafc811a203bb6541/frame/utility/src/lib.rs#L326) + transactions, that have both finality and message delivery calls. All restrictions from the + [Compensating the Cost of Message Delivery Transactions](#compensating-the-cost-of-message-delivery-transactions) + are applied. diff --git a/bridges/docs/polkadot-kusama-bridge.html b/bridges/docs/polkadot-kusama-bridge.html new file mode 100644 index 00000000000..bf248adb571 --- /dev/null +++ b/bridges/docs/polkadot-kusama-bridge.html @@ -0,0 +1,67 @@ + + + + + + Polkadot <> Kusama Bridge + + +

Polkadot <> Kusama Bridge

+

+ Our bridge connects two parachains - Kusama Bridge Hub and Polkadot Bridge Hub. Messages that + are sent over bridge have XCM format and we are using existing architecture to dispatch them. + Since both Polkadot, Kusama and their parachains already have means to exchange XCM messages + within the same consensus system (HRMP, VMP, ...), it means that we are able to connect all those + chains with our bridge. +

+

+ In our architecture, the lane that is used to relay messages over the bridge is determined by + the XCM source and destinations. So e.g. bridge between Asset Hubs Polkadot and Kusama (and opposite direction) + will use the lane 00000000, bridge between some other Polkadot Parachain and some other Kusama Parachain + will use the lane 00000001 and so on. +

+
+ flowchart LR + subgraph Polkadot Consensus + polkadot(((Polkadot))) + asset_hub_polkadot(((Polkadot Asset Hub))) + polkadot_bh(((Polkadot Bridge Hub))) + + polkadot---asset_hub_polkadot + polkadot---polkadot_bh + + asset_hub_polkadot-->|Send Message Using HRMP|polkadot_bh + + polkadot_bh-->|Send Message Using HRMP|asset_hub_polkadot + asset_hub_polkadot-->|Dispatch the Message|asset_hub_polkadot + end + subgraph Kusama Consensus + kusama_bh(((Kusama Bridge Hub))) + asset_hub_kusama(((Kusama Asset Hub))) + kusama(((Kusama))) + + kusama---asset_hub_kusama + kusama---kusama_bh + + kusama_bh-->|Send Message Using HRMP|asset_hub_kusama + asset_hub_kusama-->|Dispatch the Message|asset_hub_kusama + + asset_hub_kusama-->|Send Message Using HRMP|kusama_bh + end + + polkadot_bh<===>|Message is relayed to the Bridged Chain using lane 00000000|kusama_bh + + linkStyle 2 stroke:red + linkStyle 7 stroke:red + linkStyle 8 stroke:red + + linkStyle 3 stroke:green + linkStyle 4 stroke:green + linkStyle 9 stroke:green +
+ + + \ No newline at end of file diff --git a/bridges/modules/grandpa/Cargo.toml b/bridges/modules/grandpa/Cargo.toml new file mode 100644 index 00000000000..fcc1c2a9b07 --- /dev/null +++ b/bridges/modules/grandpa/Cargo.toml @@ -0,0 +1,63 @@ +[package] +name = "pallet-bridge-grandpa" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } +finality-grandpa = { version = "0.16.2", default-features = false } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } + +# Bridge Dependencies + +bp-runtime = { path = "../../primitives/runtime", default-features = false } +bp-header-chain = { path = "../../primitives/header-chain", default-features = false } + +# Substrate Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +# Optional Benchmarking Dependencies +bp-test-utils = { path = "../../primitives/test-utils", default-features = false, optional = true } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } + +[dev-dependencies] +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" } + +[features] +default = ["std"] +std = [ + "bp-header-chain/std", + "bp-runtime/std", + "bp-test-utils/std", + "codec/std", + "finality-grandpa/std", + "frame-support/std", + "frame-system/std", + "frame-benchmarking/std", + "log/std", + "scale-info/std", + "sp-consensus-grandpa/std", + "sp-runtime/std", + "sp-std/std", + "sp-trie/std", +] +runtime-benchmarks = [ + "bp-test-utils", + "frame-benchmarking/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", +] diff --git a/bridges/modules/grandpa/README.md b/bridges/modules/grandpa/README.md new file mode 100644 index 00000000000..27b4d2389c4 --- /dev/null +++ b/bridges/modules/grandpa/README.md @@ -0,0 +1,101 @@ +# Bridge GRANDPA Pallet + +The bridge GRANDPA pallet is a light client for the GRANDPA finality gadget, running at the bridged chain. +It may import headers and their GRANDPA finality proofs (justifications) of the bridged chain. Imported +headers then may be used to verify storage proofs by other pallets. This makes the bridge GRANDPA pallet +a basic pallet of all bridges with Substrate-based chains. It is used by all bridge types (bridge between +standalone chains, between parachains and any combination of those) and is used by other bridge pallets. +It is used by the parachains light client (bridge parachains pallet) and by messages pallet. + +## A Brief Introduction into GRANDPA Finality + +You can find detailed information on GRANDPA, by exploring its [repository](https://github.com/paritytech/finality-grandpa). +Here is the minimal reqiuired GRANDPA information to understand how pallet works. + +Any Substrate chain may use different block authorship algorithms (like BABE or Aura) to determine block producers and +generate blocks. This has nothing common with finality, though - the task of block authorship is to coordinate +blocks generation. Any block may be reverted (if there's a fork) if it is not finalized. The finality solution +for (standalone) Substrate-based chains is the GRANDPA finality gadget. If some block is finalized by the gadget, it +can't be reverted. + +In GRANDPA, there are validators, identified by their public keys. They select some generated block and produce +signatures on this block hash. If there are enough (more than `2 / 3 * N`, where `N` is number of validators) +signatures, then the block is considered finalized. The set of signatures for the block is called justification. +Anyone who knows the public keys of validators is able to verify GRANDPA justification and that it is generated +for provided header. + +There are two main things in GRANDPA that help building light clients: + +- there's no need to import all headers of the bridged chain. Light client may import finalized headers or just + some of finalized headders that it consider useful. While the validators set stays the same, the client may + import any header that is finalized by this set; + +- when validators set changes, the GRANDPA gadget adds next set to the header. So light client doesn't need to + verify storage proofs when this happens - it only needs to look at the header and see if it changes the set. + Once set is changed, all following justifications are generated by the new set. Header that is changing the + set is called "mandatory" in the pallet. As the name says, the light client need to import all such headers + to be able to operate properly. + +## Pallet Operations + +The main entrypoint of the pallet is the `submit_finality_proof` call. It has two arguments - the finalized +headers and associated GRANDPA justification. The call simply verifies the justification using current +validators set and checks if header is better than the previous best header. If both checks are passed, the +header (only its useful fields) is inserted into the runtime storage and may be used by other pallets to verify +storage proofs. + +The submitter pays regular fee for submitting all headers, except for the mandatory header. Since it is +required for the pallet operations, submitting such header is free. So if you're ok with session-length +lags (meaning that there's exactly 1 mandatory header per session), the cost of pallet calls is zero. + +When the pallet sees mandatory header, it updates the validators set with the set from the header. All +following justifications (until next mandatory header) must be generated by this new set. + +## Pallet Initialization + +As the previous section states, there are two things that are mandatory for pallet operations: best finalized +header and the current validators set. Without it the pallet can't import any headers. But how to provide +initial values for these fields? There are two options. + +First option, while it is easier, doesn't work in all cases. It is to start chain with initial header and +validators set specified in the chain specification. This won't work, however, if we want to add bridge +to already started chain. + +For the latter case we have the `initialize` call. It accepts the initial header and initial validators set. +The call may be called by the governance, root or by the pallet owner (if it is set). + +## Non-Essential Functionality + +There may be a special account in every runtime where the bridge GRANDPA module is deployed. This +account, named 'module owner', is like a module-level sudo account - he's able to halt and +resume all module operations without requiring runtime upgrade. Calls that are related to this +account are: + +- `fn set_owner()`: current module owner may call it to transfer "ownership" to another account; + +- `fn set_operating_mode()`: the module owner (or sudo account) may call this function to stop all + module operations. After this call, all finality proofs will be rejected until further `set_operating_mode` call'. + This call may be used when something extraordinary happens with the bridge; + +- `fn initialize()`: module owner may call this function to initialize the bridge. + +If pallet owner is not defined, the governance may be used to make those calls. + +## Signed Extension to Reject Obsolete Headers + +It'd be better for anyone (for chain and for submitters) to reject all transactions that are submitting +already known headers to the pallet. This way, we leave block space to other useful transactions and +we don't charge concurrent submitters for their honest actions. + +To deal with that, we have a [signed extension](./src/call_ext) that may be added to the runtime. +It does exactly what is required - rejects all transactions with already known headers. The submitter +pays nothing for such transactions - they're simply removed from the transaction pool, when the block +is built. + +You may also take a look at the [`generate_bridge_reject_obsolete_headers_and_messages`](../../bin/runtime-common/src/lib.rs) +macro that bundles several similar signed extensions in a single one. + +## GRANDPA Finality Relay + +We have an offchain actor, who is watching for GRANDPA justifications and submits them to the bridged chain. +It is the finality relay - you may look at the [crate level documentation and the code](../../relays/finality/). diff --git a/bridges/modules/grandpa/src/benchmarking.rs b/bridges/modules/grandpa/src/benchmarking.rs new file mode 100644 index 00000000000..aa222d6e4de --- /dev/null +++ b/bridges/modules/grandpa/src/benchmarking.rs @@ -0,0 +1,141 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Benchmarks for the GRANDPA Pallet. +//! +//! The main dispatchable for the GRANDPA pallet is `submit_finality_proof`, so these benchmarks are +//! based around that. There are to main factors which affect finality proof verification: +//! +//! 1. The number of `votes-ancestries` in the justification +//! 2. The number of `pre-commits` in the justification +//! +//! Vote ancestries are the headers between (`finality_target`, `head_of_chain`], where +//! `header_of_chain` is a descendant of `finality_target`. +//! +//! Pre-commits are messages which are signed by validators at the head of the chain they think is +//! the best. +//! +//! Consider the following: +//! +//! / B <- C' +//! A <- B <- C +//! +//! The common ancestor of both forks is block A, so this is what GRANDPA will finalize. In order to +//! verify this we will have vote ancestries of `[B, C, B', C']` and pre-commits `[C, C']`. +//! +//! Note that the worst case scenario here would be a justification where each validator has it's +//! own fork which is `SESSION_LENGTH` blocks long. + +use crate::*; + +use bp_header_chain::justification::required_justification_precommits; +use bp_runtime::BasicOperatingMode; +use bp_test_utils::{ + accounts, make_justification_for_header, JustificationGeneratorParams, TEST_GRANDPA_ROUND, + TEST_GRANDPA_SET_ID, +}; +use frame_benchmarking::{benchmarks_instance_pallet, whitelisted_caller}; +use frame_system::RawOrigin; +use sp_consensus_grandpa::AuthorityId; +use sp_runtime::traits::{One, Zero}; +use sp_std::vec::Vec; + +/// The maximum number of vote ancestries to include in a justification. +/// +/// In practice this would be limited by the session length (number of blocks a single authority set +/// can produce) of a given chain. +const MAX_VOTE_ANCESTRIES: u32 = 1000; + +// `1..MAX_VOTE_ANCESTRIES` is too large && benchmarks are running for almost 40m (steps=50, +// repeat=20) on a decent laptop, which is too much. Since we're building linear function here, +// let's just select some limited subrange for benchmarking. +const MAX_VOTE_ANCESTRIES_RANGE_BEGIN: u32 = MAX_VOTE_ANCESTRIES / 20; +const MAX_VOTE_ANCESTRIES_RANGE_END: u32 = + MAX_VOTE_ANCESTRIES_RANGE_BEGIN + MAX_VOTE_ANCESTRIES_RANGE_BEGIN; + +// the same with validators - if there are too much validators, let's run benchmarks on subrange +fn precommits_range_end, I: 'static>() -> u32 { + let max_bridged_authorities = T::BridgedChain::MAX_AUTHORITIES_COUNT; + if max_bridged_authorities > 128 { + sp_std::cmp::max(128, max_bridged_authorities / 5) + } else { + max_bridged_authorities + }; + required_justification_precommits(max_bridged_authorities) +} + +/// Prepare header and its justification to submit using `submit_finality_proof`. +fn prepare_benchmark_data, I: 'static>( + precommits: u32, + ancestors: u32, +) -> (BridgedHeader, GrandpaJustification>) { + // going from precommits to total authorities count + let total_authorities_count = (3 * precommits - 1) / 2; + + let authority_list = accounts(total_authorities_count as u16) + .iter() + .map(|id| (AuthorityId::from(*id), 1)) + .collect::>(); + + let genesis_header: BridgedHeader = bp_test_utils::test_header(Zero::zero()); + let genesis_hash = genesis_header.hash(); + let init_data = InitializationData { + header: Box::new(genesis_header), + authority_list, + set_id: TEST_GRANDPA_SET_ID, + operating_mode: BasicOperatingMode::Normal, + }; + + bootstrap_bridge::(init_data); + assert!(>::contains_key(genesis_hash)); + + let header: BridgedHeader = bp_test_utils::test_header(One::one()); + let params = JustificationGeneratorParams { + header: header.clone(), + round: TEST_GRANDPA_ROUND, + set_id: TEST_GRANDPA_SET_ID, + authorities: accounts(precommits as u16).iter().map(|k| (*k, 1)).collect::>(), + ancestors, + forks: 1, + }; + let justification = make_justification_for_header(params); + (header, justification) +} + +benchmarks_instance_pallet! { + // This is the "gold standard" benchmark for this extrinsic, and it's what should be used to + // annotate the weight in the pallet. + submit_finality_proof { + let p in 1 .. precommits_range_end::(); + let v in MAX_VOTE_ANCESTRIES_RANGE_BEGIN..MAX_VOTE_ANCESTRIES_RANGE_END; + let caller: T::AccountId = whitelisted_caller(); + let (header, justification) = prepare_benchmark_data::(p, v); + }: submit_finality_proof(RawOrigin::Signed(caller), Box::new(header), justification) + verify { + let genesis_header: BridgedHeader = bp_test_utils::test_header(Zero::zero()); + let header: BridgedHeader = bp_test_utils::test_header(One::one()); + let expected_hash = header.hash(); + + // check that the header#1 has been inserted + assert_eq!(>::get().unwrap().1, expected_hash); + assert!(>::contains_key(expected_hash)); + + // check that the header#0 has been pruned + assert!(!>::contains_key(genesis_header.hash())); + } + + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::TestRuntime) +} diff --git a/bridges/modules/grandpa/src/call_ext.rs b/bridges/modules/grandpa/src/call_ext.rs new file mode 100644 index 00000000000..b57aebb1ac1 --- /dev/null +++ b/bridges/modules/grandpa/src/call_ext.rs @@ -0,0 +1,311 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +use crate::{weights::WeightInfo, BridgedBlockNumber, BridgedHeader, Config, Error, Pallet}; +use bp_header_chain::{justification::GrandpaJustification, ChainWithGrandpa}; +use bp_runtime::BlockNumberOf; +use codec::Encode; +use frame_support::{dispatch::CallableCallFor, traits::IsSubType, weights::Weight, RuntimeDebug}; +use sp_runtime::{ + traits::{Header, Zero}, + transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction}, + SaturatedConversion, +}; + +/// Info about a `SubmitParachainHeads` call which tries to update a single parachain. +#[derive(Copy, Clone, PartialEq, RuntimeDebug)] +pub struct SubmitFinalityProofInfo { + /// Number of the finality target. + pub block_number: N, + /// Extra weight that we assume is included in the call. + /// + /// We have some assumptions about headers and justifications of the bridged chain. + /// We know that if our assumptions are correct, then the call must not have the + /// weight above some limit. The fee paid for weight above that limit, is never refunded. + pub extra_weight: Weight, + /// Extra size (in bytes) that we assume are included in the call. + /// + /// We have some assumptions about headers and justifications of the bridged chain. + /// We know that if our assumptions are correct, then the call must not have the + /// weight above some limit. The fee paid for bytes above that limit, is never refunded. + pub extra_size: u32, +} + +impl SubmitFinalityProofInfo { + /// Returns `true` if call size/weight is below our estimations for regular calls. + pub fn fits_limits(&self) -> bool { + self.extra_weight.is_zero() && self.extra_size.is_zero() + } +} + +/// Helper struct that provides methods for working with the `SubmitFinalityProof` call. +pub struct SubmitFinalityProofHelper, I: 'static> { + _phantom_data: sp_std::marker::PhantomData<(T, I)>, +} + +impl, I: 'static> SubmitFinalityProofHelper { + /// Check that the GRANDPA head provided by the `SubmitFinalityProof` is better than the best + /// one we know. + pub fn check_obsolete( + finality_target: BlockNumberOf, + ) -> Result<(), Error> { + let best_finalized = crate::BestFinalized::::get().ok_or_else(|| { + log::trace!( + target: crate::LOG_TARGET, + "Cannot finalize header {:?} because pallet is not yet initialized", + finality_target, + ); + >::NotInitialized + })?; + + if best_finalized.number() >= finality_target { + log::trace!( + target: crate::LOG_TARGET, + "Cannot finalize obsolete header: bundled {:?}, best {:?}", + finality_target, + best_finalized, + ); + + return Err(Error::::OldHeader) + } + + Ok(()) + } + + /// Check if the `SubmitFinalityProof` was successfully executed. + pub fn was_successful(finality_target: BlockNumberOf) -> bool { + match crate::BestFinalized::::get() { + Some(best_finalized) => best_finalized.number() == finality_target, + None => false, + } + } +} + +/// Trait representing a call that is a sub type of this pallet's call. +pub trait CallSubType, I: 'static>: + IsSubType, T>> +{ + /// Extract finality proof info from a runtime call. + fn submit_finality_proof_info( + &self, + ) -> Option>> { + if let Some(crate::Call::::submit_finality_proof { finality_target, justification }) = + self.is_sub_type() + { + return Some(submit_finality_proof_info_from_args::( + finality_target, + justification, + )) + } + + None + } + + /// Validate Grandpa headers in order to avoid "mining" transactions that provide outdated + /// bridged chain headers. Without this validation, even honest relayers may lose their funds + /// if there are multiple relays running and submitting the same information. + fn check_obsolete_submit_finality_proof(&self) -> TransactionValidity + where + Self: Sized, + { + let finality_target = match self.submit_finality_proof_info() { + Some(finality_proof) => finality_proof, + _ => return Ok(ValidTransaction::default()), + }; + + match SubmitFinalityProofHelper::::check_obsolete(finality_target.block_number) { + Ok(_) => Ok(ValidTransaction::default()), + Err(Error::::OldHeader) => InvalidTransaction::Stale.into(), + Err(_) => InvalidTransaction::Call.into(), + } + } +} + +impl, I: 'static> CallSubType for T::RuntimeCall where + T::RuntimeCall: IsSubType, T>> +{ +} + +/// Extract finality proof info from the submitted header and justification. +pub(crate) fn submit_finality_proof_info_from_args, I: 'static>( + finality_target: &BridgedHeader, + justification: &GrandpaJustification>, +) -> SubmitFinalityProofInfo> { + let block_number = *finality_target.number(); + + // the `submit_finality_proof` call will reject justifications with invalid, duplicate, + // unknown and extra signatures. It'll also reject justifications with less than necessary + // signatures. So we do not care about extra weight because of additional signatures here. + let precommits_len = justification.commit.precommits.len().saturated_into(); + let required_precommits = precommits_len; + + // We do care about extra weight because of more-than-expected headers in the votes + // ancestries. But we have problems computing extra weight for additional headers (weight of + // additional header is too small, so that our benchmarks aren't detecting that). So if there + // are more than expected headers in votes ancestries, we will treat the whole call weight + // as an extra weight. + let votes_ancestries_len = justification.votes_ancestries.len().saturated_into(); + let extra_weight = + if votes_ancestries_len > T::BridgedChain::REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY { + T::WeightInfo::submit_finality_proof(precommits_len, votes_ancestries_len) + } else { + Weight::zero() + }; + + // we can estimate extra call size easily, without any additional significant overhead + let actual_call_size: u32 = finality_target + .encoded_size() + .saturating_add(justification.encoded_size()) + .saturated_into(); + let max_expected_call_size = max_expected_call_size::(required_precommits); + let extra_size = actual_call_size.saturating_sub(max_expected_call_size); + + SubmitFinalityProofInfo { block_number, extra_weight, extra_size } +} + +/// Returns maximal expected size of `submit_finality_proof` call arguments. +fn max_expected_call_size, I: 'static>(required_precommits: u32) -> u32 { + let max_expected_justification_size = + GrandpaJustification::max_reasonable_size::(required_precommits); + + // call arguments are header and justification + T::BridgedChain::MAX_HEADER_SIZE.saturating_add(max_expected_justification_size) +} + +#[cfg(test)] +mod tests { + use crate::{ + call_ext::CallSubType, + mock::{run_test, test_header, RuntimeCall, TestBridgedChain, TestNumber, TestRuntime}, + BestFinalized, Config, WeightInfo, + }; + use bp_header_chain::ChainWithGrandpa; + use bp_runtime::HeaderId; + use bp_test_utils::{ + make_default_justification, make_justification_for_header, JustificationGeneratorParams, + }; + use frame_support::weights::Weight; + use sp_runtime::{testing::DigestItem, traits::Header as _, SaturatedConversion}; + + fn validate_block_submit(num: TestNumber) -> bool { + let bridge_grandpa_call = crate::Call::::submit_finality_proof { + finality_target: Box::new(test_header(num)), + justification: make_default_justification(&test_header(num)), + }; + RuntimeCall::check_obsolete_submit_finality_proof(&RuntimeCall::Grandpa( + bridge_grandpa_call, + )) + .is_ok() + } + + fn sync_to_header_10() { + let header10_hash = sp_core::H256::default(); + BestFinalized::::put(HeaderId(10, header10_hash)); + } + + #[test] + fn extension_rejects_obsolete_header() { + run_test(|| { + // when current best finalized is #10 and we're trying to import header#5 => tx is + // rejected + sync_to_header_10(); + assert!(!validate_block_submit(5)); + }); + } + + #[test] + fn extension_rejects_same_header() { + run_test(|| { + // when current best finalized is #10 and we're trying to import header#10 => tx is + // rejected + sync_to_header_10(); + assert!(!validate_block_submit(10)); + }); + } + + #[test] + fn extension_accepts_new_header() { + run_test(|| { + // when current best finalized is #10 and we're trying to import header#15 => tx is + // accepted + sync_to_header_10(); + assert!(validate_block_submit(15)); + }); + } + + #[test] + fn extension_returns_correct_extra_size_if_call_arguments_are_too_large() { + // when call arguments are below our limit => no refund + let small_finality_target = test_header(1); + let justification_params = JustificationGeneratorParams { + header: small_finality_target.clone(), + ..Default::default() + }; + let small_justification = make_justification_for_header(justification_params); + let small_call = RuntimeCall::Grandpa(crate::Call::submit_finality_proof { + finality_target: Box::new(small_finality_target), + justification: small_justification, + }); + assert_eq!(small_call.submit_finality_proof_info().unwrap().extra_size, 0); + + // when call arguments are too large => partial refund + let mut large_finality_target = test_header(1); + large_finality_target + .digest_mut() + .push(DigestItem::Other(vec![42u8; 1024 * 1024])); + let justification_params = JustificationGeneratorParams { + header: large_finality_target.clone(), + ..Default::default() + }; + let large_justification = make_justification_for_header(justification_params); + let large_call = RuntimeCall::Grandpa(crate::Call::submit_finality_proof { + finality_target: Box::new(large_finality_target), + justification: large_justification, + }); + assert_ne!(large_call.submit_finality_proof_info().unwrap().extra_size, 0); + } + + #[test] + fn extension_returns_correct_extra_weight_if_there_are_too_many_headers_in_votes_ancestry() { + let finality_target = test_header(1); + let mut justification_params = JustificationGeneratorParams { + header: finality_target.clone(), + ancestors: TestBridgedChain::REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY, + ..Default::default() + }; + + // when there are `REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY` headers => no refund + let justification = make_justification_for_header(justification_params.clone()); + let call = RuntimeCall::Grandpa(crate::Call::submit_finality_proof { + finality_target: Box::new(finality_target.clone()), + justification, + }); + assert_eq!(call.submit_finality_proof_info().unwrap().extra_weight, Weight::zero()); + + // when there are `REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY + 1` headers => full refund + justification_params.ancestors += 1; + let justification = make_justification_for_header(justification_params); + let call_weight = ::WeightInfo::submit_finality_proof( + justification.commit.precommits.len().saturated_into(), + justification.votes_ancestries.len().saturated_into(), + ); + let call = RuntimeCall::Grandpa(crate::Call::submit_finality_proof { + finality_target: Box::new(finality_target), + justification, + }); + assert_eq!(call.submit_finality_proof_info().unwrap().extra_weight, call_weight); + } +} diff --git a/bridges/modules/grandpa/src/lib.rs b/bridges/modules/grandpa/src/lib.rs new file mode 100644 index 00000000000..10b60878302 --- /dev/null +++ b/bridges/modules/grandpa/src/lib.rs @@ -0,0 +1,1417 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Substrate GRANDPA Pallet +//! +//! This pallet is an on-chain GRANDPA light client for Substrate based chains. +//! +//! This pallet achieves this by trustlessly verifying GRANDPA finality proofs on-chain. Once +//! verified, finalized headers are stored in the pallet, thereby creating a sparse header chain. +//! This sparse header chain can be used as a source of truth for other higher-level applications. +//! +//! The pallet is responsible for tracking GRANDPA validator set hand-offs. We only import headers +//! with justifications signed by the current validator set we know of. The header is inspected for +//! a `ScheduledChanges` digest item, which is then used to update to next validator set. +//! +//! Since this pallet only tracks finalized headers it does not deal with forks. Forks can only +//! occur if the GRANDPA validator set on the bridged chain is either colluding or there is a severe +//! bug causing resulting in an equivocation. Such events are outside the scope of this pallet. +//! Shall the fork occur on the bridged chain governance intervention will be required to +//! re-initialize the bridge and track the right fork. + +#![cfg_attr(not(feature = "std"), no_std)] +// Runtime-generated enums +#![allow(clippy::large_enum_variant)] + +pub use storage_types::StoredAuthoritySet; + +use bp_header_chain::{ + justification::GrandpaJustification, ChainWithGrandpa, HeaderChain, InitializationData, + StoredHeaderData, StoredHeaderDataBuilder, +}; +use bp_runtime::{BlockNumberOf, HashOf, HasherOf, HeaderId, HeaderOf, OwnedBridgeModule}; +use finality_grandpa::voter_set::VoterSet; +use frame_support::{dispatch::PostDispatchInfo, ensure, DefaultNoBound}; +use sp_consensus_grandpa::{ConsensusLog, GRANDPA_ENGINE_ID}; +use sp_runtime::{ + traits::{Header as HeaderT, Zero}, + SaturatedConversion, +}; +use sp_std::{boxed::Box, convert::TryInto}; + +mod call_ext; +#[cfg(test)] +mod mock; +mod storage_types; + +/// Module, containing weights for this pallet. +pub mod weights; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; + +// Re-export in crate namespace for `construct_runtime!` +pub use call_ext::*; +pub use pallet::*; +pub use weights::WeightInfo; + +/// The target that will be used when publishing logs related to this pallet. +pub const LOG_TARGET: &str = "runtime::bridge-grandpa"; + +/// Bridged chain from the pallet configuration. +pub type BridgedChain = >::BridgedChain; +/// Block number of the bridged chain. +pub type BridgedBlockNumber = BlockNumberOf<>::BridgedChain>; +/// Block hash of the bridged chain. +pub type BridgedBlockHash = HashOf<>::BridgedChain>; +/// Block id of the bridged chain. +pub type BridgedBlockId = HeaderId, BridgedBlockNumber>; +/// Hasher of the bridged chain. +pub type BridgedBlockHasher = HasherOf<>::BridgedChain>; +/// Header of the bridged chain. +pub type BridgedHeader = HeaderOf<>::BridgedChain>; +/// Header data of the bridged chain that is stored at this chain by this pallet. +pub type BridgedStoredHeaderData = + StoredHeaderData, BridgedBlockHash>; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use bp_runtime::BasicOperatingMode; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config { + /// The overarching event type. + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; + + /// The chain we are bridging to here. + type BridgedChain: ChainWithGrandpa; + + /// Maximal number of "free" mandatory header transactions per block. + /// + /// To be able to track the bridged chain, the pallet requires all headers that are + /// changing GRANDPA authorities set at the bridged chain (we call them mandatory). + /// So it is a common good deed to submit mandatory headers to the pallet. However, if the + /// bridged chain gets compromised, its validators may generate as many mandatory headers + /// as they want. And they may fill the whole block (at this chain) for free. This constants + /// limits number of calls that we may refund in a single block. All calls above this + /// limit are accepted, but are not refunded. + #[pallet::constant] + type MaxFreeMandatoryHeadersPerBlock: Get; + + /// Maximal number of finalized headers to keep in the storage. + /// + /// The setting is there to prevent growing the on-chain state indefinitely. Note + /// the setting does not relate to block numbers - we will simply keep as much items + /// in the storage, so it doesn't guarantee any fixed timeframe for finality headers. + /// + /// Incautious change of this constant may lead to orphan entries in the runtime storage. + #[pallet::constant] + type HeadersToKeep: Get; + + /// Weights gathered through benchmarking. + type WeightInfo: WeightInfo; + } + + #[pallet::pallet] + pub struct Pallet(PhantomData<(T, I)>); + + #[pallet::hooks] + impl, I: 'static> Hooks> for Pallet { + fn on_initialize(_n: BlockNumberFor) -> Weight { + FreeMandatoryHeadersRemaining::::put(T::MaxFreeMandatoryHeadersPerBlock::get()); + Weight::zero() + } + + fn on_finalize(_n: BlockNumberFor) { + FreeMandatoryHeadersRemaining::::kill(); + } + } + + impl, I: 'static> OwnedBridgeModule for Pallet { + const LOG_TARGET: &'static str = LOG_TARGET; + type OwnerStorage = PalletOwner; + type OperatingMode = BasicOperatingMode; + type OperatingModeStorage = PalletOperatingMode; + } + + #[pallet::call] + impl, I: 'static> Pallet { + /// Verify a target header is finalized according to the given finality proof. + /// + /// It will use the underlying storage pallet to fetch information about the current + /// authorities and best finalized header in order to verify that the header is finalized. + /// + /// If successful in verification, it will write the target header to the underlying storage + /// pallet. + /// + /// The call fails if: + /// + /// - the pallet is halted; + /// + /// - the pallet knows better header than the `finality_target`; + /// + /// - verification is not optimized or invalid; + /// + /// - header contains forced authorities set change or change with non-zero delay. + #[pallet::call_index(0)] + #[pallet::weight(::submit_finality_proof( + justification.commit.precommits.len().saturated_into(), + justification.votes_ancestries.len().saturated_into(), + ))] + pub fn submit_finality_proof( + _origin: OriginFor, + finality_target: Box>, + justification: GrandpaJustification>, + ) -> DispatchResultWithPostInfo { + Self::ensure_not_halted().map_err(Error::::BridgeModule)?; + + let (hash, number) = (finality_target.hash(), *finality_target.number()); + log::trace!( + target: LOG_TARGET, + "Going to try and finalize header {:?}", + finality_target + ); + + SubmitFinalityProofHelper::::check_obsolete(number)?; + + let authority_set = >::get(); + let unused_proof_size = authority_set.unused_proof_size(); + let set_id = authority_set.set_id; + verify_justification::(&justification, hash, number, authority_set.into())?; + + let is_authorities_change_enacted = + try_enact_authority_change::(&finality_target, set_id)?; + let may_refund_call_fee = is_authorities_change_enacted && + // if we have seen too many mandatory headers in this block, we don't want to refund + Self::free_mandatory_headers_remaining() > 0 && + // if arguments out of expected bounds, we don't want to refund + submit_finality_proof_info_from_args::(&finality_target, &justification) + .fits_limits(); + if may_refund_call_fee { + FreeMandatoryHeadersRemaining::::mutate(|count| { + *count = count.saturating_sub(1) + }); + } + insert_header::(*finality_target, hash); + log::info!( + target: LOG_TARGET, + "Successfully imported finalized header with hash {:?}!", + hash + ); + + // mandatory header is a header that changes authorities set. The pallet can't go + // further without importing this header. So every bridge MUST import mandatory headers. + // + // We don't want to charge extra costs for mandatory operations. So relayer is not + // paying fee for mandatory headers import transactions. + // + // If size/weight of the call is exceeds our estimated limits, the relayer still needs + // to pay for the transaction. + let pays_fee = if may_refund_call_fee { Pays::No } else { Pays::Yes }; + + // the proof size component of the call weight assumes that there are + // `MaxBridgedAuthorities` in the `CurrentAuthoritySet` (we use `MaxEncodedLen` + // estimation). But if their number is lower, then we may "refund" some `proof_size`, + // making proof smaller and leaving block space to other useful transactions + let pre_dispatch_weight = T::WeightInfo::submit_finality_proof( + justification.commit.precommits.len().saturated_into(), + justification.votes_ancestries.len().saturated_into(), + ); + let actual_weight = pre_dispatch_weight + .set_proof_size(pre_dispatch_weight.proof_size().saturating_sub(unused_proof_size)); + + Self::deposit_event(Event::UpdatedBestFinalizedHeader { number, hash }); + + Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee }) + } + + /// Bootstrap the bridge pallet with an initial header and authority set from which to sync. + /// + /// The initial configuration provided does not need to be the genesis header of the bridged + /// chain, it can be any arbitrary header. You can also provide the next scheduled set + /// change if it is already know. + /// + /// This function is only allowed to be called from a trusted origin and writes to storage + /// with practically no checks in terms of the validity of the data. It is important that + /// you ensure that valid data is being passed in. + #[pallet::call_index(1)] + #[pallet::weight((T::DbWeight::get().reads_writes(2, 5), DispatchClass::Operational))] + pub fn initialize( + origin: OriginFor, + init_data: super::InitializationData>, + ) -> DispatchResultWithPostInfo { + Self::ensure_owner_or_root(origin)?; + + let init_allowed = !>::exists(); + ensure!(init_allowed, >::AlreadyInitialized); + initialize_bridge::(init_data.clone())?; + + log::info!( + target: LOG_TARGET, + "Pallet has been initialized with the following parameters: {:?}", + init_data + ); + + Ok(().into()) + } + + /// Change `PalletOwner`. + /// + /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(2)] + #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] + pub fn set_owner(origin: OriginFor, new_owner: Option) -> DispatchResult { + >::set_owner(origin, new_owner) + } + + /// Halt or resume all pallet operations. + /// + /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(3)] + #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] + pub fn set_operating_mode( + origin: OriginFor, + operating_mode: BasicOperatingMode, + ) -> DispatchResult { + >::set_operating_mode(origin, operating_mode) + } + } + + /// Number mandatory headers that we may accept in the current block for free (returning + /// `Pays::No`). + /// + /// If the `FreeMandatoryHeadersRemaining` hits zero, all following mandatory headers in the + /// current block are accepted with fee (`Pays::Yes` is returned). + /// + /// The `FreeMandatoryHeadersRemaining` is an ephemeral value that is set to + /// `MaxFreeMandatoryHeadersPerBlock` at each block initialization and is killed on block + /// finalization. So it never ends up in the storage trie. + #[pallet::storage] + #[pallet::whitelist_storage] + #[pallet::getter(fn free_mandatory_headers_remaining)] + pub(super) type FreeMandatoryHeadersRemaining, I: 'static = ()> = + StorageValue<_, u32, ValueQuery>; + + /// Hash of the header used to bootstrap the pallet. + #[pallet::storage] + pub(super) type InitialHash, I: 'static = ()> = + StorageValue<_, BridgedBlockHash, ValueQuery>; + + /// Hash of the best finalized header. + #[pallet::storage] + #[pallet::getter(fn best_finalized)] + pub type BestFinalized, I: 'static = ()> = + StorageValue<_, BridgedBlockId, OptionQuery>; + + /// A ring buffer of imported hashes. Ordered by the insertion time. + #[pallet::storage] + pub(super) type ImportedHashes, I: 'static = ()> = StorageMap< + Hasher = Identity, + Key = u32, + Value = BridgedBlockHash, + QueryKind = OptionQuery, + OnEmpty = GetDefault, + MaxValues = MaybeHeadersToKeep, + >; + + /// Current ring buffer position. + #[pallet::storage] + pub(super) type ImportedHashesPointer, I: 'static = ()> = + StorageValue<_, u32, ValueQuery>; + + /// Relevant fields of imported headers. + #[pallet::storage] + pub type ImportedHeaders, I: 'static = ()> = StorageMap< + Hasher = Identity, + Key = BridgedBlockHash, + Value = BridgedStoredHeaderData, + QueryKind = OptionQuery, + OnEmpty = GetDefault, + MaxValues = MaybeHeadersToKeep, + >; + + /// The current GRANDPA Authority set. + #[pallet::storage] + pub type CurrentAuthoritySet, I: 'static = ()> = + StorageValue<_, StoredAuthoritySet, ValueQuery>; + + /// Optional pallet owner. + /// + /// Pallet owner has a right to halt all pallet operations and then resume it. If it is + /// `None`, then there are no direct ways to halt/resume pallet operations, but other + /// runtime methods may still be used to do that (i.e. democracy::referendum to update halt + /// flag directly or call the `halt_operations`). + #[pallet::storage] + pub type PalletOwner, I: 'static = ()> = + StorageValue<_, T::AccountId, OptionQuery>; + + /// The current operating mode of the pallet. + /// + /// Depending on the mode either all, or no transactions will be allowed. + #[pallet::storage] + pub type PalletOperatingMode, I: 'static = ()> = + StorageValue<_, BasicOperatingMode, ValueQuery>; + + #[pallet::genesis_config] + #[derive(DefaultNoBound)] + pub struct GenesisConfig, I: 'static = ()> { + /// Optional module owner account. + pub owner: Option, + /// Optional module initialization data. + pub init_data: Option>>, + } + + #[pallet::genesis_build] + impl, I: 'static> GenesisBuild for GenesisConfig { + fn build(&self) { + if let Some(ref owner) = self.owner { + >::put(owner); + } + + if let Some(init_data) = self.init_data.clone() { + initialize_bridge::(init_data).expect("genesis config is correct; qed"); + } else { + // Since the bridge hasn't been initialized we shouldn't allow anyone to perform + // transactions. + >::put(BasicOperatingMode::Halted); + } + } + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event, I: 'static = ()> { + /// Best finalized chain header has been updated to the header with given number and hash. + UpdatedBestFinalizedHeader { + number: BridgedBlockNumber, + hash: BridgedBlockHash, + }, + } + + #[pallet::error] + pub enum Error { + /// The given justification is invalid for the given header. + InvalidJustification, + /// The authority set from the underlying header chain is invalid. + InvalidAuthoritySet, + /// The header being imported is older than the best finalized header known to the pallet. + OldHeader, + /// The scheduled authority set change found in the header is unsupported by the pallet. + /// + /// This is the case for non-standard (e.g forced) authority set changes. + UnsupportedScheduledChange, + /// The pallet is not yet initialized. + NotInitialized, + /// The pallet has already been initialized. + AlreadyInitialized, + /// Too many authorities in the set. + TooManyAuthoritiesInSet, + /// Error generated by the `OwnedBridgeModule` trait. + BridgeModule(bp_runtime::OwnedBridgeModuleError), + } + + /// Check the given header for a GRANDPA scheduled authority set change. If a change + /// is found it will be enacted immediately. + /// + /// This function does not support forced changes, or scheduled changes with delays + /// since these types of changes are indicative of abnormal behavior from GRANDPA. + /// + /// Returned value will indicate if a change was enacted or not. + pub(crate) fn try_enact_authority_change, I: 'static>( + header: &BridgedHeader, + current_set_id: sp_consensus_grandpa::SetId, + ) -> Result { + let mut change_enacted = false; + + // We don't support forced changes - at that point governance intervention is required. + ensure!( + super::find_forced_change(header).is_none(), + >::UnsupportedScheduledChange + ); + + if let Some(change) = super::find_scheduled_change(header) { + // GRANDPA only includes a `delay` for forced changes, so this isn't valid. + ensure!(change.delay == Zero::zero(), >::UnsupportedScheduledChange); + + // TODO [#788]: Stop manually increasing the `set_id` here. + let next_authorities = StoredAuthoritySet:: { + authorities: change + .next_authorities + .try_into() + .map_err(|_| Error::::TooManyAuthoritiesInSet)?, + set_id: current_set_id + 1, + }; + + // Since our header schedules a change and we know the delay is 0, it must also enact + // the change. + >::put(&next_authorities); + change_enacted = true; + + log::info!( + target: LOG_TARGET, + "Transitioned from authority set {} to {}! New authorities are: {:?}", + current_set_id, + current_set_id + 1, + next_authorities, + ); + }; + + Ok(change_enacted) + } + + /// Verify a GRANDPA justification (finality proof) for a given header. + /// + /// Will use the GRANDPA current authorities known to the pallet. + /// + /// If successful it returns the decoded GRANDPA justification so we can refund any weight which + /// was overcharged in the initial call. + pub(crate) fn verify_justification, I: 'static>( + justification: &GrandpaJustification>, + hash: BridgedBlockHash, + number: BridgedBlockNumber, + authority_set: bp_header_chain::AuthoritySet, + ) -> Result<(), sp_runtime::DispatchError> { + use bp_header_chain::justification::verify_justification; + + let voter_set = + VoterSet::new(authority_set.authorities).ok_or(>::InvalidAuthoritySet)?; + let set_id = authority_set.set_id; + + Ok(verify_justification::>( + (hash, number), + set_id, + &voter_set, + justification, + ) + .map_err(|e| { + log::error!( + target: LOG_TARGET, + "Received invalid justification for {:?}: {:?}", + hash, + e, + ); + >::InvalidJustification + })?) + } + + /// Import a previously verified header to the storage. + /// + /// Note this function solely takes care of updating the storage and pruning old entries, + /// but does not verify the validity of such import. + pub(crate) fn insert_header, I: 'static>( + header: BridgedHeader, + hash: BridgedBlockHash, + ) { + let index = >::get(); + let pruning = >::try_get(index); + >::put(HeaderId(*header.number(), hash)); + >::insert(hash, header.build()); + >::insert(index, hash); + + // Update ring buffer pointer and remove old header. + >::put((index + 1) % T::HeadersToKeep::get()); + if let Ok(hash) = pruning { + log::debug!(target: LOG_TARGET, "Pruning old header: {:?}.", hash); + >::remove(hash); + } + } + + /// Since this writes to storage with no real checks this should only be used in functions that + /// were called by a trusted origin. + pub(crate) fn initialize_bridge, I: 'static>( + init_params: super::InitializationData>, + ) -> Result<(), Error> { + let super::InitializationData { header, authority_list, set_id, operating_mode } = + init_params; + let authority_set_length = authority_list.len(); + let authority_set = StoredAuthoritySet::::try_new(authority_list, set_id) + .map_err(|e| { + log::error!( + target: LOG_TARGET, + "Failed to initialize bridge. Number of authorities in the set {} is larger than the configured value {}", + authority_set_length, + T::BridgedChain::MAX_AUTHORITIES_COUNT, + ); + + e + })?; + let initial_hash = header.hash(); + + >::put(initial_hash); + >::put(0); + insert_header::(*header, initial_hash); + + >::put(authority_set); + + >::put(operating_mode); + + Ok(()) + } + + /// Adapter for using `Config::HeadersToKeep` as `MaxValues` bound in our storage maps. + pub struct MaybeHeadersToKeep(PhantomData<(T, I)>); + + // this implementation is required to use the struct as `MaxValues` + impl, I: 'static> Get> for MaybeHeadersToKeep { + fn get() -> Option { + Some(T::HeadersToKeep::get()) + } + } + + /// Initialize pallet so that it is ready for inserting new header. + /// + /// The function makes sure that the new insertion will cause the pruning of some old header. + /// + /// Returns parent header for the new header. + #[cfg(feature = "runtime-benchmarks")] + pub(crate) fn bootstrap_bridge, I: 'static>( + init_params: super::InitializationData>, + ) -> BridgedHeader { + let start_header = init_params.header.clone(); + initialize_bridge::(init_params).expect("benchmarks are correct"); + + // the most obvious way to cause pruning during next insertion would be to insert + // `HeadersToKeep` headers. But it'll make our benchmarks slow. So we will just play with + // our pruning ring-buffer. + assert_eq!(ImportedHashesPointer::::get(), 1); + ImportedHashesPointer::::put(0); + + *start_header + } +} + +impl, I: 'static> Pallet { + /// Get the best finalized block number. + pub fn best_finalized_number() -> Option> { + BestFinalized::::get().map(|id| id.number()) + } +} + +/// Bridge GRANDPA pallet as header chain. +pub type GrandpaChainHeaders = Pallet; + +impl, I: 'static> HeaderChain> for GrandpaChainHeaders { + fn finalized_header_state_root( + header_hash: HashOf>, + ) -> Option>> { + ImportedHeaders::::get(header_hash).map(|h| h.state_root) + } +} + +pub(crate) fn find_scheduled_change( + header: &H, +) -> Option> { + use sp_runtime::generic::OpaqueDigestItemId; + + let id = OpaqueDigestItemId::Consensus(&GRANDPA_ENGINE_ID); + + let filter_log = |log: ConsensusLog| match log { + ConsensusLog::ScheduledChange(change) => Some(change), + _ => None, + }; + + // find the first consensus digest with the right ID which converts to + // the right kind of consensus log. + header.digest().convert_first(|l| l.try_to(id).and_then(filter_log)) +} + +/// Checks the given header for a consensus digest signaling a **forced** scheduled change and +/// extracts it. +pub(crate) fn find_forced_change( + header: &H, +) -> Option<(H::Number, sp_consensus_grandpa::ScheduledChange)> { + use sp_runtime::generic::OpaqueDigestItemId; + + let id = OpaqueDigestItemId::Consensus(&GRANDPA_ENGINE_ID); + + let filter_log = |log: ConsensusLog| match log { + ConsensusLog::ForcedChange(delay, change) => Some((delay, change)), + _ => None, + }; + + // find the first consensus digest with the right ID which converts to + // the right kind of consensus log. + header.digest().convert_first(|l| l.try_to(id).and_then(filter_log)) +} + +/// (Re)initialize bridge with given header for using it in `pallet-bridge-messages` benchmarks. +#[cfg(feature = "runtime-benchmarks")] +pub fn initialize_for_benchmarks, I: 'static>(header: BridgedHeader) { + initialize_bridge::(InitializationData { + header: Box::new(header), + authority_list: sp_std::vec::Vec::new(), /* we don't verify any proofs in external + * benchmarks */ + set_id: 0, + operating_mode: bp_runtime::BasicOperatingMode::Normal, + }) + .expect("only used from benchmarks; benchmarks are correct; qed"); +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::mock::{ + run_test, test_header, RuntimeEvent as TestEvent, RuntimeOrigin, System, TestBridgedChain, + TestHeader, TestNumber, TestRuntime, MAX_BRIDGED_AUTHORITIES, + }; + use bp_header_chain::BridgeGrandpaCall; + use bp_runtime::BasicOperatingMode; + use bp_test_utils::{ + authority_list, generate_owned_bridge_module_tests, make_default_justification, + make_justification_for_header, JustificationGeneratorParams, ALICE, BOB, + }; + use codec::Encode; + use frame_support::{ + assert_err, assert_noop, assert_ok, + dispatch::{Pays, PostDispatchInfo}, + storage::generator::StorageValue, + }; + use frame_system::{EventRecord, Phase}; + use sp_core::Get; + use sp_runtime::{Digest, DigestItem, DispatchError}; + + fn initialize_substrate_bridge() { + System::set_block_number(1); + System::reset_events(); + + assert_ok!(init_with_origin(RuntimeOrigin::root())); + } + + fn init_with_origin( + origin: RuntimeOrigin, + ) -> Result< + InitializationData, + sp_runtime::DispatchErrorWithPostInfo, + > { + let genesis = test_header(0); + + let init_data = InitializationData { + header: Box::new(genesis), + authority_list: authority_list(), + set_id: 1, + operating_mode: BasicOperatingMode::Normal, + }; + + Pallet::::initialize(origin, init_data.clone()).map(|_| init_data) + } + + fn submit_finality_proof(header: u8) -> frame_support::dispatch::DispatchResultWithPostInfo { + let header = test_header(header.into()); + let justification = make_default_justification(&header); + + Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header), + justification, + ) + } + + fn submit_finality_proof_with_set_id( + header: u8, + set_id: u64, + ) -> frame_support::dispatch::DispatchResultWithPostInfo { + let header = test_header(header.into()); + let justification = make_justification_for_header(JustificationGeneratorParams { + header: header.clone(), + set_id, + ..Default::default() + }); + + Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header), + justification, + ) + } + + fn submit_mandatory_finality_proof( + number: u8, + set_id: u64, + ) -> frame_support::dispatch::DispatchResultWithPostInfo { + let mut header = test_header(number.into()); + // to ease tests that are using `submit_mandatory_finality_proof`, we'll be using the + // same set for all sessions + let consensus_log = + ConsensusLog::::ScheduledChange(sp_consensus_grandpa::ScheduledChange { + next_authorities: authority_list(), + delay: 0, + }); + header.digest = + Digest { logs: vec![DigestItem::Consensus(GRANDPA_ENGINE_ID, consensus_log.encode())] }; + let justification = make_justification_for_header(JustificationGeneratorParams { + header: header.clone(), + set_id, + ..Default::default() + }); + + Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header), + justification, + ) + } + + fn next_block() { + use frame_support::traits::OnInitialize; + + let current_number = frame_system::Pallet::::block_number(); + frame_system::Pallet::::set_block_number(current_number + 1); + let _ = Pallet::::on_initialize(current_number); + } + + fn change_log(delay: u64) -> Digest { + let consensus_log = + ConsensusLog::::ScheduledChange(sp_consensus_grandpa::ScheduledChange { + next_authorities: vec![(ALICE.into(), 1), (BOB.into(), 1)], + delay, + }); + + Digest { logs: vec![DigestItem::Consensus(GRANDPA_ENGINE_ID, consensus_log.encode())] } + } + + fn forced_change_log(delay: u64) -> Digest { + let consensus_log = ConsensusLog::::ForcedChange( + delay, + sp_consensus_grandpa::ScheduledChange { + next_authorities: vec![(ALICE.into(), 1), (BOB.into(), 1)], + delay, + }, + ); + + Digest { logs: vec![DigestItem::Consensus(GRANDPA_ENGINE_ID, consensus_log.encode())] } + } + + fn many_authorities_log() -> Digest { + let consensus_log = + ConsensusLog::::ScheduledChange(sp_consensus_grandpa::ScheduledChange { + next_authorities: std::iter::repeat((ALICE.into(), 1)) + .take(MAX_BRIDGED_AUTHORITIES as usize + 1) + .collect(), + delay: 0, + }); + + Digest { logs: vec![DigestItem::Consensus(GRANDPA_ENGINE_ID, consensus_log.encode())] } + } + + #[test] + fn init_root_or_owner_origin_can_initialize_pallet() { + run_test(|| { + assert_noop!(init_with_origin(RuntimeOrigin::signed(1)), DispatchError::BadOrigin); + assert_ok!(init_with_origin(RuntimeOrigin::root())); + + // Reset storage so we can initialize the pallet again + BestFinalized::::kill(); + PalletOwner::::put(2); + assert_ok!(init_with_origin(RuntimeOrigin::signed(2))); + }) + } + + #[test] + fn init_storage_entries_are_correctly_initialized() { + run_test(|| { + assert_eq!(BestFinalized::::get(), None,); + assert_eq!(Pallet::::best_finalized(), None); + assert_eq!(PalletOperatingMode::::try_get(), Err(())); + + let init_data = init_with_origin(RuntimeOrigin::root()).unwrap(); + + assert!(>::contains_key(init_data.header.hash())); + assert_eq!(BestFinalized::::get().unwrap().1, init_data.header.hash()); + assert_eq!( + CurrentAuthoritySet::::get().authorities, + init_data.authority_list + ); + assert_eq!( + PalletOperatingMode::::try_get(), + Ok(BasicOperatingMode::Normal) + ); + }) + } + + #[test] + fn init_can_only_initialize_pallet_once() { + run_test(|| { + initialize_substrate_bridge(); + assert_noop!( + init_with_origin(RuntimeOrigin::root()), + >::AlreadyInitialized + ); + }) + } + + #[test] + fn init_fails_if_there_are_too_many_authorities_in_the_set() { + run_test(|| { + let genesis = test_header(0); + let init_data = InitializationData { + header: Box::new(genesis), + authority_list: std::iter::repeat(authority_list().remove(0)) + .take(MAX_BRIDGED_AUTHORITIES as usize + 1) + .collect(), + set_id: 1, + operating_mode: BasicOperatingMode::Normal, + }; + + assert_noop!( + Pallet::::initialize(RuntimeOrigin::root(), init_data), + Error::::TooManyAuthoritiesInSet, + ); + }); + } + + #[test] + fn pallet_rejects_transactions_if_halted() { + run_test(|| { + initialize_substrate_bridge(); + + assert_ok!(Pallet::::set_operating_mode( + RuntimeOrigin::root(), + BasicOperatingMode::Halted + )); + assert_noop!( + submit_finality_proof(1), + Error::::BridgeModule(bp_runtime::OwnedBridgeModuleError::Halted) + ); + + assert_ok!(Pallet::::set_operating_mode( + RuntimeOrigin::root(), + BasicOperatingMode::Normal + )); + assert_ok!(submit_finality_proof(1)); + }) + } + + #[test] + fn pallet_rejects_header_if_not_initialized_yet() { + run_test(|| { + assert_noop!(submit_finality_proof(1), Error::::NotInitialized); + }); + } + + #[test] + fn succesfully_imports_header_with_valid_finality() { + run_test(|| { + initialize_substrate_bridge(); + + let header_number = 1; + let header = test_header(header_number.into()); + let justification = make_default_justification(&header); + + let pre_dispatch_weight = ::WeightInfo::submit_finality_proof( + justification.commit.precommits.len().try_into().unwrap_or(u32::MAX), + justification.votes_ancestries.len().try_into().unwrap_or(u32::MAX), + ); + + let result = submit_finality_proof(header_number); + assert_ok!(result); + assert_eq!(result.unwrap().pays_fee, frame_support::dispatch::Pays::Yes); + // our test config assumes 2048 max authorities and we are just using couple + let pre_dispatch_proof_size = pre_dispatch_weight.proof_size(); + let actual_proof_size = result.unwrap().actual_weight.unwrap().proof_size(); + assert!(actual_proof_size > 0); + assert!( + actual_proof_size < pre_dispatch_proof_size, + "Actual proof size {actual_proof_size} must be less than the pre-dispatch {pre_dispatch_proof_size}", + ); + + let header = test_header(1); + assert_eq!(>::get().unwrap().1, header.hash()); + assert!(>::contains_key(header.hash())); + + assert_eq!( + System::events(), + vec![EventRecord { + phase: Phase::Initialization, + event: TestEvent::Grandpa(Event::UpdatedBestFinalizedHeader { + number: *header.number(), + hash: header.hash(), + }), + topics: vec![], + }], + ); + }) + } + + #[test] + fn rejects_justification_that_skips_authority_set_transition() { + run_test(|| { + initialize_substrate_bridge(); + + let header = test_header(1); + + let params = + JustificationGeneratorParams:: { set_id: 2, ..Default::default() }; + let justification = make_justification_for_header(params); + + assert_err!( + Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header), + justification, + ), + >::InvalidJustification + ); + }) + } + + #[test] + fn does_not_import_header_with_invalid_finality_proof() { + run_test(|| { + initialize_substrate_bridge(); + + let header = test_header(1); + let mut justification = make_default_justification(&header); + justification.round = 42; + + assert_err!( + Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header), + justification, + ), + >::InvalidJustification + ); + }) + } + + #[test] + fn disallows_invalid_authority_set() { + run_test(|| { + let genesis = test_header(0); + + let invalid_authority_list = vec![(ALICE.into(), u64::MAX), (BOB.into(), u64::MAX)]; + let init_data = InitializationData { + header: Box::new(genesis), + authority_list: invalid_authority_list, + set_id: 1, + operating_mode: BasicOperatingMode::Normal, + }; + + assert_ok!(Pallet::::initialize(RuntimeOrigin::root(), init_data)); + + let header = test_header(1); + let justification = make_default_justification(&header); + + assert_err!( + Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header), + justification, + ), + >::InvalidAuthoritySet + ); + }) + } + + #[test] + fn importing_header_ensures_that_chain_is_extended() { + run_test(|| { + initialize_substrate_bridge(); + + assert_ok!(submit_finality_proof(4)); + assert_err!(submit_finality_proof(3), Error::::OldHeader); + assert_ok!(submit_finality_proof(5)); + }) + } + + #[test] + fn importing_header_enacts_new_authority_set() { + run_test(|| { + initialize_substrate_bridge(); + + let next_set_id = 2; + let next_authorities = vec![(ALICE.into(), 1), (BOB.into(), 1)]; + + // Need to update the header digest to indicate that our header signals an authority set + // change. The change will be enacted when we import our header. + let mut header = test_header(2); + header.digest = change_log(0); + + // Create a valid justification for the header + let justification = make_default_justification(&header); + + // Let's import our test header + let result = Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header.clone()), + justification, + ); + assert_ok!(result); + assert_eq!(result.unwrap().pays_fee, frame_support::dispatch::Pays::No); + + // Make sure that our header is the best finalized + assert_eq!(>::get().unwrap().1, header.hash()); + assert!(>::contains_key(header.hash())); + + // Make sure that the authority set actually changed upon importing our header + assert_eq!( + >::get(), + StoredAuthoritySet::::try_new(next_authorities, next_set_id) + .unwrap(), + ); + }) + } + + #[test] + fn relayer_pays_tx_fee_when_submitting_huge_mandatory_header() { + run_test(|| { + initialize_substrate_bridge(); + + // let's prepare a huge authorities change header, which is definitely above size limits + let mut header = test_header(2); + header.digest = change_log(0); + header.digest.push(DigestItem::Other(vec![42u8; 1024 * 1024])); + let justification = make_default_justification(&header); + + // without large digest item ^^^ the relayer would have paid zero transaction fee + // (`Pays::No`) + let result = Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header.clone()), + justification, + ); + assert_ok!(result); + assert_eq!(result.unwrap().pays_fee, frame_support::dispatch::Pays::Yes); + + // Make sure that our header is the best finalized + assert_eq!(>::get().unwrap().1, header.hash()); + assert!(>::contains_key(header.hash())); + }) + } + + #[test] + fn relayer_pays_tx_fee_when_submitting_justification_with_long_ancestry_votes() { + run_test(|| { + initialize_substrate_bridge(); + + // let's prepare a huge authorities change header, which is definitely above weight + // limits + let mut header = test_header(2); + header.digest = change_log(0); + let justification = make_justification_for_header(JustificationGeneratorParams { + header: header.clone(), + ancestors: TestBridgedChain::REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY + 1, + ..Default::default() + }); + + // without many headers in votes ancestries ^^^ the relayer would have paid zero + // transaction fee (`Pays::No`) + let result = Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header.clone()), + justification, + ); + assert_ok!(result); + assert_eq!(result.unwrap().pays_fee, frame_support::dispatch::Pays::Yes); + + // Make sure that our header is the best finalized + assert_eq!(>::get().unwrap().1, header.hash()); + assert!(>::contains_key(header.hash())); + }) + } + + #[test] + fn importing_header_rejects_header_with_scheduled_change_delay() { + run_test(|| { + initialize_substrate_bridge(); + + // Need to update the header digest to indicate that our header signals an authority set + // change. However, the change doesn't happen until the next block. + let mut header = test_header(2); + header.digest = change_log(1); + + // Create a valid justification for the header + let justification = make_default_justification(&header); + + // Should not be allowed to import this header + assert_err!( + Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header), + justification + ), + >::UnsupportedScheduledChange + ); + }) + } + + #[test] + fn importing_header_rejects_header_with_forced_changes() { + run_test(|| { + initialize_substrate_bridge(); + + // Need to update the header digest to indicate that it signals a forced authority set + // change. + let mut header = test_header(2); + header.digest = forced_change_log(0); + + // Create a valid justification for the header + let justification = make_default_justification(&header); + + // Should not be allowed to import this header + assert_err!( + Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header), + justification + ), + >::UnsupportedScheduledChange + ); + }) + } + + #[test] + fn importing_header_rejects_header_with_too_many_authorities() { + run_test(|| { + initialize_substrate_bridge(); + + // Need to update the header digest to indicate that our header signals an authority set + // change. However, the change doesn't happen until the next block. + let mut header = test_header(2); + header.digest = many_authorities_log(); + + // Create a valid justification for the header + let justification = make_default_justification(&header); + + // Should not be allowed to import this header + assert_err!( + Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header), + justification + ), + >::TooManyAuthoritiesInSet + ); + }); + } + + #[test] + fn parse_finalized_storage_proof_rejects_proof_on_unknown_header() { + run_test(|| { + assert_noop!( + Pallet::::storage_proof_checker(Default::default(), vec![],) + .map(|_| ()), + bp_header_chain::HeaderChainError::UnknownHeader, + ); + }); + } + + #[test] + fn parse_finalized_storage_accepts_valid_proof() { + run_test(|| { + let (state_root, storage_proof) = bp_runtime::craft_valid_storage_proof(); + + let mut header = test_header(2); + header.set_state_root(state_root); + + let hash = header.hash(); + >::put(HeaderId(2, hash)); + >::insert(hash, header.build()); + + assert_ok!( + Pallet::::storage_proof_checker(hash, storage_proof).map(|_| ()) + ); + }); + } + + #[test] + fn rate_limiter_disallows_free_imports_once_limit_is_hit_in_single_block() { + run_test(|| { + initialize_substrate_bridge(); + + let result = submit_mandatory_finality_proof(1, 1); + assert_eq!(result.expect("call failed").pays_fee, Pays::No); + + let result = submit_mandatory_finality_proof(2, 2); + assert_eq!(result.expect("call failed").pays_fee, Pays::No); + + let result = submit_mandatory_finality_proof(3, 3); + assert_eq!(result.expect("call failed").pays_fee, Pays::Yes); + }) + } + + #[test] + fn rate_limiter_invalid_requests_do_not_count_towards_request_count() { + run_test(|| { + let submit_invalid_request = || { + let mut header = test_header(1); + header.digest = change_log(0); + let mut invalid_justification = make_default_justification(&header); + invalid_justification.round = 42; + + Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header), + invalid_justification, + ) + }; + + initialize_substrate_bridge(); + + for _ in 0..::MaxFreeMandatoryHeadersPerBlock::get() + 1 { + assert_err!(submit_invalid_request(), >::InvalidJustification); + } + + // Can still submit free mandatory headers afterwards + let result = submit_mandatory_finality_proof(1, 1); + assert_eq!(result.expect("call failed").pays_fee, Pays::No); + + let result = submit_mandatory_finality_proof(2, 2); + assert_eq!(result.expect("call failed").pays_fee, Pays::No); + + let result = submit_mandatory_finality_proof(3, 3); + assert_eq!(result.expect("call failed").pays_fee, Pays::Yes); + }) + } + + #[test] + fn rate_limiter_allows_request_after_new_block_has_started() { + run_test(|| { + initialize_substrate_bridge(); + + let result = submit_mandatory_finality_proof(1, 1); + assert_eq!(result.expect("call failed").pays_fee, Pays::No); + + let result = submit_mandatory_finality_proof(2, 2); + assert_eq!(result.expect("call failed").pays_fee, Pays::No); + + let result = submit_mandatory_finality_proof(3, 3); + assert_eq!(result.expect("call failed").pays_fee, Pays::Yes); + + next_block(); + + let result = submit_mandatory_finality_proof(4, 4); + assert_eq!(result.expect("call failed").pays_fee, Pays::No); + + let result = submit_mandatory_finality_proof(5, 5); + assert_eq!(result.expect("call failed").pays_fee, Pays::No); + + let result = submit_mandatory_finality_proof(6, 6); + assert_eq!(result.expect("call failed").pays_fee, Pays::Yes); + }) + } + + #[test] + fn rate_limiter_ignores_non_mandatory_headers() { + run_test(|| { + initialize_substrate_bridge(); + + let result = submit_finality_proof(1); + assert_eq!(result.expect("call failed").pays_fee, Pays::Yes); + + let result = submit_mandatory_finality_proof(2, 1); + assert_eq!(result.expect("call failed").pays_fee, Pays::No); + + let result = submit_finality_proof_with_set_id(3, 2); + assert_eq!(result.expect("call failed").pays_fee, Pays::Yes); + + let result = submit_mandatory_finality_proof(4, 2); + assert_eq!(result.expect("call failed").pays_fee, Pays::No); + + let result = submit_finality_proof_with_set_id(5, 3); + assert_eq!(result.expect("call failed").pays_fee, Pays::Yes); + + let result = submit_mandatory_finality_proof(6, 3); + assert_eq!(result.expect("call failed").pays_fee, Pays::Yes); + }) + } + + #[test] + fn should_prune_headers_over_headers_to_keep_parameter() { + run_test(|| { + initialize_substrate_bridge(); + assert_ok!(submit_finality_proof(1)); + let first_header_hash = Pallet::::best_finalized().unwrap().hash(); + next_block(); + + assert_ok!(submit_finality_proof(2)); + next_block(); + assert_ok!(submit_finality_proof(3)); + next_block(); + assert_ok!(submit_finality_proof(4)); + next_block(); + assert_ok!(submit_finality_proof(5)); + next_block(); + + assert_ok!(submit_finality_proof(6)); + + assert!( + !ImportedHeaders::::contains_key(first_header_hash), + "First header should be pruned.", + ); + }) + } + + #[test] + fn storage_keys_computed_properly() { + assert_eq!( + PalletOperatingMode::::storage_value_final_key().to_vec(), + bp_header_chain::storage_keys::pallet_operating_mode_key("Grandpa").0, + ); + + assert_eq!( + CurrentAuthoritySet::::storage_value_final_key().to_vec(), + bp_header_chain::storage_keys::current_authority_set_key("Grandpa").0, + ); + + assert_eq!( + BestFinalized::::storage_value_final_key().to_vec(), + bp_header_chain::storage_keys::best_finalized_key("Grandpa").0, + ); + } + + #[test] + fn test_bridge_grandpa_call_is_correctly_defined() { + let header = test_header(0); + let init_data = InitializationData { + header: Box::new(header.clone()), + authority_list: authority_list(), + set_id: 1, + operating_mode: BasicOperatingMode::Normal, + }; + let justification = make_default_justification(&header); + + let direct_initialize_call = + Call::::initialize { init_data: init_data.clone() }; + let indirect_initialize_call = BridgeGrandpaCall::::initialize { init_data }; + assert_eq!(direct_initialize_call.encode(), indirect_initialize_call.encode()); + + let direct_submit_finality_proof_call = Call::::submit_finality_proof { + finality_target: Box::new(header.clone()), + justification: justification.clone(), + }; + let indirect_submit_finality_proof_call = + BridgeGrandpaCall::::submit_finality_proof { + finality_target: Box::new(header), + justification, + }; + assert_eq!( + direct_submit_finality_proof_call.encode(), + indirect_submit_finality_proof_call.encode() + ); + } + + generate_owned_bridge_module_tests!(BasicOperatingMode::Normal, BasicOperatingMode::Halted); + + #[test] + fn maybe_headers_to_keep_returns_correct_value() { + assert_eq!(MaybeHeadersToKeep::::get(), Some(mock::HeadersToKeep::get())); + } +} diff --git a/bridges/modules/grandpa/src/mock.rs b/bridges/modules/grandpa/src/mock.rs new file mode 100644 index 00000000000..0ebbc0bccbb --- /dev/null +++ b/bridges/modules/grandpa/src/mock.rs @@ -0,0 +1,151 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +// From construct_runtime macro +#![allow(clippy::from_over_into)] + +use bp_header_chain::ChainWithGrandpa; +use bp_runtime::Chain; +use frame_support::{ + construct_runtime, parameter_types, + traits::{ConstU32, ConstU64, Hooks}, + weights::Weight, +}; +use sp_core::sr25519::Signature; +use sp_runtime::{ + testing::{Header, H256}, + traits::{BlakeTwo256, IdentityLookup}, + Perbill, +}; + +pub type AccountId = u64; +pub type TestHeader = crate::BridgedHeader; +pub type TestNumber = crate::BridgedBlockNumber; + +type Block = frame_system::mocking::MockBlock; +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + +pub const MAX_BRIDGED_AUTHORITIES: u32 = 5; + +use crate as grandpa; + +construct_runtime! { + pub enum TestRuntime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Grandpa: grandpa::{Pallet, Call, Event}, + } +} + +parameter_types! { + pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); + pub const MaximumBlockLength: u32 = 2 * 1024; + pub const AvailableBlockRatio: Perbill = Perbill::one(); +} + +impl frame_system::Config for TestRuntime { + type RuntimeOrigin = RuntimeOrigin; + type Index = u64; + type RuntimeCall = RuntimeCall; + type BlockNumber = u64; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type Header = Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = ConstU64<250>; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); + type BaseCallFilter = frame_support::traits::Everything; + type SystemWeightInfo = (); + type DbWeight = (); + type BlockWeights = (); + type BlockLength = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = ConstU32<16>; +} + +parameter_types! { + pub const MaxFreeMandatoryHeadersPerBlock: u32 = 2; + pub const HeadersToKeep: u32 = 5; + pub const SessionLength: u64 = 5; + pub const NumValidators: u32 = 5; +} + +impl grandpa::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type BridgedChain = TestBridgedChain; + type MaxFreeMandatoryHeadersPerBlock = MaxFreeMandatoryHeadersPerBlock; + type HeadersToKeep = HeadersToKeep; + type WeightInfo = (); +} + +#[derive(Debug)] +pub struct TestBridgedChain; + +impl Chain for TestBridgedChain { + type BlockNumber = ::BlockNumber; + type Hash = ::Hash; + type Hasher = ::Hashing; + type Header = ::Header; + + type AccountId = AccountId; + type Balance = u64; + type Index = u64; + type Signature = Signature; + + fn max_extrinsic_size() -> u32 { + unreachable!() + } + fn max_extrinsic_weight() -> Weight { + unreachable!() + } +} + +impl ChainWithGrandpa for TestBridgedChain { + const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = ""; + const MAX_AUTHORITIES_COUNT: u32 = MAX_BRIDGED_AUTHORITIES; + const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 8; + const MAX_HEADER_SIZE: u32 = 256; + const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 64; +} + +/// Return test externalities to use in tests. +pub fn new_test_ext() -> sp_io::TestExternalities { + sp_io::TestExternalities::new(Default::default()) +} + +/// Return test within default test externalities context. +pub fn run_test(test: impl FnOnce() -> T) -> T { + new_test_ext().execute_with(|| { + let _ = Grandpa::on_initialize(0); + test() + }) +} + +/// Return test header with given number. +pub fn test_header(num: TestNumber) -> TestHeader { + // We wrap the call to avoid explicit type annotations in our tests + bp_test_utils::test_header(num) +} diff --git a/bridges/modules/grandpa/src/storage_types.rs b/bridges/modules/grandpa/src/storage_types.rs new file mode 100644 index 00000000000..70448286335 --- /dev/null +++ b/bridges/modules/grandpa/src/storage_types.rs @@ -0,0 +1,136 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Wrappers for public types that are implementing `MaxEncodedLen` + +use crate::{Config, Error}; + +use bp_header_chain::{AuthoritySet, ChainWithGrandpa}; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{traits::Get, BoundedVec, RuntimeDebugNoBound}; +use scale_info::TypeInfo; +use sp_consensus_grandpa::{AuthorityId, AuthorityList, AuthorityWeight, SetId}; +use sp_std::marker::PhantomData; + +/// A bounded list of Grandpa authorities with associated weights. +pub type StoredAuthorityList = + BoundedVec<(AuthorityId, AuthorityWeight), MaxBridgedAuthorities>; + +/// Adapter for using `T::BridgedChain::MAX_BRIDGED_AUTHORITIES` in `BoundedVec`. +pub struct StoredAuthorityListLimit(PhantomData<(T, I)>); + +impl, I: 'static> Get for StoredAuthorityListLimit { + fn get() -> u32 { + T::BridgedChain::MAX_AUTHORITIES_COUNT + } +} + +/// A bounded GRANDPA Authority List and ID. +#[derive(Clone, Decode, Encode, Eq, TypeInfo, MaxEncodedLen, RuntimeDebugNoBound)] +#[scale_info(skip_type_params(T, I))] +pub struct StoredAuthoritySet, I: 'static> { + /// List of GRANDPA authorities for the current round. + pub authorities: StoredAuthorityList>, + /// Monotonic identifier of the current GRANDPA authority set. + pub set_id: SetId, +} + +impl, I: 'static> StoredAuthoritySet { + /// Try to create a new bounded GRANDPA Authority Set from unbounded list. + /// + /// Returns error if number of authorities in the provided list is too large. + pub fn try_new(authorities: AuthorityList, set_id: SetId) -> Result> { + Ok(Self { + authorities: TryFrom::try_from(authorities) + .map_err(|_| Error::TooManyAuthoritiesInSet)?, + set_id, + }) + } + + /// Returns number of bytes that may be subtracted from the PoV component of + /// `submit_finality_proof` call, because the actual authorities set is smaller than the maximal + /// configured. + /// + /// Maximal authorities set size is configured by the `MaxBridgedAuthorities` constant from + /// the pallet configuration. The PoV of the call includes the size of maximal authorities + /// count. If the actual size is smaller, we may subtract extra bytes from this component. + pub fn unused_proof_size(&self) -> u64 { + // we can only safely estimate bytes that are occupied by the authority data itself. We have + // no means here to compute PoV bytes, occupied by extra trie nodes or extra bytes in the + // whole set encoding + let single_authority_max_encoded_len = + <(AuthorityId, AuthorityWeight)>::max_encoded_len() as u64; + let extra_authorities = + T::BridgedChain::MAX_AUTHORITIES_COUNT.saturating_sub(self.authorities.len() as _); + single_authority_max_encoded_len.saturating_mul(extra_authorities as u64) + } +} + +impl, I: 'static> PartialEq for StoredAuthoritySet { + fn eq(&self, other: &Self) -> bool { + self.set_id == other.set_id && self.authorities == other.authorities + } +} + +impl, I: 'static> Default for StoredAuthoritySet { + fn default() -> Self { + StoredAuthoritySet { authorities: BoundedVec::default(), set_id: 0 } + } +} + +impl, I: 'static> From> for AuthoritySet { + fn from(t: StoredAuthoritySet) -> Self { + AuthoritySet { authorities: t.authorities.into(), set_id: t.set_id } + } +} + +#[cfg(test)] +mod tests { + use crate::mock::{TestRuntime, MAX_BRIDGED_AUTHORITIES}; + use bp_test_utils::authority_list; + + type StoredAuthoritySet = super::StoredAuthoritySet; + + #[test] + fn unused_proof_size_works() { + let authority_entry = authority_list().pop().unwrap(); + + // when we have exactly `MaxBridgedAuthorities` authorities + assert_eq!( + StoredAuthoritySet::try_new( + vec![authority_entry.clone(); MAX_BRIDGED_AUTHORITIES as usize], + 0, + ) + .unwrap() + .unused_proof_size(), + 0, + ); + + // when we have less than `MaxBridgedAuthorities` authorities + assert_eq!( + StoredAuthoritySet::try_new( + vec![authority_entry; MAX_BRIDGED_AUTHORITIES as usize - 1], + 0, + ) + .unwrap() + .unused_proof_size(), + 40, + ); + + // and we can't have more than `MaxBridgedAuthorities` authorities in the bounded vec, so + // no test for this case + } +} diff --git a/bridges/modules/grandpa/src/weights.rs b/bridges/modules/grandpa/src/weights.rs new file mode 100644 index 00000000000..4b94f7adfe7 --- /dev/null +++ b/bridges/modules/grandpa/src/weights.rs @@ -0,0 +1,167 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Autogenerated weights for pallet_bridge_grandpa +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-03-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/millau-bridge-node +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_bridge_grandpa +// --extrinsic=* +// --execution=wasm +// --wasm-execution=Compiled +// --heap-pages=4096 +// --output=./modules/grandpa/src/weights.rs +// --template=./.maintain/bridge-weight-template.hbs + +#![allow(clippy::all)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_bridge_grandpa. +pub trait WeightInfo { + fn submit_finality_proof(p: u32, v: u32) -> Weight; +} + +/// Weights for `pallet_bridge_grandpa` that are generated using one of the Bridge testnets. +/// +/// Those weights are test only and must never be used in production. +pub struct BridgeWeight(PhantomData); +impl WeightInfo for BridgeWeight { + /// Storage: BridgeRialtoGrandpa PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// added: 496, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa RequestCount (r:1 w:1) + /// + /// Proof: BridgeRialtoGrandpa RequestCount (max_values: Some(1), max_size: Some(4), added: 499, + /// mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa BestFinalized (r:1 w:1) + /// + /// Proof: BridgeRialtoGrandpa BestFinalized (max_values: Some(1), max_size: Some(36), added: + /// 531, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa CurrentAuthoritySet (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa CurrentAuthoritySet (max_values: Some(1), max_size: Some(209), + /// added: 704, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHashesPointer (r:1 w:1) + /// + /// Proof: BridgeRialtoGrandpa ImportedHashesPointer (max_values: Some(1), max_size: Some(4), + /// added: 499, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHashes (r:1 w:1) + /// + /// Proof: BridgeRialtoGrandpa ImportedHashes (max_values: Some(14400), max_size: Some(36), + /// added: 2016, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:0 w:2) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// The range of component `p` is `[1, 4]`. + /// + /// The range of component `v` is `[50, 100]`. + fn submit_finality_proof(p: u32, v: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `394 + p * (60 ±0)` + // Estimated: `4745` + // Minimum execution time: 228_072 nanoseconds. + Weight::from_parts(57_853_228, 4745) + // Standard Error: 149_421 + .saturating_add(Weight::from_parts(36_708_702, 0).saturating_mul(p.into())) + // Standard Error: 10_625 + .saturating_add(Weight::from_parts(1_469_032, 0).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: BridgeRialtoGrandpa PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// added: 496, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa RequestCount (r:1 w:1) + /// + /// Proof: BridgeRialtoGrandpa RequestCount (max_values: Some(1), max_size: Some(4), added: 499, + /// mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa BestFinalized (r:1 w:1) + /// + /// Proof: BridgeRialtoGrandpa BestFinalized (max_values: Some(1), max_size: Some(36), added: + /// 531, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa CurrentAuthoritySet (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa CurrentAuthoritySet (max_values: Some(1), max_size: Some(209), + /// added: 704, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHashesPointer (r:1 w:1) + /// + /// Proof: BridgeRialtoGrandpa ImportedHashesPointer (max_values: Some(1), max_size: Some(4), + /// added: 499, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHashes (r:1 w:1) + /// + /// Proof: BridgeRialtoGrandpa ImportedHashes (max_values: Some(14400), max_size: Some(36), + /// added: 2016, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:0 w:2) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// The range of component `p` is `[1, 4]`. + /// + /// The range of component `v` is `[50, 100]`. + fn submit_finality_proof(p: u32, v: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `394 + p * (60 ±0)` + // Estimated: `4745` + // Minimum execution time: 228_072 nanoseconds. + Weight::from_parts(57_853_228, 4745) + // Standard Error: 149_421 + .saturating_add(Weight::from_parts(36_708_702, 0).saturating_mul(p.into())) + // Standard Error: 10_625 + .saturating_add(Weight::from_parts(1_469_032, 0).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } +} diff --git a/bridges/modules/messages/Cargo.toml b/bridges/modules/messages/Cargo.toml new file mode 100644 index 00000000000..34120e6908a --- /dev/null +++ b/bridges/modules/messages/Cargo.toml @@ -0,0 +1,56 @@ +[package] +name = "pallet-bridge-messages" +description = "Module that allows bridged chains to exchange messages using lane concept." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } +log = { version = "0.4.18", default-features = false } +num-traits = { version = "0.2", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } + +# Bridge dependencies + +bp-messages = { path = "../../primitives/messages", default-features = false } +bp-runtime = { path = "../../primitives/runtime", default-features = false } + +# Substrate Dependencies + +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[dev-dependencies] +bp-test-utils = { path = "../../primitives/test-utils" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" } + +[features] +default = ["std"] +std = [ + "bp-messages/std", + "bp-runtime/std", + "codec/std", + "frame-support/std", + "frame-system/std", + "frame-benchmarking/std", + "log/std", + "num-traits/std", + "scale-info/std", + "sp-core/std", + "sp-runtime/std", + "sp-std/std", +] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", +] diff --git a/bridges/modules/messages/README.md b/bridges/modules/messages/README.md new file mode 100644 index 00000000000..b5250d0dca0 --- /dev/null +++ b/bridges/modules/messages/README.md @@ -0,0 +1,242 @@ +# Bridge Messages Pallet + +The messages pallet is used to deliver messages from source chain to target chain. Message is +(almost) opaque to the module and the final goal is to hand message to the message dispatch +mechanism. + +## Contents + +- [Overview](#overview) +- [Message Workflow](#message-workflow) +- [Integrating Message Lane Module into Runtime](#integrating-messages-module-into-runtime) +- [Non-Essential Functionality](#non-essential-functionality) +- [Weights of Module Extrinsics](#weights-of-module-extrinsics) + +## Overview + +Message lane is an unidirectional channel, where messages are sent from source chain to the target +chain. At the same time, a single instance of messages module supports both outbound lanes and +inbound lanes. So the chain where the module is deployed (this chain), may act as a source chain for +outbound messages (heading to a bridged chain) and as a target chain for inbound messages (coming +from a bridged chain). + +Messages module supports multiple message lanes. Every message lane is identified with a 4-byte +identifier. Messages sent through the lane are assigned unique (for this lane) increasing integer +value that is known as nonce ("number that can only be used once"). Messages that are sent over the +same lane are guaranteed to be delivered to the target chain in the same order they're sent from +the source chain. In other words, message with nonce `N` will be delivered right before delivering a +message with nonce `N+1`. + +Single message lane may be seen as a transport channel for single application (onchain, offchain or +mixed). At the same time the module itself never dictates any lane or message rules. In the end, it +is the runtime developer who defines what message lane and message mean for this runtime. + +In our [Kusama<>Polkadot bridge](../../docs/polkadot-kusama-bridge-overview.md) we are using lane +as a channel of communication between two parachains of different relay chains. For example, lane +`[0, 0, 0, 0]` is used for Polkadot <> Kusama Asset Hub communications. Other lanes may be used to +bridge other parachains. + +## Message Workflow + +The pallet is not intended to be used by end users and provides no public calls to send the message. +Instead, it provides runtime-internal method that allows other pallets (or other runtime code) to queue +outbound messages. + +The message "appears" when some runtime code calls the `send_message()` method of the pallet. +The submitter specifies the lane that they're willing to use and the message itself. If some fee must +be paid for sending the message, it must be paid outside of the pallet. If a message passes all checks +(that include, for example, message size check, disabled lane check, ...), the nonce is assigned and +the message is stored in the module storage. The message is in an "undelivered" state now. + +We assume that there are external, offchain actors, called relayers, that are submitting module +related transactions to both target and source chains. The pallet itself has no assumptions about +relayers incentivization scheme, but it has some callbacks for paying rewards. See +[Integrating Messages Module into runtime](#Integrating-Messages-Module-into-runtime) +for details. + +Eventually, some relayer would notice this message in the "undelivered" state and it would decide to +deliver this message. Relayer then crafts `receive_messages_proof()` transaction (aka delivery +transaction) for the messages module instance, deployed at the target chain. Relayer provides +its account id at the source chain, the proof of message (or several messages), the number of +messages in the transaction and their cumulative dispatch weight. Once a transaction is mined, the +message is considered "delivered". + +Once a message is delivered, the relayer may want to confirm delivery back to the source chain. +There are two reasons why it would want to do that. The first is that we intentionally limit number +of "delivered", but not yet "confirmed" messages at inbound lanes +(see [What about other Constants in the Messages Module Configuration Trait](#What-about-other-Constants-in-the-Messages-Module-Configuration-Trait) for explanation). +So at some point, the target chain may stop accepting new messages until relayers confirm some of +these. The second is that if the relayer wants to be rewarded for delivery, it must prove the fact +that it has actually delivered the message. And this proof may only be generated after the delivery +transaction is mined. So relayer crafts the `receive_messages_delivery_proof()` transaction (aka +confirmation transaction) for the messages module instance, deployed at the source chain. Once +this transaction is mined, the message is considered "confirmed". + +The "confirmed" state is the final state of the message. But there's one last thing related to the +message - the fact that it is now "confirmed" and reward has been paid to the relayer (or at least +callback for this has been called), must be confirmed to the target chain. Otherwise, we may reach +the limit of "unconfirmed" messages at the target chain and it will stop accepting new messages. So +relayer sometimes includes a nonce of the latest "confirmed" message in the next +`receive_messages_proof()` transaction, proving that some messages have been confirmed. + +## Integrating Messages Module into Runtime + +As it has been said above, the messages module supports both outbound and inbound message lanes. +So if we will integrate a module in some runtime, it may act as the source chain runtime for +outbound messages and as the target chain runtime for inbound messages. In this section, we'll +sometimes refer to the chain we're currently integrating with, as "this chain" and the other +chain as "bridged chain". + +Messages module doesn't simply accept transactions that are claiming that the bridged chain has +some updated data for us. Instead of this, the module assumes that the bridged chain is able to +prove that updated data in some way. The proof is abstracted from the module and may be of any kind. +In our Substrate-to-Substrate bridge we're using runtime storage proofs. Other bridges may use +transaction proofs, Substrate header digests or anything else that may be proved. + +**IMPORTANT NOTE**: everything below in this chapter describes details of the messages module +configuration. But if you're interested in well-probed and relatively easy integration of two +Substrate-based chains, you may want to look at the +[bridge-runtime-common](../../bin/runtime-common/) crate. This crate is providing a lot of +helpers for integration, which may be directly used from within your runtime. Then if you'll decide +to change something in this scheme, get back here for detailed information. + +### General Information + +The messages module supports instances. Every module instance is supposed to bridge this chain +and some bridged chain. To bridge with another chain, using another instance is suggested (this +isn't forced anywhere in the code, though). Keep in mind, that the pallet may be used to build +virtual channels between multiple chains, as we do in our [Polkadot <> Kusama bridge](../../docs/polkadot-kusama-bridge-overview.md). +There, the pallet actually bridges only two parachains - Kusama Bridge Hub and Polkadot +Bridge Hub. However, other Kusama and Polkadot parachains are able to send (XCM) messages to their +Bridge Hubs. The messages will be delivered to the other side of the bridge and routed to the proper +destination parachain within the bridged chain consensus. + +Message submitters may track message progress by inspecting module events. When Message is accepted, +the `MessageAccepted` event is emitted. The event contains both message lane identifier and nonce that +has been assigned to the message. When a message is delivered to the target chain, the `MessagesDelivered` +event is emitted from the `receive_messages_delivery_proof()` transaction. The `MessagesDelivered` contains +the message lane identifier and inclusive range of delivered message nonces. + +The pallet provides no means to get the result of message dispatch at the target chain. If that is +required, it must be done outside of the pallet. For example, XCM messages, when dispatched, have +special instructions to send some data back to the sender. Other dispatchers may use similar +mechanism for that. +### How to plug-in Messages Module to Send Messages to the Bridged Chain? + +The `pallet_bridge_messages::Config` trait has 3 main associated types that are used to work with +outbound messages. The `pallet_bridge_messages::Config::TargetHeaderChain` defines how we see the +bridged chain as the target for our outbound messages. It must be able to check that the bridged +chain may accept our message - like that the message has size below maximal possible transaction +size of the chain and so on. And when the relayer sends us a confirmation transaction, this +implementation must be able to parse and verify the proof of messages delivery. Normally, you would +reuse the same (configurable) type on all chains that are sending messages to the same bridged +chain. + +The `pallet_bridge_messages::Config::LaneMessageVerifier` defines a single callback to verify outbound +messages. The simplest callback may just accept all messages. But in this case you'll need to answer +many questions first. Who will pay for the delivery and confirmation transaction? Are we sure that +someone will ever deliver this message to the bridged chain? Are we sure that we don't bloat our +runtime storage by accepting this message? What if the message is improperly encoded or has some +fields set to invalid values? Answering all those (and similar) questions would lead to correct +implementation. + +There's another thing to consider when implementing type for use in +`pallet_bridge_messages::Config::LaneMessageVerifier`. It is whether we treat all message lanes +identically, or they'll have different sets of verification rules? For example, you may reserve +lane#1 for messages coming from some 'wrapped-token' pallet - then you may verify in your +implementation that the origin is associated with this pallet. Lane#2 may be reserved for 'system' +messages and you may charge zero fee for such messages. You may have some rate limiting for messages +sent over the lane#3. Or you may just verify the same rules set for all outbound messages - it is +all up to the `pallet_bridge_messages::Config::LaneMessageVerifier` implementation. + +The last type is the `pallet_bridge_messages::Config::DeliveryConfirmationPayments`. When confirmation +transaction is received, we call the `pay_reward()` method, passing the range of delivered messages. +You may use the [`pallet-bridge-relayers`](../relayers/) pallet and its +[`DeliveryConfirmationPaymentsAdapter`](../relayers/src/payment_adapter.rs) adapter as a possible +implementation. It allows you to pay fixed reward for relaying the message and some of its portion +for confirming delivery. + +### I have a Messages Module in my Runtime, but I Want to Reject all Outbound Messages. What shall I do? + +You should be looking at the `bp_messages::source_chain::ForbidOutboundMessages` structure +[`bp_messages::source_chain`](../../primitives/messages/src/source_chain.rs). It implements +all required traits and will simply reject all transactions, related to outbound messages. + +### How to plug-in Messages Module to Receive Messages from the Bridged Chain? + +The `pallet_bridge_messages::Config` trait has 2 main associated types that are used to work with +inbound messages. The `pallet_bridge_messages::Config::SourceHeaderChain` defines how we see the +bridged chain as the source of our inbound messages. When relayer sends us a delivery transaction, +this implementation must be able to parse and verify the proof of messages wrapped in this +transaction. Normally, you would reuse the same (configurable) type on all chains that are sending +messages to the same bridged chain. + +The `pallet_bridge_messages::Config::MessageDispatch` defines a way on how to dispatch delivered +messages. Apart from actually dispatching the message, the implementation must return the correct +dispatch weight of the message before dispatch is called. + +### I have a Messages Module in my Runtime, but I Want to Reject all Inbound Messages. What shall I do? + +You should be looking at the `bp_messages::target_chain::ForbidInboundMessages` structure from +the [`bp_messages::target_chain`](../../primitives/messages/src/target_chain.rs) module. It +implements all required traits and will simply reject all transactions, related to inbound messages. + +### What about other Constants in the Messages Module Configuration Trait? + +Two settings that are used to check messages in the `send_message()` function. The +`pallet_bridge_messages::Config::ActiveOutboundLanes` is an array of all message lanes, that +may be used to send messages. All messages sent using other lanes are rejected. All messages that have +size above `pallet_bridge_messages::Config::MaximalOutboundPayloadSize` will also be rejected. + +To be able to reward the relayer for delivering messages, we store a map of message nonces range => +identifier of the relayer that has delivered this range at the target chain runtime storage. If a +relayer delivers multiple consequent ranges, they're merged into single entry. So there may be more +than one entry for the same relayer. Eventually, this whole map must be delivered back to the source +chain to confirm delivery and pay rewards. So to make sure we are able to craft this confirmation +transaction, we need to: (1) keep the size of this map below a certain limit and (2) make sure that +the weight of processing this map is below a certain limit. Both size and processing weight mostly +depend on the number of entries. The number of entries is limited with the +`pallet_bridge_messages::ConfigMaxUnrewardedRelayerEntriesAtInboundLane` parameter. Processing weight +also depends on the total number of messages that are being confirmed, because every confirmed +message needs to be read. So there's another +`pallet_bridge_messages::Config::MaxUnconfirmedMessagesAtInboundLane` parameter for that. + +When choosing values for these parameters, you must also keep in mind that if proof in your scheme +is based on finality of headers (and it is the most obvious option for Substrate-based chains with +finality notion), then choosing too small values for these parameters may cause significant delays +in message delivery. That's because there are too many actors involved in this scheme: 1) authorities +that are finalizing headers of the target chain need to finalize header with non-empty map; 2) the +headers relayer then needs to submit this header and its finality proof to the source chain; 3) the +messages relayer must then send confirmation transaction (storage proof of this map) to the source +chain; 4) when the confirmation transaction will be mined at some header, source chain authorities +must finalize this header; 5) the headers relay then needs to submit this header and its finality +proof to the target chain; 6) only now the messages relayer may submit new messages from the source +to target chain and prune the entry from the map. + +Delivery transaction requires the relayer to provide both number of entries and total number of +messages in the map. This means that the module never charges an extra cost for delivering a map - +the relayer would need to pay exactly for the number of entries+messages it has delivered. So the +best guess for values of these parameters would be the pair that would occupy `N` percent of the +maximal transaction size and weight of the source chain. The `N` should be large enough to process +large maps, at the same time keeping reserve for future source chain upgrades. + +## Non-Essential Functionality + +There may be a special account in every runtime where the messages module is deployed. This +account, named 'module owner', is like a module-level sudo account - he's able to halt and +resume all module operations without requiring runtime upgrade. Calls that are related to this +account are: +- `fn set_owner()`: current module owner may call it to transfer "ownership" to another account; +- `fn halt_operations()`: the module owner (or sudo account) may call this function to stop all + module operations. After this call, all message-related transactions will be rejected until + further `resume_operations` call'. This call may be used when something extraordinary happens with + the bridge; +- `fn resume_operations()`: module owner may call this function to resume bridge operations. The + module will resume its regular operations after this call. + +If pallet owner is not defined, the governance may be used to make those calls. + +## Messages Relay + +We have an offchain actor, who is watching for new messages and submits them to the bridged chain. +It is the messages relay - you may look at the [crate level documentation and the code](../../relays/messages/). diff --git a/bridges/modules/messages/src/benchmarking.rs b/bridges/modules/messages/src/benchmarking.rs new file mode 100644 index 00000000000..04f64b53b30 --- /dev/null +++ b/bridges/modules/messages/src/benchmarking.rs @@ -0,0 +1,461 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Messages pallet benchmarking. + +use crate::{ + inbound_lane::InboundLaneStorage, outbound_lane, weights_ext::EXPECTED_DEFAULT_MESSAGE_LENGTH, + Call, OutboundLanes, RuntimeInboundLaneStorage, +}; + +use bp_messages::{ + source_chain::TargetHeaderChain, target_chain::SourceHeaderChain, DeliveredMessages, + InboundLaneData, LaneId, MessageNonce, OutboundLaneData, UnrewardedRelayer, + UnrewardedRelayersState, +}; +use bp_runtime::StorageProofSize; +use codec::Decode; +use frame_benchmarking::{account, benchmarks_instance_pallet}; +use frame_support::weights::Weight; +use frame_system::RawOrigin; +use sp_runtime::traits::TrailingZeroInput; +use sp_std::{ops::RangeInclusive, prelude::*}; + +const SEED: u32 = 0; + +/// Pallet we're benchmarking here. +pub struct Pallet, I: 'static = ()>(crate::Pallet); + +/// Benchmark-specific message proof parameters. +#[derive(Debug)] +pub struct MessageProofParams { + /// Id of the lane. + pub lane: LaneId, + /// Range of messages to include in the proof. + pub message_nonces: RangeInclusive, + /// If `Some`, the proof needs to include this outbound lane data. + pub outbound_lane_data: Option, + /// If `true`, the caller expects that the proof will contain correct messages that will + /// be successfully dispatched. This is only called from the "optional" + /// `receive_single_message_proof_with_dispatch` benchmark. If you don't need it, just + /// return `true` from the `is_message_successfully_dispatched`. + pub is_successful_dispatch_expected: bool, + /// Proof size requirements. + pub size: StorageProofSize, +} + +/// Benchmark-specific message delivery proof parameters. +#[derive(Debug)] +pub struct MessageDeliveryProofParams { + /// Id of the lane. + pub lane: LaneId, + /// The proof needs to include this inbound lane data. + pub inbound_lane_data: InboundLaneData, + /// Proof size requirements. + pub size: StorageProofSize, +} + +/// Trait that must be implemented by runtime. +pub trait Config: crate::Config { + /// Lane id to use in benchmarks. + /// + /// By default, lane 00000000 is used. + fn bench_lane_id() -> LaneId { + LaneId([0, 0, 0, 0]) + } + + /// Return id of relayer account at the bridged chain. + /// + /// By default, zero account is returned. + fn bridged_relayer_id() -> Self::InboundRelayer { + Self::InboundRelayer::decode(&mut TrailingZeroInput::zeroes()).unwrap() + } + + /// Create given account and give it enough balance for test purposes. Used to create + /// relayer account at the target chain. Is strictly necessary when your rewards scheme + /// assumes that the relayer account must exist. + /// + /// Does nothing by default. + fn endow_account(_account: &Self::AccountId) {} + + /// Prepare messages proof to receive by the module. + fn prepare_message_proof( + params: MessageProofParams, + ) -> (::MessagesProof, Weight); + /// Prepare messages delivery proof to receive by the module. + fn prepare_message_delivery_proof( + params: MessageDeliveryProofParams, + ) -> >::MessagesDeliveryProof; + + /// Returns true if message has been successfully dispatched or not. + fn is_message_successfully_dispatched(_nonce: MessageNonce) -> bool { + true + } + + /// Returns true if given relayer has been rewarded for some of its actions. + fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool; +} + +benchmarks_instance_pallet! { + // + // Benchmarks that are used directly by the runtime calls weight formulae. + // + + // Benchmark `receive_messages_proof` extrinsic with single minimal-weight message and following conditions: + // * proof does not include outbound lane state proof; + // * inbound lane already has state, so it needs to be read and decoded; + // * message is dispatched (reminder: dispatch weight should be minimal); + // * message requires all heavy checks done by dispatcher. + // + // This is base benchmark for all other message delivery benchmarks. + receive_single_message_proof { + let relayer_id_on_source = T::bridged_relayer_id(); + let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); + + // mark messages 1..=20 as delivered + receive_messages::(20); + + let (proof, dispatch_weight) = T::prepare_message_proof(MessageProofParams { + lane: T::bench_lane_id(), + message_nonces: 21..=21, + outbound_lane_data: None, + is_successful_dispatch_expected: false, + size: StorageProofSize::Minimal(EXPECTED_DEFAULT_MESSAGE_LENGTH), + }); + }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) + verify { + assert_eq!( + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), + 21, + ); + } + + // Benchmark `receive_messages_proof` extrinsic with two minimal-weight messages and following conditions: + // * proof does not include outbound lane state proof; + // * inbound lane already has state, so it needs to be read and decoded; + // * message is dispatched (reminder: dispatch weight should be minimal); + // * message requires all heavy checks done by dispatcher. + // + // The weight of single message delivery could be approximated as + // `weight(receive_two_messages_proof) - weight(receive_single_message_proof)`. + // This won't be super-accurate if message has non-zero dispatch weight, but estimation should + // be close enough to real weight. + receive_two_messages_proof { + let relayer_id_on_source = T::bridged_relayer_id(); + let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); + + // mark messages 1..=20 as delivered + receive_messages::(20); + + let (proof, dispatch_weight) = T::prepare_message_proof(MessageProofParams { + lane: T::bench_lane_id(), + message_nonces: 21..=22, + outbound_lane_data: None, + is_successful_dispatch_expected: false, + size: StorageProofSize::Minimal(EXPECTED_DEFAULT_MESSAGE_LENGTH), + }); + }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 2, dispatch_weight) + verify { + assert_eq!( + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), + 22, + ); + } + + // Benchmark `receive_messages_proof` extrinsic with single minimal-weight message and following conditions: + // * proof includes outbound lane state proof; + // * inbound lane already has state, so it needs to be read and decoded; + // * message is successfully dispatched (reminder: dispatch weight should be minimal); + // * message requires all heavy checks done by dispatcher. + // + // The weight of outbound lane state delivery would be + // `weight(receive_single_message_proof_with_outbound_lane_state) - weight(receive_single_message_proof)`. + // This won't be super-accurate if message has non-zero dispatch weight, but estimation should + // be close enough to real weight. + receive_single_message_proof_with_outbound_lane_state { + let relayer_id_on_source = T::bridged_relayer_id(); + let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); + + // mark messages 1..=20 as delivered + receive_messages::(20); + + let (proof, dispatch_weight) = T::prepare_message_proof(MessageProofParams { + lane: T::bench_lane_id(), + message_nonces: 21..=21, + outbound_lane_data: Some(OutboundLaneData { + oldest_unpruned_nonce: 21, + latest_received_nonce: 20, + latest_generated_nonce: 21, + }), + is_successful_dispatch_expected: false, + size: StorageProofSize::Minimal(EXPECTED_DEFAULT_MESSAGE_LENGTH), + }); + }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) + verify { + let lane_state = crate::InboundLanes::::get(&T::bench_lane_id()); + assert_eq!(lane_state.last_delivered_nonce(), 21); + assert_eq!(lane_state.last_confirmed_nonce, 20); + } + + // Benchmark `receive_messages_proof` extrinsic with single minimal-weight message and following conditions: + // * the proof has large leaf with total size of approximately 1KB; + // * proof does not include outbound lane state proof; + // * inbound lane already has state, so it needs to be read and decoded; + // * message is dispatched (reminder: dispatch weight should be minimal); + // * message requires all heavy checks done by dispatcher. + // + // With single KB of messages proof, the weight of the call is increased (roughly) by + // `(receive_single_message_proof_16KB - receive_single_message_proof_1_kb) / 15`. + receive_single_message_proof_1_kb { + let relayer_id_on_source = T::bridged_relayer_id(); + let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); + + // mark messages 1..=20 as delivered + receive_messages::(20); + + let (proof, dispatch_weight) = T::prepare_message_proof(MessageProofParams { + lane: T::bench_lane_id(), + message_nonces: 21..=21, + outbound_lane_data: None, + is_successful_dispatch_expected: false, + size: StorageProofSize::HasLargeLeaf(1024), + }); + }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) + verify { + assert_eq!( + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), + 21, + ); + } + + // Benchmark `receive_messages_proof` extrinsic with single minimal-weight message and following conditions: + // * the proof has large leaf with total size of approximately 16KB; + // * proof does not include outbound lane state proof; + // * inbound lane already has state, so it needs to be read and decoded; + // * message is dispatched (reminder: dispatch weight should be minimal); + // * message requires all heavy checks done by dispatcher. + // + // Size of proof grows because it contains extra trie nodes in it. + // + // With single KB of messages proof, the weight of the call is increased (roughly) by + // `(receive_single_message_proof_16KB - receive_single_message_proof) / 15`. + receive_single_message_proof_16_kb { + let relayer_id_on_source = T::bridged_relayer_id(); + let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); + + // mark messages 1..=20 as delivered + receive_messages::(20); + + let (proof, dispatch_weight) = T::prepare_message_proof(MessageProofParams { + lane: T::bench_lane_id(), + message_nonces: 21..=21, + outbound_lane_data: None, + is_successful_dispatch_expected: false, + size: StorageProofSize::HasLargeLeaf(16 * 1024), + }); + }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) + verify { + assert_eq!( + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), + 21, + ); + } + + // Benchmark `receive_messages_delivery_proof` extrinsic with following conditions: + // * single relayer is rewarded for relaying single message; + // * relayer account does not exist (in practice it needs to exist in production environment). + // + // This is base benchmark for all other confirmations delivery benchmarks. + receive_delivery_proof_for_single_message { + let relayer_id: T::AccountId = account("relayer", 0, SEED); + + // send message that we're going to confirm + send_regular_message::(); + + let relayers_state = UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 1, + total_messages: 1, + last_delivered_nonce: 1, + }; + let proof = T::prepare_message_delivery_proof(MessageDeliveryProofParams { + lane: T::bench_lane_id(), + inbound_lane_data: InboundLaneData { + relayers: vec![UnrewardedRelayer { + relayer: relayer_id.clone(), + messages: DeliveredMessages::new(1), + }].into_iter().collect(), + last_confirmed_nonce: 0, + }, + size: StorageProofSize::Minimal(0), + }); + }: receive_messages_delivery_proof(RawOrigin::Signed(relayer_id.clone()), proof, relayers_state) + verify { + assert_eq!(OutboundLanes::::get(T::bench_lane_id()).latest_received_nonce, 1); + assert!(T::is_relayer_rewarded(&relayer_id)); + } + + // Benchmark `receive_messages_delivery_proof` extrinsic with following conditions: + // * single relayer is rewarded for relaying two messages; + // * relayer account does not exist (in practice it needs to exist in production environment). + // + // Additional weight for paying single-message reward to the same relayer could be computed + // as `weight(receive_delivery_proof_for_two_messages_by_single_relayer) + // - weight(receive_delivery_proof_for_single_message)`. + receive_delivery_proof_for_two_messages_by_single_relayer { + let relayer_id: T::AccountId = account("relayer", 0, SEED); + + // send message that we're going to confirm + send_regular_message::(); + send_regular_message::(); + + let relayers_state = UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 2, + total_messages: 2, + last_delivered_nonce: 2, + }; + let mut delivered_messages = DeliveredMessages::new(1); + delivered_messages.note_dispatched_message(); + let proof = T::prepare_message_delivery_proof(MessageDeliveryProofParams { + lane: T::bench_lane_id(), + inbound_lane_data: InboundLaneData { + relayers: vec![UnrewardedRelayer { + relayer: relayer_id.clone(), + messages: delivered_messages, + }].into_iter().collect(), + last_confirmed_nonce: 0, + }, + size: StorageProofSize::Minimal(0), + }); + }: receive_messages_delivery_proof(RawOrigin::Signed(relayer_id.clone()), proof, relayers_state) + verify { + assert_eq!(OutboundLanes::::get(T::bench_lane_id()).latest_received_nonce, 2); + assert!(T::is_relayer_rewarded(&relayer_id)); + } + + // Benchmark `receive_messages_delivery_proof` extrinsic with following conditions: + // * two relayers are rewarded for relaying single message each; + // * relayer account does not exist (in practice it needs to exist in production environment). + // + // Additional weight for paying reward to the next relayer could be computed + // as `weight(receive_delivery_proof_for_two_messages_by_two_relayers) + // - weight(receive_delivery_proof_for_two_messages_by_single_relayer)`. + receive_delivery_proof_for_two_messages_by_two_relayers { + let relayer1_id: T::AccountId = account("relayer1", 1, SEED); + let relayer2_id: T::AccountId = account("relayer2", 2, SEED); + + // send message that we're going to confirm + send_regular_message::(); + send_regular_message::(); + + let relayers_state = UnrewardedRelayersState { + unrewarded_relayer_entries: 2, + messages_in_oldest_entry: 1, + total_messages: 2, + last_delivered_nonce: 2, + }; + let proof = T::prepare_message_delivery_proof(MessageDeliveryProofParams { + lane: T::bench_lane_id(), + inbound_lane_data: InboundLaneData { + relayers: vec![ + UnrewardedRelayer { + relayer: relayer1_id.clone(), + messages: DeliveredMessages::new(1), + }, + UnrewardedRelayer { + relayer: relayer2_id.clone(), + messages: DeliveredMessages::new(2), + }, + ].into_iter().collect(), + last_confirmed_nonce: 0, + }, + size: StorageProofSize::Minimal(0), + }); + }: receive_messages_delivery_proof(RawOrigin::Signed(relayer1_id.clone()), proof, relayers_state) + verify { + assert_eq!(OutboundLanes::::get(T::bench_lane_id()).latest_received_nonce, 2); + assert!(T::is_relayer_rewarded(&relayer1_id)); + assert!(T::is_relayer_rewarded(&relayer2_id)); + } + + // + // Benchmarks that the runtime developers may use for proper pallet configuration. + // + + // This benchmark is optional and may be used when runtime developer need a way to compute + // message dispatch weight. In this case, he needs to provide messages that can go the whole + // dispatch + // + // Benchmark `receive_messages_proof` extrinsic with single message and following conditions: + // + // * proof does not include outbound lane state proof; + // * inbound lane already has state, so it needs to be read and decoded; + // * message is **SUCCESSFULLY** dispatched; + // * message requires all heavy checks done by dispatcher. + receive_single_message_proof_with_dispatch { + // maybe dispatch weight relies on the message size too? + let i in EXPECTED_DEFAULT_MESSAGE_LENGTH .. EXPECTED_DEFAULT_MESSAGE_LENGTH * 16; + + let relayer_id_on_source = T::bridged_relayer_id(); + let relayer_id_on_target = account("relayer", 0, SEED); + T::endow_account(&relayer_id_on_target); + + // mark messages 1..=20 as delivered + receive_messages::(20); + + let (proof, dispatch_weight) = T::prepare_message_proof(MessageProofParams { + lane: T::bench_lane_id(), + message_nonces: 21..=21, + outbound_lane_data: None, + is_successful_dispatch_expected: true, + size: StorageProofSize::Minimal(i), + }); + }: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight) + verify { + assert_eq!( + crate::InboundLanes::::get(&T::bench_lane_id()).last_delivered_nonce(), + 21, + ); + assert!(T::is_message_successfully_dispatched(21)); + } + + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::TestRuntime) +} + +fn send_regular_message, I: 'static>() { + let mut outbound_lane = outbound_lane::(T::bench_lane_id()); + outbound_lane.send_message(vec![]).expect("We craft valid messages"); +} + +fn receive_messages, I: 'static>(nonce: MessageNonce) { + let mut inbound_lane_storage = + RuntimeInboundLaneStorage::::from_lane_id(T::bench_lane_id()); + inbound_lane_storage.set_data(InboundLaneData { + relayers: vec![UnrewardedRelayer { + relayer: T::bridged_relayer_id(), + messages: DeliveredMessages::new(nonce), + }] + .into_iter() + .collect(), + last_confirmed_nonce: 0, + }); +} diff --git a/bridges/modules/messages/src/inbound_lane.rs b/bridges/modules/messages/src/inbound_lane.rs new file mode 100644 index 00000000000..b665b5516fc --- /dev/null +++ b/bridges/modules/messages/src/inbound_lane.rs @@ -0,0 +1,555 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Everything about incoming messages receival. + +use crate::Config; + +use bp_messages::{ + target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch}, + DeliveredMessages, InboundLaneData, LaneId, MessageKey, MessageNonce, OutboundLaneData, + ReceivalResult, UnrewardedRelayer, +}; +use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; +use frame_support::{traits::Get, RuntimeDebug}; +use scale_info::{Type, TypeInfo}; +use sp_std::prelude::PartialEq; + +/// Inbound lane storage. +pub trait InboundLaneStorage { + /// Id of relayer on source chain. + type Relayer: Clone + PartialEq; + + /// Lane id. + fn id(&self) -> LaneId; + /// Return maximal number of unrewarded relayer entries in inbound lane. + fn max_unrewarded_relayer_entries(&self) -> MessageNonce; + /// Return maximal number of unconfirmed messages in inbound lane. + fn max_unconfirmed_messages(&self) -> MessageNonce; + /// Get lane data from the storage. + fn get_or_init_data(&mut self) -> InboundLaneData; + /// Update lane data in the storage. + fn set_data(&mut self, data: InboundLaneData); +} + +/// Inbound lane data wrapper that implements `MaxEncodedLen`. +/// +/// We have already had `MaxEncodedLen`-like functionality before, but its usage has +/// been localized and we haven't been passing bounds (maximal count of unrewarded relayer entries, +/// maximal count of unconfirmed messages) everywhere. This wrapper allows us to avoid passing +/// these generic bounds all over the code. +/// +/// The encoding of this type matches encoding of the corresponding `MessageData`. +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq)] +pub struct StoredInboundLaneData, I: 'static>(pub InboundLaneData); + +impl, I: 'static> sp_std::ops::Deref for StoredInboundLaneData { + type Target = InboundLaneData; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl, I: 'static> sp_std::ops::DerefMut for StoredInboundLaneData { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +impl, I: 'static> Default for StoredInboundLaneData { + fn default() -> Self { + StoredInboundLaneData(Default::default()) + } +} + +impl, I: 'static> From> + for InboundLaneData +{ + fn from(data: StoredInboundLaneData) -> Self { + data.0 + } +} + +impl, I: 'static> EncodeLike> + for InboundLaneData +{ +} + +impl, I: 'static> TypeInfo for StoredInboundLaneData { + type Identity = Self; + + fn type_info() -> Type { + InboundLaneData::::type_info() + } +} + +impl, I: 'static> MaxEncodedLen for StoredInboundLaneData { + fn max_encoded_len() -> usize { + InboundLaneData::::encoded_size_hint( + T::MaxUnrewardedRelayerEntriesAtInboundLane::get() as usize, + ) + .unwrap_or(usize::MAX) + } +} + +/// Inbound messages lane. +pub struct InboundLane { + storage: S, +} + +impl InboundLane { + /// Create new inbound lane backed by given storage. + pub fn new(storage: S) -> Self { + InboundLane { storage } + } + + /// Returns `mut` storage reference. + pub fn storage_mut(&mut self) -> &mut S { + &mut self.storage + } + + /// Receive state of the corresponding outbound lane. + pub fn receive_state_update( + &mut self, + outbound_lane_data: OutboundLaneData, + ) -> Option { + let mut data = self.storage.get_or_init_data(); + let last_delivered_nonce = data.last_delivered_nonce(); + + if outbound_lane_data.latest_received_nonce > last_delivered_nonce { + // this is something that should never happen if proofs are correct + return None + } + if outbound_lane_data.latest_received_nonce <= data.last_confirmed_nonce { + return None + } + + let new_confirmed_nonce = outbound_lane_data.latest_received_nonce; + data.last_confirmed_nonce = new_confirmed_nonce; + // Firstly, remove all of the records where higher nonce <= new confirmed nonce + while data + .relayers + .front() + .map(|entry| entry.messages.end <= new_confirmed_nonce) + .unwrap_or(false) + { + data.relayers.pop_front(); + } + // Secondly, update the next record with lower nonce equal to new confirmed nonce if needed. + // Note: There will be max. 1 record to update as we don't allow messages from relayers to + // overlap. + match data.relayers.front_mut() { + Some(entry) if entry.messages.begin <= new_confirmed_nonce => { + entry.messages.begin = new_confirmed_nonce + 1; + }, + _ => {}, + } + + self.storage.set_data(data); + Some(outbound_lane_data.latest_received_nonce) + } + + /// Receive new message. + pub fn receive_message( + &mut self, + relayer_at_bridged_chain: &S::Relayer, + nonce: MessageNonce, + message_data: DispatchMessageData, + ) -> ReceivalResult { + let mut data = self.storage.get_or_init_data(); + if Some(nonce) != data.last_delivered_nonce().checked_add(1) { + return ReceivalResult::InvalidNonce + } + + // if there are more unrewarded relayer entries than we may accept, reject this message + if data.relayers.len() as MessageNonce >= self.storage.max_unrewarded_relayer_entries() { + return ReceivalResult::TooManyUnrewardedRelayers + } + + // if there are more unconfirmed messages than we may accept, reject this message + let unconfirmed_messages_count = nonce.saturating_sub(data.last_confirmed_nonce); + if unconfirmed_messages_count > self.storage.max_unconfirmed_messages() { + return ReceivalResult::TooManyUnconfirmedMessages + } + + // then, dispatch message + let dispatch_result = Dispatch::dispatch(DispatchMessage { + key: MessageKey { lane_id: self.storage.id(), nonce }, + data: message_data, + }); + + // now let's update inbound lane storage + match data.relayers.back_mut() { + Some(entry) if entry.relayer == *relayer_at_bridged_chain => { + entry.messages.note_dispatched_message(); + }, + _ => { + data.relayers.push_back(UnrewardedRelayer { + relayer: relayer_at_bridged_chain.clone(), + messages: DeliveredMessages::new(nonce), + }); + }, + }; + self.storage.set_data(data); + + ReceivalResult::Dispatched(dispatch_result) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + inbound_lane, + mock::{ + dispatch_result, inbound_message_data, inbound_unrewarded_relayers_state, run_test, + unrewarded_relayer, TestMessageDispatch, TestRuntime, REGULAR_PAYLOAD, TEST_LANE_ID, + TEST_RELAYER_A, TEST_RELAYER_B, TEST_RELAYER_C, + }, + RuntimeInboundLaneStorage, + }; + use bp_messages::UnrewardedRelayersState; + + fn receive_regular_message( + lane: &mut InboundLane>, + nonce: MessageNonce, + ) { + assert_eq!( + lane.receive_message::( + &TEST_RELAYER_A, + nonce, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::Dispatched(dispatch_result(0)) + ); + } + + #[test] + fn receive_status_update_ignores_status_from_the_future() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + receive_regular_message(&mut lane, 1); + assert_eq!( + lane.receive_state_update(OutboundLaneData { + latest_received_nonce: 10, + ..Default::default() + }), + None, + ); + + assert_eq!(lane.storage.get_or_init_data().last_confirmed_nonce, 0); + }); + } + + #[test] + fn receive_status_update_ignores_obsolete_status() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + receive_regular_message(&mut lane, 1); + receive_regular_message(&mut lane, 2); + receive_regular_message(&mut lane, 3); + assert_eq!( + lane.receive_state_update(OutboundLaneData { + latest_received_nonce: 3, + ..Default::default() + }), + Some(3), + ); + assert_eq!(lane.storage.get_or_init_data().last_confirmed_nonce, 3); + + assert_eq!( + lane.receive_state_update(OutboundLaneData { + latest_received_nonce: 3, + ..Default::default() + }), + None, + ); + assert_eq!(lane.storage.get_or_init_data().last_confirmed_nonce, 3); + }); + } + + #[test] + fn receive_status_update_works() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + receive_regular_message(&mut lane, 1); + receive_regular_message(&mut lane, 2); + receive_regular_message(&mut lane, 3); + assert_eq!(lane.storage.get_or_init_data().last_confirmed_nonce, 0); + assert_eq!( + lane.storage.get_or_init_data().relayers, + vec![unrewarded_relayer(1, 3, TEST_RELAYER_A)] + ); + + assert_eq!( + lane.receive_state_update(OutboundLaneData { + latest_received_nonce: 2, + ..Default::default() + }), + Some(2), + ); + assert_eq!(lane.storage.get_or_init_data().last_confirmed_nonce, 2); + assert_eq!( + lane.storage.get_or_init_data().relayers, + vec![unrewarded_relayer(3, 3, TEST_RELAYER_A)] + ); + + assert_eq!( + lane.receive_state_update(OutboundLaneData { + latest_received_nonce: 3, + ..Default::default() + }), + Some(3), + ); + assert_eq!(lane.storage.get_or_init_data().last_confirmed_nonce, 3); + assert_eq!(lane.storage.get_or_init_data().relayers, vec![]); + }); + } + + #[test] + fn receive_status_update_works_with_batches_from_relayers() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + let mut seed_storage_data = lane.storage.get_or_init_data(); + // Prepare data + seed_storage_data.last_confirmed_nonce = 0; + seed_storage_data.relayers.push_back(unrewarded_relayer(1, 1, TEST_RELAYER_A)); + // Simulate messages batch (2, 3, 4) from relayer #2 + seed_storage_data.relayers.push_back(unrewarded_relayer(2, 4, TEST_RELAYER_B)); + seed_storage_data.relayers.push_back(unrewarded_relayer(5, 5, TEST_RELAYER_C)); + lane.storage.set_data(seed_storage_data); + // Check + assert_eq!( + lane.receive_state_update(OutboundLaneData { + latest_received_nonce: 3, + ..Default::default() + }), + Some(3), + ); + assert_eq!(lane.storage.get_or_init_data().last_confirmed_nonce, 3); + assert_eq!( + lane.storage.get_or_init_data().relayers, + vec![ + unrewarded_relayer(4, 4, TEST_RELAYER_B), + unrewarded_relayer(5, 5, TEST_RELAYER_C) + ] + ); + }); + } + + #[test] + fn fails_to_receive_message_with_incorrect_nonce() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + assert_eq!( + lane.receive_message::( + &TEST_RELAYER_A, + 10, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::InvalidNonce + ); + assert_eq!(lane.storage.get_or_init_data().last_delivered_nonce(), 0); + }); + } + + #[test] + fn fails_to_receive_messages_above_unrewarded_relayer_entries_limit_per_lane() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + let max_nonce = + ::MaxUnrewardedRelayerEntriesAtInboundLane::get(); + for current_nonce in 1..max_nonce + 1 { + assert_eq!( + lane.receive_message::( + &(TEST_RELAYER_A + current_nonce), + current_nonce, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::Dispatched(dispatch_result(0)) + ); + } + // Fails to dispatch new message from different than latest relayer. + assert_eq!( + lane.receive_message::( + &(TEST_RELAYER_A + max_nonce + 1), + max_nonce + 1, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::TooManyUnrewardedRelayers, + ); + // Fails to dispatch new messages from latest relayer. Prevents griefing attacks. + assert_eq!( + lane.receive_message::( + &(TEST_RELAYER_A + max_nonce), + max_nonce + 1, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::TooManyUnrewardedRelayers, + ); + }); + } + + #[test] + fn fails_to_receive_messages_above_unconfirmed_messages_limit_per_lane() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + let max_nonce = ::MaxUnconfirmedMessagesAtInboundLane::get(); + for current_nonce in 1..=max_nonce { + assert_eq!( + lane.receive_message::( + &TEST_RELAYER_A, + current_nonce, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::Dispatched(dispatch_result(0)) + ); + } + // Fails to dispatch new message from different than latest relayer. + assert_eq!( + lane.receive_message::( + &TEST_RELAYER_B, + max_nonce + 1, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::TooManyUnconfirmedMessages, + ); + // Fails to dispatch new messages from latest relayer. + assert_eq!( + lane.receive_message::( + &TEST_RELAYER_A, + max_nonce + 1, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::TooManyUnconfirmedMessages, + ); + }); + } + + #[test] + fn correctly_receives_following_messages_from_two_relayers_alternately() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + assert_eq!( + lane.receive_message::( + &TEST_RELAYER_A, + 1, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::Dispatched(dispatch_result(0)) + ); + assert_eq!( + lane.receive_message::( + &TEST_RELAYER_B, + 2, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::Dispatched(dispatch_result(0)) + ); + assert_eq!( + lane.receive_message::( + &TEST_RELAYER_A, + 3, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::Dispatched(dispatch_result(0)) + ); + assert_eq!( + lane.storage.get_or_init_data().relayers, + vec![ + unrewarded_relayer(1, 1, TEST_RELAYER_A), + unrewarded_relayer(2, 2, TEST_RELAYER_B), + unrewarded_relayer(3, 3, TEST_RELAYER_A) + ] + ); + }); + } + + #[test] + fn rejects_same_message_from_two_different_relayers() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + assert_eq!( + lane.receive_message::( + &TEST_RELAYER_A, + 1, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::Dispatched(dispatch_result(0)) + ); + assert_eq!( + lane.receive_message::( + &TEST_RELAYER_B, + 1, + inbound_message_data(REGULAR_PAYLOAD) + ), + ReceivalResult::InvalidNonce, + ); + }); + } + + #[test] + fn correct_message_is_processed_instantly() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + receive_regular_message(&mut lane, 1); + assert_eq!(lane.storage.get_or_init_data().last_delivered_nonce(), 1); + }); + } + + #[test] + fn unspent_weight_is_returned_by_receive_message() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + let mut payload = REGULAR_PAYLOAD; + *payload.dispatch_result.unspent_weight.ref_time_mut() = 1; + assert_eq!( + lane.receive_message::( + &TEST_RELAYER_A, + 1, + inbound_message_data(payload) + ), + ReceivalResult::Dispatched(dispatch_result(1)) + ); + }); + } + + #[test] + fn first_message_is_confirmed_correctly() { + run_test(|| { + let mut lane = inbound_lane::(TEST_LANE_ID); + receive_regular_message(&mut lane, 1); + receive_regular_message(&mut lane, 2); + assert_eq!( + lane.receive_state_update(OutboundLaneData { + latest_received_nonce: 1, + ..Default::default() + }), + Some(1), + ); + assert_eq!( + inbound_unrewarded_relayers_state(TEST_LANE_ID), + UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 1, + total_messages: 1, + last_delivered_nonce: 2, + }, + ); + }); + } +} diff --git a/bridges/modules/messages/src/lib.rs b/bridges/modules/messages/src/lib.rs new file mode 100644 index 00000000000..51e6857d777 --- /dev/null +++ b/bridges/modules/messages/src/lib.rs @@ -0,0 +1,2104 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Runtime module that allows sending and receiving messages using lane concept: +//! +//! 1) the message is sent using `send_message()` call; +//! 2) every outbound message is assigned nonce; +//! 3) the messages are stored in the storage; +//! 4) external component (relay) delivers messages to bridged chain; +//! 5) messages are processed in order (ordered by assigned nonce); +//! 6) relay may send proof-of-delivery back to this chain. +//! +//! Once message is sent, its progress can be tracked by looking at module events. +//! The assigned nonce is reported using `MessageAccepted` event. When message is +//! delivered to the the bridged chain, it is reported using `MessagesDelivered` event. +//! +//! **IMPORTANT NOTE**: after generating weights (custom `WeighInfo` implementation) for +//! your runtime (where this module is plugged to), please add test for these weights. +//! The test should call the `ensure_weights_are_correct` function from this module. +//! If this test fails with your weights, then either weights are computed incorrectly, +//! or some benchmarks assumptions are broken for your runtime. + +#![cfg_attr(not(feature = "std"), no_std)] +// Generated by `decl_event!` +#![allow(clippy::unused_unit)] + +pub use inbound_lane::StoredInboundLaneData; +pub use outbound_lane::StoredMessagePayload; +pub use weights::WeightInfo; +pub use weights_ext::{ + ensure_able_to_receive_confirmation, ensure_able_to_receive_message, + ensure_weights_are_correct, WeightInfoExt, EXPECTED_DEFAULT_MESSAGE_LENGTH, + EXTRA_STORAGE_PROOF_SIZE, +}; + +use crate::{ + inbound_lane::{InboundLane, InboundLaneStorage}, + outbound_lane::{OutboundLane, OutboundLaneStorage, ReceivalConfirmationError}, +}; + +use bp_messages::{ + source_chain::{ + DeliveryConfirmationPayments, LaneMessageVerifier, SendMessageArtifacts, TargetHeaderChain, + }, + target_chain::{ + DeliveryPayments, DispatchMessage, MessageDispatch, ProvedLaneMessages, ProvedMessages, + SourceHeaderChain, + }, + DeliveredMessages, InboundLaneData, InboundMessageDetails, LaneId, MessageKey, MessageNonce, + MessagePayload, MessagesOperatingMode, OutboundLaneData, OutboundMessageDetails, + UnrewardedRelayersState, VerificationError, +}; +use bp_runtime::{BasicOperatingMode, ChainId, OwnedBridgeModule, PreComputedSize, Size}; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{dispatch::PostDispatchInfo, ensure, fail, traits::Get, DefaultNoBound}; +use sp_runtime::traits::UniqueSaturatedFrom; +use sp_std::{marker::PhantomData, prelude::*}; + +mod inbound_lane; +mod outbound_lane; +mod weights_ext; + +pub mod weights; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; + +#[cfg(test)] +mod mock; + +pub use pallet::*; + +/// The target that will be used when publishing logs related to this pallet. +pub const LOG_TARGET: &str = "runtime::bridge-messages"; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use bp_messages::{ReceivalResult, ReceivedMessages}; + use bp_runtime::RangeInclusiveExt; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config { + // General types + + /// The overarching event type. + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; + /// Benchmarks results from runtime we're plugged into. + type WeightInfo: WeightInfoExt; + + /// Gets the chain id value from the instance. + #[pallet::constant] + type BridgedChainId: Get; + + /// Get all active outbound lanes that the message pallet is serving. + type ActiveOutboundLanes: Get<&'static [LaneId]>; + /// Maximal number of unrewarded relayer entries at inbound lane. Unrewarded means that the + /// relayer has delivered messages, but either confirmations haven't been delivered back to + /// the source chain, or we haven't received reward confirmations yet. + /// + /// This constant limits maximal number of entries in the `InboundLaneData::relayers`. Keep + /// in mind that the same relayer account may take several (non-consecutive) entries in this + /// set. + type MaxUnrewardedRelayerEntriesAtInboundLane: Get; + /// Maximal number of unconfirmed messages at inbound lane. Unconfirmed means that the + /// message has been delivered, but either confirmations haven't been delivered back to the + /// source chain, or we haven't received reward confirmations for these messages yet. + /// + /// This constant limits difference between last message from last entry of the + /// `InboundLaneData::relayers` and first message at the first entry. + /// + /// There is no point of making this parameter lesser than + /// MaxUnrewardedRelayerEntriesAtInboundLane, because then maximal number of relayer entries + /// will be limited by maximal number of messages. + /// + /// This value also represents maximal number of messages in single delivery transaction. + /// Transaction that is declaring more messages than this value, will be rejected. Even if + /// these messages are from different lanes. + type MaxUnconfirmedMessagesAtInboundLane: Get; + + /// Maximal encoded size of the outbound payload. + #[pallet::constant] + type MaximalOutboundPayloadSize: Get; + /// Payload type of outbound messages. This payload is dispatched on the bridged chain. + type OutboundPayload: Parameter + Size; + + /// Payload type of inbound messages. This payload is dispatched on this chain. + type InboundPayload: Decode; + /// Identifier of relayer that deliver messages to this chain. Relayer reward is paid on the + /// bridged chain. + type InboundRelayer: Parameter + MaxEncodedLen; + /// Delivery payments. + type DeliveryPayments: DeliveryPayments; + + // Types that are used by outbound_lane (on source chain). + + /// Target header chain. + type TargetHeaderChain: TargetHeaderChain; + /// Message payload verifier. + type LaneMessageVerifier: LaneMessageVerifier; + /// Delivery confirmation payments. + type DeliveryConfirmationPayments: DeliveryConfirmationPayments; + + // Types that are used by inbound_lane (on target chain). + + /// Source header chain, as it is represented on target chain. + type SourceHeaderChain: SourceHeaderChain; + /// Message dispatch. + type MessageDispatch: MessageDispatch; + } + + /// Shortcut to messages proof type for Config. + pub type MessagesProofOf = + <>::SourceHeaderChain as SourceHeaderChain>::MessagesProof; + /// Shortcut to messages delivery proof type for Config. + pub type MessagesDeliveryProofOf = + <>::TargetHeaderChain as TargetHeaderChain< + >::OutboundPayload, + ::AccountId, + >>::MessagesDeliveryProof; + + #[pallet::pallet] + pub struct Pallet(PhantomData<(T, I)>); + + impl, I: 'static> OwnedBridgeModule for Pallet { + const LOG_TARGET: &'static str = LOG_TARGET; + type OwnerStorage = PalletOwner; + type OperatingMode = MessagesOperatingMode; + type OperatingModeStorage = PalletOperatingMode; + } + + #[pallet::hooks] + impl, I: 'static> Hooks> for Pallet + where + u32: TryFrom<::BlockNumber>, + { + fn on_idle(_block: T::BlockNumber, remaining_weight: Weight) -> Weight { + // we'll need at least to read outbound lane state, kill a message and update lane state + let db_weight = T::DbWeight::get(); + if !remaining_weight.all_gte(db_weight.reads_writes(1, 2)) { + return Weight::zero() + } + + // messages from lane with index `i` in `ActiveOutboundLanes` are pruned when + // `System::block_number() % lanes.len() == i`. Otherwise we need to read lane states on + // every block, wasting the whole `remaining_weight` for nothing and causing starvation + // of the last lane pruning + let active_lanes = T::ActiveOutboundLanes::get(); + let active_lanes_len = (active_lanes.len() as u32).into(); + let active_lane_index = u32::unique_saturated_from( + frame_system::Pallet::::block_number() % active_lanes_len, + ); + let active_lane_id = active_lanes[active_lane_index as usize]; + + // first db read - outbound lane state + let mut active_lane = outbound_lane::(active_lane_id); + let mut used_weight = db_weight.reads(1); + // and here we'll have writes + used_weight += active_lane.prune_messages(db_weight, remaining_weight - used_weight); + + // we already checked we have enough `remaining_weight` to cover this `used_weight` + used_weight + } + } + + #[pallet::call] + impl, I: 'static> Pallet { + /// Change `PalletOwner`. + /// + /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(0)] + #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] + pub fn set_owner(origin: OriginFor, new_owner: Option) -> DispatchResult { + >::set_owner(origin, new_owner) + } + + /// Halt or resume all/some pallet operations. + /// + /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(1)] + #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] + pub fn set_operating_mode( + origin: OriginFor, + operating_mode: MessagesOperatingMode, + ) -> DispatchResult { + >::set_operating_mode(origin, operating_mode) + } + + /// Receive messages proof from bridged chain. + /// + /// The weight of the call assumes that the transaction always brings outbound lane + /// state update. Because of that, the submitter (relayer) has no benefit of not including + /// this data in the transaction, so reward confirmations lags should be minimal. + /// + /// The call fails if: + /// + /// - the pallet is halted; + /// + /// - the call origin is not `Signed(_)`; + /// + /// - there are too many messages in the proof; + /// + /// - the proof verification procedure returns an error - e.g. because header used to craft + /// proof is not imported by the associated finality pallet; + /// + /// - the `dispatch_weight` argument is not sufficient to dispatch all bundled messages. + /// + /// The call may succeed, but some messages may not be delivered e.g. if they are not fit + /// into the unrewarded relayers vector. + #[pallet::call_index(2)] + #[pallet::weight(T::WeightInfo::receive_messages_proof_weight(proof, *messages_count, *dispatch_weight))] + pub fn receive_messages_proof( + origin: OriginFor, + relayer_id_at_bridged_chain: T::InboundRelayer, + proof: MessagesProofOf, + messages_count: u32, + dispatch_weight: Weight, + ) -> DispatchResultWithPostInfo { + Self::ensure_not_halted().map_err(Error::::BridgeModule)?; + let relayer_id_at_this_chain = ensure_signed(origin)?; + + // reject transactions that are declaring too many messages + ensure!( + MessageNonce::from(messages_count) <= T::MaxUnconfirmedMessagesAtInboundLane::get(), + Error::::TooManyMessagesInTheProof + ); + + // why do we need to know the weight of this (`receive_messages_proof`) call? Because + // we may want to return some funds for not-dispatching (or partially dispatching) some + // messages to the call origin (relayer). And this is done by returning actual weight + // from the call. But we only know dispatch weight of every messages. So to refund + // relayer because we have not dispatched Message, we need to: + // + // ActualWeight = DeclaredWeight - Message.DispatchWeight + // + // The DeclaredWeight is exactly what's computed here. Unfortunately it is impossible + // to get pre-computed value (and it has been already computed by the executive). + let declared_weight = T::WeightInfo::receive_messages_proof_weight( + &proof, + messages_count, + dispatch_weight, + ); + let mut actual_weight = declared_weight; + + // verify messages proof && convert proof into messages + let messages = verify_and_decode_messages_proof::< + T::SourceHeaderChain, + T::InboundPayload, + >(proof, messages_count) + .map_err(|err| { + log::trace!(target: LOG_TARGET, "Rejecting invalid messages proof: {:?}", err,); + + Error::::InvalidMessagesProof + })?; + + // dispatch messages and (optionally) update lane(s) state(s) + let mut total_messages = 0; + let mut valid_messages = 0; + let mut messages_received_status = Vec::with_capacity(messages.len()); + let mut dispatch_weight_left = dispatch_weight; + for (lane_id, lane_data) in messages { + let mut lane = inbound_lane::(lane_id); + + // subtract extra storage proof bytes from the actual PoV size - there may be + // less unrewarded relayers than the maximal configured value + let lane_extra_proof_size_bytes = lane.storage_mut().extra_proof_size_bytes(); + actual_weight = actual_weight.set_proof_size( + actual_weight.proof_size().saturating_sub(lane_extra_proof_size_bytes), + ); + + if let Some(lane_state) = lane_data.lane_state { + let updated_latest_confirmed_nonce = lane.receive_state_update(lane_state); + if let Some(updated_latest_confirmed_nonce) = updated_latest_confirmed_nonce { + log::trace!( + target: LOG_TARGET, + "Received lane {:?} state update: latest_confirmed_nonce={}. Unrewarded relayers: {:?}", + lane_id, + updated_latest_confirmed_nonce, + UnrewardedRelayersState::from(&lane.storage_mut().get_or_init_data()), + ); + } + } + + let mut lane_messages_received_status = + ReceivedMessages::new(lane_id, Vec::with_capacity(lane_data.messages.len())); + for mut message in lane_data.messages { + debug_assert_eq!(message.key.lane_id, lane_id); + total_messages += 1; + + // ensure that relayer has declared enough weight for dispatching next message + // on this lane. We can't dispatch lane messages out-of-order, so if declared + // weight is not enough, let's move to next lane + let message_dispatch_weight = T::MessageDispatch::dispatch_weight(&mut message); + if message_dispatch_weight.any_gt(dispatch_weight_left) { + log::trace!( + target: LOG_TARGET, + "Cannot dispatch any more messages on lane {:?}. Weight: declared={}, left={}", + lane_id, + message_dispatch_weight, + dispatch_weight_left, + ); + + fail!(Error::::InsufficientDispatchWeight); + } + + let receival_result = lane.receive_message::( + &relayer_id_at_bridged_chain, + message.key.nonce, + message.data, + ); + + // note that we're returning unspent weight to relayer even if message has been + // rejected by the lane. This allows relayers to submit spam transactions with + // e.g. the same set of already delivered messages over and over again, without + // losing funds for messages dispatch. But keep in mind that relayer pays base + // delivery transaction cost anyway. And base cost covers everything except + // dispatch, so we have a balance here. + let unspent_weight = match &receival_result { + ReceivalResult::Dispatched(dispatch_result) => { + valid_messages += 1; + dispatch_result.unspent_weight + }, + ReceivalResult::InvalidNonce | + ReceivalResult::TooManyUnrewardedRelayers | + ReceivalResult::TooManyUnconfirmedMessages => message_dispatch_weight, + }; + lane_messages_received_status.push(message.key.nonce, receival_result); + + let unspent_weight = unspent_weight.min(message_dispatch_weight); + dispatch_weight_left -= message_dispatch_weight - unspent_weight; + actual_weight = actual_weight.saturating_sub(unspent_weight); + } + + messages_received_status.push(lane_messages_received_status); + } + + // let's now deal with relayer payments + T::DeliveryPayments::pay_reward( + relayer_id_at_this_chain, + total_messages, + valid_messages, + actual_weight, + ); + + log::debug!( + target: LOG_TARGET, + "Received messages: total={}, valid={}. Weight used: {}/{}.", + total_messages, + valid_messages, + actual_weight, + declared_weight, + ); + + Self::deposit_event(Event::MessagesReceived(messages_received_status)); + + Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee: Pays::Yes }) + } + + /// Receive messages delivery proof from bridged chain. + #[pallet::call_index(3)] + #[pallet::weight(T::WeightInfo::receive_messages_delivery_proof_weight( + proof, + relayers_state, + ))] + pub fn receive_messages_delivery_proof( + origin: OriginFor, + proof: MessagesDeliveryProofOf, + mut relayers_state: UnrewardedRelayersState, + ) -> DispatchResultWithPostInfo { + Self::ensure_not_halted().map_err(Error::::BridgeModule)?; + + let proof_size = proof.size(); + let confirmation_relayer = ensure_signed(origin)?; + let (lane_id, lane_data) = T::TargetHeaderChain::verify_messages_delivery_proof(proof) + .map_err(|err| { + log::trace!( + target: LOG_TARGET, + "Rejecting invalid messages delivery proof: {:?}", + err, + ); + + Error::::InvalidMessagesDeliveryProof + })?; + ensure!( + relayers_state.is_valid(&lane_data), + Error::::InvalidUnrewardedRelayersState + ); + + // mark messages as delivered + let mut lane = outbound_lane::(lane_id); + let last_delivered_nonce = lane_data.last_delivered_nonce(); + let confirmed_messages = lane + .confirm_delivery( + relayers_state.total_messages, + last_delivered_nonce, + &lane_data.relayers, + ) + .map_err(Error::::ReceivalConfirmation)?; + + if let Some(confirmed_messages) = confirmed_messages { + // emit 'delivered' event + let received_range = confirmed_messages.begin..=confirmed_messages.end; + Self::deposit_event(Event::MessagesDelivered { + lane_id, + messages: confirmed_messages, + }); + + // if some new messages have been confirmed, reward relayers + let actually_rewarded_relayers = T::DeliveryConfirmationPayments::pay_reward( + lane_id, + lane_data.relayers, + &confirmation_relayer, + &received_range, + ); + + // update relayers state with actual numbers to compute actual weight below + relayers_state.unrewarded_relayer_entries = sp_std::cmp::min( + relayers_state.unrewarded_relayer_entries, + actually_rewarded_relayers, + ); + relayers_state.total_messages = sp_std::cmp::min( + relayers_state.total_messages, + received_range.checked_len().unwrap_or(MessageNonce::MAX), + ); + }; + + log::trace!( + target: LOG_TARGET, + "Received messages delivery proof up to (and including) {} at lane {:?}", + last_delivered_nonce, + lane_id, + ); + + // because of lags, the inbound lane state (`lane_data`) may have entries for + // already rewarded relayers and messages (if all entries are duplicated, then + // this transaction must be filtered out by our signed extension) + let actual_weight = T::WeightInfo::receive_messages_delivery_proof_weight( + &PreComputedSize(proof_size as usize), + &relayers_state, + ); + + Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee: Pays::Yes }) + } + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event, I: 'static = ()> { + /// Message has been accepted and is waiting to be delivered. + MessageAccepted { lane_id: LaneId, nonce: MessageNonce }, + /// Messages have been received from the bridged chain. + MessagesReceived( + Vec::DispatchLevelResult>>, + ), + /// Messages in the inclusive range have been delivered to the bridged chain. + MessagesDelivered { lane_id: LaneId, messages: DeliveredMessages }, + } + + #[pallet::error] + pub enum Error { + /// Pallet is not in Normal operating mode. + NotOperatingNormally, + /// The outbound lane is inactive. + InactiveOutboundLane, + /// Message has been treated as invalid by chain verifier. + MessageRejectedByChainVerifier(VerificationError), + /// Message has been treated as invalid by lane verifier. + MessageRejectedByLaneVerifier(VerificationError), + /// Message has been treated as invalid by the pallet logic. + MessageRejectedByPallet(VerificationError), + /// Submitter has failed to pay fee for delivering and dispatching messages. + FailedToWithdrawMessageFee, + /// The transaction brings too many messages. + TooManyMessagesInTheProof, + /// Invalid messages has been submitted. + InvalidMessagesProof, + /// Invalid messages delivery proof has been submitted. + InvalidMessagesDeliveryProof, + /// The relayer has declared invalid unrewarded relayers state in the + /// `receive_messages_delivery_proof` call. + InvalidUnrewardedRelayersState, + /// The cumulative dispatch weight, passed by relayer is not enough to cover dispatch + /// of all bundled messages. + InsufficientDispatchWeight, + /// The message someone is trying to work with (i.e. increase fee) is not yet sent. + MessageIsNotYetSent, + /// Error confirming messages receival. + ReceivalConfirmation(ReceivalConfirmationError), + /// Error generated by the `OwnedBridgeModule` trait. + BridgeModule(bp_runtime::OwnedBridgeModuleError), + } + + /// Optional pallet owner. + /// + /// Pallet owner has a right to halt all pallet operations and then resume it. If it is + /// `None`, then there are no direct ways to halt/resume pallet operations, but other + /// runtime methods may still be used to do that (i.e. democracy::referendum to update halt + /// flag directly or call the `halt_operations`). + #[pallet::storage] + #[pallet::getter(fn module_owner)] + pub type PalletOwner, I: 'static = ()> = StorageValue<_, T::AccountId>; + + /// The current operating mode of the pallet. + /// + /// Depending on the mode either all, some, or no transactions will be allowed. + #[pallet::storage] + #[pallet::getter(fn operating_mode)] + pub type PalletOperatingMode, I: 'static = ()> = + StorageValue<_, MessagesOperatingMode, ValueQuery>; + + /// Map of lane id => inbound lane data. + #[pallet::storage] + pub type InboundLanes, I: 'static = ()> = + StorageMap<_, Blake2_128Concat, LaneId, StoredInboundLaneData, ValueQuery>; + + /// Map of lane id => outbound lane data. + #[pallet::storage] + pub type OutboundLanes, I: 'static = ()> = StorageMap< + Hasher = Blake2_128Concat, + Key = LaneId, + Value = OutboundLaneData, + QueryKind = ValueQuery, + OnEmpty = GetDefault, + MaxValues = MaybeOutboundLanesCount, + >; + + /// All queued outbound messages. + #[pallet::storage] + pub type OutboundMessages, I: 'static = ()> = + StorageMap<_, Blake2_128Concat, MessageKey, StoredMessagePayload>; + + #[pallet::genesis_config] + #[derive(DefaultNoBound)] + pub struct GenesisConfig, I: 'static = ()> { + /// Initial pallet operating mode. + pub operating_mode: MessagesOperatingMode, + /// Initial pallet owner. + pub owner: Option, + /// Dummy marker. + pub phantom: sp_std::marker::PhantomData, + } + + #[pallet::genesis_build] + impl, I: 'static> GenesisBuild for GenesisConfig { + fn build(&self) { + PalletOperatingMode::::put(self.operating_mode); + if let Some(ref owner) = self.owner { + PalletOwner::::put(owner); + } + } + } + + impl, I: 'static> Pallet { + /// Get stored data of the outbound message with given nonce. + pub fn outbound_message_data(lane: LaneId, nonce: MessageNonce) -> Option { + OutboundMessages::::get(MessageKey { lane_id: lane, nonce }).map(Into::into) + } + + /// Prepare data, related to given inbound message. + pub fn inbound_message_data( + lane: LaneId, + payload: MessagePayload, + outbound_details: OutboundMessageDetails, + ) -> InboundMessageDetails { + let mut dispatch_message = DispatchMessage { + key: MessageKey { lane_id: lane, nonce: outbound_details.nonce }, + data: payload.into(), + }; + InboundMessageDetails { + dispatch_weight: T::MessageDispatch::dispatch_weight(&mut dispatch_message), + } + } + + /// Return inbound lane data. + pub fn inbound_lane_data(lane: LaneId) -> InboundLaneData { + InboundLanes::::get(lane).0 + } + } + + /// Get-parameter that returns number of active outbound lanes that the pallet maintains. + pub struct MaybeOutboundLanesCount(PhantomData<(T, I)>); + + impl, I: 'static> Get> for MaybeOutboundLanesCount { + fn get() -> Option { + Some(T::ActiveOutboundLanes::get().len() as u32) + } + } +} + +impl bp_messages::source_chain::MessagesBridge + for Pallet +where + T: Config, + I: 'static, +{ + type Error = sp_runtime::DispatchErrorWithPostInfo; + + fn send_message( + sender: T::RuntimeOrigin, + lane: LaneId, + message: T::OutboundPayload, + ) -> Result { + crate::send_message::(sender, lane, message) + } +} + +/// Function that actually sends message. +fn send_message, I: 'static>( + submitter: T::RuntimeOrigin, + lane_id: LaneId, + payload: T::OutboundPayload, +) -> sp_std::result::Result< + SendMessageArtifacts, + sp_runtime::DispatchErrorWithPostInfo, +> { + ensure_normal_operating_mode::()?; + + // let's check if outbound lane is active + ensure!(T::ActiveOutboundLanes::get().contains(&lane_id), Error::::InactiveOutboundLane,); + + // let's first check if message can be delivered to target chain + T::TargetHeaderChain::verify_message(&payload).map_err(|err| { + log::trace!( + target: LOG_TARGET, + "Message to lane {:?} is rejected by target chain: {:?}", + lane_id, + err, + ); + + Error::::MessageRejectedByChainVerifier(err) + })?; + + // now let's enforce any additional lane rules + let mut lane = outbound_lane::(lane_id); + T::LaneMessageVerifier::verify_message(&submitter, &lane_id, &lane.data(), &payload).map_err( + |err| { + log::trace!( + target: LOG_TARGET, + "Message to lane {:?} is rejected by lane verifier: {:?}", + lane_id, + err, + ); + + Error::::MessageRejectedByLaneVerifier(err) + }, + )?; + + // finally, save message in outbound storage and emit event + let encoded_payload = payload.encode(); + let encoded_payload_len = encoded_payload.len(); + let nonce = lane + .send_message(encoded_payload) + .map_err(Error::::MessageRejectedByPallet)?; + + log::trace!( + target: LOG_TARGET, + "Accepted message {} to lane {:?}. Message size: {:?}", + nonce, + lane_id, + encoded_payload_len, + ); + + Pallet::::deposit_event(Event::MessageAccepted { lane_id, nonce }); + + Ok(SendMessageArtifacts { nonce }) +} + +/// Ensure that the pallet is in normal operational mode. +fn ensure_normal_operating_mode, I: 'static>() -> Result<(), Error> { + if PalletOperatingMode::::get() == + MessagesOperatingMode::Basic(BasicOperatingMode::Normal) + { + return Ok(()) + } + + Err(Error::::NotOperatingNormally) +} + +/// Creates new inbound lane object, backed by runtime storage. +fn inbound_lane, I: 'static>( + lane_id: LaneId, +) -> InboundLane> { + InboundLane::new(RuntimeInboundLaneStorage::from_lane_id(lane_id)) +} + +/// Creates new outbound lane object, backed by runtime storage. +fn outbound_lane, I: 'static>( + lane_id: LaneId, +) -> OutboundLane> { + OutboundLane::new(RuntimeOutboundLaneStorage { lane_id, _phantom: Default::default() }) +} + +/// Runtime inbound lane storage. +struct RuntimeInboundLaneStorage, I: 'static = ()> { + lane_id: LaneId, + cached_data: Option>, + _phantom: PhantomData, +} + +impl, I: 'static> RuntimeInboundLaneStorage { + /// Creates new runtime inbound lane storage. + fn from_lane_id(lane_id: LaneId) -> RuntimeInboundLaneStorage { + RuntimeInboundLaneStorage { lane_id, cached_data: None, _phantom: Default::default() } + } +} + +impl, I: 'static> RuntimeInboundLaneStorage { + /// Returns number of bytes that may be subtracted from the PoV component of + /// `receive_messages_proof` call, because the actual inbound lane state is smaller than the + /// maximal configured. + /// + /// Maximal inbound lane state set size is configured by the + /// `MaxUnrewardedRelayerEntriesAtInboundLane` constant from the pallet configuration. The PoV + /// of the call includes the maximal size of inbound lane state. If the actual size is smaller, + /// we may subtract extra bytes from this component. + pub fn extra_proof_size_bytes(&mut self) -> u64 { + let max_encoded_len = StoredInboundLaneData::::max_encoded_len(); + let relayers_count = self.get_or_init_data().relayers.len(); + let actual_encoded_len = + InboundLaneData::::encoded_size_hint(relayers_count) + .unwrap_or(usize::MAX); + max_encoded_len.saturating_sub(actual_encoded_len) as _ + } +} + +impl, I: 'static> InboundLaneStorage for RuntimeInboundLaneStorage { + type Relayer = T::InboundRelayer; + + fn id(&self) -> LaneId { + self.lane_id + } + + fn max_unrewarded_relayer_entries(&self) -> MessageNonce { + T::MaxUnrewardedRelayerEntriesAtInboundLane::get() + } + + fn max_unconfirmed_messages(&self) -> MessageNonce { + T::MaxUnconfirmedMessagesAtInboundLane::get() + } + + fn get_or_init_data(&mut self) -> InboundLaneData { + match self.cached_data { + Some(ref data) => data.clone(), + None => { + let data: InboundLaneData = + InboundLanes::::get(self.lane_id).into(); + self.cached_data = Some(data.clone()); + data + }, + } + } + + fn set_data(&mut self, data: InboundLaneData) { + self.cached_data = Some(data.clone()); + InboundLanes::::insert(self.lane_id, StoredInboundLaneData::(data)) + } +} + +/// Runtime outbound lane storage. +struct RuntimeOutboundLaneStorage { + lane_id: LaneId, + _phantom: PhantomData<(T, I)>, +} + +impl, I: 'static> OutboundLaneStorage for RuntimeOutboundLaneStorage { + fn id(&self) -> LaneId { + self.lane_id + } + + fn data(&self) -> OutboundLaneData { + OutboundLanes::::get(self.lane_id) + } + + fn set_data(&mut self, data: OutboundLaneData) { + OutboundLanes::::insert(self.lane_id, data) + } + + #[cfg(test)] + fn message(&self, nonce: &MessageNonce) -> Option { + OutboundMessages::::get(MessageKey { lane_id: self.lane_id, nonce: *nonce }) + .map(Into::into) + } + + fn save_message( + &mut self, + nonce: MessageNonce, + message_payload: MessagePayload, + ) -> Result<(), VerificationError> { + OutboundMessages::::insert( + MessageKey { lane_id: self.lane_id, nonce }, + StoredMessagePayload::::try_from(message_payload) + .map_err(|_| VerificationError::MessageTooLarge)?, + ); + Ok(()) + } + + fn remove_message(&mut self, nonce: &MessageNonce) { + OutboundMessages::::remove(MessageKey { lane_id: self.lane_id, nonce: *nonce }); + } +} + +/// Verify messages proof and return proved messages with decoded payload. +fn verify_and_decode_messages_proof( + proof: Chain::MessagesProof, + messages_count: u32, +) -> Result>, VerificationError> { + // `receive_messages_proof` weight formula and `MaxUnconfirmedMessagesAtInboundLane` check + // guarantees that the `message_count` is sane and Vec may be allocated. + // (tx with too many messages will either be rejected from the pool, or will fail earlier) + Chain::verify_messages_proof(proof, messages_count).map(|messages_by_lane| { + messages_by_lane + .into_iter() + .map(|(lane, lane_data)| { + ( + lane, + ProvedLaneMessages { + lane_state: lane_data.lane_state, + messages: lane_data.messages.into_iter().map(Into::into).collect(), + }, + ) + }) + .collect() + }) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + mock::{ + inbound_unrewarded_relayers_state, message, message_payload, run_test, + unrewarded_relayer, AccountId, DbWeight, RuntimeEvent as TestEvent, RuntimeOrigin, + TestDeliveryConfirmationPayments, TestDeliveryPayments, TestMessagesDeliveryProof, + TestMessagesProof, TestRelayer, TestRuntime, TestWeightInfo, MAX_OUTBOUND_PAYLOAD_SIZE, + PAYLOAD_REJECTED_BY_TARGET_CHAIN, REGULAR_PAYLOAD, TEST_LANE_ID, TEST_LANE_ID_2, + TEST_LANE_ID_3, TEST_RELAYER_A, TEST_RELAYER_B, + }, + outbound_lane::ReceivalConfirmationError, + }; + use bp_messages::{BridgeMessagesCall, UnrewardedRelayer, UnrewardedRelayersState}; + use bp_test_utils::generate_owned_bridge_module_tests; + use frame_support::{ + assert_noop, assert_ok, + dispatch::Pays, + storage::generator::{StorageMap, StorageValue}, + traits::Hooks, + weights::Weight, + }; + use frame_system::{EventRecord, Pallet as System, Phase}; + use sp_runtime::DispatchError; + + fn get_ready_for_events() { + System::::set_block_number(1); + System::::reset_events(); + } + + fn send_regular_message() { + get_ready_for_events(); + + let message_nonce = + outbound_lane::(TEST_LANE_ID).data().latest_generated_nonce + 1; + send_message::(RuntimeOrigin::signed(1), TEST_LANE_ID, REGULAR_PAYLOAD) + .expect("send_message has failed"); + + // check event with assigned nonce + assert_eq!( + System::::events(), + vec![EventRecord { + phase: Phase::Initialization, + event: TestEvent::Messages(Event::MessageAccepted { + lane_id: TEST_LANE_ID, + nonce: message_nonce + }), + topics: vec![], + }], + ); + } + + fn receive_messages_delivery_proof() { + System::::set_block_number(1); + System::::reset_events(); + + assert_ok!(Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID, + InboundLaneData { + last_confirmed_nonce: 1, + relayers: vec![UnrewardedRelayer { + relayer: 0, + messages: DeliveredMessages::new(1), + }] + .into_iter() + .collect(), + }, + ))), + UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 1, + total_messages: 1, + last_delivered_nonce: 1, + }, + )); + + assert_eq!( + System::::events(), + vec![EventRecord { + phase: Phase::Initialization, + event: TestEvent::Messages(Event::MessagesDelivered { + lane_id: TEST_LANE_ID, + messages: DeliveredMessages::new(1), + }), + topics: vec![], + }], + ); + } + + #[test] + fn pallet_rejects_transactions_if_halted() { + run_test(|| { + // send message first to be able to check that delivery_proof fails later + send_regular_message(); + + PalletOperatingMode::::put(MessagesOperatingMode::Basic( + BasicOperatingMode::Halted, + )); + + assert_noop!( + send_message::( + RuntimeOrigin::signed(1), + TEST_LANE_ID, + REGULAR_PAYLOAD, + ), + Error::::NotOperatingNormally, + ); + + assert_noop!( + Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + Ok(vec![message(2, REGULAR_PAYLOAD)]).into(), + 1, + REGULAR_PAYLOAD.declared_weight, + ), + Error::::BridgeModule(bp_runtime::OwnedBridgeModuleError::Halted), + ); + + assert_noop!( + Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID, + InboundLaneData { + last_confirmed_nonce: 1, + relayers: vec![unrewarded_relayer(1, 1, TEST_RELAYER_A)] + .into_iter() + .collect(), + }, + ))), + UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 1, + total_messages: 1, + last_delivered_nonce: 1, + }, + ), + Error::::BridgeModule(bp_runtime::OwnedBridgeModuleError::Halted), + ); + }); + } + + #[test] + fn pallet_rejects_new_messages_in_rejecting_outbound_messages_operating_mode() { + run_test(|| { + // send message first to be able to check that delivery_proof fails later + send_regular_message(); + + PalletOperatingMode::::put( + MessagesOperatingMode::RejectingOutboundMessages, + ); + + assert_noop!( + send_message::( + RuntimeOrigin::signed(1), + TEST_LANE_ID, + REGULAR_PAYLOAD, + ), + Error::::NotOperatingNormally, + ); + + assert_ok!(Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + Ok(vec![message(1, REGULAR_PAYLOAD)]).into(), + 1, + REGULAR_PAYLOAD.declared_weight, + ),); + + assert_ok!(Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID, + InboundLaneData { + last_confirmed_nonce: 1, + relayers: vec![unrewarded_relayer(1, 1, TEST_RELAYER_A)] + .into_iter() + .collect(), + }, + ))), + UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 1, + total_messages: 1, + last_delivered_nonce: 1, + }, + )); + }); + } + + #[test] + fn send_message_works() { + run_test(|| { + send_regular_message(); + }); + } + + #[test] + fn send_message_rejects_too_large_message() { + run_test(|| { + let mut message_payload = message_payload(1, 0); + // the payload isn't simply extra, so it'll definitely overflow + // `MAX_OUTBOUND_PAYLOAD_SIZE` if we add `MAX_OUTBOUND_PAYLOAD_SIZE` bytes to extra + message_payload + .extra + .extend_from_slice(&[0u8; MAX_OUTBOUND_PAYLOAD_SIZE as usize]); + assert_noop!( + send_message::( + RuntimeOrigin::signed(1), + TEST_LANE_ID, + message_payload.clone(), + ), + Error::::MessageRejectedByPallet( + VerificationError::MessageTooLarge + ), + ); + + // let's check that we're able to send `MAX_OUTBOUND_PAYLOAD_SIZE` messages + while message_payload.encoded_size() as u32 > MAX_OUTBOUND_PAYLOAD_SIZE { + message_payload.extra.pop(); + } + assert_eq!(message_payload.encoded_size() as u32, MAX_OUTBOUND_PAYLOAD_SIZE); + assert_ok!(send_message::( + RuntimeOrigin::signed(1), + TEST_LANE_ID, + message_payload, + ),); + }) + } + + #[test] + fn chain_verifier_rejects_invalid_message_in_send_message() { + run_test(|| { + // messages with this payload are rejected by target chain verifier + assert_noop!( + send_message::( + RuntimeOrigin::signed(1), + TEST_LANE_ID, + PAYLOAD_REJECTED_BY_TARGET_CHAIN, + ), + Error::::MessageRejectedByChainVerifier(VerificationError::Other( + mock::TEST_ERROR + )), + ); + }); + } + + #[test] + fn lane_verifier_rejects_invalid_message_in_send_message() { + run_test(|| { + // messages with zero fee are rejected by lane verifier + let mut message = REGULAR_PAYLOAD; + message.reject_by_lane_verifier = true; + assert_noop!( + send_message::(RuntimeOrigin::signed(1), TEST_LANE_ID, message,), + Error::::MessageRejectedByLaneVerifier(VerificationError::Other( + mock::TEST_ERROR + )), + ); + }); + } + + #[test] + fn receive_messages_proof_works() { + run_test(|| { + assert_ok!(Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + Ok(vec![message(1, REGULAR_PAYLOAD)]).into(), + 1, + REGULAR_PAYLOAD.declared_weight, + )); + + assert_eq!(InboundLanes::::get(TEST_LANE_ID).0.last_delivered_nonce(), 1); + + assert!(TestDeliveryPayments::is_reward_paid(1)); + }); + } + + #[test] + fn receive_messages_proof_updates_confirmed_message_nonce() { + run_test(|| { + // say we have received 10 messages && last confirmed message is 8 + InboundLanes::::insert( + TEST_LANE_ID, + InboundLaneData { + last_confirmed_nonce: 8, + relayers: vec![ + unrewarded_relayer(9, 9, TEST_RELAYER_A), + unrewarded_relayer(10, 10, TEST_RELAYER_B), + ] + .into_iter() + .collect(), + }, + ); + assert_eq!( + inbound_unrewarded_relayers_state(TEST_LANE_ID), + UnrewardedRelayersState { + unrewarded_relayer_entries: 2, + messages_in_oldest_entry: 1, + total_messages: 2, + last_delivered_nonce: 10, + }, + ); + + // message proof includes outbound lane state with latest confirmed message updated to 9 + let mut message_proof: TestMessagesProof = + Ok(vec![message(11, REGULAR_PAYLOAD)]).into(); + message_proof.result.as_mut().unwrap()[0].1.lane_state = + Some(OutboundLaneData { latest_received_nonce: 9, ..Default::default() }); + + assert_ok!(Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + message_proof, + 1, + REGULAR_PAYLOAD.declared_weight, + )); + + assert_eq!( + InboundLanes::::get(TEST_LANE_ID).0, + InboundLaneData { + last_confirmed_nonce: 9, + relayers: vec![ + unrewarded_relayer(10, 10, TEST_RELAYER_B), + unrewarded_relayer(11, 11, TEST_RELAYER_A) + ] + .into_iter() + .collect(), + }, + ); + assert_eq!( + inbound_unrewarded_relayers_state(TEST_LANE_ID), + UnrewardedRelayersState { + unrewarded_relayer_entries: 2, + messages_in_oldest_entry: 1, + total_messages: 2, + last_delivered_nonce: 11, + }, + ); + }); + } + + #[test] + fn receive_messages_proof_does_not_accept_message_if_dispatch_weight_is_not_enough() { + run_test(|| { + let mut declared_weight = REGULAR_PAYLOAD.declared_weight; + *declared_weight.ref_time_mut() -= 1; + assert_noop!( + Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + Ok(vec![message(1, REGULAR_PAYLOAD)]).into(), + 1, + declared_weight, + ), + Error::::InsufficientDispatchWeight + ); + assert_eq!(InboundLanes::::get(TEST_LANE_ID).last_delivered_nonce(), 0); + }); + } + + #[test] + fn receive_messages_proof_rejects_invalid_proof() { + run_test(|| { + assert_noop!( + Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + Err(()).into(), + 1, + Weight::zero(), + ), + Error::::InvalidMessagesProof, + ); + }); + } + + #[test] + fn receive_messages_proof_rejects_proof_with_too_many_messages() { + run_test(|| { + assert_noop!( + Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + Ok(vec![message(1, REGULAR_PAYLOAD)]).into(), + u32::MAX, + Weight::zero(), + ), + Error::::TooManyMessagesInTheProof, + ); + }); + } + + #[test] + fn receive_messages_delivery_proof_works() { + run_test(|| { + send_regular_message(); + receive_messages_delivery_proof(); + + assert_eq!( + OutboundLanes::::get(TEST_LANE_ID).latest_received_nonce, + 1, + ); + }); + } + + #[test] + fn receive_messages_delivery_proof_rewards_relayers() { + run_test(|| { + assert_ok!(send_message::( + RuntimeOrigin::signed(1), + TEST_LANE_ID, + REGULAR_PAYLOAD, + )); + assert_ok!(send_message::( + RuntimeOrigin::signed(1), + TEST_LANE_ID, + REGULAR_PAYLOAD, + )); + + // this reports delivery of message 1 => reward is paid to TEST_RELAYER_A + let single_message_delivery_proof = TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID, + InboundLaneData { + relayers: vec![unrewarded_relayer(1, 1, TEST_RELAYER_A)].into_iter().collect(), + ..Default::default() + }, + ))); + let single_message_delivery_proof_size = single_message_delivery_proof.size(); + let result = Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + single_message_delivery_proof, + UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 1, + total_messages: 1, + last_delivered_nonce: 1, + }, + ); + assert_ok!(result); + assert_eq!( + result.unwrap().actual_weight.unwrap(), + TestWeightInfo::receive_messages_delivery_proof_weight( + &PreComputedSize(single_message_delivery_proof_size as _), + &UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + total_messages: 1, + ..Default::default() + }, + ) + ); + assert!(TestDeliveryConfirmationPayments::is_reward_paid(TEST_RELAYER_A, 1)); + assert!(!TestDeliveryConfirmationPayments::is_reward_paid(TEST_RELAYER_B, 1)); + + // this reports delivery of both message 1 and message 2 => reward is paid only to + // TEST_RELAYER_B + let two_messages_delivery_proof = TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID, + InboundLaneData { + relayers: vec![ + unrewarded_relayer(1, 1, TEST_RELAYER_A), + unrewarded_relayer(2, 2, TEST_RELAYER_B), + ] + .into_iter() + .collect(), + ..Default::default() + }, + ))); + let two_messages_delivery_proof_size = two_messages_delivery_proof.size(); + let result = Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + two_messages_delivery_proof, + UnrewardedRelayersState { + unrewarded_relayer_entries: 2, + messages_in_oldest_entry: 1, + total_messages: 2, + last_delivered_nonce: 2, + }, + ); + assert_ok!(result); + // even though the pre-dispatch weight was for two messages, the actual weight is + // for single message only + assert_eq!( + result.unwrap().actual_weight.unwrap(), + TestWeightInfo::receive_messages_delivery_proof_weight( + &PreComputedSize(two_messages_delivery_proof_size as _), + &UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + total_messages: 1, + ..Default::default() + }, + ) + ); + assert!(!TestDeliveryConfirmationPayments::is_reward_paid(TEST_RELAYER_A, 1)); + assert!(TestDeliveryConfirmationPayments::is_reward_paid(TEST_RELAYER_B, 1)); + }); + } + + #[test] + fn receive_messages_delivery_proof_rejects_invalid_proof() { + run_test(|| { + assert_noop!( + Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(Err(())), + Default::default(), + ), + Error::::InvalidMessagesDeliveryProof, + ); + }); + } + + #[test] + fn receive_messages_delivery_proof_rejects_proof_if_declared_relayers_state_is_invalid() { + run_test(|| { + // when number of relayers entries is invalid + assert_noop!( + Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID, + InboundLaneData { + relayers: vec![ + unrewarded_relayer(1, 1, TEST_RELAYER_A), + unrewarded_relayer(2, 2, TEST_RELAYER_B) + ] + .into_iter() + .collect(), + ..Default::default() + } + ))), + UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + total_messages: 2, + last_delivered_nonce: 2, + ..Default::default() + }, + ), + Error::::InvalidUnrewardedRelayersState, + ); + + // when number of messages is invalid + assert_noop!( + Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID, + InboundLaneData { + relayers: vec![ + unrewarded_relayer(1, 1, TEST_RELAYER_A), + unrewarded_relayer(2, 2, TEST_RELAYER_B) + ] + .into_iter() + .collect(), + ..Default::default() + } + ))), + UnrewardedRelayersState { + unrewarded_relayer_entries: 2, + total_messages: 1, + last_delivered_nonce: 2, + ..Default::default() + }, + ), + Error::::InvalidUnrewardedRelayersState, + ); + + // when last delivered nonce is invalid + assert_noop!( + Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID, + InboundLaneData { + relayers: vec![ + unrewarded_relayer(1, 1, TEST_RELAYER_A), + unrewarded_relayer(2, 2, TEST_RELAYER_B) + ] + .into_iter() + .collect(), + ..Default::default() + } + ))), + UnrewardedRelayersState { + unrewarded_relayer_entries: 2, + total_messages: 2, + last_delivered_nonce: 8, + ..Default::default() + }, + ), + Error::::InvalidUnrewardedRelayersState, + ); + }); + } + + #[test] + fn receive_messages_accepts_single_message_with_invalid_payload() { + run_test(|| { + let mut invalid_message = message(1, REGULAR_PAYLOAD); + invalid_message.payload = Vec::new(); + + assert_ok!(Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + Ok(vec![invalid_message]).into(), + 1, + Weight::zero(), /* weight may be zero in this case (all messages are + * improperly encoded) */ + ),); + + assert_eq!(InboundLanes::::get(TEST_LANE_ID).last_delivered_nonce(), 1,); + }); + } + + #[test] + fn receive_messages_accepts_batch_with_message_with_invalid_payload() { + run_test(|| { + let mut invalid_message = message(2, REGULAR_PAYLOAD); + invalid_message.payload = Vec::new(); + + assert_ok!(Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + Ok( + vec![message(1, REGULAR_PAYLOAD), invalid_message, message(3, REGULAR_PAYLOAD),] + ) + .into(), + 3, + REGULAR_PAYLOAD.declared_weight + REGULAR_PAYLOAD.declared_weight, + ),); + + assert_eq!(InboundLanes::::get(TEST_LANE_ID).last_delivered_nonce(), 3,); + }); + } + + #[test] + fn actual_dispatch_weight_does_not_overlow() { + run_test(|| { + let message1 = message(1, message_payload(0, u64::MAX / 2)); + let message2 = message(2, message_payload(0, u64::MAX / 2)); + let message3 = message(3, message_payload(0, u64::MAX / 2)); + + assert_noop!( + Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + // this may cause overflow if source chain storage is invalid + Ok(vec![message1, message2, message3]).into(), + 3, + Weight::MAX, + ), + Error::::InsufficientDispatchWeight + ); + assert_eq!(InboundLanes::::get(TEST_LANE_ID).last_delivered_nonce(), 0); + }); + } + + #[test] + fn ref_time_refund_from_receive_messages_proof_works() { + run_test(|| { + fn submit_with_unspent_weight( + nonce: MessageNonce, + unspent_weight: u64, + ) -> (Weight, Weight) { + let mut payload = REGULAR_PAYLOAD; + *payload.dispatch_result.unspent_weight.ref_time_mut() = unspent_weight; + let proof = Ok(vec![message(nonce, payload)]).into(); + let messages_count = 1; + let pre_dispatch_weight = + ::WeightInfo::receive_messages_proof_weight( + &proof, + messages_count, + REGULAR_PAYLOAD.declared_weight, + ); + let result = Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + proof, + messages_count, + REGULAR_PAYLOAD.declared_weight, + ) + .expect("delivery has failed"); + let post_dispatch_weight = + result.actual_weight.expect("receive_messages_proof always returns Some"); + + // message delivery transactions are never free + assert_eq!(result.pays_fee, Pays::Yes); + + (pre_dispatch_weight, post_dispatch_weight) + } + + // when dispatch is returning `unspent_weight < declared_weight` + let (pre, post) = submit_with_unspent_weight(1, 1); + assert_eq!(post.ref_time(), pre.ref_time() - 1); + + // when dispatch is returning `unspent_weight = declared_weight` + let (pre, post) = + submit_with_unspent_weight(2, REGULAR_PAYLOAD.declared_weight.ref_time()); + assert_eq!( + post.ref_time(), + pre.ref_time() - REGULAR_PAYLOAD.declared_weight.ref_time() + ); + + // when dispatch is returning `unspent_weight > declared_weight` + let (pre, post) = + submit_with_unspent_weight(3, REGULAR_PAYLOAD.declared_weight.ref_time() + 1); + assert_eq!( + post.ref_time(), + pre.ref_time() - REGULAR_PAYLOAD.declared_weight.ref_time() + ); + + // when there's no unspent weight + let (pre, post) = submit_with_unspent_weight(4, 0); + assert_eq!(post.ref_time(), pre.ref_time()); + + // when dispatch is returning `unspent_weight < declared_weight` + let (pre, post) = submit_with_unspent_weight(5, 1); + assert_eq!(post.ref_time(), pre.ref_time() - 1); + }); + } + + #[test] + fn proof_size_refund_from_receive_messages_proof_works() { + run_test(|| { + let max_entries = crate::mock::MaxUnrewardedRelayerEntriesAtInboundLane::get() as usize; + + // if there's maximal number of unrewarded relayer entries at the inbound lane, then + // `proof_size` is unchanged in post-dispatch weight + let proof: TestMessagesProof = Ok(vec![message(101, REGULAR_PAYLOAD)]).into(); + let messages_count = 1; + let pre_dispatch_weight = + ::WeightInfo::receive_messages_proof_weight( + &proof, + messages_count, + REGULAR_PAYLOAD.declared_weight, + ); + InboundLanes::::insert( + TEST_LANE_ID, + StoredInboundLaneData(InboundLaneData { + relayers: vec![ + UnrewardedRelayer { + relayer: 42, + messages: DeliveredMessages { begin: 0, end: 100 } + }; + max_entries + ] + .into_iter() + .collect(), + last_confirmed_nonce: 0, + }), + ); + let post_dispatch_weight = Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + proof.clone(), + messages_count, + REGULAR_PAYLOAD.declared_weight, + ) + .unwrap() + .actual_weight + .unwrap(); + assert_eq!(post_dispatch_weight.proof_size(), pre_dispatch_weight.proof_size()); + + // if count of unrewarded relayer entries is less than maximal, then some `proof_size` + // must be refunded + InboundLanes::::insert( + TEST_LANE_ID, + StoredInboundLaneData(InboundLaneData { + relayers: vec![ + UnrewardedRelayer { + relayer: 42, + messages: DeliveredMessages { begin: 0, end: 100 } + }; + max_entries - 1 + ] + .into_iter() + .collect(), + last_confirmed_nonce: 0, + }), + ); + let post_dispatch_weight = Pallet::::receive_messages_proof( + RuntimeOrigin::signed(1), + TEST_RELAYER_A, + proof, + messages_count, + REGULAR_PAYLOAD.declared_weight, + ) + .unwrap() + .actual_weight + .unwrap(); + assert!( + post_dispatch_weight.proof_size() < pre_dispatch_weight.proof_size(), + "Expected post-dispatch PoV {} to be less than pre-dispatch PoV {}", + post_dispatch_weight.proof_size(), + pre_dispatch_weight.proof_size(), + ); + }); + } + + #[test] + fn messages_delivered_callbacks_are_called() { + run_test(|| { + send_regular_message(); + send_regular_message(); + send_regular_message(); + + // messages 1+2 are confirmed in 1 tx, message 3 in a separate tx + // dispatch of message 2 has failed + let mut delivered_messages_1_and_2 = DeliveredMessages::new(1); + delivered_messages_1_and_2.note_dispatched_message(); + let messages_1_and_2_proof = Ok(( + TEST_LANE_ID, + InboundLaneData { + last_confirmed_nonce: 0, + relayers: vec![UnrewardedRelayer { + relayer: 0, + messages: delivered_messages_1_and_2.clone(), + }] + .into_iter() + .collect(), + }, + )); + let delivered_message_3 = DeliveredMessages::new(3); + let messages_3_proof = Ok(( + TEST_LANE_ID, + InboundLaneData { + last_confirmed_nonce: 0, + relayers: vec![UnrewardedRelayer { relayer: 0, messages: delivered_message_3 }] + .into_iter() + .collect(), + }, + )); + + // first tx with messages 1+2 + assert_ok!(Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(messages_1_and_2_proof), + UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 2, + total_messages: 2, + last_delivered_nonce: 2, + }, + )); + // second tx with message 3 + assert_ok!(Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(messages_3_proof), + UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 1, + total_messages: 1, + last_delivered_nonce: 3, + }, + )); + }); + } + + #[test] + fn receive_messages_delivery_proof_rejects_proof_if_trying_to_confirm_more_messages_than_expected( + ) { + run_test(|| { + // send message first to be able to check that delivery_proof fails later + send_regular_message(); + + // 1) InboundLaneData declares that the `last_confirmed_nonce` is 1; + // 2) InboundLaneData has no entries => `InboundLaneData::last_delivered_nonce()` + // returns `last_confirmed_nonce`; + // 3) it means that we're going to confirm delivery of messages 1..=1; + // 4) so the number of declared messages (see `UnrewardedRelayersState`) is `0` and + // numer of actually confirmed messages is `1`. + assert_noop!( + Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID, + InboundLaneData { last_confirmed_nonce: 1, relayers: Default::default() }, + ))), + UnrewardedRelayersState { last_delivered_nonce: 1, ..Default::default() }, + ), + Error::::ReceivalConfirmation( + ReceivalConfirmationError::TryingToConfirmMoreMessagesThanExpected + ), + ); + }); + } + + #[test] + fn storage_keys_computed_properly() { + assert_eq!( + PalletOperatingMode::::storage_value_final_key().to_vec(), + bp_messages::storage_keys::operating_mode_key("Messages").0, + ); + + assert_eq!( + OutboundMessages::::storage_map_final_key(MessageKey { + lane_id: TEST_LANE_ID, + nonce: 42 + }), + bp_messages::storage_keys::message_key("Messages", &TEST_LANE_ID, 42).0, + ); + + assert_eq!( + OutboundLanes::::storage_map_final_key(TEST_LANE_ID), + bp_messages::storage_keys::outbound_lane_data_key("Messages", &TEST_LANE_ID).0, + ); + + assert_eq!( + InboundLanes::::storage_map_final_key(TEST_LANE_ID), + bp_messages::storage_keys::inbound_lane_data_key("Messages", &TEST_LANE_ID).0, + ); + } + + #[test] + fn inbound_message_details_works() { + run_test(|| { + assert_eq!( + Pallet::::inbound_message_data( + TEST_LANE_ID, + REGULAR_PAYLOAD.encode(), + OutboundMessageDetails { nonce: 0, dispatch_weight: Weight::zero(), size: 0 }, + ), + InboundMessageDetails { dispatch_weight: REGULAR_PAYLOAD.declared_weight }, + ); + }); + } + + #[test] + fn on_idle_callback_respects_remaining_weight() { + run_test(|| { + send_regular_message(); + send_regular_message(); + send_regular_message(); + send_regular_message(); + + assert_ok!(Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID, + InboundLaneData { + last_confirmed_nonce: 4, + relayers: vec![unrewarded_relayer(1, 4, TEST_RELAYER_A)] + .into_iter() + .collect(), + }, + ))), + UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 4, + total_messages: 4, + last_delivered_nonce: 4, + }, + )); + + // all 4 messages may be pruned now + assert_eq!( + outbound_lane::(TEST_LANE_ID).data().latest_received_nonce, + 4 + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID).data().oldest_unpruned_nonce, + 1 + ); + System::::set_block_number(2); + + // if passed wight is too low to do anything + let dbw = DbWeight::get(); + assert_eq!( + Pallet::::on_idle(0, dbw.reads_writes(1, 1)), + Weight::zero(), + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID).data().oldest_unpruned_nonce, + 1 + ); + + // if passed wight is enough to prune single message + assert_eq!( + Pallet::::on_idle(0, dbw.reads_writes(1, 2)), + dbw.reads_writes(1, 2), + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID).data().oldest_unpruned_nonce, + 2 + ); + + // if passed wight is enough to prune two more messages + assert_eq!( + Pallet::::on_idle(0, dbw.reads_writes(1, 3)), + dbw.reads_writes(1, 3), + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID).data().oldest_unpruned_nonce, + 4 + ); + + // if passed wight is enough to prune many messages + assert_eq!( + Pallet::::on_idle(0, dbw.reads_writes(100, 100)), + dbw.reads_writes(1, 2), + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID).data().oldest_unpruned_nonce, + 5 + ); + }); + } + + #[test] + fn on_idle_callback_is_rotating_lanes_to_prune() { + run_test(|| { + // send + receive confirmation for lane 1 + send_regular_message(); + receive_messages_delivery_proof(); + // send + receive confirmation for lane 2 + assert_ok!(send_message::( + RuntimeOrigin::signed(1), + TEST_LANE_ID_2, + REGULAR_PAYLOAD, + )); + assert_ok!(Pallet::::receive_messages_delivery_proof( + RuntimeOrigin::signed(1), + TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID_2, + InboundLaneData { + last_confirmed_nonce: 1, + relayers: vec![unrewarded_relayer(1, 1, TEST_RELAYER_A)] + .into_iter() + .collect(), + }, + ))), + UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 1, + total_messages: 1, + last_delivered_nonce: 1, + }, + )); + + // nothing is pruned yet + assert_eq!( + outbound_lane::(TEST_LANE_ID).data().latest_received_nonce, + 1 + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID).data().oldest_unpruned_nonce, + 1 + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID_2).data().latest_received_nonce, + 1 + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID_2).data().oldest_unpruned_nonce, + 1 + ); + + // in block#2.on_idle lane messages of lane 1 are pruned + let dbw = DbWeight::get(); + System::::set_block_number(2); + assert_eq!( + Pallet::::on_idle(0, dbw.reads_writes(100, 100)), + dbw.reads_writes(1, 2), + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID).data().oldest_unpruned_nonce, + 2 + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID_2).data().oldest_unpruned_nonce, + 1 + ); + + // in block#3.on_idle lane messages of lane 2 are pruned + System::::set_block_number(3); + + assert_eq!( + Pallet::::on_idle(0, dbw.reads_writes(100, 100)), + dbw.reads_writes(1, 2), + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID).data().oldest_unpruned_nonce, + 2 + ); + assert_eq!( + outbound_lane::(TEST_LANE_ID_2).data().oldest_unpruned_nonce, + 2 + ); + }); + } + + #[test] + fn outbound_message_from_unconfigured_lane_is_rejected() { + run_test(|| { + assert_noop!( + send_message::( + RuntimeOrigin::signed(1), + TEST_LANE_ID_3, + REGULAR_PAYLOAD, + ), + Error::::InactiveOutboundLane, + ); + }); + } + + #[test] + fn test_bridge_messages_call_is_correctly_defined() { + let account_id = 1; + let message_proof: TestMessagesProof = Ok(vec![message(1, REGULAR_PAYLOAD)]).into(); + let message_delivery_proof = TestMessagesDeliveryProof(Ok(( + TEST_LANE_ID, + InboundLaneData { + last_confirmed_nonce: 1, + relayers: vec![UnrewardedRelayer { + relayer: 0, + messages: DeliveredMessages::new(1), + }] + .into_iter() + .collect(), + }, + ))); + let unrewarded_relayer_state = UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + total_messages: 1, + last_delivered_nonce: 1, + ..Default::default() + }; + + let direct_receive_messages_proof_call = Call::::receive_messages_proof { + relayer_id_at_bridged_chain: account_id, + proof: message_proof.clone(), + messages_count: 1, + dispatch_weight: REGULAR_PAYLOAD.declared_weight, + }; + let indirect_receive_messages_proof_call = BridgeMessagesCall::< + AccountId, + TestMessagesProof, + TestMessagesDeliveryProof, + >::receive_messages_proof { + relayer_id_at_bridged_chain: account_id, + proof: message_proof, + messages_count: 1, + dispatch_weight: REGULAR_PAYLOAD.declared_weight, + }; + assert_eq!( + direct_receive_messages_proof_call.encode(), + indirect_receive_messages_proof_call.encode() + ); + + let direct_receive_messages_delivery_proof_call = + Call::::receive_messages_delivery_proof { + proof: message_delivery_proof.clone(), + relayers_state: unrewarded_relayer_state.clone(), + }; + let indirect_receive_messages_delivery_proof_call = BridgeMessagesCall::< + AccountId, + TestMessagesProof, + TestMessagesDeliveryProof, + >::receive_messages_delivery_proof { + proof: message_delivery_proof, + relayers_state: unrewarded_relayer_state, + }; + assert_eq!( + direct_receive_messages_delivery_proof_call.encode(), + indirect_receive_messages_delivery_proof_call.encode() + ); + } + + generate_owned_bridge_module_tests!( + MessagesOperatingMode::Basic(BasicOperatingMode::Normal), + MessagesOperatingMode::Basic(BasicOperatingMode::Halted) + ); + + #[test] + fn inbound_storage_extra_proof_size_bytes_works() { + fn relayer_entry() -> UnrewardedRelayer { + UnrewardedRelayer { relayer: 42u64, messages: DeliveredMessages { begin: 0, end: 100 } } + } + + fn storage(relayer_entries: usize) -> RuntimeInboundLaneStorage { + RuntimeInboundLaneStorage { + lane_id: Default::default(), + cached_data: Some(InboundLaneData { + relayers: vec![relayer_entry(); relayer_entries].into_iter().collect(), + last_confirmed_nonce: 0, + }), + _phantom: Default::default(), + } + } + + let max_entries = crate::mock::MaxUnrewardedRelayerEntriesAtInboundLane::get() as usize; + + // when we have exactly `MaxUnrewardedRelayerEntriesAtInboundLane` unrewarded relayers + assert_eq!(storage(max_entries).extra_proof_size_bytes(), 0); + + // when we have less than `MaxUnrewardedRelayerEntriesAtInboundLane` unrewarded relayers + assert_eq!( + storage(max_entries - 1).extra_proof_size_bytes(), + relayer_entry().encode().len() as u64 + ); + assert_eq!( + storage(max_entries - 2).extra_proof_size_bytes(), + 2 * relayer_entry().encode().len() as u64 + ); + + // when we have more than `MaxUnrewardedRelayerEntriesAtInboundLane` unrewarded relayers + // (shall not happen in practice) + assert_eq!(storage(max_entries + 1).extra_proof_size_bytes(), 0); + } + + #[test] + fn maybe_outbound_lanes_count_returns_correct_value() { + assert_eq!( + MaybeOutboundLanesCount::::get(), + Some(mock::ActiveOutboundLanes::get().len() as u32) + ); + } +} diff --git a/bridges/modules/messages/src/mock.rs b/bridges/modules/messages/src/mock.rs new file mode 100644 index 00000000000..8716c5bc3ac --- /dev/null +++ b/bridges/modules/messages/src/mock.rs @@ -0,0 +1,500 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +// From construct_runtime macro +#![allow(clippy::from_over_into)] + +use crate::Config; + +use bp_messages::{ + calc_relayers_rewards, + source_chain::{DeliveryConfirmationPayments, LaneMessageVerifier, TargetHeaderChain}, + target_chain::{ + DeliveryPayments, DispatchMessage, DispatchMessageData, MessageDispatch, + ProvedLaneMessages, ProvedMessages, SourceHeaderChain, + }, + DeliveredMessages, InboundLaneData, LaneId, Message, MessageKey, MessageNonce, MessagePayload, + OutboundLaneData, UnrewardedRelayer, UnrewardedRelayersState, VerificationError, +}; +use bp_runtime::{messages::MessageDispatchResult, Size}; +use codec::{Decode, Encode}; +use frame_support::{ + parameter_types, + traits::ConstU64, + weights::{constants::RocksDbWeight, Weight}, +}; +use scale_info::TypeInfo; +use sp_core::H256; +use sp_runtime::{ + testing::Header as SubstrateHeader, + traits::{BlakeTwo256, ConstU32, IdentityLookup}, + Perbill, +}; +use std::{ + collections::{BTreeMap, VecDeque}, + ops::RangeInclusive, +}; + +pub type AccountId = u64; +pub type Balance = u64; +#[derive(Decode, Encode, Clone, Debug, PartialEq, Eq, TypeInfo)] +pub struct TestPayload { + /// Field that may be used to identify messages. + pub id: u64, + /// Reject this message by lane verifier? + pub reject_by_lane_verifier: bool, + /// Dispatch weight that is declared by the message sender. + pub declared_weight: Weight, + /// Message dispatch result. + /// + /// Note: in correct code `dispatch_result.unspent_weight` will always be <= `declared_weight`, + /// but for test purposes we'll be making it larger than `declared_weight` sometimes. + pub dispatch_result: MessageDispatchResult, + /// Extra bytes that affect payload size. + pub extra: Vec, +} +pub type TestMessageFee = u64; +pub type TestRelayer = u64; +pub type TestDispatchLevelResult = (); + +type Block = frame_system::mocking::MockBlock; +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + +use crate as pallet_bridge_messages; + +frame_support::construct_runtime! { + pub enum TestRuntime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Event}, + Messages: pallet_bridge_messages::{Pallet, Call, Event}, + } +} + +parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); + pub const MaximumBlockLength: u32 = 2 * 1024; + pub const AvailableBlockRatio: Perbill = Perbill::one(); +} + +pub type DbWeight = RocksDbWeight; + +impl frame_system::Config for TestRuntime { + type RuntimeOrigin = RuntimeOrigin; + type Index = u64; + type RuntimeCall = RuntimeCall; + type BlockNumber = u64; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type Header = SubstrateHeader; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = ConstU64<250>; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type BaseCallFilter = frame_support::traits::Everything; + type SystemWeightInfo = (); + type BlockWeights = (); + type BlockLength = (); + type DbWeight = DbWeight; + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +impl pallet_balances::Config for TestRuntime { + type MaxLocks = (); + type Balance = Balance; + type DustRemoval = (); + type RuntimeEvent = RuntimeEvent; + type ExistentialDeposit = ConstU64<1>; + type AccountStore = frame_system::Pallet; + type WeightInfo = (); + type MaxReserves = (); + type ReserveIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; + type FreezeIdentifier = (); + type MaxHolds = ConstU32<0>; + type MaxFreezes = ConstU32<0>; +} + +parameter_types! { + pub const MaxMessagesToPruneAtOnce: u64 = 10; + pub const MaxUnrewardedRelayerEntriesAtInboundLane: u64 = 16; + pub const MaxUnconfirmedMessagesAtInboundLane: u64 = 128; + pub const TestBridgedChainId: bp_runtime::ChainId = *b"test"; + pub const ActiveOutboundLanes: &'static [LaneId] = &[TEST_LANE_ID, TEST_LANE_ID_2]; +} + +/// weights of messages pallet calls we use in tests. +pub type TestWeightInfo = (); + +impl Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = TestWeightInfo; + type ActiveOutboundLanes = ActiveOutboundLanes; + type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane; + type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane; + + type MaximalOutboundPayloadSize = frame_support::traits::ConstU32; + type OutboundPayload = TestPayload; + + type InboundPayload = TestPayload; + type InboundRelayer = TestRelayer; + type DeliveryPayments = TestDeliveryPayments; + + type TargetHeaderChain = TestTargetHeaderChain; + type LaneMessageVerifier = TestLaneMessageVerifier; + type DeliveryConfirmationPayments = TestDeliveryConfirmationPayments; + + type SourceHeaderChain = TestSourceHeaderChain; + type MessageDispatch = TestMessageDispatch; + type BridgedChainId = TestBridgedChainId; +} + +#[cfg(feature = "runtime-benchmarks")] +impl crate::benchmarking::Config<()> for TestRuntime { + fn bench_lane_id() -> LaneId { + TEST_LANE_ID + } + + fn prepare_message_proof( + params: crate::benchmarking::MessageProofParams, + ) -> (TestMessagesProof, Weight) { + // in mock run we only care about benchmarks correctness, not the benchmark results + // => ignore size related arguments + let (messages, total_dispatch_weight) = + params.message_nonces.into_iter().map(|n| message(n, REGULAR_PAYLOAD)).fold( + (Vec::new(), Weight::zero()), + |(mut messages, total_dispatch_weight), message| { + let weight = REGULAR_PAYLOAD.declared_weight; + messages.push(message); + (messages, total_dispatch_weight.saturating_add(weight)) + }, + ); + let mut proof: TestMessagesProof = Ok(messages).into(); + proof.result.as_mut().unwrap().get_mut(0).unwrap().1.lane_state = params.outbound_lane_data; + (proof, total_dispatch_weight) + } + + fn prepare_message_delivery_proof( + params: crate::benchmarking::MessageDeliveryProofParams, + ) -> TestMessagesDeliveryProof { + // in mock run we only care about benchmarks correctness, not the benchmark results + // => ignore size related arguments + TestMessagesDeliveryProof(Ok((params.lane, params.inbound_lane_data))) + } + + fn is_relayer_rewarded(_relayer: &AccountId) -> bool { + true + } +} + +impl Size for TestPayload { + fn size(&self) -> u32 { + 16 + self.extra.len() as u32 + } +} + +/// Maximal outbound payload size. +pub const MAX_OUTBOUND_PAYLOAD_SIZE: u32 = 4096; + +/// Account that has balance to use in tests. +pub const ENDOWED_ACCOUNT: AccountId = 0xDEAD; + +/// Account id of test relayer. +pub const TEST_RELAYER_A: AccountId = 100; + +/// Account id of additional test relayer - B. +pub const TEST_RELAYER_B: AccountId = 101; + +/// Account id of additional test relayer - C. +pub const TEST_RELAYER_C: AccountId = 102; + +/// Error that is returned by all test implementations. +pub const TEST_ERROR: &str = "Test error"; + +/// Lane that we're using in tests. +pub const TEST_LANE_ID: LaneId = LaneId([0, 0, 0, 1]); + +/// Secondary lane that we're using in tests. +pub const TEST_LANE_ID_2: LaneId = LaneId([0, 0, 0, 2]); + +/// Inactive outbound lane. +pub const TEST_LANE_ID_3: LaneId = LaneId([0, 0, 0, 3]); + +/// Regular message payload. +pub const REGULAR_PAYLOAD: TestPayload = message_payload(0, 50); + +/// Payload that is rejected by `TestTargetHeaderChain`. +pub const PAYLOAD_REJECTED_BY_TARGET_CHAIN: TestPayload = message_payload(1, 50); + +/// Vec of proved messages, grouped by lane. +pub type MessagesByLaneVec = Vec<(LaneId, ProvedLaneMessages)>; + +/// Test messages proof. +#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] +pub struct TestMessagesProof { + pub result: Result, +} + +impl Size for TestMessagesProof { + fn size(&self) -> u32 { + 0 + } +} + +impl From, ()>> for TestMessagesProof { + fn from(result: Result, ()>) -> Self { + Self { + result: result.map(|messages| { + let mut messages_by_lane: BTreeMap> = + BTreeMap::new(); + for message in messages { + messages_by_lane.entry(message.key.lane_id).or_default().messages.push(message); + } + messages_by_lane.into_iter().collect() + }), + } + } +} + +/// Messages delivery proof used in tests. +#[derive(Debug, Encode, Decode, Eq, Clone, PartialEq, TypeInfo)] +pub struct TestMessagesDeliveryProof(pub Result<(LaneId, InboundLaneData), ()>); + +impl Size for TestMessagesDeliveryProof { + fn size(&self) -> u32 { + 0 + } +} + +/// Target header chain that is used in tests. +#[derive(Debug, Default)] +pub struct TestTargetHeaderChain; + +impl TargetHeaderChain for TestTargetHeaderChain { + type MessagesDeliveryProof = TestMessagesDeliveryProof; + + fn verify_message(payload: &TestPayload) -> Result<(), VerificationError> { + if *payload == PAYLOAD_REJECTED_BY_TARGET_CHAIN { + Err(VerificationError::Other(TEST_ERROR)) + } else { + Ok(()) + } + } + + fn verify_messages_delivery_proof( + proof: Self::MessagesDeliveryProof, + ) -> Result<(LaneId, InboundLaneData), VerificationError> { + proof.0.map_err(|_| VerificationError::Other(TEST_ERROR)) + } +} + +/// Lane message verifier that is used in tests. +#[derive(Debug, Default)] +pub struct TestLaneMessageVerifier; + +impl LaneMessageVerifier for TestLaneMessageVerifier { + fn verify_message( + _submitter: &RuntimeOrigin, + _lane: &LaneId, + _lane_outbound_data: &OutboundLaneData, + payload: &TestPayload, + ) -> Result<(), VerificationError> { + if !payload.reject_by_lane_verifier { + Ok(()) + } else { + Err(VerificationError::Other(TEST_ERROR)) + } + } +} + +/// Reward payments at the target chain during delivery transaction. +#[derive(Debug, Default)] +pub struct TestDeliveryPayments; + +impl TestDeliveryPayments { + /// Returns true if given relayer has been rewarded with given balance. The reward-paid flag is + /// cleared after the call. + pub fn is_reward_paid(relayer: AccountId) -> bool { + let key = (b":delivery-relayer-reward:", relayer).encode(); + frame_support::storage::unhashed::take::(&key).is_some() + } +} + +impl DeliveryPayments for TestDeliveryPayments { + type Error = &'static str; + + fn pay_reward( + relayer: AccountId, + _total_messages: MessageNonce, + _valid_messages: MessageNonce, + _actual_weight: Weight, + ) { + let key = (b":delivery-relayer-reward:", relayer).encode(); + frame_support::storage::unhashed::put(&key, &true); + } +} + +/// Reward payments at the source chain during delivery confirmation transaction. +#[derive(Debug, Default)] +pub struct TestDeliveryConfirmationPayments; + +impl TestDeliveryConfirmationPayments { + /// Returns true if given relayer has been rewarded with given balance. The reward-paid flag is + /// cleared after the call. + pub fn is_reward_paid(relayer: AccountId, fee: TestMessageFee) -> bool { + let key = (b":relayer-reward:", relayer, fee).encode(); + frame_support::storage::unhashed::take::(&key).is_some() + } +} + +impl DeliveryConfirmationPayments for TestDeliveryConfirmationPayments { + type Error = &'static str; + + fn pay_reward( + _lane_id: LaneId, + messages_relayers: VecDeque>, + _confirmation_relayer: &AccountId, + received_range: &RangeInclusive, + ) -> MessageNonce { + let relayers_rewards = calc_relayers_rewards(messages_relayers, received_range); + let rewarded_relayers = relayers_rewards.len(); + for (relayer, reward) in &relayers_rewards { + let key = (b":relayer-reward:", relayer, reward).encode(); + frame_support::storage::unhashed::put(&key, &true); + } + + rewarded_relayers as _ + } +} + +/// Source header chain that is used in tests. +#[derive(Debug)] +pub struct TestSourceHeaderChain; + +impl SourceHeaderChain for TestSourceHeaderChain { + type MessagesProof = TestMessagesProof; + + fn verify_messages_proof( + proof: Self::MessagesProof, + _messages_count: u32, + ) -> Result, VerificationError> { + proof + .result + .map(|proof| proof.into_iter().collect()) + .map_err(|_| VerificationError::Other(TEST_ERROR)) + } +} + +/// Source header chain that is used in tests. +#[derive(Debug)] +pub struct TestMessageDispatch; + +impl MessageDispatch for TestMessageDispatch { + type DispatchPayload = TestPayload; + type DispatchLevelResult = TestDispatchLevelResult; + + fn dispatch_weight(message: &mut DispatchMessage) -> Weight { + match message.data.payload.as_ref() { + Ok(payload) => payload.declared_weight, + Err(_) => Weight::zero(), + } + } + + fn dispatch( + message: DispatchMessage, + ) -> MessageDispatchResult { + match message.data.payload.as_ref() { + Ok(payload) => payload.dispatch_result.clone(), + Err(_) => dispatch_result(0), + } + } +} + +/// Return test lane message with given nonce and payload. +pub fn message(nonce: MessageNonce, payload: TestPayload) -> Message { + Message { key: MessageKey { lane_id: TEST_LANE_ID, nonce }, payload: payload.encode() } +} + +/// Return valid outbound message data, constructed from given payload. +pub fn outbound_message_data(payload: TestPayload) -> MessagePayload { + payload.encode() +} + +/// Return valid inbound (dispatch) message data, constructed from given payload. +pub fn inbound_message_data(payload: TestPayload) -> DispatchMessageData { + DispatchMessageData { payload: Ok(payload) } +} + +/// Constructs message payload using given arguments and zero unspent weight. +pub const fn message_payload(id: u64, declared_weight: u64) -> TestPayload { + TestPayload { + id, + reject_by_lane_verifier: false, + declared_weight: Weight::from_parts(declared_weight, 0), + dispatch_result: dispatch_result(0), + extra: Vec::new(), + } +} + +/// Returns message dispatch result with given unspent weight. +pub const fn dispatch_result( + unspent_weight: u64, +) -> MessageDispatchResult { + MessageDispatchResult { + unspent_weight: Weight::from_parts(unspent_weight, 0), + dispatch_level_result: (), + } +} + +/// Constructs unrewarded relayer entry from nonces range and relayer id. +pub fn unrewarded_relayer( + begin: MessageNonce, + end: MessageNonce, + relayer: TestRelayer, +) -> UnrewardedRelayer { + UnrewardedRelayer { relayer, messages: DeliveredMessages { begin, end } } +} + +/// Returns unrewarded relayers state at given lane. +pub fn inbound_unrewarded_relayers_state(lane: bp_messages::LaneId) -> UnrewardedRelayersState { + let inbound_lane_data = crate::InboundLanes::::get(lane).0; + UnrewardedRelayersState::from(&inbound_lane_data) +} + +/// Return test externalities to use in tests. +pub fn new_test_ext() -> sp_io::TestExternalities { + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + pallet_balances::GenesisConfig:: { balances: vec![(ENDOWED_ACCOUNT, 1_000_000)] } + .assimilate_storage(&mut t) + .unwrap(); + sp_io::TestExternalities::new(t) +} + +/// Run pallet test. +pub fn run_test(test: impl FnOnce() -> T) -> T { + new_test_ext().execute_with(test) +} diff --git a/bridges/modules/messages/src/outbound_lane.rs b/bridges/modules/messages/src/outbound_lane.rs new file mode 100644 index 00000000000..0cf0c4ccb42 --- /dev/null +++ b/bridges/modules/messages/src/outbound_lane.rs @@ -0,0 +1,431 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Everything about outgoing messages sending. + +use crate::{Config, LOG_TARGET}; + +use bp_messages::{ + DeliveredMessages, LaneId, MessageNonce, MessagePayload, OutboundLaneData, UnrewardedRelayer, + VerificationError, +}; +use codec::{Decode, Encode}; +use frame_support::{ + weights::{RuntimeDbWeight, Weight}, + BoundedVec, PalletError, RuntimeDebug, +}; +use num_traits::Zero; +use scale_info::TypeInfo; +use sp_std::collections::vec_deque::VecDeque; + +/// Outbound lane storage. +pub trait OutboundLaneStorage { + /// Lane id. + fn id(&self) -> LaneId; + /// Get lane data from the storage. + fn data(&self) -> OutboundLaneData; + /// Update lane data in the storage. + fn set_data(&mut self, data: OutboundLaneData); + /// Returns saved outbound message payload. + #[cfg(test)] + fn message(&self, nonce: &MessageNonce) -> Option; + /// Save outbound message in the storage. + fn save_message( + &mut self, + nonce: MessageNonce, + message_payload: MessagePayload, + ) -> Result<(), VerificationError>; + /// Remove outbound message from the storage. + fn remove_message(&mut self, nonce: &MessageNonce); +} + +/// Outbound message data wrapper that implements `MaxEncodedLen`. +pub type StoredMessagePayload = BoundedVec>::MaximalOutboundPayloadSize>; + +/// Result of messages receival confirmation. +#[derive(Encode, Decode, RuntimeDebug, PartialEq, Eq, PalletError, TypeInfo)] +pub enum ReceivalConfirmationError { + /// Bridged chain is trying to confirm more messages than we have generated. May be a result + /// of invalid bridged chain storage. + FailedToConfirmFutureMessages, + /// The unrewarded relayers vec contains an empty entry. May be a result of invalid bridged + /// chain storage. + EmptyUnrewardedRelayerEntry, + /// The unrewarded relayers vec contains non-consecutive entries. May be a result of invalid + /// bridged chain storage. + NonConsecutiveUnrewardedRelayerEntries, + /// The chain has more messages that need to be confirmed than there is in the proof. + TryingToConfirmMoreMessagesThanExpected, +} + +/// Outbound messages lane. +pub struct OutboundLane { + storage: S, +} + +impl OutboundLane { + /// Create new outbound lane backed by given storage. + pub fn new(storage: S) -> Self { + OutboundLane { storage } + } + + /// Get this lane data. + pub fn data(&self) -> OutboundLaneData { + self.storage.data() + } + + /// Send message over lane. + /// + /// Returns new message nonce. + pub fn send_message( + &mut self, + message_payload: MessagePayload, + ) -> Result { + let mut data = self.storage.data(); + let nonce = data.latest_generated_nonce + 1; + data.latest_generated_nonce = nonce; + + self.storage.save_message(nonce, message_payload)?; + self.storage.set_data(data); + + Ok(nonce) + } + + /// Confirm messages delivery. + pub fn confirm_delivery( + &mut self, + max_allowed_messages: MessageNonce, + latest_delivered_nonce: MessageNonce, + relayers: &VecDeque>, + ) -> Result, ReceivalConfirmationError> { + let mut data = self.storage.data(); + let confirmed_messages = DeliveredMessages { + begin: data.latest_received_nonce.saturating_add(1), + end: latest_delivered_nonce, + }; + if confirmed_messages.total_messages() == 0 { + return Ok(None) + } + if confirmed_messages.end > data.latest_generated_nonce { + return Err(ReceivalConfirmationError::FailedToConfirmFutureMessages) + } + if confirmed_messages.total_messages() > max_allowed_messages { + // that the relayer has declared correct number of messages that the proof contains (it + // is checked outside of the function). But it may happen (but only if this/bridged + // chain storage is corrupted, though) that the actual number of confirmed messages if + // larger than declared. This would mean that 'reward loop' will take more time than the + // weight formula accounts, so we can't allow that. + log::trace!( + target: LOG_TARGET, + "Messages delivery proof contains too many messages to confirm: {} vs declared {}", + confirmed_messages.total_messages(), + max_allowed_messages, + ); + return Err(ReceivalConfirmationError::TryingToConfirmMoreMessagesThanExpected) + } + + ensure_unrewarded_relayers_are_correct(confirmed_messages.end, relayers)?; + + data.latest_received_nonce = confirmed_messages.end; + self.storage.set_data(data); + + Ok(Some(confirmed_messages)) + } + + /// Prune at most `max_messages_to_prune` already received messages. + /// + /// Returns weight, consumed by messages pruning and lane state update. + pub fn prune_messages( + &mut self, + db_weight: RuntimeDbWeight, + mut remaining_weight: Weight, + ) -> Weight { + let write_weight = db_weight.writes(1); + let two_writes_weight = write_weight + write_weight; + let mut spent_weight = Weight::zero(); + let mut data = self.storage.data(); + while remaining_weight.all_gte(two_writes_weight) && + data.oldest_unpruned_nonce <= data.latest_received_nonce + { + self.storage.remove_message(&data.oldest_unpruned_nonce); + + spent_weight += write_weight; + remaining_weight -= write_weight; + data.oldest_unpruned_nonce += 1; + } + + if !spent_weight.is_zero() { + spent_weight += write_weight; + self.storage.set_data(data); + } + + spent_weight + } +} + +/// Verifies unrewarded relayers vec. +/// +/// Returns `Err(_)` if unrewarded relayers vec contains invalid data, meaning that the bridged +/// chain has invalid runtime storage. +fn ensure_unrewarded_relayers_are_correct( + latest_received_nonce: MessageNonce, + relayers: &VecDeque>, +) -> Result<(), ReceivalConfirmationError> { + let mut expected_entry_begin = relayers.front().map(|entry| entry.messages.begin); + for entry in relayers { + // unrewarded relayer entry must have at least 1 unconfirmed message + // (guaranteed by the `InboundLane::receive_message()`) + if entry.messages.end < entry.messages.begin { + return Err(ReceivalConfirmationError::EmptyUnrewardedRelayerEntry) + } + // every entry must confirm range of messages that follows previous entry range + // (guaranteed by the `InboundLane::receive_message()`) + if expected_entry_begin != Some(entry.messages.begin) { + return Err(ReceivalConfirmationError::NonConsecutiveUnrewardedRelayerEntries) + } + expected_entry_begin = entry.messages.end.checked_add(1); + // entry can't confirm messages larger than `inbound_lane_data.latest_received_nonce()` + // (guaranteed by the `InboundLane::receive_message()`) + if entry.messages.end > latest_received_nonce { + return Err(ReceivalConfirmationError::FailedToConfirmFutureMessages) + } + } + + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + mock::{ + outbound_message_data, run_test, unrewarded_relayer, TestRelayer, TestRuntime, + REGULAR_PAYLOAD, TEST_LANE_ID, + }, + outbound_lane, + }; + use frame_support::{assert_ok, weights::constants::RocksDbWeight}; + use sp_std::ops::RangeInclusive; + + fn unrewarded_relayers( + nonces: RangeInclusive, + ) -> VecDeque> { + vec![unrewarded_relayer(*nonces.start(), *nonces.end(), 0)] + .into_iter() + .collect() + } + + fn delivered_messages(nonces: RangeInclusive) -> DeliveredMessages { + DeliveredMessages { begin: *nonces.start(), end: *nonces.end() } + } + + fn assert_3_messages_confirmation_fails( + latest_received_nonce: MessageNonce, + relayers: &VecDeque>, + ) -> Result, ReceivalConfirmationError> { + run_test(|| { + let mut lane = outbound_lane::(TEST_LANE_ID); + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert_eq!(lane.storage.data().latest_generated_nonce, 3); + assert_eq!(lane.storage.data().latest_received_nonce, 0); + let result = lane.confirm_delivery(3, latest_received_nonce, relayers); + assert_eq!(lane.storage.data().latest_generated_nonce, 3); + assert_eq!(lane.storage.data().latest_received_nonce, 0); + result + }) + } + + #[test] + fn send_message_works() { + run_test(|| { + let mut lane = outbound_lane::(TEST_LANE_ID); + assert_eq!(lane.storage.data().latest_generated_nonce, 0); + assert_eq!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD)), Ok(1)); + assert!(lane.storage.message(&1).is_some()); + assert_eq!(lane.storage.data().latest_generated_nonce, 1); + }); + } + + #[test] + fn confirm_delivery_works() { + run_test(|| { + let mut lane = outbound_lane::(TEST_LANE_ID); + assert_eq!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD)), Ok(1)); + assert_eq!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD)), Ok(2)); + assert_eq!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD)), Ok(3)); + assert_eq!(lane.storage.data().latest_generated_nonce, 3); + assert_eq!(lane.storage.data().latest_received_nonce, 0); + assert_eq!( + lane.confirm_delivery(3, 3, &unrewarded_relayers(1..=3)), + Ok(Some(delivered_messages(1..=3))), + ); + assert_eq!(lane.storage.data().latest_generated_nonce, 3); + assert_eq!(lane.storage.data().latest_received_nonce, 3); + }); + } + + #[test] + fn confirm_delivery_rejects_nonce_lesser_than_latest_received() { + run_test(|| { + let mut lane = outbound_lane::(TEST_LANE_ID); + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert_eq!(lane.storage.data().latest_generated_nonce, 3); + assert_eq!(lane.storage.data().latest_received_nonce, 0); + assert_eq!( + lane.confirm_delivery(3, 3, &unrewarded_relayers(1..=3)), + Ok(Some(delivered_messages(1..=3))), + ); + assert_eq!(lane.confirm_delivery(3, 3, &unrewarded_relayers(1..=3)), Ok(None),); + assert_eq!(lane.storage.data().latest_generated_nonce, 3); + assert_eq!(lane.storage.data().latest_received_nonce, 3); + + assert_eq!(lane.confirm_delivery(1, 2, &unrewarded_relayers(1..=1)), Ok(None),); + assert_eq!(lane.storage.data().latest_generated_nonce, 3); + assert_eq!(lane.storage.data().latest_received_nonce, 3); + }); + } + + #[test] + fn confirm_delivery_rejects_nonce_larger_than_last_generated() { + assert_eq!( + assert_3_messages_confirmation_fails(10, &unrewarded_relayers(1..=10),), + Err(ReceivalConfirmationError::FailedToConfirmFutureMessages), + ); + } + + #[test] + fn confirm_delivery_fails_if_entry_confirms_future_messages() { + assert_eq!( + assert_3_messages_confirmation_fails( + 3, + &unrewarded_relayers(1..=1) + .into_iter() + .chain(unrewarded_relayers(2..=30).into_iter()) + .chain(unrewarded_relayers(3..=3).into_iter()) + .collect(), + ), + Err(ReceivalConfirmationError::FailedToConfirmFutureMessages), + ); + } + + #[test] + #[allow(clippy::reversed_empty_ranges)] + fn confirm_delivery_fails_if_entry_is_empty() { + assert_eq!( + assert_3_messages_confirmation_fails( + 3, + &unrewarded_relayers(1..=1) + .into_iter() + .chain(unrewarded_relayers(2..=1).into_iter()) + .chain(unrewarded_relayers(2..=3).into_iter()) + .collect(), + ), + Err(ReceivalConfirmationError::EmptyUnrewardedRelayerEntry), + ); + } + + #[test] + fn confirm_delivery_fails_if_entries_are_non_consecutive() { + assert_eq!( + assert_3_messages_confirmation_fails( + 3, + &unrewarded_relayers(1..=1) + .into_iter() + .chain(unrewarded_relayers(3..=3).into_iter()) + .chain(unrewarded_relayers(2..=2).into_iter()) + .collect(), + ), + Err(ReceivalConfirmationError::NonConsecutiveUnrewardedRelayerEntries), + ); + } + + #[test] + fn prune_messages_works() { + run_test(|| { + let mut lane = outbound_lane::(TEST_LANE_ID); + // when lane is empty, nothing is pruned + assert_eq!( + lane.prune_messages(RocksDbWeight::get(), RocksDbWeight::get().writes(101)), + Weight::zero() + ); + assert_eq!(lane.storage.data().oldest_unpruned_nonce, 1); + // when nothing is confirmed, nothing is pruned + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert!(lane.storage.message(&1).is_some()); + assert!(lane.storage.message(&2).is_some()); + assert!(lane.storage.message(&3).is_some()); + assert_eq!( + lane.prune_messages(RocksDbWeight::get(), RocksDbWeight::get().writes(101)), + Weight::zero() + ); + assert_eq!(lane.storage.data().oldest_unpruned_nonce, 1); + // after confirmation, some messages are received + assert_eq!( + lane.confirm_delivery(2, 2, &unrewarded_relayers(1..=2)), + Ok(Some(delivered_messages(1..=2))), + ); + assert_eq!( + lane.prune_messages(RocksDbWeight::get(), RocksDbWeight::get().writes(101)), + RocksDbWeight::get().writes(3), + ); + assert!(lane.storage.message(&1).is_none()); + assert!(lane.storage.message(&2).is_none()); + assert!(lane.storage.message(&3).is_some()); + assert_eq!(lane.storage.data().oldest_unpruned_nonce, 3); + // after last message is confirmed, everything is pruned + assert_eq!( + lane.confirm_delivery(1, 3, &unrewarded_relayers(3..=3)), + Ok(Some(delivered_messages(3..=3))), + ); + assert_eq!( + lane.prune_messages(RocksDbWeight::get(), RocksDbWeight::get().writes(101)), + RocksDbWeight::get().writes(2), + ); + assert!(lane.storage.message(&1).is_none()); + assert!(lane.storage.message(&2).is_none()); + assert!(lane.storage.message(&3).is_none()); + assert_eq!(lane.storage.data().oldest_unpruned_nonce, 4); + }); + } + + #[test] + fn confirm_delivery_detects_when_more_than_expected_messages_are_confirmed() { + run_test(|| { + let mut lane = outbound_lane::(TEST_LANE_ID); + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert_ok!(lane.send_message(outbound_message_data(REGULAR_PAYLOAD))); + assert_eq!( + lane.confirm_delivery(0, 3, &unrewarded_relayers(1..=3)), + Err(ReceivalConfirmationError::TryingToConfirmMoreMessagesThanExpected), + ); + assert_eq!( + lane.confirm_delivery(2, 3, &unrewarded_relayers(1..=3)), + Err(ReceivalConfirmationError::TryingToConfirmMoreMessagesThanExpected), + ); + assert_eq!( + lane.confirm_delivery(3, 3, &unrewarded_relayers(1..=3)), + Ok(Some(delivered_messages(1..=3))), + ); + }); + } +} diff --git a/bridges/modules/messages/src/weights.rs b/bridges/modules/messages/src/weights.rs new file mode 100644 index 00000000000..9880f1dd1ea --- /dev/null +++ b/bridges/modules/messages/src/weights.rs @@ -0,0 +1,525 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Autogenerated weights for RialtoMessages +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/millau-bridge-node +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=RialtoMessages +// --extrinsic=* +// --execution=wasm +// --wasm-execution=Compiled +// --heap-pages=4096 +// --output=./modules/messages/src/weights.rs +// --template=./.maintain/bridge-weight-template.hbs + +#![allow(clippy::all)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for RialtoMessages. +pub trait WeightInfo { + fn receive_single_message_proof() -> Weight; + fn receive_two_messages_proof() -> Weight; + fn receive_single_message_proof_with_outbound_lane_state() -> Weight; + fn receive_single_message_proof_1_kb() -> Weight; + fn receive_single_message_proof_16_kb() -> Weight; + fn receive_delivery_proof_for_single_message() -> Weight; + fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight; + fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight; + fn receive_single_message_proof_with_dispatch(i: u32) -> Weight; +} + +/// Weights for `RialtoMessages` that are generated using one of the Bridge testnets. +/// +/// Those weights are test only and must never be used in production. +pub struct BridgeWeight(PhantomData); +impl WeightInfo for BridgeWeight { + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + fn receive_single_message_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 52_321 nanoseconds. + Weight::from_parts(54_478_000, 57170) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + fn receive_two_messages_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 64_597 nanoseconds. + Weight::from_parts(69_267_000, 57170) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_with_outbound_lane_state() -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 64_079 nanoseconds. + Weight::from_parts(65_905_000, 57170) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_1_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 50_588 nanoseconds. + Weight::from_parts(53_544_000, 57170) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_16_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 78_269 nanoseconds. + Weight::from_parts(81_748_000, 57170) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// 539, mode: MaxEncodedLen) + /// + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + fn receive_delivery_proof_for_single_message() -> Weight { + // Proof Size summary in bytes: + // Measured: `579` + // Estimated: `9584` + // Minimum execution time: 45_786 nanoseconds. + Weight::from_parts(47_382_000, 9584) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// 539, mode: MaxEncodedLen) + /// + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { + // Proof Size summary in bytes: + // Measured: `596` + // Estimated: `9584` + // Minimum execution time: 44_544 nanoseconds. + Weight::from_parts(45_451_000, 9584) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// 539, mode: MaxEncodedLen) + /// + /// Storage: BridgeRelayers RelayerRewards (r:2 w:2) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { + // Proof Size summary in bytes: + // Measured: `596` + // Estimated: `12124` + // Minimum execution time: 47_344 nanoseconds. + Weight::from_parts(48_311_000, 12124) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + /// + /// The range of component `i` is `[128, 2048]`. + fn receive_single_message_proof_with_dispatch(i: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 52_385 nanoseconds. + Weight::from_parts(54_919_468, 57170) + // Standard Error: 108 + .saturating_add(Weight::from_parts(3_286, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + fn receive_single_message_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 52_321 nanoseconds. + Weight::from_parts(54_478_000, 57170) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + fn receive_two_messages_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 64_597 nanoseconds. + Weight::from_parts(69_267_000, 57170) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_with_outbound_lane_state() -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 64_079 nanoseconds. + Weight::from_parts(65_905_000, 57170) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_1_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 50_588 nanoseconds. + Weight::from_parts(53_544_000, 57170) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_16_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 78_269 nanoseconds. + Weight::from_parts(81_748_000, 57170) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// 539, mode: MaxEncodedLen) + /// + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + fn receive_delivery_proof_for_single_message() -> Weight { + // Proof Size summary in bytes: + // Measured: `579` + // Estimated: `9584` + // Minimum execution time: 45_786 nanoseconds. + Weight::from_parts(47_382_000, 9584) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// 539, mode: MaxEncodedLen) + /// + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { + // Proof Size summary in bytes: + // Measured: `596` + // Estimated: `9584` + // Minimum execution time: 44_544 nanoseconds. + Weight::from_parts(45_451_000, 9584) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages OutboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: + /// 539, mode: MaxEncodedLen) + /// + /// Storage: BridgeRelayers RelayerRewards (r:2 w:2) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { + // Proof Size summary in bytes: + // Measured: `596` + // Estimated: `12124` + // Minimum execution time: 47_344 nanoseconds. + Weight::from_parts(48_311_000, 12124) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: BridgeRialtoMessages PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), + /// added: 497, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoMessages InboundLanes (r:1 w:1) + /// + /// Proof: BridgeRialtoMessages InboundLanes (max_values: None, max_size: Some(49180), added: + /// 51655, mode: MaxEncodedLen) + /// + /// The range of component `i` is `[128, 2048]`. + fn receive_single_message_proof_with_dispatch(i: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `618` + // Estimated: `57170` + // Minimum execution time: 52_385 nanoseconds. + Weight::from_parts(54_919_468, 57170) + // Standard Error: 108 + .saturating_add(Weight::from_parts(3_286, 0).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} diff --git a/bridges/modules/messages/src/weights_ext.rs b/bridges/modules/messages/src/weights_ext.rs new file mode 100644 index 00000000000..3aefd6be7ca --- /dev/null +++ b/bridges/modules/messages/src/weights_ext.rs @@ -0,0 +1,487 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Weight-related utilities. + +use crate::weights::WeightInfo; + +use bp_messages::{MessageNonce, UnrewardedRelayersState}; +use bp_runtime::{PreComputedSize, Size}; +use frame_support::weights::Weight; + +/// Size of the message being delivered in benchmarks. +pub const EXPECTED_DEFAULT_MESSAGE_LENGTH: u32 = 128; + +/// We assume that size of signed extensions on all our chains and size of all 'small' arguments of +/// calls we're checking here would fit 1KB. +const SIGNED_EXTENSIONS_SIZE: u32 = 1024; + +/// Number of extra bytes (excluding size of storage value itself) of storage proof, built at +/// Rialto chain. This mostly depends on number of entries (and their density) in the storage trie. +/// Some reserve is reserved to account future chain growth. +pub const EXTRA_STORAGE_PROOF_SIZE: u32 = 1024; + +/// Ensure that weights from `WeightInfoExt` implementation are looking correct. +pub fn ensure_weights_are_correct() { + // all components of weight formulae must have zero `proof_size`, because the `proof_size` is + // benchmarked using `MaxEncodedLen` approach and there are no components that cause additional + // db reads + + // verify `receive_messages_proof` weight components + assert_ne!(W::receive_messages_proof_overhead().ref_time(), 0); + assert_ne!(W::receive_messages_proof_overhead().proof_size(), 0); + // W::receive_messages_proof_messages_overhead(1).ref_time() may be zero because: + // the message processing code (`InboundLane::receive_message`) is minimal and may not be + // accounted by our benchmarks + assert_eq!(W::receive_messages_proof_messages_overhead(1).proof_size(), 0); + // W::receive_messages_proof_outbound_lane_state_overhead().ref_time() may be zero because: + // the outbound lane state processing code (`InboundLane::receive_state_update`) is minimal and + // may not be accounted by our benchmarks + assert_eq!(W::receive_messages_proof_outbound_lane_state_overhead().proof_size(), 0); + assert_ne!(W::storage_proof_size_overhead(1).ref_time(), 0); + assert_eq!(W::storage_proof_size_overhead(1).proof_size(), 0); + + // verify `receive_messages_delivery_proof` weight components + assert_ne!(W::receive_messages_delivery_proof_overhead().ref_time(), 0); + assert_ne!(W::receive_messages_delivery_proof_overhead().proof_size(), 0); + // W::receive_messages_delivery_proof_messages_overhead(1).ref_time() may be zero because: + // there's no code that iterates over confirmed messages in confirmation transaction + assert_eq!(W::receive_messages_delivery_proof_messages_overhead(1).proof_size(), 0); + assert_ne!(W::receive_messages_delivery_proof_relayers_overhead(1).ref_time(), 0); + // W::receive_messages_delivery_proof_relayers_overhead(1).proof_size() is an exception + // it may or may not cause additional db reads, so proof size may vary + assert_ne!(W::storage_proof_size_overhead(1).ref_time(), 0); + assert_eq!(W::storage_proof_size_overhead(1).proof_size(), 0); + + // verify `receive_message_proof` weight + let receive_messages_proof_weight = + W::receive_messages_proof_weight(&PreComputedSize(1), 10, Weight::zero()); + assert_ne!(receive_messages_proof_weight.ref_time(), 0); + assert_ne!(receive_messages_proof_weight.proof_size(), 0); + messages_proof_size_does_not_affect_proof_size::(); + messages_count_does_not_affect_proof_size::(); + + // verify `receive_message_proof` weight + let receive_messages_delivery_proof_weight = W::receive_messages_delivery_proof_weight( + &PreComputedSize(1), + &UnrewardedRelayersState::default(), + ); + assert_ne!(receive_messages_delivery_proof_weight.ref_time(), 0); + assert_ne!(receive_messages_delivery_proof_weight.proof_size(), 0); + messages_delivery_proof_size_does_not_affect_proof_size::(); + total_messages_in_delivery_proof_does_not_affect_proof_size::(); +} + +/// Ensure that we're able to receive maximal (by-size and by-weight) message from other chain. +pub fn ensure_able_to_receive_message( + max_extrinsic_size: u32, + max_extrinsic_weight: Weight, + max_incoming_message_proof_size: u32, + max_incoming_message_dispatch_weight: Weight, +) { + // verify that we're able to receive proof of maximal-size message + let max_delivery_transaction_size = + max_incoming_message_proof_size.saturating_add(SIGNED_EXTENSIONS_SIZE); + assert!( + max_delivery_transaction_size <= max_extrinsic_size, + "Size of maximal message delivery transaction {max_incoming_message_proof_size} + {SIGNED_EXTENSIONS_SIZE} is larger than maximal possible transaction size {max_extrinsic_size}", + ); + + // verify that we're able to receive proof of maximal-size message with maximal dispatch weight + let max_delivery_transaction_dispatch_weight = W::receive_messages_proof_weight( + &PreComputedSize( + (max_incoming_message_proof_size + W::expected_extra_storage_proof_size()) as usize, + ), + 1, + max_incoming_message_dispatch_weight, + ); + assert!( + max_delivery_transaction_dispatch_weight.all_lte(max_extrinsic_weight), + "Weight of maximal message delivery transaction + {max_delivery_transaction_dispatch_weight} is larger than maximal possible transaction weight {max_extrinsic_weight}", + ); +} + +/// Ensure that we're able to receive maximal confirmation from other chain. +pub fn ensure_able_to_receive_confirmation( + max_extrinsic_size: u32, + max_extrinsic_weight: Weight, + max_inbound_lane_data_proof_size_from_peer_chain: u32, + max_unrewarded_relayer_entries_at_peer_inbound_lane: MessageNonce, + max_unconfirmed_messages_at_inbound_lane: MessageNonce, +) { + // verify that we're able to receive confirmation of maximal-size + let max_confirmation_transaction_size = + max_inbound_lane_data_proof_size_from_peer_chain.saturating_add(SIGNED_EXTENSIONS_SIZE); + assert!( + max_confirmation_transaction_size <= max_extrinsic_size, + "Size of maximal message delivery confirmation transaction {max_inbound_lane_data_proof_size_from_peer_chain} + {SIGNED_EXTENSIONS_SIZE} is larger than maximal possible transaction size {max_extrinsic_size}", + ); + + // verify that we're able to reward maximal number of relayers that have delivered maximal + // number of messages + let max_confirmation_transaction_dispatch_weight = W::receive_messages_delivery_proof_weight( + &PreComputedSize(max_inbound_lane_data_proof_size_from_peer_chain as usize), + &UnrewardedRelayersState { + unrewarded_relayer_entries: max_unrewarded_relayer_entries_at_peer_inbound_lane, + total_messages: max_unconfirmed_messages_at_inbound_lane, + ..Default::default() + }, + ); + assert!( + max_confirmation_transaction_dispatch_weight.all_lte(max_extrinsic_weight), + "Weight of maximal confirmation transaction {max_confirmation_transaction_dispatch_weight} is larger than maximal possible transaction weight {max_extrinsic_weight}", + ); +} + +/// Panics if `proof_size` of message delivery call depends on the message proof size. +fn messages_proof_size_does_not_affect_proof_size() { + let dispatch_weight = Weight::zero(); + let weight_when_proof_size_is_8k = + W::receive_messages_proof_weight(&PreComputedSize(8 * 1024), 1, dispatch_weight); + let weight_when_proof_size_is_16k = + W::receive_messages_proof_weight(&PreComputedSize(16 * 1024), 1, dispatch_weight); + + ensure_weight_components_are_not_zero(weight_when_proof_size_is_8k); + ensure_weight_components_are_not_zero(weight_when_proof_size_is_16k); + ensure_proof_size_is_the_same( + weight_when_proof_size_is_8k, + weight_when_proof_size_is_16k, + "Messages proof size does not affect values that we read from our storage", + ); +} + +/// Panics if `proof_size` of message delivery call depends on the messages count. +/// +/// In practice, it will depend on the messages count, because most probably every +/// message will read something from db during dispatch. But this must be accounted +/// by the `dispatch_weight`. +fn messages_count_does_not_affect_proof_size() { + let messages_proof_size = PreComputedSize(8 * 1024); + let dispatch_weight = Weight::zero(); + let weight_of_one_incoming_message = + W::receive_messages_proof_weight(&messages_proof_size, 1, dispatch_weight); + let weight_of_two_incoming_messages = + W::receive_messages_proof_weight(&messages_proof_size, 2, dispatch_weight); + + ensure_weight_components_are_not_zero(weight_of_one_incoming_message); + ensure_weight_components_are_not_zero(weight_of_two_incoming_messages); + ensure_proof_size_is_the_same( + weight_of_one_incoming_message, + weight_of_two_incoming_messages, + "Number of same-lane incoming messages does not affect values that we read from our storage", + ); +} + +/// Panics if `proof_size` of delivery confirmation call depends on the delivery proof size. +fn messages_delivery_proof_size_does_not_affect_proof_size() { + let relayers_state = UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 1, + total_messages: 1, + last_delivered_nonce: 1, + }; + let weight_when_proof_size_is_8k = + W::receive_messages_delivery_proof_weight(&PreComputedSize(8 * 1024), &relayers_state); + let weight_when_proof_size_is_16k = + W::receive_messages_delivery_proof_weight(&PreComputedSize(16 * 1024), &relayers_state); + + ensure_weight_components_are_not_zero(weight_when_proof_size_is_8k); + ensure_weight_components_are_not_zero(weight_when_proof_size_is_16k); + ensure_proof_size_is_the_same( + weight_when_proof_size_is_8k, + weight_when_proof_size_is_16k, + "Messages delivery proof size does not affect values that we read from our storage", + ); +} + +/// Panics if `proof_size` of delivery confirmation call depends on the number of confirmed +/// messages. +fn total_messages_in_delivery_proof_does_not_affect_proof_size() { + let proof_size = PreComputedSize(8 * 1024); + let weight_when_1k_messages_confirmed = W::receive_messages_delivery_proof_weight( + &proof_size, + &UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 1, + total_messages: 1024, + last_delivered_nonce: 1, + }, + ); + let weight_when_2k_messages_confirmed = W::receive_messages_delivery_proof_weight( + &proof_size, + &UnrewardedRelayersState { + unrewarded_relayer_entries: 1, + messages_in_oldest_entry: 1, + total_messages: 2048, + last_delivered_nonce: 1, + }, + ); + + ensure_weight_components_are_not_zero(weight_when_1k_messages_confirmed); + ensure_weight_components_are_not_zero(weight_when_2k_messages_confirmed); + ensure_proof_size_is_the_same( + weight_when_1k_messages_confirmed, + weight_when_2k_messages_confirmed, + "More messages in delivery proof does not affect values that we read from our storage", + ); +} + +/// Panics if either Weight' `proof_size` or `ref_time` are zero. +fn ensure_weight_components_are_not_zero(weight: Weight) { + assert_ne!(weight.ref_time(), 0); + assert_ne!(weight.proof_size(), 0); +} + +/// Panics if `proof_size` of `weight1` is not equal to `proof_size` of `weight2`. +fn ensure_proof_size_is_the_same(weight1: Weight, weight2: Weight, msg: &str) { + assert_eq!( + weight1.proof_size(), + weight2.proof_size(), + "{msg}: {} must be equal to {}", + weight1.proof_size(), + weight2.proof_size(), + ); +} + +/// Extended weight info. +pub trait WeightInfoExt: WeightInfo { + /// Size of proof that is already included in the single message delivery weight. + /// + /// The message submitter (at source chain) has already covered this cost. But there are two + /// factors that may increase proof size: (1) the message size may be larger than predefined + /// and (2) relayer may add extra trie nodes to the proof. So if proof size is larger than + /// this value, we're going to charge relayer for that. + fn expected_extra_storage_proof_size() -> u32; + + // Our configuration assumes that the runtime has special signed extensions used to: + // + // 1) reject obsolete delivery and confirmation transactions; + // + // 2) refund transaction cost to relayer and register his rewards. + // + // The checks in (1) are trivial, so its computation weight may be ignored. And we only touch + // storage values that are read during the call. So we may ignore the weight of this check. + // + // However, during (2) we read and update storage values of other pallets + // (`pallet-bridge-relayers` and balances/assets pallet). So we need to add this weight to the + // weight of our call. Hence two following methods. + + /// Extra weight that is added to the `receive_messages_proof` call weight by signed extensions + /// that are declared at runtime level. + fn receive_messages_proof_overhead_from_runtime() -> Weight; + + /// Extra weight that is added to the `receive_messages_delivery_proof` call weight by signed + /// extensions that are declared at runtime level. + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight; + + // Functions that are directly mapped to extrinsics weights. + + /// Weight of message delivery extrinsic. + fn receive_messages_proof_weight( + proof: &impl Size, + messages_count: u32, + dispatch_weight: Weight, + ) -> Weight { + // basic components of extrinsic weight + let transaction_overhead = Self::receive_messages_proof_overhead(); + let transaction_overhead_from_runtime = + Self::receive_messages_proof_overhead_from_runtime(); + let outbound_state_delivery_weight = + Self::receive_messages_proof_outbound_lane_state_overhead(); + let messages_delivery_weight = + Self::receive_messages_proof_messages_overhead(MessageNonce::from(messages_count)); + let messages_dispatch_weight = dispatch_weight; + + // proof size overhead weight + let expected_proof_size = EXPECTED_DEFAULT_MESSAGE_LENGTH + .saturating_mul(messages_count.saturating_sub(1)) + .saturating_add(Self::expected_extra_storage_proof_size()); + let actual_proof_size = proof.size(); + let proof_size_overhead = Self::storage_proof_size_overhead( + actual_proof_size.saturating_sub(expected_proof_size), + ); + + transaction_overhead + .saturating_add(transaction_overhead_from_runtime) + .saturating_add(outbound_state_delivery_weight) + .saturating_add(messages_delivery_weight) + .saturating_add(messages_dispatch_weight) + .saturating_add(proof_size_overhead) + } + + /// Weight of confirmation delivery extrinsic. + fn receive_messages_delivery_proof_weight( + proof: &impl Size, + relayers_state: &UnrewardedRelayersState, + ) -> Weight { + // basic components of extrinsic weight + let transaction_overhead = Self::receive_messages_delivery_proof_overhead(); + let transaction_overhead_from_runtime = + Self::receive_messages_delivery_proof_overhead_from_runtime(); + let messages_overhead = + Self::receive_messages_delivery_proof_messages_overhead(relayers_state.total_messages); + let relayers_overhead = Self::receive_messages_delivery_proof_relayers_overhead( + relayers_state.unrewarded_relayer_entries, + ); + + // proof size overhead weight + let expected_proof_size = Self::expected_extra_storage_proof_size(); + let actual_proof_size = proof.size(); + let proof_size_overhead = Self::storage_proof_size_overhead( + actual_proof_size.saturating_sub(expected_proof_size), + ); + + transaction_overhead + .saturating_add(transaction_overhead_from_runtime) + .saturating_add(messages_overhead) + .saturating_add(relayers_overhead) + .saturating_add(proof_size_overhead) + } + + // Functions that are used by extrinsics weights formulas. + + /// Returns weight overhead of message delivery transaction (`receive_messages_proof`). + fn receive_messages_proof_overhead() -> Weight { + let weight_of_two_messages_and_two_tx_overheads = + Self::receive_single_message_proof().saturating_mul(2); + let weight_of_two_messages_and_single_tx_overhead = Self::receive_two_messages_proof(); + weight_of_two_messages_and_two_tx_overheads + .saturating_sub(weight_of_two_messages_and_single_tx_overhead) + } + + /// Returns weight that needs to be accounted when receiving given a number of messages with + /// message delivery transaction (`receive_messages_proof`). + fn receive_messages_proof_messages_overhead(messages: MessageNonce) -> Weight { + let weight_of_two_messages_and_single_tx_overhead = Self::receive_two_messages_proof(); + let weight_of_single_message_and_single_tx_overhead = Self::receive_single_message_proof(); + weight_of_two_messages_and_single_tx_overhead + .saturating_sub(weight_of_single_message_and_single_tx_overhead) + .saturating_mul(messages as _) + } + + /// Returns weight that needs to be accounted when message delivery transaction + /// (`receive_messages_proof`) is carrying outbound lane state proof. + fn receive_messages_proof_outbound_lane_state_overhead() -> Weight { + let weight_of_single_message_and_lane_state = + Self::receive_single_message_proof_with_outbound_lane_state(); + let weight_of_single_message = Self::receive_single_message_proof(); + weight_of_single_message_and_lane_state.saturating_sub(weight_of_single_message) + } + + /// Returns weight overhead of delivery confirmation transaction + /// (`receive_messages_delivery_proof`). + fn receive_messages_delivery_proof_overhead() -> Weight { + let weight_of_two_messages_and_two_tx_overheads = + Self::receive_delivery_proof_for_single_message().saturating_mul(2); + let weight_of_two_messages_and_single_tx_overhead = + Self::receive_delivery_proof_for_two_messages_by_single_relayer(); + weight_of_two_messages_and_two_tx_overheads + .saturating_sub(weight_of_two_messages_and_single_tx_overhead) + } + + /// Returns weight that needs to be accounted when receiving confirmations for given a number of + /// messages with delivery confirmation transaction (`receive_messages_delivery_proof`). + fn receive_messages_delivery_proof_messages_overhead(messages: MessageNonce) -> Weight { + let weight_of_two_messages = + Self::receive_delivery_proof_for_two_messages_by_single_relayer(); + let weight_of_single_message = Self::receive_delivery_proof_for_single_message(); + weight_of_two_messages + .saturating_sub(weight_of_single_message) + .saturating_mul(messages as _) + } + + /// Returns weight that needs to be accounted when receiving confirmations for given a number of + /// relayers entries with delivery confirmation transaction (`receive_messages_delivery_proof`). + fn receive_messages_delivery_proof_relayers_overhead(relayers: MessageNonce) -> Weight { + let weight_of_two_messages_by_two_relayers = + Self::receive_delivery_proof_for_two_messages_by_two_relayers(); + let weight_of_two_messages_by_single_relayer = + Self::receive_delivery_proof_for_two_messages_by_single_relayer(); + weight_of_two_messages_by_two_relayers + .saturating_sub(weight_of_two_messages_by_single_relayer) + .saturating_mul(relayers as _) + } + + /// Returns weight that needs to be accounted when storage proof of given size is received + /// (either in `receive_messages_proof` or `receive_messages_delivery_proof`). + /// + /// **IMPORTANT**: this overhead is already included in the 'base' transaction cost - e.g. proof + /// size depends on messages count or number of entries in the unrewarded relayers set. So this + /// shouldn't be added to cost of transaction, but instead should act as a minimal cost that the + /// relayer must pay when it relays proof of given size (even if cost based on other parameters + /// is less than that cost). + fn storage_proof_size_overhead(proof_size: u32) -> Weight { + let proof_size_in_bytes = proof_size; + let byte_weight = (Self::receive_single_message_proof_16_kb() - + Self::receive_single_message_proof_1_kb()) / + (15 * 1024); + proof_size_in_bytes * byte_weight + } + + // Functions that may be used by runtime developers. + + /// Returns dispatch weight of message of given size. + /// + /// This function would return correct value only if your runtime is configured to run + /// `receive_single_message_proof_with_dispatch` benchmark. See its requirements for + /// details. + fn message_dispatch_weight(message_size: u32) -> Weight { + // There may be a tiny overweight/underweight here, because we don't account how message + // size affects all steps before dispatch. But the effect should be small enough and we + // may ignore it. + Self::receive_single_message_proof_with_dispatch(message_size) + .saturating_sub(Self::receive_single_message_proof()) + } +} + +impl WeightInfoExt for () { + fn expected_extra_storage_proof_size() -> u32 { + EXTRA_STORAGE_PROOF_SIZE + } + + fn receive_messages_proof_overhead_from_runtime() -> Weight { + Weight::zero() + } + + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { + Weight::zero() + } +} + +impl WeightInfoExt for crate::weights::BridgeWeight { + fn expected_extra_storage_proof_size() -> u32 { + EXTRA_STORAGE_PROOF_SIZE + } + + fn receive_messages_proof_overhead_from_runtime() -> Weight { + Weight::zero() + } + + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { + Weight::zero() + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{mock::TestRuntime, weights::BridgeWeight}; + + #[test] + fn ensure_default_weights_are_correct() { + ensure_weights_are_correct::>(); + } +} diff --git a/bridges/modules/parachains/Cargo.toml b/bridges/modules/parachains/Cargo.toml new file mode 100644 index 00000000000..5ee30f594c7 --- /dev/null +++ b/bridges/modules/parachains/Cargo.toml @@ -0,0 +1,60 @@ +[package] +name = "pallet-bridge-parachains" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } + +# Bridge Dependencies + +bp-header-chain = { path = "../../primitives/header-chain", default-features = false } +bp-parachains = { path = "../../primitives/parachains", default-features = false } +bp-polkadot-core = { path = "../../primitives/polkadot-core", default-features = false } +bp-runtime = { path = "../../primitives/runtime", default-features = false } +pallet-bridge-grandpa = { path = "../grandpa", default-features = false } + +# Substrate Dependencies + +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[dev-dependencies] +bp-header-chain = { path = "../../primitives/header-chain" } +bp-test-utils = { path = "../../primitives/test-utils" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" } + +[features] +default = ["std"] +std = [ + "bp-header-chain/std", + "bp-parachains/std", + "bp-polkadot-core/std", + "bp-runtime/std", + "codec/std", + "frame-support/std", + "frame-system/std", + "frame-benchmarking/std", + "log/std", + "pallet-bridge-grandpa/std", + "scale-info/std", + "sp-runtime/std", + "sp-std/std", + "sp-trie/std", +] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", +] diff --git a/bridges/modules/parachains/README.md b/bridges/modules/parachains/README.md new file mode 100644 index 00000000000..5982c65ad31 --- /dev/null +++ b/bridges/modules/parachains/README.md @@ -0,0 +1,90 @@ +# Bridge Parachains Pallet + +The bridge parachains pallet is a light client for one or several parachains of the bridged relay chain. +It serves as a source of finalized parachain headers and is used when you need to build a bridge with +a parachain. + +The pallet requires [bridge GRANDPA pallet](../grandpa/) to be deployed at the same chain - it is used +to verify storage proofs, generated at the bridged relay chain. + +## A Brief Introduction into Parachains Finality + +You can find detailed information on parachains finality in the [Polkadot](https://github.com/paritytech/polkadot) +and [Cumulus](https://github.com/paritytech/cumulus) repositories. This section gives a brief overview of how +the parachain finality works and how to build a light client for a parachain. + +The main thing there is that the parachain generates blocks on its own, but it can't achieve finality without +help of its relay chain. Instead, the parachain collators create a block and hand it over to the relay chain +validators. Validators validate the block and register the new parachain head in the +[`Heads` map](https://github.com/paritytech/polkadot/blob/88013730166ba90745ae7c9eb3e0c1be1513c7cc/runtime/parachains/src/paras/mod.rs#L645) +of the [`paras`](https://github.com/paritytech/polkadot/tree/master/runtime/parachains/src/paras) pallet, +deployed at the relay chain. Keep in mind that this pallet, deployed at a relay chain, is **NOT** a bridge pallet, +even though the names are similar. + +And what the bridge parachains pallet does, is simply verifying storage proofs of parachain heads within that +`Heads` map. It does that using relay chain header, that has been previously imported by the +[bridge GRANDPA pallet](../grandpa/). Once the proof is verified, the pallet knows that the given parachain +header has been finalized by the relay chain. The parachain header fields may then be used to verify storage +proofs, coming from the parachain. This allows the pallet to be used e.g. as a source of finality for the messages +pallet. + +## Pallet Operations + +The main entrypoint of the pallet is the `submit_parachain_heads` call. It has three arguments: + +- storage proof of parachain heads from the `Heads` map; + +- parachain identifiers and hashes of their heads from the storage proof; + +- the relay block, at which the storage proof has been generated. + +The pallet may track multiple parachains. And the parachains may use different primitives - one may use 128-bit block +numbers, other - 32-bit. To avoid extra decode operations, the pallet is using relay chain block number to order +parachain headers. Any finalized descendant of finalized relay block `RB`, which has parachain block `PB` in +its `Heads` map, is guaranteed to have either `PB`, or its descendant. So parachain block number grows with relay +block number. + +The pallet may reject parachain head if it already knows better (or the same) head. In addition, pallet rejects +heads of untracked parachains. + +The pallet doesn't track anything behind parachain heads. So it requires no initialization - it is ready to accept +headers right after deployment. + +## Non-Essential Functionality + +There may be a special account in every runtime where the bridge parachains module is deployed. This +account, named 'module owner', is like a module-level sudo account - he's able to halt and +resume all module operations without requiring runtime upgrade. Calls that are related to this +account are: + +- `fn set_owner()`: current module owner may call it to transfer "ownership" to another account; + +- `fn set_operating_mode()`: the module owner (or sudo account) may call this function to stop all + module operations. After this call, all finality proofs will be rejected until further `set_operating_mode` call'. + This call may be used when something extraordinary happens with the bridge. + +If pallet owner is not defined, the governance may be used to make those calls. + +## Signed Extension to Reject Obsolete Headers + +It'd be better for anyone (for chain and for submitters) to reject all transactions that are submitting +already known parachain heads to the pallet. This way, we leave block space to other useful transactions and +we don't charge concurrent submitters for their honest actions. + +To deal with that, we have a [signed extension](./src/call_ext) that may be added to the runtime. +It does exactly what is required - rejects all transactions with already known heads. The submitter +pays nothing for such transactions - they're simply removed from the transaction pool, when the block +is built. + +The signed extension, however, is a bit limited - it only works with transactions that provide single +parachain head. So it won't work with multiple parachain heads transactions. This fits our needs +for [Kusama <> Polkadot bridge](../../docs/polkadot-kusama-bridge-overview.md). If you need to deal +with other transaction formats, you may implement similar extension for your runtime. + +You may also take a look at the [`generate_bridge_reject_obsolete_headers_and_messages`](../../bin/runtime-common/src/lib.rs) +macro that bundles several similar signed extensions in a single one. + +## Parachains Finality Relay + +We have an offchain actor, who is watching for new parachain heads and submits them to the bridged chain. +It is the parachains relay - you may look at the [crate level documentation and the code](../../relays/parachains/). diff --git a/bridges/modules/parachains/src/benchmarking.rs b/bridges/modules/parachains/src/benchmarking.rs new file mode 100644 index 00000000000..59c4642cde9 --- /dev/null +++ b/bridges/modules/parachains/src/benchmarking.rs @@ -0,0 +1,116 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Parachains finality pallet benchmarking. + +use crate::{ + weights_ext::DEFAULT_PARACHAIN_HEAD_SIZE, Call, RelayBlockHash, RelayBlockHasher, + RelayBlockNumber, +}; + +use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId}; +use bp_runtime::StorageProofSize; +use frame_benchmarking::{account, benchmarks_instance_pallet}; +use frame_system::RawOrigin; +use sp_std::prelude::*; + +/// Pallet we're benchmarking here. +pub struct Pallet, I: 'static = ()>(crate::Pallet); + +/// Trait that must be implemented by runtime to benchmark the parachains finality pallet. +pub trait Config: crate::Config { + /// Returns vector of supported parachains. + fn parachains() -> Vec; + /// Generate parachain heads proof and prepare environment for verifying this proof. + fn prepare_parachain_heads_proof( + parachains: &[ParaId], + parachain_head_size: u32, + proof_size: StorageProofSize, + ) -> (RelayBlockNumber, RelayBlockHash, ParaHeadsProof, Vec<(ParaId, ParaHash)>); +} + +benchmarks_instance_pallet! { + where_clause { + where + >::BridgedChain: + bp_runtime::Chain< + BlockNumber = RelayBlockNumber, + Hash = RelayBlockHash, + Hasher = RelayBlockHasher, + >, + } + + // Benchmark `submit_parachain_heads` extrinsic with different number of parachains. + submit_parachain_heads_with_n_parachains { + let p in 1..(T::parachains().len() + 1) as u32; + + let sender = account("sender", 0, 0); + let mut parachains = T::parachains(); + let _ = if p <= parachains.len() as u32 { + parachains.split_off(p as usize) + } else { + Default::default() + }; + log::trace!(target: crate::LOG_TARGET, "=== {:?}", parachains.len()); + let (relay_block_number, relay_block_hash, parachain_heads_proof, parachains_heads) = T::prepare_parachain_heads_proof( + ¶chains, + DEFAULT_PARACHAIN_HEAD_SIZE, + StorageProofSize::Minimal(0), + ); + let at_relay_block = (relay_block_number, relay_block_hash); + }: submit_parachain_heads(RawOrigin::Signed(sender), at_relay_block, parachains_heads, parachain_heads_proof) + verify { + for parachain in parachains { + assert!(crate::Pallet::::best_parachain_head(parachain).is_some()); + } + } + + // Benchmark `submit_parachain_heads` extrinsic with 1kb proof size. + submit_parachain_heads_with_1kb_proof { + let sender = account("sender", 0, 0); + let parachains = vec![T::parachains()[0]]; + let (relay_block_number, relay_block_hash, parachain_heads_proof, parachains_heads) = T::prepare_parachain_heads_proof( + ¶chains, + DEFAULT_PARACHAIN_HEAD_SIZE, + StorageProofSize::HasLargeLeaf(1024), + ); + let at_relay_block = (relay_block_number, relay_block_hash); + }: submit_parachain_heads(RawOrigin::Signed(sender), at_relay_block, parachains_heads, parachain_heads_proof) + verify { + for parachain in parachains { + assert!(crate::Pallet::::best_parachain_head(parachain).is_some()); + } + } + + // Benchmark `submit_parachain_heads` extrinsic with 16kb proof size. + submit_parachain_heads_with_16kb_proof { + let sender = account("sender", 0, 0); + let parachains = vec![T::parachains()[0]]; + let (relay_block_number, relay_block_hash, parachain_heads_proof, parachains_heads) = T::prepare_parachain_heads_proof( + ¶chains, + DEFAULT_PARACHAIN_HEAD_SIZE, + StorageProofSize::HasLargeLeaf(16 * 1024), + ); + let at_relay_block = (relay_block_number, relay_block_hash); + }: submit_parachain_heads(RawOrigin::Signed(sender), at_relay_block, parachains_heads, parachain_heads_proof) + verify { + for parachain in parachains { + assert!(crate::Pallet::::best_parachain_head(parachain).is_some()); + } + } + + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::TestRuntime) +} diff --git a/bridges/modules/parachains/src/call_ext.rs b/bridges/modules/parachains/src/call_ext.rs new file mode 100644 index 00000000000..ee3770146c2 --- /dev/null +++ b/bridges/modules/parachains/src/call_ext.rs @@ -0,0 +1,243 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +use crate::{Config, Pallet, RelayBlockNumber}; +use bp_parachains::BestParaHeadHash; +use bp_polkadot_core::parachains::{ParaHash, ParaId}; +use frame_support::{dispatch::CallableCallFor, traits::IsSubType, RuntimeDebug}; +use sp_runtime::transaction_validity::{InvalidTransaction, TransactionValidity, ValidTransaction}; + +/// Info about a `SubmitParachainHeads` call which tries to update a single parachain. +#[derive(PartialEq, RuntimeDebug)] +pub struct SubmitParachainHeadsInfo { + /// Number of the finalized relay block that has been used to prove parachain finality. + pub at_relay_block_number: RelayBlockNumber, + /// Parachain identifier. + pub para_id: ParaId, + /// Hash of the bundled parachain head. + pub para_head_hash: ParaHash, +} + +/// Helper struct that provides methods for working with the `SubmitParachainHeads` call. +pub struct SubmitParachainHeadsHelper, I: 'static> { + _phantom_data: sp_std::marker::PhantomData<(T, I)>, +} + +impl, I: 'static> SubmitParachainHeadsHelper { + /// Check if the para head provided by the `SubmitParachainHeads` is better than the best one + /// we know. + pub fn is_obsolete(update: &SubmitParachainHeadsInfo) -> bool { + let stored_best_head = match crate::ParasInfo::::get(update.para_id) { + Some(stored_best_head) => stored_best_head, + None => return false, + }; + + if stored_best_head.best_head_hash.at_relay_block_number >= update.at_relay_block_number { + log::trace!( + target: crate::LOG_TARGET, + "The parachain head can't be updated. The parachain head for {:?} \ + was already updated at better relay chain block {} >= {}.", + update.para_id, + stored_best_head.best_head_hash.at_relay_block_number, + update.at_relay_block_number + ); + return true + } + + if stored_best_head.best_head_hash.head_hash == update.para_head_hash { + log::trace!( + target: crate::LOG_TARGET, + "The parachain head can't be updated. The parachain head hash for {:?} \ + was already updated to {} at block {} < {}.", + update.para_id, + update.para_head_hash, + stored_best_head.best_head_hash.at_relay_block_number, + update.at_relay_block_number + ); + return true + } + + false + } + + /// Check if the `SubmitParachainHeads` was successfully executed. + pub fn was_successful(update: &SubmitParachainHeadsInfo) -> bool { + match crate::ParasInfo::::get(update.para_id) { + Some(stored_best_head) => + stored_best_head.best_head_hash == + BestParaHeadHash { + at_relay_block_number: update.at_relay_block_number, + head_hash: update.para_head_hash, + }, + None => false, + } + } +} + +/// Trait representing a call that is a sub type of this pallet's call. +pub trait CallSubType, I: 'static>: + IsSubType, T>> +{ + /// Create a new instance of `SubmitParachainHeadsInfo` from a `SubmitParachainHeads` call with + /// one single parachain entry. + fn one_entry_submit_parachain_heads_info(&self) -> Option { + if let Some(crate::Call::::submit_parachain_heads { + ref at_relay_block, + ref parachains, + .. + }) = self.is_sub_type() + { + if let &[(para_id, para_head_hash)] = parachains.as_slice() { + return Some(SubmitParachainHeadsInfo { + at_relay_block_number: at_relay_block.0, + para_id, + para_head_hash, + }) + } + } + + None + } + + /// Create a new instance of `SubmitParachainHeadsInfo` from a `SubmitParachainHeads` call with + /// one single parachain entry, if the entry is for the provided parachain id. + fn submit_parachain_heads_info_for(&self, para_id: u32) -> Option { + self.one_entry_submit_parachain_heads_info() + .filter(|update| update.para_id.0 == para_id) + } + + /// Validate parachain heads in order to avoid "mining" transactions that provide + /// outdated bridged parachain heads. Without this validation, even honest relayers + /// may lose their funds if there are multiple relays running and submitting the + /// same information. + /// + /// This validation only works with transactions that are updating single parachain + /// head. We can't use unbounded validation - it may take too long and either break + /// block production, or "eat" significant portion of block production time literally + /// for nothing. In addition, the single-parachain-head-per-transaction is how the + /// pallet will be used in our environment. + fn check_obsolete_submit_parachain_heads(&self) -> TransactionValidity + where + Self: Sized, + { + let update = match self.one_entry_submit_parachain_heads_info() { + Some(update) => update, + None => return Ok(ValidTransaction::default()), + }; + + if SubmitParachainHeadsHelper::::is_obsolete(&update) { + return InvalidTransaction::Stale.into() + } + + Ok(ValidTransaction::default()) + } +} + +impl CallSubType for T::RuntimeCall +where + T: Config, + T::RuntimeCall: IsSubType, T>>, +{ +} + +#[cfg(test)] +mod tests { + use crate::{ + mock::{run_test, RuntimeCall, TestRuntime}, + CallSubType, ParaInfo, ParasInfo, RelayBlockNumber, + }; + use bp_parachains::BestParaHeadHash; + use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId}; + + fn validate_submit_parachain_heads( + num: RelayBlockNumber, + parachains: Vec<(ParaId, ParaHash)>, + ) -> bool { + RuntimeCall::Parachains(crate::Call::::submit_parachain_heads { + at_relay_block: (num, Default::default()), + parachains, + parachain_heads_proof: ParaHeadsProof(Vec::new()), + }) + .check_obsolete_submit_parachain_heads() + .is_ok() + } + + fn sync_to_relay_header_10() { + ParasInfo::::insert( + ParaId(1), + ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: 10, + head_hash: [1u8; 32].into(), + }, + next_imported_hash_position: 0, + }, + ); + } + + #[test] + fn extension_rejects_header_from_the_obsolete_relay_block() { + run_test(|| { + // when current best finalized is #10 and we're trying to import header#5 => tx is + // rejected + sync_to_relay_header_10(); + assert!(!validate_submit_parachain_heads(5, vec![(ParaId(1), [1u8; 32].into())])); + }); + } + + #[test] + fn extension_rejects_header_from_the_same_relay_block() { + run_test(|| { + // when current best finalized is #10 and we're trying to import header#10 => tx is + // rejected + sync_to_relay_header_10(); + assert!(!validate_submit_parachain_heads(10, vec![(ParaId(1), [1u8; 32].into())])); + }); + } + + #[test] + fn extension_rejects_header_from_new_relay_block_with_same_hash() { + run_test(|| { + // when current best finalized is #10 and we're trying to import header#10 => tx is + // rejected + sync_to_relay_header_10(); + assert!(!validate_submit_parachain_heads(20, vec![(ParaId(1), [1u8; 32].into())])); + }); + } + + #[test] + fn extension_accepts_new_header() { + run_test(|| { + // when current best finalized is #10 and we're trying to import header#15 => tx is + // accepted + sync_to_relay_header_10(); + assert!(validate_submit_parachain_heads(15, vec![(ParaId(1), [2u8; 32].into())])); + }); + } + + #[test] + fn extension_accepts_if_more_than_one_parachain_is_submitted() { + run_test(|| { + // when current best finalized is #10 and we're trying to import header#5, but another + // parachain head is also supplied => tx is accepted + sync_to_relay_header_10(); + assert!(validate_submit_parachain_heads( + 5, + vec![(ParaId(1), [1u8; 32].into()), (ParaId(2), [1u8; 32].into())] + )); + }); + } +} diff --git a/bridges/modules/parachains/src/lib.rs b/bridges/modules/parachains/src/lib.rs new file mode 100644 index 00000000000..b17b52163d8 --- /dev/null +++ b/bridges/modules/parachains/src/lib.rs @@ -0,0 +1,1582 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Parachains finality module. +//! +//! This module needs to be deployed with GRANDPA module, which is syncing relay +//! chain blocks. The main entry point of this module is `submit_parachain_heads`, which +//! accepts storage proof of some parachain `Heads` entries from bridged relay chain. +//! It requires corresponding relay headers to be already synced. + +#![cfg_attr(not(feature = "std"), no_std)] + +pub use weights::WeightInfo; +pub use weights_ext::WeightInfoExt; + +use bp_header_chain::{HeaderChain, HeaderChainError}; +use bp_parachains::{parachain_head_storage_key_at_source, ParaInfo, ParaStoredHeaderData}; +use bp_polkadot_core::parachains::{ParaHash, ParaHead, ParaHeadsProof, ParaId}; +use bp_runtime::{Chain, HashOf, HeaderId, HeaderIdOf, Parachain, StorageProofError}; +use frame_support::{dispatch::PostDispatchInfo, DefaultNoBound}; +use sp_std::{marker::PhantomData, vec::Vec}; + +#[cfg(feature = "runtime-benchmarks")] +use bp_parachains::ParaStoredHeaderDataBuilder; +#[cfg(feature = "runtime-benchmarks")] +use bp_runtime::HeaderOf; +#[cfg(feature = "runtime-benchmarks")] +use codec::Encode; + +// Re-export in crate namespace for `construct_runtime!`. +pub use call_ext::*; +pub use pallet::*; + +pub mod weights; +pub mod weights_ext; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; + +mod call_ext; +#[cfg(test)] +mod mock; + +/// The target that will be used when publishing logs related to this pallet. +pub const LOG_TARGET: &str = "runtime::bridge-parachains"; + +/// Block hash of the bridged relay chain. +pub type RelayBlockHash = bp_polkadot_core::Hash; +/// Block number of the bridged relay chain. +pub type RelayBlockNumber = bp_polkadot_core::BlockNumber; +/// Hasher of the bridged relay chain. +pub type RelayBlockHasher = bp_polkadot_core::Hasher; + +/// Artifacts of the parachains head update. +struct UpdateParachainHeadArtifacts { + /// New best head of the parachain. + pub best_head: ParaInfo, + /// If `true`, some old parachain head has been pruned during update. + pub prune_happened: bool, +} + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use bp_parachains::{ + BestParaHeadHash, ImportedParaHeadsKeyProvider, ParaStoredHeaderDataBuilder, + ParasInfoKeyProvider, + }; + use bp_runtime::{ + BasicOperatingMode, BoundedStorageValue, OwnedBridgeModule, StorageDoubleMapKeyProvider, + StorageMapKeyProvider, + }; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + /// Stored parachain head data of given parachains pallet. + pub type StoredParaHeadDataOf = + BoundedStorageValue<>::MaxParaHeadDataSize, ParaStoredHeaderData>; + /// Weight info of the given parachains pallet. + pub type WeightInfoOf = >::WeightInfo; + type GrandpaPalletOf = + pallet_bridge_grandpa::Pallet>::BridgesGrandpaPalletInstance>; + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event, I: 'static = ()> { + /// The caller has provided head of parachain that the pallet is not configured to track. + UntrackedParachainRejected { parachain: ParaId }, + /// The caller has declared that he has provided given parachain head, but it is missing + /// from the storage proof. + MissingParachainHead { parachain: ParaId }, + /// The caller has provided parachain head hash that is not matching the hash read from the + /// storage proof. + IncorrectParachainHeadHash { + parachain: ParaId, + parachain_head_hash: ParaHash, + actual_parachain_head_hash: ParaHash, + }, + /// The caller has provided obsolete parachain head, which is already known to the pallet. + RejectedObsoleteParachainHead { parachain: ParaId, parachain_head_hash: ParaHash }, + /// The caller has provided parachain head that exceeds the maximal configured head size. + RejectedLargeParachainHead { + parachain: ParaId, + parachain_head_hash: ParaHash, + parachain_head_size: u32, + }, + /// Parachain head has been updated. + UpdatedParachainHead { parachain: ParaId, parachain_head_hash: ParaHash }, + } + + #[pallet::error] + pub enum Error { + /// Relay chain block hash is unknown to us. + UnknownRelayChainBlock, + /// The number of stored relay block is different from what the relayer has provided. + InvalidRelayChainBlockNumber, + /// Parachain heads storage proof is invalid. + HeaderChainStorageProof(HeaderChainError), + /// Error generated by the `OwnedBridgeModule` trait. + BridgeModule(bp_runtime::OwnedBridgeModuleError), + } + + /// Convenience trait for defining `BridgedChain` bounds. + pub trait BoundedBridgeGrandpaConfig: + pallet_bridge_grandpa::Config + { + type BridgedRelayChain: Chain< + BlockNumber = RelayBlockNumber, + Hash = RelayBlockHash, + Hasher = RelayBlockHasher, + >; + } + + impl BoundedBridgeGrandpaConfig for T + where + T: pallet_bridge_grandpa::Config, + T::BridgedChain: + Chain, + { + type BridgedRelayChain = T::BridgedChain; + } + + #[pallet::config] + #[pallet::disable_frame_system_supertrait_check] + pub trait Config: + BoundedBridgeGrandpaConfig + { + /// The overarching event type. + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; + /// Benchmarks results from runtime we're plugged into. + type WeightInfo: WeightInfoExt; + + /// Instance of bridges GRANDPA pallet (within this runtime) that this pallet is linked to. + /// + /// The GRANDPA pallet instance must be configured to import headers of relay chain that + /// we're interested in. + type BridgesGrandpaPalletInstance: 'static; + + /// Name of the original `paras` pallet in the `construct_runtime!()` call at the bridged + /// chain. + /// + /// Please keep in mind that this should be the name of the `runtime_parachains::paras` + /// pallet from polkadot repository, not the `pallet-bridge-parachains`. + #[pallet::constant] + type ParasPalletName: Get<&'static str>; + + /// Parachain head data builder. + /// + /// We never store parachain heads here, since they may be too big (e.g. because of large + /// digest items). Instead we're using the same approach as `pallet-bridge-grandpa` + /// pallet - we are only storing `bp_messages::StoredHeaderData` (number and state root), + /// which is enough for our applications. However, we work with different parachains here + /// and they can use different primitives (for block numbers and hash). So we can't store + /// it directly. Instead, we're storing `bp_messages::StoredHeaderData` in SCALE-encoded + /// form, wrapping it into `bp_parachains::ParaStoredHeaderData`. + /// + /// This builder helps to convert from `HeadData` to `bp_parachains::ParaStoredHeaderData`. + type ParaStoredHeaderDataBuilder: ParaStoredHeaderDataBuilder; + + /// Maximal number of single parachain heads to keep in the storage. + /// + /// The setting is there to prevent growing the on-chain state indefinitely. Note + /// the setting does not relate to parachain block numbers - we will simply keep as much + /// items in the storage, so it doesn't guarantee any fixed timeframe for heads. + /// + /// Incautious change of this constant may lead to orphan entries in the runtime storage. + #[pallet::constant] + type HeadsToKeep: Get; + + /// Maximal size (in bytes) of the SCALE-encoded parachain head data + /// (`bp_parachains::ParaStoredHeaderData`). + /// + /// Keep in mind that the size of any tracked parachain header data must not exceed this + /// value. So if you're going to track multiple parachains, one of which is using large + /// hashes, you shall choose this maximal value. + /// + /// There's no mandatory headers in this pallet, so it can't stall if there's some header + /// that exceeds this bound. + #[pallet::constant] + type MaxParaHeadDataSize: Get; + } + + /// Optional pallet owner. + /// + /// Pallet owner has a right to halt all pallet operations and then resume them. If it is + /// `None`, then there are no direct ways to halt/resume pallet operations, but other + /// runtime methods may still be used to do that (i.e. democracy::referendum to update halt + /// flag directly or call the `halt_operations`). + #[pallet::storage] + pub type PalletOwner, I: 'static = ()> = + StorageValue<_, T::AccountId, OptionQuery>; + + /// The current operating mode of the pallet. + /// + /// Depending on the mode either all, or no transactions will be allowed. + #[pallet::storage] + pub type PalletOperatingMode, I: 'static = ()> = + StorageValue<_, BasicOperatingMode, ValueQuery>; + + /// Parachains info. + /// + /// Contains the following info: + /// - best parachain head hash + /// - the head of the `ImportedParaHashes` ring buffer + #[pallet::storage] + pub type ParasInfo, I: 'static = ()> = StorageMap< + Hasher = ::Hasher, + Key = ::Key, + Value = ::Value, + QueryKind = OptionQuery, + OnEmpty = GetDefault, + MaxValues = MaybeMaxParachains, + >; + + /// State roots of parachain heads which have been imported into the pallet. + #[pallet::storage] + pub type ImportedParaHeads, I: 'static = ()> = StorageDoubleMap< + Hasher1 = ::Hasher1, + Key1 = ::Key1, + Hasher2 = ::Hasher2, + Key2 = ::Key2, + Value = StoredParaHeadDataOf, + QueryKind = OptionQuery, + OnEmpty = GetDefault, + MaxValues = MaybeMaxTotalParachainHashes, + >; + + /// A ring buffer of imported parachain head hashes. Ordered by the insertion time. + #[pallet::storage] + pub(super) type ImportedParaHashes, I: 'static = ()> = StorageDoubleMap< + Hasher1 = Blake2_128Concat, + Key1 = ParaId, + Hasher2 = Twox64Concat, + Key2 = u32, + Value = ParaHash, + QueryKind = OptionQuery, + OnEmpty = GetDefault, + MaxValues = MaybeMaxTotalParachainHashes, + >; + + #[pallet::pallet] + pub struct Pallet(PhantomData<(T, I)>); + + impl, I: 'static> OwnedBridgeModule for Pallet { + const LOG_TARGET: &'static str = LOG_TARGET; + type OwnerStorage = PalletOwner; + type OperatingMode = BasicOperatingMode; + type OperatingModeStorage = PalletOperatingMode; + } + + #[pallet::call] + impl, I: 'static> Pallet { + /// Submit proof of one or several parachain heads. + /// + /// The proof is supposed to be proof of some `Heads` entries from the + /// `polkadot-runtime-parachains::paras` pallet instance, deployed at the bridged chain. + /// The proof is supposed to be crafted at the `relay_header_hash` that must already be + /// imported by corresponding GRANDPA pallet at this chain. + /// + /// The call fails if: + /// + /// - the pallet is halted; + /// + /// - the relay chain block `at_relay_block` is not imported by the associated bridge + /// GRANDPA pallet. + /// + /// The call may succeed, but some heads may not be updated e.g. because pallet knows + /// better head or it isn't tracked by the pallet. + #[pallet::call_index(0)] + #[pallet::weight(WeightInfoOf::::submit_parachain_heads_weight( + T::DbWeight::get(), + parachain_heads_proof, + parachains.len() as _, + ))] + pub fn submit_parachain_heads( + _origin: OriginFor, + at_relay_block: (RelayBlockNumber, RelayBlockHash), + parachains: Vec<(ParaId, ParaHash)>, + parachain_heads_proof: ParaHeadsProof, + ) -> DispatchResultWithPostInfo { + Self::ensure_not_halted().map_err(Error::::BridgeModule)?; + + // we'll need relay chain header to verify that parachains heads are always increasing. + let (relay_block_number, relay_block_hash) = at_relay_block; + let relay_block = pallet_bridge_grandpa::ImportedHeaders::< + T, + T::BridgesGrandpaPalletInstance, + >::get(relay_block_hash) + .ok_or(Error::::UnknownRelayChainBlock)?; + ensure!( + relay_block.number == relay_block_number, + Error::::InvalidRelayChainBlockNumber, + ); + + // now parse storage proof and read parachain heads + let mut actual_weight = WeightInfoOf::::submit_parachain_heads_weight( + T::DbWeight::get(), + ¶chain_heads_proof, + parachains.len() as _, + ); + + let mut storage = GrandpaPalletOf::::storage_proof_checker( + relay_block_hash, + parachain_heads_proof.0, + ) + .map_err(Error::::HeaderChainStorageProof)?; + + for (parachain, parachain_head_hash) in parachains { + let parachain_head = match Self::read_parachain_head(&mut storage, parachain) { + Ok(Some(parachain_head)) => parachain_head, + Ok(None) => { + log::trace!( + target: LOG_TARGET, + "The head of parachain {:?} is None. {}", + parachain, + if ParasInfo::::contains_key(parachain) { + "Looks like it is not yet registered at the source relay chain" + } else { + "Looks like it has been deregistered from the source relay chain" + }, + ); + Self::deposit_event(Event::MissingParachainHead { parachain }); + continue + }, + Err(e) => { + log::trace!( + target: LOG_TARGET, + "The read of head of parachain {:?} has failed: {:?}", + parachain, + e, + ); + Self::deposit_event(Event::MissingParachainHead { parachain }); + continue + }, + }; + + // if relayer has specified invalid parachain head hash, ignore the head + // (this isn't strictly necessary, but better safe than sorry) + let actual_parachain_head_hash = parachain_head.hash(); + if parachain_head_hash != actual_parachain_head_hash { + log::trace!( + target: LOG_TARGET, + "The submitter has specified invalid parachain {:?} head hash: \ + {:?} vs {:?}", + parachain, + parachain_head_hash, + actual_parachain_head_hash, + ); + Self::deposit_event(Event::IncorrectParachainHeadHash { + parachain, + parachain_head_hash, + actual_parachain_head_hash, + }); + continue + } + + // convert from parachain head into stored parachain head data + let parachain_head_data = + match T::ParaStoredHeaderDataBuilder::try_build(parachain, ¶chain_head) { + Some(parachain_head_data) => parachain_head_data, + None => { + log::trace!( + target: LOG_TARGET, + "The head of parachain {:?} has been provided, but it is not tracked by the pallet", + parachain, + ); + Self::deposit_event(Event::UntrackedParachainRejected { parachain }); + continue + }, + }; + + let update_result: Result<_, ()> = + ParasInfo::::try_mutate(parachain, |stored_best_head| { + let artifacts = Pallet::::update_parachain_head( + parachain, + stored_best_head.take(), + relay_block_number, + parachain_head_data, + parachain_head_hash, + )?; + *stored_best_head = Some(artifacts.best_head); + Ok(artifacts.prune_happened) + }); + + // we're refunding weight if update has not happened and if pruning has not happened + let is_update_happened = matches!(update_result, Ok(_)); + if !is_update_happened { + actual_weight = actual_weight.saturating_sub( + WeightInfoOf::::parachain_head_storage_write_weight( + T::DbWeight::get(), + ), + ); + } + let is_prune_happened = matches!(update_result, Ok(true)); + if !is_prune_happened { + actual_weight = actual_weight.saturating_sub( + WeightInfoOf::::parachain_head_pruning_weight(T::DbWeight::get()), + ); + } + } + + // even though we may have accepted some parachain heads, we can't allow relayers to + // submit proof with unused trie nodes + // => treat this as an error + // + // (we can throw error here, because now all our calls are transactional) + storage.ensure_no_unused_nodes().map_err(|e| { + Error::::HeaderChainStorageProof(HeaderChainError::StorageProof(e)) + })?; + + Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee: Pays::Yes }) + } + + /// Change `PalletOwner`. + /// + /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(1)] + #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] + pub fn set_owner(origin: OriginFor, new_owner: Option) -> DispatchResult { + >::set_owner(origin, new_owner) + } + + /// Halt or resume all pallet operations. + /// + /// May only be called either by root, or by `PalletOwner`. + #[pallet::call_index(2)] + #[pallet::weight((T::DbWeight::get().reads_writes(1, 1), DispatchClass::Operational))] + pub fn set_operating_mode( + origin: OriginFor, + operating_mode: BasicOperatingMode, + ) -> DispatchResult { + >::set_operating_mode(origin, operating_mode) + } + } + + impl, I: 'static> Pallet { + /// Get stored parachain info. + pub fn best_parachain_info(parachain: ParaId) -> Option { + ParasInfo::::get(parachain) + } + + /// Get best finalized head data of the given parachain. + pub fn best_parachain_head(parachain: ParaId) -> Option { + let best_para_head_hash = ParasInfo::::get(parachain)?.best_head_hash.head_hash; + ImportedParaHeads::::get(parachain, best_para_head_hash).map(|h| h.into_inner()) + } + + /// Get best finalized head hash of the given parachain. + pub fn best_parachain_head_hash(parachain: ParaId) -> Option { + Some(ParasInfo::::get(parachain)?.best_head_hash.head_hash) + } + + /// Get best finalized head id of the given parachain. + pub fn best_parachain_head_id + Parachain>( + ) -> Result>, codec::Error> { + let parachain = ParaId(C::PARACHAIN_ID); + let best_head_hash = match Self::best_parachain_head_hash(parachain) { + Some(best_head_hash) => best_head_hash, + None => return Ok(None), + }; + let encoded_head = match Self::parachain_head(parachain, best_head_hash) { + Some(encoded_head) => encoded_head, + None => return Ok(None), + }; + encoded_head + .decode_parachain_head_data::() + .map(|data| Some(HeaderId(data.number, best_head_hash))) + } + + /// Get parachain head data with given hash. + pub fn parachain_head(parachain: ParaId, hash: ParaHash) -> Option { + ImportedParaHeads::::get(parachain, hash).map(|h| h.into_inner()) + } + + /// Read parachain head from storage proof. + fn read_parachain_head( + storage: &mut bp_runtime::StorageProofChecker, + parachain: ParaId, + ) -> Result, StorageProofError> { + let parachain_head_key = + parachain_head_storage_key_at_source(T::ParasPalletName::get(), parachain); + storage.read_and_decode_value(parachain_head_key.0.as_ref()) + } + + /// Try to update parachain head. + pub(super) fn update_parachain_head( + parachain: ParaId, + stored_best_head: Option, + new_at_relay_block_number: RelayBlockNumber, + new_head_data: ParaStoredHeaderData, + new_head_hash: ParaHash, + ) -> Result { + // check if head has been already updated at better relay chain block. Without this + // check, we may import heads in random order + let update = SubmitParachainHeadsInfo { + at_relay_block_number: new_at_relay_block_number, + para_id: parachain, + para_head_hash: new_head_hash, + }; + if SubmitParachainHeadsHelper::::is_obsolete(&update) { + Self::deposit_event(Event::RejectedObsoleteParachainHead { + parachain, + parachain_head_hash: new_head_hash, + }); + return Err(()) + } + + // verify that the parachain head data size is <= `MaxParaHeadDataSize` + let updated_head_data = + match StoredParaHeadDataOf::::try_from_inner(new_head_data) { + Ok(updated_head_data) => updated_head_data, + Err(e) => { + log::trace!( + target: LOG_TARGET, + "The parachain head can't be updated. The parachain head data size \ + for {:?} is {}. It exceeds maximal configured size {}.", + parachain, + e.value_size, + e.maximal_size, + ); + + Self::deposit_event(Event::RejectedLargeParachainHead { + parachain, + parachain_head_hash: new_head_hash, + parachain_head_size: e.value_size as _, + }); + + return Err(()) + }, + }; + + let next_imported_hash_position = stored_best_head + .map_or(0, |stored_best_head| stored_best_head.next_imported_hash_position); + + // insert updated best parachain head + let head_hash_to_prune = + ImportedParaHashes::::try_get(parachain, next_imported_hash_position); + let updated_best_para_head = ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: new_at_relay_block_number, + head_hash: new_head_hash, + }, + next_imported_hash_position: (next_imported_hash_position + 1) % + T::HeadsToKeep::get(), + }; + ImportedParaHashes::::insert( + parachain, + next_imported_hash_position, + new_head_hash, + ); + ImportedParaHeads::::insert(parachain, new_head_hash, updated_head_data); + log::trace!( + target: LOG_TARGET, + "Updated head of parachain {:?} to {}", + parachain, + new_head_hash, + ); + + // remove old head + let prune_happened = head_hash_to_prune.is_ok(); + if let Ok(head_hash_to_prune) = head_hash_to_prune { + log::trace!( + target: LOG_TARGET, + "Pruning old head of parachain {:?}: {}", + parachain, + head_hash_to_prune, + ); + ImportedParaHeads::::remove(parachain, head_hash_to_prune); + } + Self::deposit_event(Event::UpdatedParachainHead { + parachain, + parachain_head_hash: new_head_hash, + }); + + Ok(UpdateParachainHeadArtifacts { best_head: updated_best_para_head, prune_happened }) + } + } + + #[pallet::genesis_config] + #[derive(DefaultNoBound)] + pub struct GenesisConfig, I: 'static = ()> { + /// Initial pallet operating mode. + pub operating_mode: BasicOperatingMode, + /// Initial pallet owner. + pub owner: Option, + /// Dummy marker. + pub phantom: sp_std::marker::PhantomData, + } + + #[pallet::genesis_build] + impl, I: 'static> GenesisBuild for GenesisConfig { + fn build(&self) { + PalletOperatingMode::::put(self.operating_mode); + if let Some(ref owner) = self.owner { + PalletOwner::::put(owner); + } + } + } + + /// Returns maximal number of parachains, supported by the pallet. + pub struct MaybeMaxParachains(PhantomData<(T, I)>); + + impl, I: 'static> Get> for MaybeMaxParachains { + fn get() -> Option { + Some(T::ParaStoredHeaderDataBuilder::supported_parachains()) + } + } + + /// Returns total number of all parachains hashes/heads, stored by the pallet. + pub struct MaybeMaxTotalParachainHashes(PhantomData<(T, I)>); + + impl, I: 'static> Get> for MaybeMaxTotalParachainHashes { + fn get() -> Option { + Some( + T::ParaStoredHeaderDataBuilder::supported_parachains() + .saturating_mul(T::HeadsToKeep::get()), + ) + } + } +} + +/// Single parachain header chain adapter. +pub struct ParachainHeaders(PhantomData<(T, I, C)>); + +impl, I: 'static, C: Parachain> HeaderChain + for ParachainHeaders +{ + fn finalized_header_state_root(hash: HashOf) -> Option> { + Pallet::::parachain_head(ParaId(C::PARACHAIN_ID), hash) + .and_then(|head| head.decode_parachain_head_data::().ok()) + .map(|h| h.state_root) + } +} + +/// (Re)initialize pallet with given header for using it in `pallet-bridge-messages` benchmarks. +#[cfg(feature = "runtime-benchmarks")] +pub fn initialize_for_benchmarks, I: 'static, PC: Parachain>( + header: HeaderOf, +) { + let parachain = ParaId(PC::PARACHAIN_ID); + let parachain_head = ParaHead(header.encode()); + let updated_head_data = T::ParaStoredHeaderDataBuilder::try_build(parachain, ¶chain_head) + .expect("failed to build stored parachain head in benchmarks"); + Pallet::::update_parachain_head( + parachain, + None, + 0, + updated_head_data, + parachain_head.hash(), + ) + .expect("failed to insert parachain head in benchmarks"); +} + +#[cfg(test)] +pub(crate) mod tests { + use super::*; + use crate::mock::{ + run_test, test_relay_header, BigParachainHeader, RegularParachainHasher, + RegularParachainHeader, RuntimeEvent as TestEvent, RuntimeOrigin, TestRuntime, + UNTRACKED_PARACHAIN_ID, + }; + use bp_test_utils::prepare_parachain_heads_proof; + use codec::Encode; + + use bp_parachains::{ + BestParaHeadHash, BridgeParachainCall, ImportedParaHeadsKeyProvider, ParasInfoKeyProvider, + }; + use bp_runtime::{ + BasicOperatingMode, OwnedBridgeModuleError, StorageDoubleMapKeyProvider, + StorageMapKeyProvider, + }; + use bp_test_utils::{ + authority_list, generate_owned_bridge_module_tests, make_default_justification, + }; + use frame_support::{ + assert_noop, assert_ok, + dispatch::DispatchResultWithPostInfo, + storage::generator::{StorageDoubleMap, StorageMap}, + traits::{Get, OnInitialize}, + weights::Weight, + }; + use frame_system::{EventRecord, Pallet as System, Phase}; + use sp_core::Hasher; + use sp_runtime::{traits::Header as HeaderT, DispatchError}; + + type BridgesGrandpaPalletInstance = pallet_bridge_grandpa::Instance1; + type WeightInfo = ::WeightInfo; + type DbWeight = ::DbWeight; + + pub(crate) fn initialize(state_root: RelayBlockHash) -> RelayBlockHash { + pallet_bridge_grandpa::Pallet::::initialize( + RuntimeOrigin::root(), + bp_header_chain::InitializationData { + header: Box::new(test_relay_header(0, state_root)), + authority_list: authority_list(), + set_id: 1, + operating_mode: BasicOperatingMode::Normal, + }, + ) + .unwrap(); + + System::::set_block_number(1); + System::::reset_events(); + + test_relay_header(0, state_root).hash() + } + + fn proceed(num: RelayBlockNumber, state_root: RelayBlockHash) -> ParaHash { + pallet_bridge_grandpa::Pallet::::on_initialize( + 0, + ); + + let header = test_relay_header(num, state_root); + let hash = header.hash(); + let justification = make_default_justification(&header); + assert_ok!( + pallet_bridge_grandpa::Pallet::::submit_finality_proof( + RuntimeOrigin::signed(1), + Box::new(header), + justification, + ) + ); + + hash + } + + fn initial_best_head(parachain: u32) -> ParaInfo { + ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: 0, + head_hash: head_data(parachain, 0).hash(), + }, + next_imported_hash_position: 1, + } + } + + pub(crate) fn head_data(parachain: u32, head_number: u32) -> ParaHead { + ParaHead( + RegularParachainHeader::new( + head_number as _, + Default::default(), + RegularParachainHasher::hash(&(parachain, head_number).encode()), + Default::default(), + Default::default(), + ) + .encode(), + ) + } + + fn stored_head_data(parachain: u32, head_number: u32) -> ParaStoredHeaderData { + ParaStoredHeaderData( + (head_number as u64, RegularParachainHasher::hash(&(parachain, head_number).encode())) + .encode(), + ) + } + + fn big_head_data(parachain: u32, head_number: u32) -> ParaHead { + ParaHead( + BigParachainHeader::new( + head_number as _, + Default::default(), + RegularParachainHasher::hash(&(parachain, head_number).encode()), + Default::default(), + Default::default(), + ) + .encode(), + ) + } + + fn big_stored_head_data(parachain: u32, head_number: u32) -> ParaStoredHeaderData { + ParaStoredHeaderData( + (head_number as u128, RegularParachainHasher::hash(&(parachain, head_number).encode())) + .encode(), + ) + } + + fn head_hash(parachain: u32, head_number: u32) -> ParaHash { + head_data(parachain, head_number).hash() + } + + fn import_parachain_1_head( + relay_chain_block: RelayBlockNumber, + relay_state_root: RelayBlockHash, + parachains: Vec<(ParaId, ParaHash)>, + proof: ParaHeadsProof, + ) -> DispatchResultWithPostInfo { + Pallet::::submit_parachain_heads( + RuntimeOrigin::signed(1), + (relay_chain_block, test_relay_header(relay_chain_block, relay_state_root).hash()), + parachains, + proof, + ) + } + + fn weight_of_import_parachain_1_head(proof: &ParaHeadsProof, prune_expected: bool) -> Weight { + let db_weight = ::DbWeight::get(); + WeightInfoOf::::submit_parachain_heads_weight(db_weight, proof, 1) + .saturating_sub(if prune_expected { + Weight::zero() + } else { + WeightInfoOf::::parachain_head_pruning_weight(db_weight) + }) + } + + #[test] + fn submit_parachain_heads_checks_operating_mode() { + let (state_root, proof, parachains) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 0))]); + + run_test(|| { + initialize(state_root); + + // `submit_parachain_heads()` should fail when the pallet is halted. + PalletOperatingMode::::put(BasicOperatingMode::Halted); + assert_noop!( + Pallet::::submit_parachain_heads( + RuntimeOrigin::signed(1), + (0, test_relay_header(0, state_root).hash()), + parachains.clone(), + proof.clone(), + ), + Error::::BridgeModule(OwnedBridgeModuleError::Halted) + ); + + // `submit_parachain_heads()` should succeed now that the pallet is resumed. + PalletOperatingMode::::put(BasicOperatingMode::Normal); + assert_ok!(Pallet::::submit_parachain_heads( + RuntimeOrigin::signed(1), + (0, test_relay_header(0, state_root).hash()), + parachains, + proof, + ),); + }); + } + + #[test] + fn imports_initial_parachain_heads() { + let (state_root, proof, parachains) = + prepare_parachain_heads_proof::(vec![ + (1, head_data(1, 0)), + (3, head_data(3, 10)), + ]); + run_test(|| { + initialize(state_root); + + // we're trying to update heads of parachains 1, 2 and 3 + let expected_weight = + WeightInfo::submit_parachain_heads_weight(DbWeight::get(), &proof, 2); + let result = Pallet::::submit_parachain_heads( + RuntimeOrigin::signed(1), + (0, test_relay_header(0, state_root).hash()), + parachains, + proof, + ); + assert_ok!(result); + assert_eq!(result.expect("checked above").actual_weight, Some(expected_weight)); + + // but only 1 and 2 are updated, because proof is missing head of parachain#2 + assert_eq!(ParasInfo::::get(ParaId(1)), Some(initial_best_head(1))); + assert_eq!(ParasInfo::::get(ParaId(2)), None); + assert_eq!( + ParasInfo::::get(ParaId(3)), + Some(ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: 0, + head_hash: head_data(3, 10).hash() + }, + next_imported_hash_position: 1, + }) + ); + + assert_eq!( + ImportedParaHeads::::get( + ParaId(1), + initial_best_head(1).best_head_hash.head_hash + ) + .map(|h| h.into_inner()), + Some(stored_head_data(1, 0)) + ); + assert_eq!( + ImportedParaHeads::::get( + ParaId(2), + initial_best_head(2).best_head_hash.head_hash + ) + .map(|h| h.into_inner()), + None + ); + assert_eq!( + ImportedParaHeads::::get(ParaId(3), head_hash(3, 10)) + .map(|h| h.into_inner()), + Some(stored_head_data(3, 10)) + ); + + assert_eq!( + System::::events(), + vec![ + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(1), + parachain_head_hash: initial_best_head(1).best_head_hash.head_hash, + }), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(3), + parachain_head_hash: head_data(3, 10).hash(), + }), + topics: vec![], + } + ], + ); + }); + } + + #[test] + fn imports_parachain_heads_is_able_to_progress() { + let (state_root_5, proof_5, parachains_5) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 5))]); + let (state_root_10, proof_10, parachains_10) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 10))]); + run_test(|| { + // start with relay block #0 and import head#5 of parachain#1 + initialize(state_root_5); + assert_ok!(import_parachain_1_head(0, state_root_5, parachains_5, proof_5)); + assert_eq!( + ParasInfo::::get(ParaId(1)), + Some(ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: 0, + head_hash: head_data(1, 5).hash() + }, + next_imported_hash_position: 1, + }) + ); + assert_eq!( + ImportedParaHeads::::get(ParaId(1), head_data(1, 5).hash()) + .map(|h| h.into_inner()), + Some(stored_head_data(1, 5)) + ); + assert_eq!( + ImportedParaHeads::::get(ParaId(1), head_data(1, 10).hash()) + .map(|h| h.into_inner()), + None + ); + assert_eq!( + System::::events(), + vec![EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(1), + parachain_head_hash: head_data(1, 5).hash(), + }), + topics: vec![], + }], + ); + + // import head#10 of parachain#1 at relay block #1 + let relay_1_hash = proceed(1, state_root_10); + assert_ok!(import_parachain_1_head(1, state_root_10, parachains_10, proof_10)); + assert_eq!( + ParasInfo::::get(ParaId(1)), + Some(ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: 1, + head_hash: head_data(1, 10).hash() + }, + next_imported_hash_position: 2, + }) + ); + assert_eq!( + ImportedParaHeads::::get(ParaId(1), head_data(1, 5).hash()) + .map(|h| h.into_inner()), + Some(stored_head_data(1, 5)) + ); + assert_eq!( + ImportedParaHeads::::get(ParaId(1), head_data(1, 10).hash()) + .map(|h| h.into_inner()), + Some(stored_head_data(1, 10)) + ); + assert_eq!( + System::::events(), + vec![ + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(1), + parachain_head_hash: head_data(1, 5).hash(), + }), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Grandpa1( + pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader { + number: 1, + hash: relay_1_hash, + } + ), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(1), + parachain_head_hash: head_data(1, 10).hash(), + }), + topics: vec![], + } + ], + ); + }); + } + + #[test] + fn ignores_untracked_parachain() { + let (state_root, proof, parachains) = + prepare_parachain_heads_proof::(vec![ + (1, head_data(1, 5)), + (UNTRACKED_PARACHAIN_ID, head_data(1, 5)), + (2, head_data(1, 5)), + ]); + run_test(|| { + // start with relay block #0 and try to import head#5 of parachain#1 and untracked + // parachain + let expected_weight = + WeightInfo::submit_parachain_heads_weight(DbWeight::get(), &proof, 3) + .saturating_sub(WeightInfo::parachain_head_storage_write_weight( + DbWeight::get(), + )); + initialize(state_root); + let result = Pallet::::submit_parachain_heads( + RuntimeOrigin::signed(1), + (0, test_relay_header(0, state_root).hash()), + parachains, + proof, + ); + assert_ok!(result); + assert_eq!(result.expect("checked above").actual_weight, Some(expected_weight)); + assert_eq!( + ParasInfo::::get(ParaId(1)), + Some(ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: 0, + head_hash: head_data(1, 5).hash() + }, + next_imported_hash_position: 1, + }) + ); + assert_eq!(ParasInfo::::get(ParaId(UNTRACKED_PARACHAIN_ID)), None,); + assert_eq!( + ParasInfo::::get(ParaId(2)), + Some(ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: 0, + head_hash: head_data(1, 5).hash() + }, + next_imported_hash_position: 1, + }) + ); + assert_eq!( + System::::events(), + vec![ + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(1), + parachain_head_hash: head_data(1, 5).hash(), + }), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UntrackedParachainRejected { + parachain: ParaId(UNTRACKED_PARACHAIN_ID), + }), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(2), + parachain_head_hash: head_data(1, 5).hash(), + }), + topics: vec![], + } + ], + ); + }); + } + + #[test] + fn does_nothing_when_already_imported_this_head_at_previous_relay_header() { + let (state_root, proof, parachains) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 0))]); + run_test(|| { + // import head#0 of parachain#1 at relay block#0 + initialize(state_root); + assert_ok!(import_parachain_1_head(0, state_root, parachains.clone(), proof.clone())); + assert_eq!(ParasInfo::::get(ParaId(1)), Some(initial_best_head(1))); + assert_eq!( + System::::events(), + vec![EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(1), + parachain_head_hash: initial_best_head(1).best_head_hash.head_hash, + }), + topics: vec![], + }], + ); + + // try to import head#0 of parachain#1 at relay block#1 + // => call succeeds, but nothing is changed + let relay_1_hash = proceed(1, state_root); + assert_ok!(import_parachain_1_head(1, state_root, parachains, proof)); + assert_eq!(ParasInfo::::get(ParaId(1)), Some(initial_best_head(1))); + assert_eq!( + System::::events(), + vec![ + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(1), + parachain_head_hash: initial_best_head(1).best_head_hash.head_hash, + }), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Grandpa1( + pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader { + number: 1, + hash: relay_1_hash, + } + ), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::RejectedObsoleteParachainHead { + parachain: ParaId(1), + parachain_head_hash: initial_best_head(1).best_head_hash.head_hash, + }), + topics: vec![], + } + ], + ); + }); + } + + #[test] + fn does_nothing_when_already_imported_head_at_better_relay_header() { + let (state_root_5, proof_5, parachains_5) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 5))]); + let (state_root_10, proof_10, parachains_10) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 10))]); + run_test(|| { + // start with relay block #0 + initialize(state_root_5); + + // head#10 of parachain#1 at relay block#1 + let relay_1_hash = proceed(1, state_root_10); + assert_ok!(import_parachain_1_head(1, state_root_10, parachains_10, proof_10)); + assert_eq!( + ParasInfo::::get(ParaId(1)), + Some(ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: 1, + head_hash: head_data(1, 10).hash() + }, + next_imported_hash_position: 1, + }) + ); + assert_eq!( + System::::events(), + vec![ + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Grandpa1( + pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader { + number: 1, + hash: relay_1_hash, + } + ), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(1), + parachain_head_hash: head_data(1, 10).hash(), + }), + topics: vec![], + } + ], + ); + + // now try to import head#5 at relay block#0 + // => nothing is changed, because better head has already been imported + assert_ok!(import_parachain_1_head(0, state_root_5, parachains_5, proof_5)); + assert_eq!( + ParasInfo::::get(ParaId(1)), + Some(ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: 1, + head_hash: head_data(1, 10).hash() + }, + next_imported_hash_position: 1, + }) + ); + assert_eq!( + System::::events(), + vec![ + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Grandpa1( + pallet_bridge_grandpa::Event::UpdatedBestFinalizedHeader { + number: 1, + hash: relay_1_hash, + } + ), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(1), + parachain_head_hash: head_data(1, 10).hash(), + }), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::RejectedObsoleteParachainHead { + parachain: ParaId(1), + parachain_head_hash: head_data(1, 5).hash(), + }), + topics: vec![], + } + ], + ); + }); + } + + #[test] + fn does_nothing_when_parachain_head_is_too_large() { + let (state_root, proof, parachains) = + prepare_parachain_heads_proof::(vec![ + (1, head_data(1, 5)), + (4, big_head_data(1, 5)), + ]); + run_test(|| { + // start with relay block #0 and try to import head#5 of parachain#1 and big parachain + initialize(state_root); + let result = Pallet::::submit_parachain_heads( + RuntimeOrigin::signed(1), + (0, test_relay_header(0, state_root).hash()), + parachains, + proof, + ); + assert_ok!(result); + assert_eq!( + ParasInfo::::get(ParaId(1)), + Some(ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: 0, + head_hash: head_data(1, 5).hash() + }, + next_imported_hash_position: 1, + }) + ); + assert_eq!(ParasInfo::::get(ParaId(4)), None); + assert_eq!( + System::::events(), + vec![ + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::UpdatedParachainHead { + parachain: ParaId(1), + parachain_head_hash: head_data(1, 5).hash(), + }), + topics: vec![], + }, + EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::RejectedLargeParachainHead { + parachain: ParaId(4), + parachain_head_hash: big_head_data(1, 5).hash(), + parachain_head_size: big_stored_head_data(1, 5).encoded_size() as u32, + }), + topics: vec![], + }, + ], + ); + }); + } + + #[test] + fn prunes_old_heads() { + run_test(|| { + let heads_to_keep = crate::mock::HeadsToKeep::get(); + + // import exactly `HeadsToKeep` headers + for i in 0..heads_to_keep { + let (state_root, proof, parachains) = prepare_parachain_heads_proof::< + RegularParachainHeader, + >(vec![(1, head_data(1, i))]); + if i == 0 { + initialize(state_root); + } else { + proceed(i, state_root); + } + + let expected_weight = weight_of_import_parachain_1_head(&proof, false); + let result = import_parachain_1_head(i, state_root, parachains, proof); + assert_ok!(result); + assert_eq!(result.expect("checked above").actual_weight, Some(expected_weight)); + } + + // nothing is pruned yet + for i in 0..heads_to_keep { + assert!(ImportedParaHeads::::get(ParaId(1), head_data(1, i).hash()) + .is_some()); + } + + // import next relay chain header and next parachain head + let (state_root, proof, parachains) = prepare_parachain_heads_proof::< + RegularParachainHeader, + >(vec![(1, head_data(1, heads_to_keep))]); + proceed(heads_to_keep, state_root); + let expected_weight = weight_of_import_parachain_1_head(&proof, true); + let result = import_parachain_1_head(heads_to_keep, state_root, parachains, proof); + assert_ok!(result); + assert_eq!(result.expect("checked above").actual_weight, Some(expected_weight)); + + // and the head#0 is pruned + assert!( + ImportedParaHeads::::get(ParaId(1), head_data(1, 0).hash()).is_none() + ); + for i in 1..=heads_to_keep { + assert!(ImportedParaHeads::::get(ParaId(1), head_data(1, i).hash()) + .is_some()); + } + }); + } + + #[test] + fn fails_on_unknown_relay_chain_block() { + let (state_root, proof, parachains) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 5))]); + run_test(|| { + // start with relay block #0 + initialize(state_root); + + // try to import head#5 of parachain#1 at unknown relay chain block #1 + assert_noop!( + import_parachain_1_head(1, state_root, parachains, proof), + Error::::UnknownRelayChainBlock + ); + }); + } + + #[test] + fn fails_on_invalid_storage_proof() { + let (_state_root, proof, parachains) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 5))]); + run_test(|| { + // start with relay block #0 + initialize(Default::default()); + + // try to import head#5 of parachain#1 at relay chain block #0 + assert_noop!( + import_parachain_1_head(0, Default::default(), parachains, proof), + Error::::HeaderChainStorageProof(HeaderChainError::StorageProof( + StorageProofError::StorageRootMismatch + )) + ); + }); + } + + #[test] + fn is_not_rewriting_existing_head_if_failed_to_read_updated_head() { + let (state_root_5, proof_5, parachains_5) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 5))]); + let (state_root_10_at_20, proof_10_at_20, parachains_10_at_20) = + prepare_parachain_heads_proof::(vec![(2, head_data(2, 10))]); + let (state_root_10_at_30, proof_10_at_30, parachains_10_at_30) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 10))]); + run_test(|| { + // we've already imported head#5 of parachain#1 at relay block#10 + initialize(state_root_5); + import_parachain_1_head(0, state_root_5, parachains_5, proof_5).expect("ok"); + assert_eq!( + Pallet::::best_parachain_head(ParaId(1)), + Some(stored_head_data(1, 5)) + ); + + // then if someone is pretending to provide updated head#10 of parachain#1 at relay + // block#20, but fails to do that + // + // => we'll leave previous value + proceed(20, state_root_10_at_20); + assert_ok!(Pallet::::submit_parachain_heads( + RuntimeOrigin::signed(1), + (20, test_relay_header(20, state_root_10_at_20).hash()), + parachains_10_at_20, + proof_10_at_20, + ),); + assert_eq!( + Pallet::::best_parachain_head(ParaId(1)), + Some(stored_head_data(1, 5)) + ); + + // then if someone is pretending to provide updated head#10 of parachain#1 at relay + // block#30, and actualy provides it + // + // => we'll update value + proceed(30, state_root_10_at_30); + assert_ok!(Pallet::::submit_parachain_heads( + RuntimeOrigin::signed(1), + (30, test_relay_header(30, state_root_10_at_30).hash()), + parachains_10_at_30, + proof_10_at_30, + ),); + assert_eq!( + Pallet::::best_parachain_head(ParaId(1)), + Some(stored_head_data(1, 10)) + ); + }); + } + + #[test] + fn storage_keys_computed_properly() { + assert_eq!( + ParasInfo::::storage_map_final_key(ParaId(42)).to_vec(), + ParasInfoKeyProvider::final_key("Parachains", &ParaId(42)).0 + ); + + assert_eq!( + ImportedParaHeads::::storage_double_map_final_key( + ParaId(42), + ParaHash::from([21u8; 32]) + ) + .to_vec(), + ImportedParaHeadsKeyProvider::final_key( + "Parachains", + &ParaId(42), + &ParaHash::from([21u8; 32]) + ) + .0, + ); + } + + #[test] + fn ignores_parachain_head_if_it_is_missing_from_storage_proof() { + let (state_root, proof, _) = + prepare_parachain_heads_proof::(vec![]); + let parachains = vec![(ParaId(2), Default::default())]; + run_test(|| { + initialize(state_root); + assert_ok!(Pallet::::submit_parachain_heads( + RuntimeOrigin::signed(1), + (0, test_relay_header(0, state_root).hash()), + parachains, + proof, + )); + assert_eq!( + System::::events(), + vec![EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::MissingParachainHead { + parachain: ParaId(2), + }), + topics: vec![], + }], + ); + }); + } + + #[test] + fn ignores_parachain_head_if_parachain_head_hash_is_wrong() { + let (state_root, proof, _) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 0))]); + let parachains = vec![(ParaId(1), head_data(1, 10).hash())]; + run_test(|| { + initialize(state_root); + assert_ok!(Pallet::::submit_parachain_heads( + RuntimeOrigin::signed(1), + (0, test_relay_header(0, state_root).hash()), + parachains, + proof, + )); + assert_eq!( + System::::events(), + vec![EventRecord { + phase: Phase::Initialization, + event: TestEvent::Parachains(Event::IncorrectParachainHeadHash { + parachain: ParaId(1), + parachain_head_hash: head_data(1, 10).hash(), + actual_parachain_head_hash: head_data(1, 0).hash(), + }), + topics: vec![], + }], + ); + }); + } + + #[test] + fn test_bridge_parachain_call_is_correctly_defined() { + let (state_root, proof, _) = + prepare_parachain_heads_proof::(vec![(1, head_data(1, 0))]); + let parachains = vec![(ParaId(2), Default::default())]; + let relay_header_id = (0, test_relay_header(0, state_root).hash()); + + let direct_submit_parachain_heads_call = Call::::submit_parachain_heads { + at_relay_block: relay_header_id, + parachains: parachains.clone(), + parachain_heads_proof: proof.clone(), + }; + let indirect_submit_parachain_heads_call = BridgeParachainCall::submit_parachain_heads { + at_relay_block: relay_header_id, + parachains, + parachain_heads_proof: proof, + }; + assert_eq!( + direct_submit_parachain_heads_call.encode(), + indirect_submit_parachain_heads_call.encode() + ); + } + + generate_owned_bridge_module_tests!(BasicOperatingMode::Normal, BasicOperatingMode::Halted); + + #[test] + fn maybe_max_parachains_returns_correct_value() { + assert_eq!(MaybeMaxParachains::::get(), Some(mock::TOTAL_PARACHAINS)); + } + + #[test] + fn maybe_max_total_parachain_hashes_returns_correct_value() { + assert_eq!( + MaybeMaxTotalParachainHashes::::get(), + Some(mock::TOTAL_PARACHAINS * mock::HeadsToKeep::get()), + ); + } +} diff --git a/bridges/modules/parachains/src/mock.rs b/bridges/modules/parachains/src/mock.rs new file mode 100644 index 00000000000..0a61d91d7b2 --- /dev/null +++ b/bridges/modules/parachains/src/mock.rs @@ -0,0 +1,350 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +use bp_header_chain::ChainWithGrandpa; +use bp_polkadot_core::parachains::ParaId; +use bp_runtime::{Chain, Parachain}; +use frame_support::{construct_runtime, parameter_types, traits::ConstU32, weights::Weight}; +use sp_runtime::{ + testing::{Header, H256}, + traits::{BlakeTwo256, Header as HeaderT, IdentityLookup}, + MultiSignature, Perbill, +}; + +use crate as pallet_bridge_parachains; + +pub type AccountId = u64; +pub type TestNumber = u64; + +pub type RelayBlockHeader = + sp_runtime::generic::Header; + +type Block = frame_system::mocking::MockBlock; +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + +pub const PARAS_PALLET_NAME: &str = "Paras"; +pub const UNTRACKED_PARACHAIN_ID: u32 = 10; +// use exact expected encoded size: `vec_len_size + header_number_size + state_root_hash_size` +pub const MAXIMAL_PARACHAIN_HEAD_DATA_SIZE: u32 = 1 + 8 + 32; +// total parachains that we use in tests +pub const TOTAL_PARACHAINS: u32 = 4; + +pub type RegularParachainHeader = sp_runtime::testing::Header; +pub type RegularParachainHasher = BlakeTwo256; +pub type BigParachainHeader = sp_runtime::generic::Header; + +pub struct Parachain1; + +impl Chain for Parachain1 { + type BlockNumber = u64; + type Hash = H256; + type Hasher = RegularParachainHasher; + type Header = RegularParachainHeader; + type AccountId = u64; + type Balance = u64; + type Index = u64; + type Signature = MultiSignature; + + fn max_extrinsic_size() -> u32 { + 0 + } + fn max_extrinsic_weight() -> Weight { + Weight::zero() + } +} + +impl Parachain for Parachain1 { + const PARACHAIN_ID: u32 = 1; +} + +pub struct Parachain2; + +impl Chain for Parachain2 { + type BlockNumber = u64; + type Hash = H256; + type Hasher = RegularParachainHasher; + type Header = RegularParachainHeader; + type AccountId = u64; + type Balance = u64; + type Index = u64; + type Signature = MultiSignature; + + fn max_extrinsic_size() -> u32 { + 0 + } + fn max_extrinsic_weight() -> Weight { + Weight::zero() + } +} + +impl Parachain for Parachain2 { + const PARACHAIN_ID: u32 = 2; +} + +pub struct Parachain3; + +impl Chain for Parachain3 { + type BlockNumber = u64; + type Hash = H256; + type Hasher = RegularParachainHasher; + type Header = RegularParachainHeader; + type AccountId = u64; + type Balance = u64; + type Index = u64; + type Signature = MultiSignature; + + fn max_extrinsic_size() -> u32 { + 0 + } + fn max_extrinsic_weight() -> Weight { + Weight::zero() + } +} + +impl Parachain for Parachain3 { + const PARACHAIN_ID: u32 = 3; +} + +// this parachain is using u128 as block number and stored head data size exceeds limit +pub struct BigParachain; + +impl Chain for BigParachain { + type BlockNumber = u128; + type Hash = H256; + type Hasher = RegularParachainHasher; + type Header = BigParachainHeader; + type AccountId = u64; + type Balance = u64; + type Index = u64; + type Signature = MultiSignature; + + fn max_extrinsic_size() -> u32 { + 0 + } + fn max_extrinsic_weight() -> Weight { + Weight::zero() + } +} + +impl Parachain for BigParachain { + const PARACHAIN_ID: u32 = 4; +} + +construct_runtime! { + pub enum TestRuntime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Grandpa1: pallet_bridge_grandpa::::{Pallet, Event}, + Grandpa2: pallet_bridge_grandpa::::{Pallet, Event}, + Parachains: pallet_bridge_parachains::{Call, Pallet, Event}, + } +} + +parameter_types! { + pub const BlockHashCount: TestNumber = 250; + pub const MaximumBlockWeight: Weight = Weight::from_parts(1024, 0); + pub const MaximumBlockLength: u32 = 2 * 1024; + pub const AvailableBlockRatio: Perbill = Perbill::one(); +} + +impl frame_system::Config for TestRuntime { + type RuntimeOrigin = RuntimeOrigin; + type Index = u64; + type RuntimeCall = RuntimeCall; + type BlockNumber = TestNumber; + type Hash = H256; + type Hashing = RegularParachainHasher; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type Header = Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = BlockHashCount; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); + type BaseCallFilter = frame_support::traits::Everything; + type SystemWeightInfo = (); + type DbWeight = (); + type BlockWeights = (); + type BlockLength = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = ConstU32<16>; +} + +parameter_types! { + pub const SessionLength: u64 = 5; + pub const NumValidators: u32 = 5; + pub const HeadersToKeep: u32 = 5; +} + +impl pallet_bridge_grandpa::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type BridgedChain = TestBridgedChain; + type MaxFreeMandatoryHeadersPerBlock = ConstU32<2>; + type HeadersToKeep = HeadersToKeep; + type WeightInfo = (); +} + +impl pallet_bridge_grandpa::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type BridgedChain = TestBridgedChain; + type MaxFreeMandatoryHeadersPerBlock = ConstU32<2>; + type HeadersToKeep = HeadersToKeep; + type WeightInfo = (); +} + +parameter_types! { + pub const HeadsToKeep: u32 = 4; + pub const ParasPalletName: &'static str = PARAS_PALLET_NAME; + pub GetTenFirstParachains: Vec = (0..10).map(ParaId).collect(); +} + +impl pallet_bridge_parachains::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); + type BridgesGrandpaPalletInstance = pallet_bridge_grandpa::Instance1; + type ParasPalletName = ParasPalletName; + type ParaStoredHeaderDataBuilder = (Parachain1, Parachain2, Parachain3, BigParachain); + type HeadsToKeep = HeadsToKeep; + type MaxParaHeadDataSize = ConstU32; +} + +#[cfg(feature = "runtime-benchmarks")] +impl pallet_bridge_parachains::benchmarking::Config<()> for TestRuntime { + fn parachains() -> Vec { + vec![ + ParaId(Parachain1::PARACHAIN_ID), + ParaId(Parachain2::PARACHAIN_ID), + ParaId(Parachain3::PARACHAIN_ID), + ] + } + + fn prepare_parachain_heads_proof( + parachains: &[ParaId], + _parachain_head_size: u32, + _proof_size: bp_runtime::StorageProofSize, + ) -> ( + crate::RelayBlockNumber, + crate::RelayBlockHash, + bp_polkadot_core::parachains::ParaHeadsProof, + Vec<(ParaId, bp_polkadot_core::parachains::ParaHash)>, + ) { + // in mock run we only care about benchmarks correctness, not the benchmark results + // => ignore size related arguments + let (state_root, proof, parachains) = + bp_test_utils::prepare_parachain_heads_proof::( + parachains.iter().map(|p| (p.0, crate::tests::head_data(p.0, 1))).collect(), + ); + let relay_genesis_hash = crate::tests::initialize(state_root); + (0, relay_genesis_hash, proof, parachains) + } +} + +#[derive(Debug)] +pub struct TestBridgedChain; + +impl Chain for TestBridgedChain { + type BlockNumber = crate::RelayBlockNumber; + type Hash = crate::RelayBlockHash; + type Hasher = crate::RelayBlockHasher; + type Header = RelayBlockHeader; + + type AccountId = AccountId; + type Balance = u32; + type Index = u32; + type Signature = sp_runtime::testing::TestSignature; + + fn max_extrinsic_size() -> u32 { + unreachable!() + } + + fn max_extrinsic_weight() -> Weight { + unreachable!() + } +} + +impl ChainWithGrandpa for TestBridgedChain { + const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = ""; + const MAX_AUTHORITIES_COUNT: u32 = 16; + const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 8; + const MAX_HEADER_SIZE: u32 = 256; + const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 64; +} + +#[derive(Debug)] +pub struct OtherBridgedChain; + +impl Chain for OtherBridgedChain { + type BlockNumber = u64; + type Hash = crate::RelayBlockHash; + type Hasher = crate::RelayBlockHasher; + type Header = sp_runtime::generic::Header; + + type AccountId = AccountId; + type Balance = u32; + type Index = u32; + type Signature = sp_runtime::testing::TestSignature; + + fn max_extrinsic_size() -> u32 { + unreachable!() + } + + fn max_extrinsic_weight() -> Weight { + unreachable!() + } +} + +impl ChainWithGrandpa for OtherBridgedChain { + const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = ""; + const MAX_AUTHORITIES_COUNT: u32 = 16; + const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 8; + const MAX_HEADER_SIZE: u32 = 256; + const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 64; +} + +/// Return test externalities to use in tests. +pub fn new_test_ext() -> sp_io::TestExternalities { + sp_io::TestExternalities::new(Default::default()) +} + +/// Run pallet test. +pub fn run_test(test: impl FnOnce() -> T) -> T { + new_test_ext().execute_with(|| { + System::set_block_number(1); + System::reset_events(); + test() + }) +} + +/// Return test relay chain header with given number. +pub fn test_relay_header( + num: crate::RelayBlockNumber, + state_root: crate::RelayBlockHash, +) -> RelayBlockHeader { + RelayBlockHeader::new( + num, + Default::default(), + state_root, + Default::default(), + Default::default(), + ) +} diff --git a/bridges/modules/parachains/src/weights.rs b/bridges/modules/parachains/src/weights.rs new file mode 100644 index 00000000000..1e81dba72fe --- /dev/null +++ b/bridges/modules/parachains/src/weights.rs @@ -0,0 +1,273 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Autogenerated weights for pallet_bridge_parachains +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-03-02, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/millau-bridge-node +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_bridge_parachains +// --extrinsic=* +// --execution=wasm +// --wasm-execution=Compiled +// --heap-pages=4096 +// --output=./modules/parachains/src/weights.rs +// --template=./.maintain/bridge-weight-template.hbs + +#![allow(clippy::all)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_bridge_parachains. +pub trait WeightInfo { + fn submit_parachain_heads_with_n_parachains(p: u32) -> Weight; + fn submit_parachain_heads_with_1kb_proof() -> Weight; + fn submit_parachain_heads_with_16kb_proof() -> Weight; +} + +/// Weights for `pallet_bridge_parachains` that are generated using one of the Bridge testnets. +/// +/// Those weights are test only and must never be used in production. +pub struct BridgeWeight(PhantomData); +impl WeightInfo for BridgeWeight { + /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// added: 496, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// 555, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Some(64), added: 1549, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Some(196), added: 1681, mode: MaxEncodedLen) + /// + /// The range of component `p` is `[1, 2]`. + fn submit_parachain_heads_with_n_parachains(p: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `366` + // Estimated: `4648` + // Minimum execution time: 36_701 nanoseconds. + Weight::from_parts(38_597_828, 4648) + // Standard Error: 190_859 + .saturating_add(Weight::from_parts(60_685, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// added: 496, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// 555, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Some(64), added: 1549, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Some(196), added: 1681, mode: MaxEncodedLen) + fn submit_parachain_heads_with_1kb_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `366` + // Estimated: `4648` + // Minimum execution time: 38_189 nanoseconds. + Weight::from_parts(39_252_000, 4648) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// added: 496, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// 555, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Some(64), added: 1549, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Some(196), added: 1681, mode: MaxEncodedLen) + fn submit_parachain_heads_with_16kb_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `366` + // Estimated: `4648` + // Minimum execution time: 62_868 nanoseconds. + Weight::from_parts(63_581_000, 4648) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// added: 496, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// 555, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Some(64), added: 1549, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Some(196), added: 1681, mode: MaxEncodedLen) + /// + /// The range of component `p` is `[1, 2]`. + fn submit_parachain_heads_with_n_parachains(p: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `366` + // Estimated: `4648` + // Minimum execution time: 36_701 nanoseconds. + Weight::from_parts(38_597_828, 4648) + // Standard Error: 190_859 + .saturating_add(Weight::from_parts(60_685, 0).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// added: 496, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// 555, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Some(64), added: 1549, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Some(196), added: 1681, mode: MaxEncodedLen) + fn submit_parachain_heads_with_1kb_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `366` + // Estimated: `4648` + // Minimum execution time: 38_189 nanoseconds. + Weight::from_parts(39_252_000, 4648) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: BridgeRialtoParachains PalletOperatingMode (r:1 w:0) + /// + /// Proof: BridgeRialtoParachains PalletOperatingMode (max_values: Some(1), max_size: Some(1), + /// added: 496, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoGrandpa ImportedHeaders (r:1 w:0) + /// + /// Proof: BridgeRialtoGrandpa ImportedHeaders (max_values: Some(14400), max_size: Some(68), + /// added: 2048, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ParasInfo (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ParasInfo (max_values: Some(1), max_size: Some(60), added: + /// 555, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHashes (r:1 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHashes (max_values: Some(1024), max_size: + /// Some(64), added: 1549, mode: MaxEncodedLen) + /// + /// Storage: BridgeRialtoParachains ImportedParaHeads (r:0 w:1) + /// + /// Proof: BridgeRialtoParachains ImportedParaHeads (max_values: Some(1024), max_size: + /// Some(196), added: 1681, mode: MaxEncodedLen) + fn submit_parachain_heads_with_16kb_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `366` + // Estimated: `4648` + // Minimum execution time: 62_868 nanoseconds. + Weight::from_parts(63_581_000, 4648) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } +} diff --git a/bridges/modules/parachains/src/weights_ext.rs b/bridges/modules/parachains/src/weights_ext.rs new file mode 100644 index 00000000000..eecdfe90359 --- /dev/null +++ b/bridges/modules/parachains/src/weights_ext.rs @@ -0,0 +1,107 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Weight-related utilities. + +use crate::weights::{BridgeWeight, WeightInfo}; + +use bp_runtime::Size; +use frame_support::weights::{RuntimeDbWeight, Weight}; + +/// Size of the regular parachain head. +/// +/// It's not that we are expecting all parachain heads to share the same size or that we would +/// reject all heads that have larger/lesser size. It is about head size that we use in benchmarks. +/// Relayer would need to pay additional fee for extra bytes. +/// +/// 384 is a bit larger (1.3 times) than the size of the randomly chosen Polkadot block. +pub const DEFAULT_PARACHAIN_HEAD_SIZE: u32 = 384; + +/// Number of extra bytes (excluding size of storage value itself) of storage proof, built at +/// the Rialto chain. +pub const EXTRA_STORAGE_PROOF_SIZE: u32 = 1024; + +/// Extended weight info. +pub trait WeightInfoExt: WeightInfo { + /// Storage proof overhead, that is included in every storage proof. + /// + /// The relayer would pay some extra fee for additional proof bytes, since they mean + /// more hashing operations. + fn expected_extra_storage_proof_size() -> u32; + + /// Weight of the parachain heads delivery extrinsic. + fn submit_parachain_heads_weight( + db_weight: RuntimeDbWeight, + proof: &impl Size, + parachains_count: u32, + ) -> Weight { + // weight of the `submit_parachain_heads` with exactly `parachains_count` parachain + // heads of the default size (`DEFAULT_PARACHAIN_HEAD_SIZE`) + let base_weight = Self::submit_parachain_heads_with_n_parachains(parachains_count); + + // overhead because of extra storage proof bytes + let expected_proof_size = parachains_count + .saturating_mul(DEFAULT_PARACHAIN_HEAD_SIZE) + .saturating_add(Self::expected_extra_storage_proof_size()); + let actual_proof_size = proof.size(); + let proof_size_overhead = Self::storage_proof_size_overhead( + actual_proof_size.saturating_sub(expected_proof_size), + ); + + // potential pruning weight (refunded if hasn't happened) + let pruning_weight = + Self::parachain_head_pruning_weight(db_weight).saturating_mul(parachains_count as u64); + + base_weight.saturating_add(proof_size_overhead).saturating_add(pruning_weight) + } + + /// Returns weight of single parachain head storage update. + /// + /// This weight only includes db write operations that happens if parachain head is actually + /// updated. All extra weights (weight of storage proof validation, additional checks, ...) is + /// not included. + fn parachain_head_storage_write_weight(db_weight: RuntimeDbWeight) -> Weight { + // it's just a couple of operations - we need to write the hash (`ImportedParaHashes`) and + // the head itself (`ImportedParaHeads`. Pruning is not included here + db_weight.writes(2) + } + + /// Returns weight of single parachain head pruning. + fn parachain_head_pruning_weight(db_weight: RuntimeDbWeight) -> Weight { + // it's just one write operation, we don't want any benchmarks for that + db_weight.writes(1) + } + + /// Returns weight that needs to be accounted when storage proof of given size is received. + fn storage_proof_size_overhead(extra_proof_bytes: u32) -> Weight { + let extra_byte_weight = (Self::submit_parachain_heads_with_16kb_proof() - + Self::submit_parachain_heads_with_1kb_proof()) / + (15 * 1024); + extra_byte_weight.saturating_mul(extra_proof_bytes as u64) + } +} + +impl WeightInfoExt for () { + fn expected_extra_storage_proof_size() -> u32 { + EXTRA_STORAGE_PROOF_SIZE + } +} + +impl WeightInfoExt for BridgeWeight { + fn expected_extra_storage_proof_size() -> u32 { + EXTRA_STORAGE_PROOF_SIZE + } +} diff --git a/bridges/modules/relayers/Cargo.toml b/bridges/modules/relayers/Cargo.toml new file mode 100644 index 00000000000..9fbc0996ba7 --- /dev/null +++ b/bridges/modules/relayers/Cargo.toml @@ -0,0 +1,59 @@ +[package] +name = "pallet-bridge-relayers" +description = "Module used to store relayer rewards and coordinate relayers set." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } + +# Bridge dependencies + +bp-messages = { path = "../../primitives/messages", default-features = false } +bp-relayers = { path = "../../primitives/relayers", default-features = false } +bp-runtime = { path = "../../primitives/runtime", default-features = false } +pallet-bridge-messages = { path = "../messages", default-features = false } + +# Substrate Dependencies + +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[dev-dependencies] +bp-runtime = { path = "../../primitives/runtime" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } + +[features] +default = ["std"] +std = [ + "bp-messages/std", + "bp-relayers/std", + "bp-runtime/std", + "codec/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "log/std", + "scale-info/std", + "sp-arithmetic/std", + "sp-runtime/std", + "sp-std/std", +] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", +] diff --git a/bridges/modules/relayers/README.md b/bridges/modules/relayers/README.md new file mode 100644 index 00000000000..656200f4486 --- /dev/null +++ b/bridges/modules/relayers/README.md @@ -0,0 +1,14 @@ +# Bridge Relayers Pallet + +The pallet serves as a storage for pending bridge relayer rewards. Any runtime component may register reward +to some relayer for doing some useful job at some messages lane. Later, the relayer may claim its rewards +using the `claim_rewards` call. + +The reward payment procedure is abstracted from the pallet code. One of possible implementations, is the +[`PayLaneRewardFromAccount`](../../primitives/relayers/src/lib.rs), which just does a `Currency::transfer` +call to relayer account from the relayer-rewards account, determined by the message lane id. + +We have two examples of how this pallet is used in production. Rewards are registered at the target chain to +compensate fees of message delivery transactions (and linked finality delivery calls). At the source chain, rewards +are registered during delivery confirmation transactions. You may find more information about that in the +[Kusama <> Polkadot bridge](../../docs/polkadot-kusama-bridge-overview.md) documentation. diff --git a/bridges/modules/relayers/src/benchmarking.rs b/bridges/modules/relayers/src/benchmarking.rs new file mode 100644 index 00000000000..d66a11ff06d --- /dev/null +++ b/bridges/modules/relayers/src/benchmarking.rs @@ -0,0 +1,131 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Benchmarks for the relayers Pallet. + +#![cfg(feature = "runtime-benchmarks")] + +use crate::*; + +use bp_messages::LaneId; +use bp_relayers::RewardsAccountOwner; +use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_system::RawOrigin; +use sp_runtime::traits::One; + +/// Reward amount that is (hopefully) is larger than existential deposit across all chains. +const REWARD_AMOUNT: u32 = u32::MAX; + +/// Pallet we're benchmarking here. +pub struct Pallet(crate::Pallet); + +/// Trait that must be implemented by runtime. +pub trait Config: crate::Config { + /// Prepare environment for paying given reward for serving given lane. + fn prepare_rewards_account(account_params: RewardsAccountParams, reward: Self::Reward); + /// Give enough balance to given account. + fn deposit_account(account: Self::AccountId, balance: Self::Reward); +} + +benchmarks! { + // Benchmark `claim_rewards` call. + claim_rewards { + let lane = LaneId([0, 0, 0, 0]); + let account_params = + RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain); + let relayer: T::AccountId = whitelisted_caller(); + let reward = T::Reward::from(REWARD_AMOUNT); + + T::prepare_rewards_account(account_params, reward); + RelayerRewards::::insert(&relayer, account_params, reward); + }: _(RawOrigin::Signed(relayer), account_params) + verify { + // we can't check anything here, because `PaymentProcedure` is responsible for + // payment logic, so we assume that if call has succeeded, the procedure has + // also completed successfully + } + + // Benchmark `register` call. + register { + let relayer: T::AccountId = whitelisted_caller(); + let valid_till = frame_system::Pallet::::block_number() + .saturating_add(crate::Pallet::::required_registration_lease()) + .saturating_add(One::one()) + .saturating_add(One::one()); + + T::deposit_account(relayer.clone(), crate::Pallet::::required_stake()); + }: _(RawOrigin::Signed(relayer.clone()), valid_till) + verify { + assert!(crate::Pallet::::is_registration_active(&relayer)); + } + + // Benchmark `deregister` call. + deregister { + let relayer: T::AccountId = whitelisted_caller(); + let valid_till = frame_system::Pallet::::block_number() + .saturating_add(crate::Pallet::::required_registration_lease()) + .saturating_add(One::one()) + .saturating_add(One::one()); + T::deposit_account(relayer.clone(), crate::Pallet::::required_stake()); + crate::Pallet::::register(RawOrigin::Signed(relayer.clone()).into(), valid_till).unwrap(); + + frame_system::Pallet::::set_block_number(valid_till.saturating_add(One::one())); + }: _(RawOrigin::Signed(relayer.clone())) + verify { + assert!(!crate::Pallet::::is_registration_active(&relayer)); + } + + // Benchmark `slash_and_deregister` method of the pallet. We are adding this weight to + // the weight of message delivery call if `RefundBridgedParachainMessages` signed extension + // is deployed at runtime level. + slash_and_deregister { + // prepare and register relayer account + let relayer: T::AccountId = whitelisted_caller(); + let valid_till = frame_system::Pallet::::block_number() + .saturating_add(crate::Pallet::::required_registration_lease()) + .saturating_add(One::one()) + .saturating_add(One::one()); + T::deposit_account(relayer.clone(), crate::Pallet::::required_stake()); + crate::Pallet::::register(RawOrigin::Signed(relayer.clone()).into(), valid_till).unwrap(); + + // create slash destination account + let lane = LaneId([0, 0, 0, 0]); + let slash_destination = RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain); + T::prepare_rewards_account(slash_destination.clone(), Zero::zero()); + }: { + crate::Pallet::::slash_and_deregister(&relayer, slash_destination) + } + verify { + assert!(!crate::Pallet::::is_registration_active(&relayer)); + } + + // Benchmark `register_relayer_reward` method of the pallet. We are adding this weight to + // the weight of message delivery call if `RefundBridgedParachainMessages` signed extension + // is deployed at runtime level. + register_relayer_reward { + let lane = LaneId([0, 0, 0, 0]); + let relayer: T::AccountId = whitelisted_caller(); + let account_params = + RewardsAccountParams::new(lane, *b"test", RewardsAccountOwner::ThisChain); + }: { + crate::Pallet::::register_relayer_reward(account_params.clone(), &relayer, One::one()); + } + verify { + assert_eq!(RelayerRewards::::get(relayer, &account_params), Some(One::one())); + } + + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::TestRuntime) +} diff --git a/bridges/modules/relayers/src/lib.rs b/bridges/modules/relayers/src/lib.rs new file mode 100644 index 00000000000..54b888cf29d --- /dev/null +++ b/bridges/modules/relayers/src/lib.rs @@ -0,0 +1,880 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Runtime module that is used to store relayer rewards and (in the future) to +//! coordinate relations between relayers. + +#![cfg_attr(not(feature = "std"), no_std)] +#![warn(missing_docs)] + +use bp_relayers::{ + PaymentProcedure, Registration, RelayerRewardsKeyProvider, RewardsAccountParams, StakeAndSlash, +}; +use bp_runtime::StorageDoubleMapKeyProvider; +use frame_support::fail; +use sp_arithmetic::traits::{AtLeast32BitUnsigned, Zero}; +use sp_runtime::{traits::CheckedSub, Saturating}; +use sp_std::marker::PhantomData; + +pub use pallet::*; +pub use payment_adapter::DeliveryConfirmationPaymentsAdapter; +pub use stake_adapter::StakeAndSlashNamed; +pub use weights::WeightInfo; +pub use weights_ext::WeightInfoExt; + +pub mod benchmarking; + +mod mock; +mod payment_adapter; +mod stake_adapter; +mod weights_ext; + +pub mod weights; + +/// The target that will be used when publishing logs related to this pallet. +pub const LOG_TARGET: &str = "runtime::bridge-relayers"; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + /// `RelayerRewardsKeyProvider` for given configuration. + type RelayerRewardsKeyProviderOf = + RelayerRewardsKeyProvider<::AccountId, ::Reward>; + + #[pallet::config] + pub trait Config: frame_system::Config { + /// The overarching event type. + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// Type of relayer reward. + type Reward: AtLeast32BitUnsigned + Copy + Parameter + MaxEncodedLen; + /// Pay rewards scheme. + type PaymentProcedure: PaymentProcedure; + /// Stake and slash scheme. + type StakeAndSlash: StakeAndSlash; + /// Pallet call weights. + type WeightInfo: WeightInfoExt; + } + + #[pallet::pallet] + pub struct Pallet(PhantomData); + + #[pallet::call] + impl Pallet { + /// Claim accumulated rewards. + #[pallet::call_index(0)] + #[pallet::weight(T::WeightInfo::claim_rewards())] + pub fn claim_rewards( + origin: OriginFor, + rewards_account_params: RewardsAccountParams, + ) -> DispatchResult { + let relayer = ensure_signed(origin)?; + + RelayerRewards::::try_mutate_exists( + &relayer, + rewards_account_params, + |maybe_reward| -> DispatchResult { + let reward = maybe_reward.take().ok_or(Error::::NoRewardForRelayer)?; + T::PaymentProcedure::pay_reward(&relayer, rewards_account_params, reward) + .map_err(|e| { + log::trace!( + target: LOG_TARGET, + "Failed to pay {:?} rewards to {:?}: {:?}", + rewards_account_params, + relayer, + e, + ); + Error::::FailedToPayReward + })?; + + Self::deposit_event(Event::::RewardPaid { + relayer: relayer.clone(), + rewards_account_params, + reward, + }); + Ok(()) + }, + ) + } + + /// Register relayer or update its registration. + /// + /// Registration allows relayer to get priority boost for its message delivery transactions. + #[pallet::call_index(1)] + #[pallet::weight(T::WeightInfo::register())] + pub fn register(origin: OriginFor, valid_till: T::BlockNumber) -> DispatchResult { + let relayer = ensure_signed(origin)?; + + // valid till must be larger than the current block number and the lease must be larger + // than the `RequiredRegistrationLease` + let lease = valid_till.saturating_sub(frame_system::Pallet::::block_number()); + ensure!( + lease > Pallet::::required_registration_lease(), + Error::::InvalidRegistrationLease + ); + + RegisteredRelayers::::try_mutate(&relayer, |maybe_registration| -> DispatchResult { + let mut registration = maybe_registration + .unwrap_or_else(|| Registration { valid_till, stake: Zero::zero() }); + + // new `valid_till` must be larger (or equal) than the old one + ensure!( + valid_till >= registration.valid_till, + Error::::CannotReduceRegistrationLease, + ); + registration.valid_till = valid_till; + + // regarding stake, there are three options: + // - if relayer stake is larger than required stake, we may do unreserve + // - if relayer stake equals to required stake, we do nothing + // - if relayer stake is smaller than required stake, we do additional reserve + let required_stake = Pallet::::required_stake(); + if let Some(to_unreserve) = registration.stake.checked_sub(&required_stake) { + Self::do_unreserve(&relayer, to_unreserve)?; + } else if let Some(to_reserve) = required_stake.checked_sub(®istration.stake) { + T::StakeAndSlash::reserve(&relayer, to_reserve).map_err(|e| { + log::trace!( + target: LOG_TARGET, + "Failed to reserve {:?} on relayer {:?} account: {:?}", + to_reserve, + relayer, + e, + ); + + Error::::FailedToReserve + })?; + } + registration.stake = required_stake; + + log::trace!(target: LOG_TARGET, "Successfully registered relayer: {:?}", relayer); + Self::deposit_event(Event::::RegistrationUpdated { + relayer: relayer.clone(), + registration, + }); + + *maybe_registration = Some(registration); + + Ok(()) + }) + } + + /// `Deregister` relayer. + /// + /// After this call, message delivery transactions of the relayer won't get any priority + /// boost. + #[pallet::call_index(2)] + #[pallet::weight(T::WeightInfo::deregister())] + pub fn deregister(origin: OriginFor) -> DispatchResult { + let relayer = ensure_signed(origin)?; + + RegisteredRelayers::::try_mutate(&relayer, |maybe_registration| -> DispatchResult { + let registration = match maybe_registration.take() { + Some(registration) => registration, + None => fail!(Error::::NotRegistered), + }; + + // we can't deregister until `valid_till + 1` + ensure!( + registration.valid_till < frame_system::Pallet::::block_number(), + Error::::RegistrationIsStillActive, + ); + + // if stake is non-zero, we should do unreserve + if !registration.stake.is_zero() { + Self::do_unreserve(&relayer, registration.stake)?; + } + + log::trace!(target: LOG_TARGET, "Successfully deregistered relayer: {:?}", relayer); + Self::deposit_event(Event::::Deregistered { relayer: relayer.clone() }); + + *maybe_registration = None; + + Ok(()) + }) + } + } + + impl Pallet { + /// Returns true if given relayer registration is active at current block. + /// + /// This call respects both `RequiredStake` and `RequiredRegistrationLease`, meaning that + /// it'll return false if registered stake is lower than required or if remaining lease + /// is less than `RequiredRegistrationLease`. + pub fn is_registration_active(relayer: &T::AccountId) -> bool { + let registration = match Self::registered_relayer(relayer) { + Some(registration) => registration, + None => return false, + }; + + // registration is inactive if relayer stake is less than required + if registration.stake < Self::required_stake() { + return false + } + + // registration is inactive if it ends soon + let remaining_lease = registration + .valid_till + .saturating_sub(frame_system::Pallet::::block_number()); + if remaining_lease <= Self::required_registration_lease() { + return false + } + + true + } + + /// Slash and `deregister` relayer. This function slashes all staked balance. + /// + /// It may fail inside, but error is swallowed and we only log it. + pub fn slash_and_deregister( + relayer: &T::AccountId, + slash_destination: RewardsAccountParams, + ) { + let registration = match RegisteredRelayers::::take(relayer) { + Some(registration) => registration, + None => { + log::trace!( + target: crate::LOG_TARGET, + "Cannot slash unregistered relayer {:?}", + relayer, + ); + + return + }, + }; + + match T::StakeAndSlash::repatriate_reserved( + relayer, + slash_destination, + registration.stake, + ) { + Ok(failed_to_slash) if failed_to_slash.is_zero() => { + log::trace!( + target: crate::LOG_TARGET, + "Relayer account {:?} has been slashed for {:?}. Funds were deposited to {:?}", + relayer, + registration.stake, + slash_destination, + ); + }, + Ok(failed_to_slash) => { + log::trace!( + target: crate::LOG_TARGET, + "Relayer account {:?} has been partially slashed for {:?}. Funds were deposited to {:?}. \ + Failed to slash: {:?}", + relayer, + registration.stake, + slash_destination, + failed_to_slash, + ); + }, + Err(e) => { + // TODO: document this. Where? + + // it may fail if there's no beneficiary account. For us it means that this + // account must exists before we'll deploy the bridge + log::debug!( + target: crate::LOG_TARGET, + "Failed to slash relayer account {:?}: {:?}. Maybe beneficiary account doesn't exist? \ + Beneficiary: {:?}, amount: {:?}, failed to slash: {:?}", + relayer, + e, + slash_destination, + registration.stake, + registration.stake, + ); + }, + } + } + + /// Register reward for given relayer. + pub fn register_relayer_reward( + rewards_account_params: RewardsAccountParams, + relayer: &T::AccountId, + reward: T::Reward, + ) { + if reward.is_zero() { + return + } + + RelayerRewards::::mutate( + relayer, + rewards_account_params, + |old_reward: &mut Option| { + let new_reward = old_reward.unwrap_or_else(Zero::zero).saturating_add(reward); + *old_reward = Some(new_reward); + + log::trace!( + target: crate::LOG_TARGET, + "Relayer {:?} can now claim reward for serving payer {:?}: {:?}", + relayer, + rewards_account_params, + new_reward, + ); + }, + ); + } + + /// Return required registration lease. + pub(crate) fn required_registration_lease() -> T::BlockNumber { + >::RequiredRegistrationLease::get() + } + + /// Return required stake. + pub(crate) fn required_stake() -> T::Reward { + >::RequiredStake::get() + } + + /// `Unreserve` given amount on relayer account. + fn do_unreserve(relayer: &T::AccountId, amount: T::Reward) -> DispatchResult { + let failed_to_unreserve = T::StakeAndSlash::unreserve(relayer, amount); + if !failed_to_unreserve.is_zero() { + log::trace!( + target: LOG_TARGET, + "Failed to unreserve {:?}/{:?} on relayer {:?} account", + failed_to_unreserve, + amount, + relayer, + ); + + fail!(Error::::FailedToUnreserve) + } + + Ok(()) + } + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + /// Reward has been paid to the relayer. + RewardPaid { + /// Relayer account that has been rewarded. + relayer: T::AccountId, + /// Relayer has received reward from this account. + rewards_account_params: RewardsAccountParams, + /// Reward amount. + reward: T::Reward, + }, + /// Relayer registration has been added or updated. + RegistrationUpdated { + /// Relayer account that has been registered. + relayer: T::AccountId, + /// Relayer registration. + registration: Registration, + }, + /// Relayer has been `deregistered`. + Deregistered { + /// Relayer account that has been `deregistered`. + relayer: T::AccountId, + }, + /// Relayer has been slashed and `deregistered`. + SlashedAndDeregistered { + /// Relayer account that has been `deregistered`. + relayer: T::AccountId, + /// Registration that was removed. + registration: Registration, + }, + } + + #[pallet::error] + pub enum Error { + /// No reward can be claimed by given relayer. + NoRewardForRelayer, + /// Reward payment procedure has failed. + FailedToPayReward, + /// The relayer has tried to register for past block or registration lease + /// is too short. + InvalidRegistrationLease, + /// New registration lease is less than the previous one. + CannotReduceRegistrationLease, + /// Failed to reserve enough funds on relayer account. + FailedToReserve, + /// Failed to `unreserve` enough funds on relayer account. + FailedToUnreserve, + /// Cannot `deregister` if not registered. + NotRegistered, + /// Failed to `deregister` relayer, because lease is still active. + RegistrationIsStillActive, + } + + /// Map of the relayer => accumulated reward. + #[pallet::storage] + #[pallet::getter(fn relayer_reward)] + pub type RelayerRewards = StorageDoubleMap< + _, + as StorageDoubleMapKeyProvider>::Hasher1, + as StorageDoubleMapKeyProvider>::Key1, + as StorageDoubleMapKeyProvider>::Hasher2, + as StorageDoubleMapKeyProvider>::Key2, + as StorageDoubleMapKeyProvider>::Value, + OptionQuery, + >; + + /// Relayers that have reserved some of their balance to get free priority boost + /// for their message delivery transactions. + /// + /// Other relayers may submit transactions as well, but they will have default + /// priority and will be rejected (without significant tip) in case if registered + /// relayer is present. + #[pallet::storage] + #[pallet::getter(fn registered_relayer)] + pub type RegisteredRelayers = StorageMap< + _, + Blake2_128Concat, + T::AccountId, + Registration, + OptionQuery, + >; +} + +#[cfg(test)] +mod tests { + use super::*; + use mock::{RuntimeEvent as TestEvent, *}; + + use crate::Event::RewardPaid; + use bp_messages::LaneId; + use bp_relayers::RewardsAccountOwner; + use frame_support::{ + assert_noop, assert_ok, + traits::fungible::{Inspect, Mutate}, + }; + use frame_system::{EventRecord, Pallet as System, Phase}; + use sp_runtime::DispatchError; + + fn get_ready_for_events() { + System::::set_block_number(1); + System::::reset_events(); + } + + #[test] + fn root_cant_claim_anything() { + run_test(|| { + assert_noop!( + Pallet::::claim_rewards( + RuntimeOrigin::root(), + TEST_REWARDS_ACCOUNT_PARAMS + ), + DispatchError::BadOrigin, + ); + }); + } + + #[test] + fn relayer_cant_claim_if_no_reward_exists() { + run_test(|| { + assert_noop!( + Pallet::::claim_rewards( + RuntimeOrigin::signed(REGULAR_RELAYER), + TEST_REWARDS_ACCOUNT_PARAMS + ), + Error::::NoRewardForRelayer, + ); + }); + } + + #[test] + fn relayer_cant_claim_if_payment_procedure_fails() { + run_test(|| { + RelayerRewards::::insert( + FAILING_RELAYER, + TEST_REWARDS_ACCOUNT_PARAMS, + 100, + ); + assert_noop!( + Pallet::::claim_rewards( + RuntimeOrigin::signed(FAILING_RELAYER), + TEST_REWARDS_ACCOUNT_PARAMS + ), + Error::::FailedToPayReward, + ); + }); + } + + #[test] + fn relayer_can_claim_reward() { + run_test(|| { + get_ready_for_events(); + + RelayerRewards::::insert( + REGULAR_RELAYER, + TEST_REWARDS_ACCOUNT_PARAMS, + 100, + ); + assert_ok!(Pallet::::claim_rewards( + RuntimeOrigin::signed(REGULAR_RELAYER), + TEST_REWARDS_ACCOUNT_PARAMS + )); + assert_eq!( + RelayerRewards::::get(REGULAR_RELAYER, TEST_REWARDS_ACCOUNT_PARAMS), + None + ); + + // Check if the `RewardPaid` event was emitted. + assert_eq!( + System::::events().last(), + Some(&EventRecord { + phase: Phase::Initialization, + event: TestEvent::Relayers(RewardPaid { + relayer: REGULAR_RELAYER, + rewards_account_params: TEST_REWARDS_ACCOUNT_PARAMS, + reward: 100 + }), + topics: vec![], + }), + ); + }); + } + + #[test] + fn pay_reward_from_account_actually_pays_reward() { + type Balances = pallet_balances::Pallet; + type PayLaneRewardFromAccount = bp_relayers::PayRewardFromAccount; + + run_test(|| { + let in_lane_0 = RewardsAccountParams::new( + LaneId([0, 0, 0, 0]), + *b"test", + RewardsAccountOwner::ThisChain, + ); + let out_lane_1 = RewardsAccountParams::new( + LaneId([0, 0, 0, 1]), + *b"test", + RewardsAccountOwner::BridgedChain, + ); + + let in_lane0_rewards_account = PayLaneRewardFromAccount::rewards_account(in_lane_0); + let out_lane1_rewards_account = PayLaneRewardFromAccount::rewards_account(out_lane_1); + + Balances::mint_into(&in_lane0_rewards_account, 100).unwrap(); + Balances::mint_into(&out_lane1_rewards_account, 100).unwrap(); + assert_eq!(Balances::balance(&in_lane0_rewards_account), 100); + assert_eq!(Balances::balance(&out_lane1_rewards_account), 100); + assert_eq!(Balances::balance(&1), 0); + + PayLaneRewardFromAccount::pay_reward(&1, in_lane_0, 100).unwrap(); + assert_eq!(Balances::balance(&in_lane0_rewards_account), 0); + assert_eq!(Balances::balance(&out_lane1_rewards_account), 100); + assert_eq!(Balances::balance(&1), 100); + + PayLaneRewardFromAccount::pay_reward(&1, out_lane_1, 100).unwrap(); + assert_eq!(Balances::balance(&in_lane0_rewards_account), 0); + assert_eq!(Balances::balance(&out_lane1_rewards_account), 0); + assert_eq!(Balances::balance(&1), 200); + }); + } + + #[test] + fn register_fails_if_valid_till_is_a_past_block() { + run_test(|| { + System::::set_block_number(100); + + assert_noop!( + Pallet::::register(RuntimeOrigin::signed(REGISTER_RELAYER), 50), + Error::::InvalidRegistrationLease, + ); + }); + } + + #[test] + fn register_fails_if_valid_till_lease_is_less_than_required() { + run_test(|| { + System::::set_block_number(100); + + assert_noop!( + Pallet::::register( + RuntimeOrigin::signed(REGISTER_RELAYER), + 99 + Lease::get() + ), + Error::::InvalidRegistrationLease, + ); + }); + } + + #[test] + fn register_works() { + run_test(|| { + get_ready_for_events(); + + assert_ok!(Pallet::::register( + RuntimeOrigin::signed(REGISTER_RELAYER), + 150 + )); + assert_eq!(Balances::reserved_balance(REGISTER_RELAYER), Stake::get()); + assert_eq!( + Pallet::::registered_relayer(REGISTER_RELAYER), + Some(Registration { valid_till: 150, stake: Stake::get() }), + ); + + assert_eq!( + System::::events().last(), + Some(&EventRecord { + phase: Phase::Initialization, + event: TestEvent::Relayers(Event::RegistrationUpdated { + relayer: REGISTER_RELAYER, + registration: Registration { valid_till: 150, stake: Stake::get() }, + }), + topics: vec![], + }), + ); + }); + } + + #[test] + fn register_fails_if_new_valid_till_is_lesser_than_previous() { + run_test(|| { + assert_ok!(Pallet::::register( + RuntimeOrigin::signed(REGISTER_RELAYER), + 150 + )); + + assert_noop!( + Pallet::::register(RuntimeOrigin::signed(REGISTER_RELAYER), 125), + Error::::CannotReduceRegistrationLease, + ); + }); + } + + #[test] + fn register_fails_if_it_cant_unreserve_some_balance_if_required_stake_decreases() { + run_test(|| { + RegisteredRelayers::::insert( + REGISTER_RELAYER, + Registration { valid_till: 150, stake: Stake::get() + 1 }, + ); + + assert_noop!( + Pallet::::register(RuntimeOrigin::signed(REGISTER_RELAYER), 150), + Error::::FailedToUnreserve, + ); + }); + } + + #[test] + fn register_unreserves_some_balance_if_required_stake_decreases() { + run_test(|| { + get_ready_for_events(); + + RegisteredRelayers::::insert( + REGISTER_RELAYER, + Registration { valid_till: 150, stake: Stake::get() + 1 }, + ); + TestStakeAndSlash::reserve(®ISTER_RELAYER, Stake::get() + 1).unwrap(); + assert_eq!(Balances::reserved_balance(REGISTER_RELAYER), Stake::get() + 1); + let free_balance = Balances::free_balance(REGISTER_RELAYER); + + assert_ok!(Pallet::::register( + RuntimeOrigin::signed(REGISTER_RELAYER), + 150 + )); + assert_eq!(Balances::reserved_balance(REGISTER_RELAYER), Stake::get()); + assert_eq!(Balances::free_balance(REGISTER_RELAYER), free_balance + 1); + assert_eq!( + Pallet::::registered_relayer(REGISTER_RELAYER), + Some(Registration { valid_till: 150, stake: Stake::get() }), + ); + + assert_eq!( + System::::events().last(), + Some(&EventRecord { + phase: Phase::Initialization, + event: TestEvent::Relayers(Event::RegistrationUpdated { + relayer: REGISTER_RELAYER, + registration: Registration { valid_till: 150, stake: Stake::get() } + }), + topics: vec![], + }), + ); + }); + } + + #[test] + fn register_fails_if_it_cant_reserve_some_balance() { + run_test(|| { + Balances::set_balance(®ISTER_RELAYER, 0); + assert_noop!( + Pallet::::register(RuntimeOrigin::signed(REGISTER_RELAYER), 150), + Error::::FailedToReserve, + ); + }); + } + + #[test] + fn register_fails_if_it_cant_reserve_some_balance_if_required_stake_increases() { + run_test(|| { + RegisteredRelayers::::insert( + REGISTER_RELAYER, + Registration { valid_till: 150, stake: Stake::get() - 1 }, + ); + Balances::set_balance(®ISTER_RELAYER, 0); + + assert_noop!( + Pallet::::register(RuntimeOrigin::signed(REGISTER_RELAYER), 150), + Error::::FailedToReserve, + ); + }); + } + + #[test] + fn register_reserves_some_balance_if_required_stake_increases() { + run_test(|| { + get_ready_for_events(); + + RegisteredRelayers::::insert( + REGISTER_RELAYER, + Registration { valid_till: 150, stake: Stake::get() - 1 }, + ); + TestStakeAndSlash::reserve(®ISTER_RELAYER, Stake::get() - 1).unwrap(); + + let free_balance = Balances::free_balance(REGISTER_RELAYER); + assert_ok!(Pallet::::register( + RuntimeOrigin::signed(REGISTER_RELAYER), + 150 + )); + assert_eq!(Balances::reserved_balance(REGISTER_RELAYER), Stake::get()); + assert_eq!(Balances::free_balance(REGISTER_RELAYER), free_balance - 1); + assert_eq!( + Pallet::::registered_relayer(REGISTER_RELAYER), + Some(Registration { valid_till: 150, stake: Stake::get() }), + ); + + assert_eq!( + System::::events().last(), + Some(&EventRecord { + phase: Phase::Initialization, + event: TestEvent::Relayers(Event::RegistrationUpdated { + relayer: REGISTER_RELAYER, + registration: Registration { valid_till: 150, stake: Stake::get() } + }), + topics: vec![], + }), + ); + }); + } + + #[test] + fn deregister_fails_if_not_registered() { + run_test(|| { + assert_noop!( + Pallet::::deregister(RuntimeOrigin::signed(REGISTER_RELAYER)), + Error::::NotRegistered, + ); + }); + } + + #[test] + fn deregister_fails_if_registration_is_still_active() { + run_test(|| { + assert_ok!(Pallet::::register( + RuntimeOrigin::signed(REGISTER_RELAYER), + 150 + )); + + System::::set_block_number(100); + + assert_noop!( + Pallet::::deregister(RuntimeOrigin::signed(REGISTER_RELAYER)), + Error::::RegistrationIsStillActive, + ); + }); + } + + #[test] + fn deregister_works() { + run_test(|| { + get_ready_for_events(); + + assert_ok!(Pallet::::register( + RuntimeOrigin::signed(REGISTER_RELAYER), + 150 + )); + + System::::set_block_number(151); + + let reserved_balance = Balances::reserved_balance(REGISTER_RELAYER); + let free_balance = Balances::free_balance(REGISTER_RELAYER); + assert_ok!(Pallet::::deregister(RuntimeOrigin::signed(REGISTER_RELAYER))); + assert_eq!( + Balances::reserved_balance(REGISTER_RELAYER), + reserved_balance - Stake::get() + ); + assert_eq!(Balances::free_balance(REGISTER_RELAYER), free_balance + Stake::get()); + + assert_eq!( + System::::events().last(), + Some(&EventRecord { + phase: Phase::Initialization, + event: TestEvent::Relayers(Event::Deregistered { relayer: REGISTER_RELAYER }), + topics: vec![], + }), + ); + }); + } + + #[test] + fn is_registration_active_is_false_for_unregistered_relayer() { + run_test(|| { + assert!(!Pallet::::is_registration_active(®ISTER_RELAYER)); + }); + } + + #[test] + fn is_registration_active_is_false_when_stake_is_too_low() { + run_test(|| { + RegisteredRelayers::::insert( + REGISTER_RELAYER, + Registration { valid_till: 150, stake: Stake::get() - 1 }, + ); + assert!(!Pallet::::is_registration_active(®ISTER_RELAYER)); + }); + } + + #[test] + fn is_registration_active_is_false_when_remaining_lease_is_too_low() { + run_test(|| { + System::::set_block_number(150 - Lease::get()); + + RegisteredRelayers::::insert( + REGISTER_RELAYER, + Registration { valid_till: 150, stake: Stake::get() }, + ); + assert!(!Pallet::::is_registration_active(®ISTER_RELAYER)); + }); + } + + #[test] + fn is_registration_active_is_true_when_relayer_is_properly_registeered() { + run_test(|| { + System::::set_block_number(150 - Lease::get()); + + RegisteredRelayers::::insert( + REGISTER_RELAYER, + Registration { valid_till: 151, stake: Stake::get() }, + ); + assert!(Pallet::::is_registration_active(®ISTER_RELAYER)); + }); + } +} diff --git a/bridges/modules/relayers/src/mock.rs b/bridges/modules/relayers/src/mock.rs new file mode 100644 index 00000000000..d8c5bd90967 --- /dev/null +++ b/bridges/modules/relayers/src/mock.rs @@ -0,0 +1,185 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +#![cfg(test)] + +use crate as pallet_bridge_relayers; + +use bp_messages::LaneId; +use bp_relayers::{ + PayRewardFromAccount, PaymentProcedure, RewardsAccountOwner, RewardsAccountParams, +}; +use frame_support::{parameter_types, traits::fungible::Mutate, weights::RuntimeDbWeight}; +use sp_core::H256; +use sp_runtime::{ + testing::Header as SubstrateHeader, + traits::{BlakeTwo256, ConstU32, IdentityLookup}, +}; + +pub type AccountId = u64; +pub type Balance = u64; +pub type BlockNumber = u64; + +pub type TestStakeAndSlash = pallet_bridge_relayers::StakeAndSlashNamed< + AccountId, + BlockNumber, + Balances, + ReserveId, + Stake, + Lease, +>; + +type Block = frame_system::mocking::MockBlock; +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + +frame_support::construct_runtime! { + pub enum TestRuntime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Event}, + Relayers: pallet_bridge_relayers::{Pallet, Call, Event}, + } +} + +parameter_types! { + pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { read: 1, write: 2 }; + pub const ExistentialDeposit: Balance = 1; + pub const ReserveId: [u8; 8] = *b"brdgrlrs"; + pub const Stake: Balance = 1_000; + pub const Lease: BlockNumber = 8; +} + +impl frame_system::Config for TestRuntime { + type RuntimeOrigin = RuntimeOrigin; + type Index = u64; + type RuntimeCall = RuntimeCall; + type BlockNumber = BlockNumber; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type Header = SubstrateHeader; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = frame_support::traits::ConstU64<250>; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type BaseCallFilter = frame_support::traits::Everything; + type SystemWeightInfo = (); + type BlockWeights = (); + type BlockLength = (); + type DbWeight = DbWeight; + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +impl pallet_balances::Config for TestRuntime { + type MaxLocks = (); + type Balance = Balance; + type DustRemoval = (); + type RuntimeEvent = RuntimeEvent; + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = frame_system::Pallet; + type WeightInfo = (); + type MaxReserves = ConstU32<1>; + type ReserveIdentifier = [u8; 8]; + type RuntimeHoldReason = RuntimeHoldReason; + type FreezeIdentifier = (); + type MaxHolds = ConstU32<0>; + type MaxFreezes = ConstU32<0>; +} + +impl pallet_bridge_relayers::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type Reward = Balance; + type PaymentProcedure = TestPaymentProcedure; + type StakeAndSlash = TestStakeAndSlash; + type WeightInfo = (); +} + +#[cfg(feature = "runtime-benchmarks")] +impl pallet_bridge_relayers::benchmarking::Config for TestRuntime { + fn prepare_rewards_account(account_params: RewardsAccountParams, reward: Balance) { + let rewards_account = + bp_relayers::PayRewardFromAccount::::rewards_account( + account_params, + ); + Self::deposit_account(rewards_account, reward); + } + + fn deposit_account(account: Self::AccountId, balance: Self::Reward) { + Balances::mint_into(&account, balance.saturating_add(ExistentialDeposit::get())).unwrap(); + } +} + +/// Message lane that we're using in tests. +pub const TEST_REWARDS_ACCOUNT_PARAMS: RewardsAccountParams = + RewardsAccountParams::new(LaneId([0, 0, 0, 0]), *b"test", RewardsAccountOwner::ThisChain); + +/// Regular relayer that may receive rewards. +pub const REGULAR_RELAYER: AccountId = 1; + +/// Relayer that can't receive rewards. +pub const FAILING_RELAYER: AccountId = 2; + +/// Relayer that is able to register. +pub const REGISTER_RELAYER: AccountId = 42; + +/// Payment procedure that rejects payments to the `FAILING_RELAYER`. +pub struct TestPaymentProcedure; + +impl TestPaymentProcedure { + pub fn rewards_account(params: RewardsAccountParams) -> AccountId { + PayRewardFromAccount::<(), AccountId>::rewards_account(params) + } +} + +impl PaymentProcedure for TestPaymentProcedure { + type Error = (); + + fn pay_reward( + relayer: &AccountId, + _lane_id: RewardsAccountParams, + _reward: Balance, + ) -> Result<(), Self::Error> { + match *relayer { + FAILING_RELAYER => Err(()), + _ => Ok(()), + } + } +} + +/// Return test externalities to use in tests. +pub fn new_test_ext() -> sp_io::TestExternalities { + let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + sp_io::TestExternalities::new(t) +} + +/// Run pallet test. +pub fn run_test(test: impl FnOnce() -> T) -> T { + new_test_ext().execute_with(|| { + Balances::mint_into(®ISTER_RELAYER, ExistentialDeposit::get() + 10 * Stake::get()) + .unwrap(); + + test() + }) +} diff --git a/bridges/modules/relayers/src/payment_adapter.rs b/bridges/modules/relayers/src/payment_adapter.rs new file mode 100644 index 00000000000..a9536cfc027 --- /dev/null +++ b/bridges/modules/relayers/src/payment_adapter.rs @@ -0,0 +1,158 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Code that allows relayers pallet to be used as a payment mechanism for the messages pallet. + +use crate::{Config, Pallet}; + +use bp_messages::{ + source_chain::{DeliveryConfirmationPayments, RelayersRewards}, + LaneId, MessageNonce, +}; +use bp_relayers::{RewardsAccountOwner, RewardsAccountParams}; +use frame_support::{sp_runtime::SaturatedConversion, traits::Get}; +use sp_arithmetic::traits::{Saturating, Zero}; +use sp_std::{collections::vec_deque::VecDeque, marker::PhantomData, ops::RangeInclusive}; + +/// Adapter that allows relayers pallet to be used as a delivery+dispatch payment mechanism +/// for the messages pallet. +pub struct DeliveryConfirmationPaymentsAdapter( + PhantomData<(T, MI, DeliveryReward)>, +); + +impl DeliveryConfirmationPayments + for DeliveryConfirmationPaymentsAdapter +where + T: Config + pallet_bridge_messages::Config, + MI: 'static, + DeliveryReward: Get, +{ + type Error = &'static str; + + fn pay_reward( + lane_id: LaneId, + messages_relayers: VecDeque>, + confirmation_relayer: &T::AccountId, + received_range: &RangeInclusive, + ) -> MessageNonce { + let relayers_rewards = + bp_messages::calc_relayers_rewards::(messages_relayers, received_range); + let rewarded_relayers = relayers_rewards.len(); + + register_relayers_rewards::( + confirmation_relayer, + relayers_rewards, + RewardsAccountParams::new( + lane_id, + T::BridgedChainId::get(), + RewardsAccountOwner::BridgedChain, + ), + DeliveryReward::get(), + ); + + rewarded_relayers as _ + } +} + +// Update rewards to given relayers, optionally rewarding confirmation relayer. +fn register_relayers_rewards( + confirmation_relayer: &T::AccountId, + relayers_rewards: RelayersRewards, + lane_id: RewardsAccountParams, + delivery_fee: T::Reward, +) { + // reward every relayer except `confirmation_relayer` + let mut confirmation_relayer_reward = T::Reward::zero(); + for (relayer, messages) in relayers_rewards { + // sane runtime configurations guarantee that the number of messages will be below + // `u32::MAX` + let relayer_reward = T::Reward::saturated_from(messages).saturating_mul(delivery_fee); + + if relayer != *confirmation_relayer { + Pallet::::register_relayer_reward(lane_id, &relayer, relayer_reward); + } else { + confirmation_relayer_reward = + confirmation_relayer_reward.saturating_add(relayer_reward); + } + } + + // finally - pay reward to confirmation relayer + Pallet::::register_relayer_reward( + lane_id, + confirmation_relayer, + confirmation_relayer_reward, + ); +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{mock::*, RelayerRewards}; + + const RELAYER_1: AccountId = 1; + const RELAYER_2: AccountId = 2; + const RELAYER_3: AccountId = 3; + + fn relayers_rewards() -> RelayersRewards { + vec![(RELAYER_1, 2), (RELAYER_2, 3)].into_iter().collect() + } + + #[test] + fn confirmation_relayer_is_rewarded_if_it_has_also_delivered_messages() { + run_test(|| { + register_relayers_rewards::( + &RELAYER_2, + relayers_rewards(), + TEST_REWARDS_ACCOUNT_PARAMS, + 50, + ); + + assert_eq!( + RelayerRewards::::get(RELAYER_1, TEST_REWARDS_ACCOUNT_PARAMS), + Some(100) + ); + assert_eq!( + RelayerRewards::::get(RELAYER_2, TEST_REWARDS_ACCOUNT_PARAMS), + Some(150) + ); + }); + } + + #[test] + fn confirmation_relayer_is_not_rewarded_if_it_has_not_delivered_any_messages() { + run_test(|| { + register_relayers_rewards::( + &RELAYER_3, + relayers_rewards(), + TEST_REWARDS_ACCOUNT_PARAMS, + 50, + ); + + assert_eq!( + RelayerRewards::::get(RELAYER_1, TEST_REWARDS_ACCOUNT_PARAMS), + Some(100) + ); + assert_eq!( + RelayerRewards::::get(RELAYER_2, TEST_REWARDS_ACCOUNT_PARAMS), + Some(150) + ); + assert_eq!( + RelayerRewards::::get(RELAYER_3, TEST_REWARDS_ACCOUNT_PARAMS), + None + ); + }); + } +} diff --git a/bridges/modules/relayers/src/stake_adapter.rs b/bridges/modules/relayers/src/stake_adapter.rs new file mode 100644 index 00000000000..055b6a111ec --- /dev/null +++ b/bridges/modules/relayers/src/stake_adapter.rs @@ -0,0 +1,186 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Code that allows `NamedReservableCurrency` to be used as a `StakeAndSlash` +//! mechanism of the relayers pallet. + +use bp_relayers::{PayRewardFromAccount, RewardsAccountParams, StakeAndSlash}; +use codec::Codec; +use frame_support::traits::{tokens::BalanceStatus, NamedReservableCurrency}; +use sp_runtime::{traits::Get, DispatchError, DispatchResult}; +use sp_std::{fmt::Debug, marker::PhantomData}; + +/// `StakeAndSlash` that works with `NamedReservableCurrency` and uses named +/// reservations. +/// +/// **WARNING**: this implementation assumes that the relayers pallet is configured to +/// use the [`bp_relayers::PayRewardFromAccount`] as its relayers payment scheme. +pub struct StakeAndSlashNamed( + PhantomData<(AccountId, BlockNumber, Currency, ReserveId, Stake, Lease)>, +); + +impl + StakeAndSlash + for StakeAndSlashNamed +where + AccountId: Codec + Debug, + Currency: NamedReservableCurrency, + ReserveId: Get, + Stake: Get, + Lease: Get, +{ + type RequiredStake = Stake; + type RequiredRegistrationLease = Lease; + + fn reserve(relayer: &AccountId, amount: Currency::Balance) -> DispatchResult { + Currency::reserve_named(&ReserveId::get(), relayer, amount) + } + + fn unreserve(relayer: &AccountId, amount: Currency::Balance) -> Currency::Balance { + Currency::unreserve_named(&ReserveId::get(), relayer, amount) + } + + fn repatriate_reserved( + relayer: &AccountId, + beneficiary: RewardsAccountParams, + amount: Currency::Balance, + ) -> Result { + let beneficiary_account = + PayRewardFromAccount::<(), AccountId>::rewards_account(beneficiary); + Currency::repatriate_reserved_named( + &ReserveId::get(), + relayer, + &beneficiary_account, + amount, + BalanceStatus::Free, + ) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::mock::*; + + use frame_support::traits::fungible::Mutate; + + fn test_stake() -> Balance { + Stake::get() + } + + #[test] + fn reserve_works() { + run_test(|| { + assert!(TestStakeAndSlash::reserve(&1, test_stake()).is_err()); + assert_eq!(Balances::free_balance(1), 0); + assert_eq!(Balances::reserved_balance(1), 0); + + Balances::mint_into(&2, test_stake() - 1).unwrap(); + assert!(TestStakeAndSlash::reserve(&2, test_stake()).is_err()); + assert_eq!(Balances::free_balance(2), test_stake() - 1); + assert_eq!(Balances::reserved_balance(2), 0); + + Balances::mint_into(&3, test_stake() * 2).unwrap(); + assert_eq!(TestStakeAndSlash::reserve(&3, test_stake()), Ok(())); + assert_eq!(Balances::free_balance(3), test_stake()); + assert_eq!(Balances::reserved_balance(3), test_stake()); + }) + } + + #[test] + fn unreserve_works() { + run_test(|| { + assert_eq!(TestStakeAndSlash::unreserve(&1, test_stake()), test_stake()); + assert_eq!(Balances::free_balance(1), 0); + assert_eq!(Balances::reserved_balance(1), 0); + + Balances::mint_into(&2, test_stake() * 2).unwrap(); + TestStakeAndSlash::reserve(&2, test_stake() / 3).unwrap(); + assert_eq!( + TestStakeAndSlash::unreserve(&2, test_stake()), + test_stake() - test_stake() / 3 + ); + assert_eq!(Balances::free_balance(2), test_stake() * 2); + assert_eq!(Balances::reserved_balance(2), 0); + + Balances::mint_into(&3, test_stake() * 2).unwrap(); + TestStakeAndSlash::reserve(&3, test_stake()).unwrap(); + assert_eq!(TestStakeAndSlash::unreserve(&3, test_stake()), 0); + assert_eq!(Balances::free_balance(3), test_stake() * 2); + assert_eq!(Balances::reserved_balance(3), 0); + }) + } + + #[test] + fn repatriate_reserved_works() { + run_test(|| { + let beneficiary = TEST_REWARDS_ACCOUNT_PARAMS; + let beneficiary_account = TestPaymentProcedure::rewards_account(beneficiary); + + let mut expected_balance = ExistentialDeposit::get(); + Balances::mint_into(&beneficiary_account, expected_balance).unwrap(); + + assert_eq!( + TestStakeAndSlash::repatriate_reserved(&1, beneficiary, test_stake()), + Ok(test_stake()) + ); + assert_eq!(Balances::free_balance(1), 0); + assert_eq!(Balances::reserved_balance(1), 0); + assert_eq!(Balances::free_balance(beneficiary_account), expected_balance); + assert_eq!(Balances::reserved_balance(beneficiary_account), 0); + + expected_balance += test_stake() / 3; + Balances::mint_into(&2, test_stake() * 2).unwrap(); + TestStakeAndSlash::reserve(&2, test_stake() / 3).unwrap(); + assert_eq!( + TestStakeAndSlash::repatriate_reserved(&2, beneficiary, test_stake()), + Ok(test_stake() - test_stake() / 3) + ); + assert_eq!(Balances::free_balance(2), test_stake() * 2 - test_stake() / 3); + assert_eq!(Balances::reserved_balance(2), 0); + assert_eq!(Balances::free_balance(beneficiary_account), expected_balance); + assert_eq!(Balances::reserved_balance(beneficiary_account), 0); + + expected_balance += test_stake(); + Balances::mint_into(&3, test_stake() * 2).unwrap(); + TestStakeAndSlash::reserve(&3, test_stake()).unwrap(); + assert_eq!( + TestStakeAndSlash::repatriate_reserved(&3, beneficiary, test_stake()), + Ok(0) + ); + assert_eq!(Balances::free_balance(3), test_stake()); + assert_eq!(Balances::reserved_balance(3), 0); + assert_eq!(Balances::free_balance(beneficiary_account), expected_balance); + assert_eq!(Balances::reserved_balance(beneficiary_account), 0); + }) + } + + #[test] + fn repatriate_reserved_doesnt_work_when_beneficiary_account_is_missing() { + run_test(|| { + let beneficiary = TEST_REWARDS_ACCOUNT_PARAMS; + let beneficiary_account = TestPaymentProcedure::rewards_account(beneficiary); + + Balances::mint_into(&3, test_stake() * 2).unwrap(); + TestStakeAndSlash::reserve(&3, test_stake()).unwrap(); + assert!(TestStakeAndSlash::repatriate_reserved(&3, beneficiary, test_stake()).is_err()); + assert_eq!(Balances::free_balance(3), test_stake()); + assert_eq!(Balances::reserved_balance(3), test_stake()); + assert_eq!(Balances::free_balance(beneficiary_account), 0); + assert_eq!(Balances::reserved_balance(beneficiary_account), 0); + }); + } +} diff --git a/bridges/modules/relayers/src/weights.rs b/bridges/modules/relayers/src/weights.rs new file mode 100644 index 00000000000..1bc195a5424 --- /dev/null +++ b/bridges/modules/relayers/src/weights.rs @@ -0,0 +1,259 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Autogenerated weights for pallet_bridge_relayers +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-04-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `covid`, CPU: `11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/millau-bridge-node +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_bridge_relayers +// --extrinsic=* +// --execution=wasm +// --wasm-execution=Compiled +// --heap-pages=4096 +// --output=./modules/relayers/src/weights.rs +// --template=./.maintain/bridge-weight-template.hbs + +#![allow(clippy::all)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{ + traits::Get, + weights::{constants::RocksDbWeight, Weight}, +}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_bridge_relayers. +pub trait WeightInfo { + fn claim_rewards() -> Weight; + fn register() -> Weight; + fn deregister() -> Weight; + fn slash_and_deregister() -> Weight; + fn register_relayer_reward() -> Weight; +} + +/// Weights for `pallet_bridge_relayers` that are generated using one of the Bridge testnets. +/// +/// Those weights are test only and must never be used in production. +pub struct BridgeWeight(PhantomData); +impl WeightInfo for BridgeWeight { + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances TotalIssuance (r:1 w:0) + /// + /// Proof: Balances TotalIssuance (max_values: Some(1), max_size: Some(8), added: 503, mode: + /// MaxEncodedLen) + /// + /// Storage: System Account (r:1 w:1) + /// + /// Proof: System Account (max_values: None, max_size: Some(104), added: 2579, mode: + /// MaxEncodedLen) + fn claim_rewards() -> Weight { + // Proof Size summary in bytes: + // Measured: `294` + // Estimated: `8592` + // Minimum execution time: 77_614 nanoseconds. + Weight::from_parts(79_987_000, 8592) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + fn register() -> Weight { + // Proof Size summary in bytes: + // Measured: `87` + // Estimated: `7843` + // Minimum execution time: 39_590 nanoseconds. + Weight::from_parts(40_546_000, 7843) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + fn deregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `264` + // Estimated: `7843` + // Minimum execution time: 43_332 nanoseconds. + Weight::from_parts(45_087_000, 7843) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + /// + /// Storage: System Account (r:1 w:1) + /// + /// Proof: System Account (max_values: None, max_size: Some(104), added: 2579, mode: + /// MaxEncodedLen) + fn slash_and_deregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `380` + // Estimated: `11412` + // Minimum execution time: 42_358 nanoseconds. + Weight::from_parts(43_539_000, 11412) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + fn register_relayer_reward() -> Weight { + // Proof Size summary in bytes: + // Measured: `12` + // Estimated: `3530` + // Minimum execution time: 6_338 nanoseconds. + Weight::from_parts(6_526_000, 3530) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances TotalIssuance (r:1 w:0) + /// + /// Proof: Balances TotalIssuance (max_values: Some(1), max_size: Some(8), added: 503, mode: + /// MaxEncodedLen) + /// + /// Storage: System Account (r:1 w:1) + /// + /// Proof: System Account (max_values: None, max_size: Some(104), added: 2579, mode: + /// MaxEncodedLen) + fn claim_rewards() -> Weight { + // Proof Size summary in bytes: + // Measured: `294` + // Estimated: `8592` + // Minimum execution time: 77_614 nanoseconds. + Weight::from_parts(79_987_000, 8592) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + fn register() -> Weight { + // Proof Size summary in bytes: + // Measured: `87` + // Estimated: `7843` + // Minimum execution time: 39_590 nanoseconds. + Weight::from_parts(40_546_000, 7843) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + fn deregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `264` + // Estimated: `7843` + // Minimum execution time: 43_332 nanoseconds. + Weight::from_parts(45_087_000, 7843) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(64), added: 2539, + /// mode: MaxEncodedLen) + /// + /// Storage: Balances Reserves (r:1 w:1) + /// + /// Proof: Balances Reserves (max_values: None, max_size: Some(849), added: 3324, mode: + /// MaxEncodedLen) + /// + /// Storage: System Account (r:1 w:1) + /// + /// Proof: System Account (max_values: None, max_size: Some(104), added: 2579, mode: + /// MaxEncodedLen) + fn slash_and_deregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `380` + // Estimated: `11412` + // Minimum execution time: 42_358 nanoseconds. + Weight::from_parts(43_539_000, 11412) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(65), added: 2540, + /// mode: MaxEncodedLen) + fn register_relayer_reward() -> Weight { + // Proof Size summary in bytes: + // Measured: `12` + // Estimated: `3530` + // Minimum execution time: 6_338 nanoseconds. + Weight::from_parts(6_526_000, 3530) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} diff --git a/bridges/modules/relayers/src/weights_ext.rs b/bridges/modules/relayers/src/weights_ext.rs new file mode 100644 index 00000000000..d459b0686bd --- /dev/null +++ b/bridges/modules/relayers/src/weights_ext.rs @@ -0,0 +1,49 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Weight-related utilities. + +use crate::weights::WeightInfo; + +use frame_support::pallet_prelude::Weight; + +/// Extended weight info. +pub trait WeightInfoExt: WeightInfo { + /// Returns weight, that needs to be added to the pre-dispatch weight of message delivery call, + /// if `RefundBridgedParachainMessages` signed extension is deployed at runtime level. + fn receive_messages_proof_overhead_from_runtime() -> Weight { + Self::slash_and_deregister().max(Self::register_relayer_reward()) + } + + /// Returns weight, that needs to be added to the pre-dispatch weight of message delivery + /// confirmation call, if `RefundBridgedParachainMessages` signed extension is deployed at + /// runtime level. + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { + Self::register_relayer_reward() + } + + /// Returns weight that we need to deduct from the message delivery call weight that has + /// completed successfully. + /// + /// Usually, the weight of `slash_and_deregister` is larger than the weight of the + /// `register_relayer_reward`. So if relayer has been rewarded, we want to deduct the difference + /// to get the actual post-dispatch weight. + fn extra_weight_of_successful_receive_messages_proof_call() -> Weight { + Self::slash_and_deregister().saturating_sub(Self::register_relayer_reward()) + } +} + +impl WeightInfoExt for T {} diff --git a/bridges/primitives/chain-bridge-hub-cumulus/Cargo.toml b/bridges/primitives/chain-bridge-hub-cumulus/Cargo.toml new file mode 100644 index 00000000000..2bbe3d029a3 --- /dev/null +++ b/bridges/primitives/chain-bridge-hub-cumulus/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "bp-bridge-hub-cumulus" +description = "Primitives of BridgeHubRococo parachain runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +# Bridge Dependencies + +bp-polkadot-core = { path = "../../primitives/polkadot-core", default-features = false } +bp-messages = { path = "../../primitives/messages", default-features = false } +bp-runtime = { path = "../../primitives/runtime", default-features = false } + +# Substrate Based Dependencies + +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +# Polkadot Dependencies +polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-polkadot-core/std", + "bp-messages/std", + "bp-runtime/std", + "frame-system/std", + "frame-support/std", + "sp-api/std", + "sp-std/std", + "polkadot-primitives/std", +] diff --git a/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs b/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs new file mode 100644 index 00000000000..4c9f9e20468 --- /dev/null +++ b/bridges/primitives/chain-bridge-hub-cumulus/src/lib.rs @@ -0,0 +1,216 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] + +pub use bp_polkadot_core::{ + AccountId, AccountInfoStorageMapKeyProvider, AccountPublic, Balance, BlockNumber, Hash, Hasher, + Hashing, Header, Index, Nonce, Perbill, Signature, SignedBlock, UncheckedExtrinsic, + EXTRA_STORAGE_PROOF_SIZE, TX_EXTRA_BYTES, +}; + +use bp_messages::*; +use bp_runtime::extensions::{ + BridgeRejectObsoleteHeadersAndMessages, ChargeTransactionPayment, CheckEra, CheckGenesis, + CheckNonZeroSender, CheckNonce, CheckSpecVersion, CheckTxVersion, CheckWeight, + GenericSignedExtension, RefundBridgedParachainMessagesSchema, +}; +use frame_support::{ + dispatch::DispatchClass, + parameter_types, + sp_runtime::{MultiAddress, MultiSigner}, + weights::constants, +}; +use frame_system::limits; +use sp_std::time::Duration; + +/// Average block interval in Cumulus-based parachains. +/// +/// Corresponds to the `MILLISECS_PER_BLOCK` from `parachains_common` crate. +pub const AVERAGE_BLOCK_INTERVAL: Duration = Duration::from_secs(12); + +/// All cumulus bridge hubs allow normal extrinsics to fill block up to 75 percent. +/// +/// This is a copy-paste from the cumulus repo's `parachains-common` crate. +pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); + +/// All cumulus bridge hubs chains allow for 0.5 seconds of compute with a 6-second average block +/// time. +/// +/// This is a copy-paste from the cumulus repo's `parachains-common` crate. +const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(constants::WEIGHT_REF_TIME_PER_SECOND, 0) + .saturating_div(2) + .set_proof_size(polkadot_primitives::v4::MAX_POV_SIZE as u64); + +/// All cumulus bridge hubs assume that about 5 percent of the block weight is consumed by +/// `on_initialize` handlers. This is used to limit the maximal weight of a single extrinsic. +/// +/// This is a copy-paste from the cumulus repo's `parachains-common` crate. +pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); + +parameter_types! { + pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio( + 5 * 1024 * 1024, + NORMAL_DISPATCH_RATIO, + ); + + /// Importing a block with 0 Extrinsics. + pub const BlockExecutionWeight: Weight = Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS, 0) + .saturating_mul(5_000_000); + /// Executing a NO-OP `System::remarks` Extrinsic. + pub const ExtrinsicBaseWeight: Weight = Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS, 0) + .saturating_mul(125_000); + + pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder() + .base_block(BlockExecutionWeight::get()) + .for_class(DispatchClass::all(), |weights| { + weights.base_extrinsic = ExtrinsicBaseWeight::get(); + }) + .for_class(DispatchClass::Normal, |weights| { + weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); + }) + .for_class(DispatchClass::Operational, |weights| { + weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); + // Operational transactions have an extra reserved space, so that they + // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. + weights.reserved = Some( + MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT, + ); + }) + .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) + .build_or_panic(); +} + +/// Public key of the chain account that may be used to verify signatures. +pub type AccountSigner = MultiSigner; + +/// The address format for describing accounts. +pub type Address = MultiAddress; + +// Note about selecting values of two following constants: +// +// Normal transactions have limit of 75% of 1/2 second weight for Cumulus parachains. Let's keep +// some reserve for the rest of stuff there => let's select values that fit in 50% of maximal limit. +// +// Using current constants, the limit would be: +// +// `75% * WEIGHT_REF_TIME_PER_SECOND * 1 / 2 * 50% = 0.75 * 1_000_000_000_000 / 2 * 0.5 = +// 187_500_000_000` +// +// According to (preliminary) weights of messages pallet, cost of additional message is zero and the +// cost of additional relayer is `8_000_000 + db read + db write`. Let's say we want no more than +// 4096 unconfirmed messages (no any scientific justification for that - it just looks large +// enough). And then we can't have more than 4096 relayers. E.g. for 1024 relayers is (using +// `RocksDbWeight`): +// +// `1024 * (8_000_000 + db read + db write) = 1024 * (8_000_000 + 25_000_000 + 100_000_000) = +// 136_192_000_000` +// +// So 1024 looks like good approximation for the number of relayers. If something is wrong in those +// assumptions, or something will change, it shall be caught by the +// `ensure_able_to_receive_confirmation` test. + +/// Maximal number of unrewarded relayer entries at inbound lane for Cumulus-based parachains. +pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 1024; + +/// Maximal number of unconfirmed messages at inbound lane for Cumulus-based parachains. +pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 4096; + +/// Extra signed extension data that is used by all bridge hubs. +pub type SignedExtra = ( + CheckNonZeroSender, + CheckSpecVersion, + CheckTxVersion, + CheckGenesis, + CheckEra, + CheckNonce, + CheckWeight, + ChargeTransactionPayment, + BridgeRejectObsoleteHeadersAndMessages, + RefundBridgedParachainMessagesSchema, +); + +/// Signed extension that is used by all bridge hubs. +pub type SignedExtension = GenericSignedExtension; + +/// Helper trait to define some extra methods on bridge hubs signed extension (and +/// overcome Rust limitations). +pub trait BridgeHubSignedExtension { + /// Create signed extension from its components. + fn from_params( + spec_version: u32, + transaction_version: u32, + era: bp_runtime::TransactionEra, + genesis_hash: Hash, + nonce: Index, + tip: Balance, + ) -> Self; + + /// Return transaction nonce. + fn nonce(&self) -> Index; + + /// Return transaction tip. + fn tip(&self) -> Balance; +} + +impl BridgeHubSignedExtension for SignedExtension { + /// Create signed extension from its components. + fn from_params( + spec_version: u32, + transaction_version: u32, + era: bp_runtime::TransactionEra, + genesis_hash: Hash, + nonce: Index, + tip: Balance, + ) -> Self { + GenericSignedExtension::new( + ( + (), // non-zero sender + (), // spec version + (), // tx version + (), // genesis + era.frame_era(), // era + nonce.into(), // nonce (compact encoding) + (), // Check weight + tip.into(), // transaction payment / tip (compact encoding) + (), // bridge reject obsolete headers and msgs + (), // bridge reward to relayer for message passing + ), + Some(( + (), + spec_version, + transaction_version, + genesis_hash, + era.signed_payload(genesis_hash), + (), + (), + (), + (), + (), + )), + ) + } + + /// Return transaction nonce. + fn nonce(&self) -> Index { + self.payload.5 .0 + } + + /// Return transaction tip. + fn tip(&self) -> Balance { + self.payload.7 .0 + } +} diff --git a/bridges/primitives/chain-bridge-hub-kusama/Cargo.toml b/bridges/primitives/chain-bridge-hub-kusama/Cargo.toml new file mode 100644 index 00000000000..6d4334eaa57 --- /dev/null +++ b/bridges/primitives/chain-bridge-hub-kusama/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "bp-bridge-hub-kusama" +description = "Primitives of BridgeHubRococo parachain runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +# Bridge Dependencies + +bp-bridge-hub-cumulus = { path = "../chain-bridge-hub-cumulus", default-features = false } +bp-runtime = { path = "../../primitives/runtime", default-features = false } +bp-messages = { path = "../../primitives/messages", default-features = false } + +# Substrate Based Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-bridge-hub-cumulus/std", + "bp-messages/std", + "bp-runtime/std", + "frame-support/std", + "sp-api/std", + "sp-std/std", +] diff --git a/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs b/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs new file mode 100644 index 00000000000..00b6c8301e4 --- /dev/null +++ b/bridges/primitives/chain-bridge-hub-kusama/src/lib.rs @@ -0,0 +1,82 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Module with configuration which reflects BridgeHubKusama runtime setup (AccountId, Headers, +//! Hashes...) + +#![cfg_attr(not(feature = "std"), no_std)] + +pub use bp_bridge_hub_cumulus::*; +use bp_messages::*; +use bp_runtime::{ + decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain, +}; +use frame_support::{ + dispatch::DispatchClass, + sp_runtime::{MultiAddress, MultiSigner}, + RuntimeDebug, +}; +use sp_std::prelude::*; + +/// BridgeHubKusama parachain. +#[derive(RuntimeDebug)] +pub struct BridgeHubKusama; + +impl Chain for BridgeHubKusama { + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; + + type AccountId = AccountId; + type Balance = Balance; + type Index = Index; + type Signature = Signature; + + fn max_extrinsic_size() -> u32 { + *BlockLength::get().max.get(DispatchClass::Normal) + } + + fn max_extrinsic_weight() -> Weight { + BlockWeights::get() + .get(DispatchClass::Normal) + .max_extrinsic + .unwrap_or(Weight::MAX) + } +} + +impl Parachain for BridgeHubKusama { + const PARACHAIN_ID: u32 = BRIDGE_HUB_KUSAMA_PARACHAIN_ID; +} + +/// Public key of the chain account that may be used to verify signatures. +pub type AccountSigner = MultiSigner; + +/// The address format for describing accounts. +pub type Address = MultiAddress; + +/// Identifier of BridgeHubKusama in the Kusama relay chain. +pub const BRIDGE_HUB_KUSAMA_PARACHAIN_ID: u32 = 1002; + +/// Name of the With-BridgeHubKusama messages pallet instance that is deployed at bridged chains. +pub const WITH_BRIDGE_HUB_KUSAMA_MESSAGES_PALLET_NAME: &str = "BridgeKusamaMessages"; + +/// Name of the With-BridgeHubKusama bridge-relayers pallet instance that is deployed at bridged +/// chains. +pub const WITH_BRIDGE_HUB_KUSAMA_RELAYERS_PALLET_NAME: &str = "BridgeRelayers"; + +decl_bridge_finality_runtime_apis!(bridge_hub_kusama); +decl_bridge_messages_runtime_apis!(bridge_hub_kusama); diff --git a/bridges/primitives/chain-bridge-hub-polkadot/Cargo.toml b/bridges/primitives/chain-bridge-hub-polkadot/Cargo.toml new file mode 100644 index 00000000000..2a0ab3213c8 --- /dev/null +++ b/bridges/primitives/chain-bridge-hub-polkadot/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "bp-bridge-hub-polkadot" +description = "Primitives of BridgeHubWococo parachain runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] + +# Bridge Dependencies + +bp-bridge-hub-cumulus = { path = "../chain-bridge-hub-cumulus", default-features = false } +bp-runtime = { path = "../../primitives/runtime", default-features = false } +bp-messages = { path = "../../primitives/messages", default-features = false } + +# Substrate Based Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-bridge-hub-cumulus/std", + "bp-runtime/std", + "bp-messages/std", + "frame-support/std", + "sp-api/std", + "sp-std/std", +] diff --git a/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs b/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs new file mode 100644 index 00000000000..8bd9167b618 --- /dev/null +++ b/bridges/primitives/chain-bridge-hub-polkadot/src/lib.rs @@ -0,0 +1,72 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Module with configuration which reflects BridgeHubPolkadot runtime setup +//! (AccountId, Headers, Hashes...) + +#![cfg_attr(not(feature = "std"), no_std)] + +pub use bp_bridge_hub_cumulus::*; +use bp_messages::*; +use bp_runtime::{ + decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain, +}; +use frame_support::{dispatch::DispatchClass, RuntimeDebug}; +use sp_std::prelude::*; + +/// BridgeHubPolkadot parachain. +#[derive(RuntimeDebug)] +pub struct BridgeHubPolkadot; + +impl Chain for BridgeHubPolkadot { + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; + + type AccountId = AccountId; + type Balance = Balance; + type Index = Index; + type Signature = Signature; + + fn max_extrinsic_size() -> u32 { + *BlockLength::get().max.get(DispatchClass::Normal) + } + + fn max_extrinsic_weight() -> Weight { + BlockWeights::get() + .get(DispatchClass::Normal) + .max_extrinsic + .unwrap_or(Weight::MAX) + } +} + +impl Parachain for BridgeHubPolkadot { + const PARACHAIN_ID: u32 = BRIDGE_HUB_POLKADOT_PARACHAIN_ID; +} + +/// Identifier of BridgeHubPolkadot in the Polkadot relay chain. +pub const BRIDGE_HUB_POLKADOT_PARACHAIN_ID: u32 = 1002; + +/// Name of the With-BridgeHubPolkadot messages pallet instance that is deployed at bridged chains. +pub const WITH_BRIDGE_HUB_POLKADOT_MESSAGES_PALLET_NAME: &str = "BridgePolkadotMessages"; + +/// Name of the With-BridgeHubPolkadot bridge-relayers pallet instance that is deployed at bridged +/// chains. +pub const WITH_BRIDGE_HUB_POLKADOT_RELAYERS_PALLET_NAME: &str = "BridgeRelayers"; + +decl_bridge_finality_runtime_apis!(bridge_hub_polkadot); +decl_bridge_messages_runtime_apis!(bridge_hub_polkadot); diff --git a/bridges/primitives/chain-bridge-hub-rococo/Cargo.toml b/bridges/primitives/chain-bridge-hub-rococo/Cargo.toml new file mode 100644 index 00000000000..85c4225ab55 --- /dev/null +++ b/bridges/primitives/chain-bridge-hub-rococo/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "bp-bridge-hub-rococo" +description = "Primitives of BridgeHubRococo parachain runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +# Bridge Dependencies + +bp-bridge-hub-cumulus = { path = "../chain-bridge-hub-cumulus", default-features = false } +bp-runtime = { path = "../../primitives/runtime", default-features = false } +bp-messages = { path = "../../primitives/messages", default-features = false } + +# Substrate Based Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-bridge-hub-cumulus/std", + "bp-messages/std", + "bp-runtime/std", + "frame-support/std", + "sp-api/std", + "sp-std/std", +] diff --git a/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs b/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs new file mode 100644 index 00000000000..936e4d1beb7 --- /dev/null +++ b/bridges/primitives/chain-bridge-hub-rococo/src/lib.rs @@ -0,0 +1,82 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Module with configuration which reflects BridgeHubRococo runtime setup (AccountId, Headers, +//! Hashes...) + +#![cfg_attr(not(feature = "std"), no_std)] + +pub use bp_bridge_hub_cumulus::*; +use bp_messages::*; +use bp_runtime::{ + decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain, +}; +use frame_support::{ + dispatch::DispatchClass, + sp_runtime::{MultiAddress, MultiSigner}, + RuntimeDebug, +}; +use sp_std::prelude::*; + +/// BridgeHubRococo parachain. +#[derive(RuntimeDebug)] +pub struct BridgeHubRococo; + +impl Chain for BridgeHubRococo { + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; + + type AccountId = AccountId; + type Balance = Balance; + type Index = Index; + type Signature = Signature; + + fn max_extrinsic_size() -> u32 { + *BlockLength::get().max.get(DispatchClass::Normal) + } + + fn max_extrinsic_weight() -> Weight { + BlockWeights::get() + .get(DispatchClass::Normal) + .max_extrinsic + .unwrap_or(Weight::MAX) + } +} + +impl Parachain for BridgeHubRococo { + const PARACHAIN_ID: u32 = BRIDGE_HUB_ROCOCO_PARACHAIN_ID; +} + +/// Public key of the chain account that may be used to verify signatures. +pub type AccountSigner = MultiSigner; + +/// The address format for describing accounts. +pub type Address = MultiAddress; + +/// Identifier of BridgeHubRococo in the Rococo relay chain. +pub const BRIDGE_HUB_ROCOCO_PARACHAIN_ID: u32 = 1013; + +/// Name of the With-BridgeHubRococo messages pallet instance that is deployed at bridged chains. +pub const WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME: &str = "BridgeRococoMessages"; + +/// Name of the With-BridgeHubRococo bridge-relayers pallet instance that is deployed at bridged +/// chains. +pub const WITH_BRIDGE_HUB_ROCOCO_RELAYERS_PALLET_NAME: &str = "BridgeRelayers"; + +decl_bridge_finality_runtime_apis!(bridge_hub_rococo); +decl_bridge_messages_runtime_apis!(bridge_hub_rococo); diff --git a/bridges/primitives/chain-bridge-hub-wococo/Cargo.toml b/bridges/primitives/chain-bridge-hub-wococo/Cargo.toml new file mode 100644 index 00000000000..24ecdb7adbc --- /dev/null +++ b/bridges/primitives/chain-bridge-hub-wococo/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "bp-bridge-hub-wococo" +description = "Primitives of BridgeHubWococo parachain runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] + +# Bridge Dependencies + +bp-bridge-hub-cumulus = { path = "../chain-bridge-hub-cumulus", default-features = false } +bp-runtime = { path = "../../primitives/runtime", default-features = false } +bp-messages = { path = "../../primitives/messages", default-features = false } + +# Substrate Based Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-bridge-hub-cumulus/std", + "bp-runtime/std", + "bp-messages/std", + "frame-support/std", + "sp-api/std", + "sp-std/std", +] diff --git a/bridges/primitives/chain-bridge-hub-wococo/src/lib.rs b/bridges/primitives/chain-bridge-hub-wococo/src/lib.rs new file mode 100644 index 00000000000..00704995c5e --- /dev/null +++ b/bridges/primitives/chain-bridge-hub-wococo/src/lib.rs @@ -0,0 +1,72 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Module with configuration which reflects BridgeHubWococo runtime setup +//! (AccountId, Headers, Hashes...) + +#![cfg_attr(not(feature = "std"), no_std)] + +pub use bp_bridge_hub_cumulus::*; +use bp_messages::*; +use bp_runtime::{ + decl_bridge_finality_runtime_apis, decl_bridge_messages_runtime_apis, Chain, Parachain, +}; +use frame_support::{dispatch::DispatchClass, RuntimeDebug}; +use sp_std::prelude::*; + +/// BridgeHubWococo parachain. +#[derive(RuntimeDebug)] +pub struct BridgeHubWococo; + +impl Chain for BridgeHubWococo { + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; + + type AccountId = AccountId; + type Balance = Balance; + type Index = Index; + type Signature = Signature; + + fn max_extrinsic_size() -> u32 { + *BlockLength::get().max.get(DispatchClass::Normal) + } + + fn max_extrinsic_weight() -> Weight { + BlockWeights::get() + .get(DispatchClass::Normal) + .max_extrinsic + .unwrap_or(Weight::MAX) + } +} + +impl Parachain for BridgeHubWococo { + const PARACHAIN_ID: u32 = BRIDGE_HUB_WOCOCO_PARACHAIN_ID; +} + +/// Identifier of BridgeHubWococo in the Wococo relay chain. +pub const BRIDGE_HUB_WOCOCO_PARACHAIN_ID: u32 = 1014; + +/// Name of the With-BridgeHubWococo messages pallet instance that is deployed at bridged chains. +pub const WITH_BRIDGE_HUB_WOCOCO_MESSAGES_PALLET_NAME: &str = "BridgeWococoMessages"; + +/// Name of the With-BridgeHubWococo bridge-relayers pallet instance that is deployed at bridged +/// chains. +pub const WITH_BRIDGE_HUB_WOCOCO_RELAYERS_PALLET_NAME: &str = "BridgeRelayers"; + +decl_bridge_finality_runtime_apis!(bridge_hub_wococo); +decl_bridge_messages_runtime_apis!(bridge_hub_wococo); diff --git a/bridges/primitives/chain-kusama/Cargo.toml b/bridges/primitives/chain-kusama/Cargo.toml new file mode 100644 index 00000000000..7f48ded1a37 --- /dev/null +++ b/bridges/primitives/chain-kusama/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "bp-kusama" +description = "Primitives of Kusama runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] + +# Bridge Dependencies + +bp-header-chain = { path = "../header-chain", default-features = false } +bp-polkadot-core = { path = "../polkadot-core", default-features = false } +bp-runtime = { path = "../runtime", default-features = false } + +# Substrate Based Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-header-chain/std", + "bp-polkadot-core/std", + "bp-runtime/std", + "frame-support/std", + "sp-api/std", +] diff --git a/bridges/primitives/chain-kusama/src/lib.rs b/bridges/primitives/chain-kusama/src/lib.rs new file mode 100644 index 00000000000..5cef6ae0ee6 --- /dev/null +++ b/bridges/primitives/chain-kusama/src/lib.rs @@ -0,0 +1,72 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] +// RuntimeApi generated functions +#![allow(clippy::too_many_arguments)] + +pub use bp_polkadot_core::*; + +use bp_header_chain::ChainWithGrandpa; +use bp_runtime::{decl_bridge_finality_runtime_apis, Chain}; +use frame_support::weights::Weight; + +/// Kusama Chain +pub struct Kusama; + +impl Chain for Kusama { + type BlockNumber = ::BlockNumber; + type Hash = ::Hash; + type Hasher = ::Hasher; + type Header = ::Header; + + type AccountId = ::AccountId; + type Balance = ::Balance; + type Index = ::Index; + type Signature = ::Signature; + + fn max_extrinsic_size() -> u32 { + PolkadotLike::max_extrinsic_size() + } + + fn max_extrinsic_weight() -> Weight { + PolkadotLike::max_extrinsic_weight() + } +} + +impl ChainWithGrandpa for Kusama { + const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = WITH_KUSAMA_GRANDPA_PALLET_NAME; + const MAX_AUTHORITIES_COUNT: u32 = MAX_AUTHORITIES_COUNT; + const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = + REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY; + const MAX_HEADER_SIZE: u32 = MAX_HEADER_SIZE; + const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = AVERAGE_HEADER_SIZE_IN_JUSTIFICATION; +} + +/// Name of the parachains pallet in the Kusama runtime. +pub const PARAS_PALLET_NAME: &str = "Paras"; + +/// Name of the With-Kusama GRANDPA pallet instance that is deployed at bridged chains. +pub const WITH_KUSAMA_GRANDPA_PALLET_NAME: &str = "BridgeKusamaGrandpa"; + +/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Polkadot +/// parachains. +/// +/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some +/// reserve. +pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128; + +decl_bridge_finality_runtime_apis!(kusama); diff --git a/bridges/primitives/chain-polkadot/Cargo.toml b/bridges/primitives/chain-polkadot/Cargo.toml new file mode 100644 index 00000000000..def26bdda1c --- /dev/null +++ b/bridges/primitives/chain-polkadot/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "bp-polkadot" +description = "Primitives of Polkadot runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] + +# Bridge Dependencies + +bp-header-chain = { path = "../header-chain", default-features = false } +bp-polkadot-core = { path = "../polkadot-core", default-features = false } +bp-runtime = { path = "../runtime", default-features = false } + +# Substrate Based Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-header-chain/std", + "bp-polkadot-core/std", + "bp-runtime/std", + "frame-support/std", + "sp-api/std", +] diff --git a/bridges/primitives/chain-polkadot/src/lib.rs b/bridges/primitives/chain-polkadot/src/lib.rs new file mode 100644 index 00000000000..51d9f6f0233 --- /dev/null +++ b/bridges/primitives/chain-polkadot/src/lib.rs @@ -0,0 +1,72 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] +// RuntimeApi generated functions +#![allow(clippy::too_many_arguments)] + +pub use bp_polkadot_core::*; + +use bp_header_chain::ChainWithGrandpa; +use bp_runtime::{decl_bridge_finality_runtime_apis, Chain}; +use frame_support::weights::Weight; + +/// Polkadot Chain +pub struct Polkadot; + +impl Chain for Polkadot { + type BlockNumber = ::BlockNumber; + type Hash = ::Hash; + type Hasher = ::Hasher; + type Header = ::Header; + + type AccountId = ::AccountId; + type Balance = ::Balance; + type Index = ::Index; + type Signature = ::Signature; + + fn max_extrinsic_size() -> u32 { + PolkadotLike::max_extrinsic_size() + } + + fn max_extrinsic_weight() -> Weight { + PolkadotLike::max_extrinsic_weight() + } +} + +impl ChainWithGrandpa for Polkadot { + const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = WITH_POLKADOT_GRANDPA_PALLET_NAME; + const MAX_AUTHORITIES_COUNT: u32 = MAX_AUTHORITIES_COUNT; + const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = + REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY; + const MAX_HEADER_SIZE: u32 = MAX_HEADER_SIZE; + const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = AVERAGE_HEADER_SIZE_IN_JUSTIFICATION; +} + +/// Name of the parachains pallet in the Polkadot runtime. +pub const PARAS_PALLET_NAME: &str = "Paras"; + +/// Name of the With-Polkadot GRANDPA pallet instance that is deployed at bridged chains. +pub const WITH_POLKADOT_GRANDPA_PALLET_NAME: &str = "BridgePolkadotGrandpa"; + +/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Polkadot +/// parachains. +/// +/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some +/// reserve. +pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128; + +decl_bridge_finality_runtime_apis!(polkadot); diff --git a/bridges/primitives/chain-rococo/Cargo.toml b/bridges/primitives/chain-rococo/Cargo.toml new file mode 100644 index 00000000000..4e21bd38b7a --- /dev/null +++ b/bridges/primitives/chain-rococo/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "bp-rococo" +description = "Primitives of Rococo runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] + +# Bridge Dependencies + +bp-header-chain = { path = "../header-chain", default-features = false } +bp-polkadot-core = { path = "../polkadot-core", default-features = false } +bp-runtime = { path = "../runtime", default-features = false } + +# Substrate Based Dependencies + +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-header-chain/std", + "bp-polkadot-core/std", + "bp-runtime/std", + "frame-support/std", + "sp-api/std", +] diff --git a/bridges/primitives/chain-rococo/src/lib.rs b/bridges/primitives/chain-rococo/src/lib.rs new file mode 100644 index 00000000000..0cb0b1d41e6 --- /dev/null +++ b/bridges/primitives/chain-rococo/src/lib.rs @@ -0,0 +1,76 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] +// RuntimeApi generated functions +#![allow(clippy::too_many_arguments)] + +pub use bp_polkadot_core::*; + +use bp_header_chain::ChainWithGrandpa; +use bp_runtime::{decl_bridge_finality_runtime_apis, Chain}; +use frame_support::{parameter_types, weights::Weight}; + +/// Rococo Chain +pub struct Rococo; + +impl Chain for Rococo { + type BlockNumber = ::BlockNumber; + type Hash = ::Hash; + type Hasher = ::Hasher; + type Header = ::Header; + + type AccountId = ::AccountId; + type Balance = ::Balance; + type Index = ::Index; + type Signature = ::Signature; + + fn max_extrinsic_size() -> u32 { + PolkadotLike::max_extrinsic_size() + } + + fn max_extrinsic_weight() -> Weight { + PolkadotLike::max_extrinsic_weight() + } +} + +impl ChainWithGrandpa for Rococo { + const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = WITH_ROCOCO_GRANDPA_PALLET_NAME; + const MAX_AUTHORITIES_COUNT: u32 = MAX_AUTHORITIES_COUNT; + const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = + REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY; + const MAX_HEADER_SIZE: u32 = MAX_HEADER_SIZE; + const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = AVERAGE_HEADER_SIZE_IN_JUSTIFICATION; +} + +parameter_types! { + pub const SS58Prefix: u8 = 42; +} + +/// Name of the parachains pallet in the Rococo runtime. +pub const PARAS_PALLET_NAME: &str = "Paras"; + +/// Name of the With-Rococo GRANDPA pallet instance that is deployed at bridged chains. +pub const WITH_ROCOCO_GRANDPA_PALLET_NAME: &str = "BridgeRococoGrandpa"; + +/// Maximal size of encoded `bp_parachains::ParaStoredHeaderData` structure among all Rococo +/// parachains. +/// +/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some +/// reserve. +pub const MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE: u32 = 128; + +decl_bridge_finality_runtime_apis!(rococo); diff --git a/bridges/primitives/chain-wococo/Cargo.toml b/bridges/primitives/chain-wococo/Cargo.toml new file mode 100644 index 00000000000..25fd7b9fd94 --- /dev/null +++ b/bridges/primitives/chain-wococo/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "bp-wococo" +description = "Primitives of Wococo runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] + +# Bridge Dependencies + +bp-header-chain = { path = "../header-chain", default-features = false } +bp-polkadot-core = { path = "../polkadot-core", default-features = false } +bp-runtime = { path = "../runtime", default-features = false } +bp-rococo = { path = "../chain-rococo", default-features = false } + +# Substrate Based Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-header-chain/std", + "bp-polkadot-core/std", + "bp-runtime/std", + "bp-rococo/std", + "frame-support/std", + "sp-api/std", +] diff --git a/bridges/primitives/chain-wococo/src/lib.rs b/bridges/primitives/chain-wococo/src/lib.rs new file mode 100644 index 00000000000..2df019496ab --- /dev/null +++ b/bridges/primitives/chain-wococo/src/lib.rs @@ -0,0 +1,65 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] +// RuntimeApi generated functions +#![allow(clippy::too_many_arguments)] + +pub use bp_polkadot_core::*; +pub use bp_rococo::{ + SS58Prefix, MAX_AUTHORITIES_COUNT, MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE, PARAS_PALLET_NAME, +}; + +use bp_header_chain::ChainWithGrandpa; +use bp_runtime::{decl_bridge_finality_runtime_apis, Chain}; +use frame_support::weights::Weight; + +/// Wococo Chain +pub struct Wococo; + +impl Chain for Wococo { + type BlockNumber = ::BlockNumber; + type Hash = ::Hash; + type Hasher = ::Hasher; + type Header = ::Header; + + type AccountId = ::AccountId; + type Balance = ::Balance; + type Index = ::Index; + type Signature = ::Signature; + + fn max_extrinsic_size() -> u32 { + PolkadotLike::max_extrinsic_size() + } + + fn max_extrinsic_weight() -> Weight { + PolkadotLike::max_extrinsic_weight() + } +} + +impl ChainWithGrandpa for Wococo { + const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = WITH_WOCOCO_GRANDPA_PALLET_NAME; + const MAX_AUTHORITIES_COUNT: u32 = MAX_AUTHORITIES_COUNT; + const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = + REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY; + const MAX_HEADER_SIZE: u32 = MAX_HEADER_SIZE; + const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = AVERAGE_HEADER_SIZE_IN_JUSTIFICATION; +} + +/// Name of the With-Wococo GRANDPA pallet instance that is deployed at bridged chains. +pub const WITH_WOCOCO_GRANDPA_PALLET_NAME: &str = "BridgeWococoGrandpa"; + +decl_bridge_finality_runtime_apis!(wococo); diff --git a/bridges/primitives/header-chain/Cargo.toml b/bridges/primitives/header-chain/Cargo.toml new file mode 100644 index 00000000000..32f81315537 --- /dev/null +++ b/bridges/primitives/header-chain/Cargo.toml @@ -0,0 +1,45 @@ +[package] +name = "bp-header-chain" +description = "A common interface for describing what a bridge pallet should be able to do." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } +finality-grandpa = { version = "0.16.2", default-features = false } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } +serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } + +# Bridge dependencies + +bp-runtime = { path = "../runtime", default-features = false } + +# Substrate Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] } +sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[dev-dependencies] +bp-test-utils = { path = "../test-utils" } +hex = "0.4" +hex-literal = "0.4" + +[features] +default = ["std"] +std = [ + "bp-runtime/std", + "codec/std", + "finality-grandpa/std", + "serde/std", + "frame-support/std", + "scale-info/std", + "sp-core/std", + "sp-consensus-grandpa/std", + "sp-runtime/std", + "sp-std/std", +] diff --git a/bridges/primitives/header-chain/src/justification.rs b/bridges/primitives/header-chain/src/justification.rs new file mode 100644 index 00000000000..8433107fce2 --- /dev/null +++ b/bridges/primitives/header-chain/src/justification.rs @@ -0,0 +1,409 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Pallet for checking GRANDPA Finality Proofs. +//! +//! Adapted copy of substrate/client/finality-grandpa/src/justification.rs. If origin +//! will ever be moved to the sp_consensus_grandpa, we should reuse that implementation. + +use crate::ChainWithGrandpa; + +use bp_runtime::{BlockNumberOf, Chain, HashOf}; +use codec::{Decode, Encode, MaxEncodedLen}; +use finality_grandpa::voter_set::VoterSet; +use frame_support::RuntimeDebug; +use scale_info::TypeInfo; +use sp_consensus_grandpa::{AuthorityId, AuthoritySignature, SetId}; +use sp_runtime::{traits::Header as HeaderT, SaturatedConversion}; +use sp_std::{ + collections::{btree_map::BTreeMap, btree_set::BTreeSet}, + prelude::*, +}; + +/// A GRANDPA Justification is a proof that a given header was finalized +/// at a certain height and with a certain set of authorities. +/// +/// This particular proof is used to prove that headers on a bridged chain +/// (so not our chain) have been finalized correctly. +#[derive(Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] +pub struct GrandpaJustification { + /// The round (voting period) this justification is valid for. + pub round: u64, + /// The set of votes for the chain which is to be finalized. + pub commit: + finality_grandpa::Commit, + /// A proof that the chain of blocks in the commit are related to each other. + pub votes_ancestries: Vec
, +} + +// TODO: remove and use `RuntimeDebug` (https://github.com/paritytech/parity-bridges-common/issues/2136) +impl sp_std::fmt::Debug for GrandpaJustification
{ + fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + #[cfg(feature = "std")] + { + fmt.debug_struct("GrandpaJustification") + .field("round", &self.round) + .field("commit", &self.commit) + .field("votes_ancestries", &self.votes_ancestries) + .finish() + } + + #[cfg(not(feature = "std"))] + { + fmt.write_str("") + } + } +} + +impl GrandpaJustification { + /// Returns reasonable size of justification using constants from the provided chain. + /// + /// An imprecise analogue of `MaxEncodedLen` implementation. We don't use it for + /// any precise calculations - that's just an estimation. + pub fn max_reasonable_size(required_precommits: u32) -> u32 + where + C: Chain
+ ChainWithGrandpa, + { + // we don't need precise results here - just estimations, so some details + // are removed from computations (e.g. bytes required to encode vector length) + + // structures in `finality_grandpa` crate are not implementing `MaxEncodedLength`, so + // here's our estimation for the `finality_grandpa::Commit` struct size + // + // precommit is: hash + number + // signed precommit is: precommit + signature (64b) + authority id + // commit is: hash + number + vec of signed precommits + let signed_precommit_size: u32 = BlockNumberOf::::max_encoded_len() + .saturating_add(HashOf::::max_encoded_len().saturated_into()) + .saturating_add(64) + .saturating_add(AuthorityId::max_encoded_len().saturated_into()) + .saturated_into(); + let max_expected_signed_commit_size = signed_precommit_size + .saturating_mul(required_precommits) + .saturating_add(BlockNumberOf::::max_encoded_len().saturated_into()) + .saturating_add(HashOf::::max_encoded_len().saturated_into()); + + // justification is a signed GRANDPA commit, `votes_ancestries` vector and round number + let max_expected_votes_ancestries_size = C::REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY + .saturating_mul(C::AVERAGE_HEADER_SIZE_IN_JUSTIFICATION); + + 8u32.saturating_add(max_expected_signed_commit_size) + .saturating_add(max_expected_votes_ancestries_size) + } +} + +impl crate::FinalityProof for GrandpaJustification { + fn target_header_number(&self) -> H::Number { + self.commit.target_number + } +} + +/// Justification verification error. +#[derive(Eq, RuntimeDebug, PartialEq)] +pub enum Error { + /// Failed to decode justification. + JustificationDecode, + /// Justification is finalizing unexpected header. + InvalidJustificationTarget, + /// Justification contains redundant votes. + RedundantVotesInJustification, + /// Justification contains unknown authority precommit. + UnknownAuthorityVote, + /// Justification contains duplicate authority precommit. + DuplicateAuthorityVote, + /// The authority has provided an invalid signature. + InvalidAuthoritySignature, + /// The justification contains precommit for header that is not a descendant of the commit + /// header. + PrecommitIsNotCommitDescendant, + /// The cumulative weight of all votes in the justification is not enough to justify commit + /// header finalization. + TooLowCumulativeWeight, + /// The justification contains extra (unused) headers in its `votes_ancestries` field. + ExtraHeadersInVotesAncestries, +} + +/// Given GRANDPA authorities set size, return number of valid authorities votes that the +/// justification must have to be valid. +/// +/// This function assumes that all authorities have the same vote weight. +pub fn required_justification_precommits(authorities_set_length: u32) -> u32 { + authorities_set_length - authorities_set_length.saturating_sub(1) / 3 +} + +/// Decode justification target. +pub fn decode_justification_target( + raw_justification: &[u8], +) -> Result<(Header::Hash, Header::Number), Error> { + GrandpaJustification::
::decode(&mut &*raw_justification) + .map(|justification| (justification.commit.target_hash, justification.commit.target_number)) + .map_err(|_| Error::JustificationDecode) +} + +/// Verify and optimize given justification by removing unknown and duplicate votes. +pub fn verify_and_optimize_justification( + finalized_target: (Header::Hash, Header::Number), + authorities_set_id: SetId, + authorities_set: &VoterSet, + justification: GrandpaJustification
, +) -> Result, Error> +where + Header::Number: finality_grandpa::BlockNumberOps, +{ + let mut optimizer = OptimizationCallbacks(Vec::new()); + verify_justification_with_callbacks( + finalized_target, + authorities_set_id, + authorities_set, + &justification, + &mut optimizer, + )?; + Ok(optimizer.optimize(justification)) +} + +/// Verify that justification, that is generated by given authority set, finalizes given header. +pub fn verify_justification( + finalized_target: (Header::Hash, Header::Number), + authorities_set_id: SetId, + authorities_set: &VoterSet, + justification: &GrandpaJustification
, +) -> Result<(), Error> +where + Header::Number: finality_grandpa::BlockNumberOps, +{ + verify_justification_with_callbacks( + finalized_target, + authorities_set_id, + authorities_set, + justification, + &mut StrictVerificationCallbacks, + ) +} + +/// Verification callbacks. +trait VerificationCallbacks { + /// Called when we see a precommit from unknown authority. + fn on_unkown_authority(&mut self, precommit_idx: usize) -> Result<(), Error>; + /// Called when we see a precommit with duplicate vote from known authority. + fn on_duplicate_authority_vote(&mut self, precommit_idx: usize) -> Result<(), Error>; + /// Called when we see a precommit after we've collected enough votes from authorities. + fn on_redundant_authority_vote(&mut self, precommit_idx: usize) -> Result<(), Error>; +} + +/// Verification callbacks that reject all unknown, duplicate or redundant votes. +struct StrictVerificationCallbacks; + +impl VerificationCallbacks for StrictVerificationCallbacks { + fn on_unkown_authority(&mut self, _precommit_idx: usize) -> Result<(), Error> { + Err(Error::UnknownAuthorityVote) + } + + fn on_duplicate_authority_vote(&mut self, _precommit_idx: usize) -> Result<(), Error> { + Err(Error::DuplicateAuthorityVote) + } + + fn on_redundant_authority_vote(&mut self, _precommit_idx: usize) -> Result<(), Error> { + Err(Error::RedundantVotesInJustification) + } +} + +/// Verification callbacks for justification optimization. +struct OptimizationCallbacks(Vec); + +impl OptimizationCallbacks { + fn optimize( + self, + mut justification: GrandpaJustification
, + ) -> GrandpaJustification
{ + for invalid_precommit_idx in self.0.into_iter().rev() { + justification.commit.precommits.remove(invalid_precommit_idx); + } + justification + } +} + +impl VerificationCallbacks for OptimizationCallbacks { + fn on_unkown_authority(&mut self, precommit_idx: usize) -> Result<(), Error> { + self.0.push(precommit_idx); + Ok(()) + } + + fn on_duplicate_authority_vote(&mut self, precommit_idx: usize) -> Result<(), Error> { + self.0.push(precommit_idx); + Ok(()) + } + + fn on_redundant_authority_vote(&mut self, precommit_idx: usize) -> Result<(), Error> { + self.0.push(precommit_idx); + Ok(()) + } +} + +/// Verify that justification, that is generated by given authority set, finalizes given header. +fn verify_justification_with_callbacks( + finalized_target: (Header::Hash, Header::Number), + authorities_set_id: SetId, + authorities_set: &VoterSet, + justification: &GrandpaJustification
, + callbacks: &mut C, +) -> Result<(), Error> +where + Header::Number: finality_grandpa::BlockNumberOps, +{ + // ensure that it is justification for the expected header + if (justification.commit.target_hash, justification.commit.target_number) != finalized_target { + return Err(Error::InvalidJustificationTarget) + } + + let threshold = authorities_set.threshold().0.into(); + let mut chain = AncestryChain::new(&justification.votes_ancestries); + let mut signature_buffer = Vec::new(); + let mut votes = BTreeSet::new(); + let mut cumulative_weight = 0u64; + + for (precommit_idx, signed) in justification.commit.precommits.iter().enumerate() { + // if we have collected enough precommits, we probabably want to fail/remove extra + // precommits + if cumulative_weight >= threshold { + callbacks.on_redundant_authority_vote(precommit_idx)?; + continue + } + + // authority must be in the set + let authority_info = match authorities_set.get(&signed.id) { + Some(authority_info) => authority_info, + None => { + callbacks.on_unkown_authority(precommit_idx)?; + continue + }, + }; + + // check if authority has already voted in the same round. + // + // there's a lot of code in `validate_commit` and `import_precommit` functions inside + // `finality-grandpa` crate (mostly related to reporting equivocations). But the only thing + // that we care about is that only first vote from the authority is accepted + if !votes.insert(signed.id.clone()) { + callbacks.on_duplicate_authority_vote(precommit_idx)?; + continue + } + + // everything below this line can't just `continue`, because state is already altered + + // precommits aren't allowed for block lower than the target + if signed.precommit.target_number < justification.commit.target_number { + return Err(Error::PrecommitIsNotCommitDescendant) + } + // all precommits must be descendants of target block + chain = chain + .ensure_descendant(&justification.commit.target_hash, &signed.precommit.target_hash)?; + // since we know now that the precommit target is the descendant of the justification + // target, we may increase 'weight' of the justification target + // + // there's a lot of code in the `VoteGraph::insert` method inside `finality-grandpa` crate, + // but in the end it is only used to find GHOST, which we don't care about. The only thing + // that we care about is that the justification target has enough weight + cumulative_weight = cumulative_weight.checked_add(authority_info.weight().0.into()).expect( + "sum of weights of ALL authorities is expected not to overflow - this is guaranteed by\ + existence of VoterSet;\ + the order of loop conditions guarantees that we can account vote from same authority\ + multiple times;\ + thus we'll never overflow the u64::MAX;\ + qed", + ); + + // verify authority signature + if !sp_consensus_grandpa::check_message_signature_with_buffer( + &finality_grandpa::Message::Precommit(signed.precommit.clone()), + &signed.id, + &signed.signature, + justification.round, + authorities_set_id, + &mut signature_buffer, + ) { + return Err(Error::InvalidAuthoritySignature) + } + } + + // check that there are no extra headers in the justification + if !chain.unvisited.is_empty() { + return Err(Error::ExtraHeadersInVotesAncestries) + } + + // check that the cumulative weight of validators voted for the justification target (or one + // of its descendents) is larger than required threshold. + if cumulative_weight >= threshold { + Ok(()) + } else { + Err(Error::TooLowCumulativeWeight) + } +} + +/// Votes ancestries with useful methods. +#[derive(RuntimeDebug)] +pub struct AncestryChain { + /// Header hash => parent header hash mapping. + pub parents: BTreeMap, + /// Hashes of headers that were not visited by `is_ancestor` method. + pub unvisited: BTreeSet, +} + +impl AncestryChain
{ + /// Create new ancestry chain. + pub fn new(ancestry: &[Header]) -> AncestryChain
{ + let mut parents = BTreeMap::new(); + let mut unvisited = BTreeSet::new(); + for ancestor in ancestry { + let hash = ancestor.hash(); + let parent_hash = *ancestor.parent_hash(); + parents.insert(hash, parent_hash); + unvisited.insert(hash); + } + AncestryChain { parents, unvisited } + } + + /// Returns `Ok(_)` if `precommit_target` is a descendant of the `commit_target` block and + /// `Err(_)` otherwise. + pub fn ensure_descendant( + mut self, + commit_target: &Header::Hash, + precommit_target: &Header::Hash, + ) -> Result { + let mut current_hash = *precommit_target; + loop { + if current_hash == *commit_target { + break + } + + let is_visited_before = !self.unvisited.remove(¤t_hash); + current_hash = match self.parents.get(¤t_hash) { + Some(parent_hash) => { + if is_visited_before { + // `Some(parent_hash)` means that the `current_hash` is in the `parents` + // container `is_visited_before` means that it has been visited before in + // some of previous calls => since we assume that previous call has finished + // with `true`, this also will be finished with `true` + return Ok(self) + } + + *parent_hash + }, + None => return Err(Error::PrecommitIsNotCommitDescendant), + }; + } + Ok(self) + } +} diff --git a/bridges/primitives/header-chain/src/lib.rs b/bridges/primitives/header-chain/src/lib.rs new file mode 100644 index 00000000000..cf08a936234 --- /dev/null +++ b/bridges/primitives/header-chain/src/lib.rs @@ -0,0 +1,223 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Defines traits which represent a common interface for Substrate pallets which want to +//! incorporate bridge functionality. + +#![cfg_attr(not(feature = "std"), no_std)] + +use bp_runtime::{ + BasicOperatingMode, Chain, HashOf, HasherOf, HeaderOf, RawStorageProof, StorageProofChecker, + StorageProofError, +}; +use codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen}; +use core::{clone::Clone, cmp::Eq, default::Default, fmt::Debug}; +use frame_support::PalletError; +use scale_info::TypeInfo; +use serde::{Deserialize, Serialize}; +use sp_consensus_grandpa::{AuthorityList, ConsensusLog, SetId, GRANDPA_ENGINE_ID}; +use sp_runtime::{traits::Header as HeaderT, Digest, RuntimeDebug}; +use sp_std::boxed::Box; + +pub mod justification; +pub mod storage_keys; + +/// Header chain error. +#[derive(Clone, Decode, Encode, Eq, PartialEq, PalletError, Debug, TypeInfo)] +pub enum HeaderChainError { + /// Header with given hash is missing from the chain. + UnknownHeader, + /// Storage proof related error. + StorageProof(StorageProofError), +} + +/// Header data that we're storing on-chain. +/// +/// Even though we may store full header, our applications (XCM) only use couple of header +/// fields. Extracting those values makes on-chain storage and PoV smaller, which is good. +#[derive(Clone, Decode, Encode, Eq, MaxEncodedLen, PartialEq, RuntimeDebug, TypeInfo)] +pub struct StoredHeaderData { + /// Header number. + pub number: Number, + /// Header state root. + pub state_root: Hash, +} + +/// Stored header data builder. +pub trait StoredHeaderDataBuilder { + /// Build header data from self. + fn build(&self) -> StoredHeaderData; +} + +impl StoredHeaderDataBuilder for H { + fn build(&self) -> StoredHeaderData { + StoredHeaderData { number: *self.number(), state_root: *self.state_root() } + } +} + +/// Substrate header chain, abstracted from the way it is stored. +pub trait HeaderChain { + /// Returns state (storage) root of given finalized header. + fn finalized_header_state_root(header_hash: HashOf) -> Option>; + /// Get storage proof checker using finalized header. + fn storage_proof_checker( + header_hash: HashOf, + storage_proof: RawStorageProof, + ) -> Result>, HeaderChainError> { + let state_root = Self::finalized_header_state_root(header_hash) + .ok_or(HeaderChainError::UnknownHeader)?; + StorageProofChecker::new(state_root, storage_proof).map_err(HeaderChainError::StorageProof) + } +} + +/// A type that can be used as a parameter in a dispatchable function. +/// +/// When using `decl_module` all arguments for call functions must implement this trait. +pub trait Parameter: Codec + EncodeLike + Clone + Eq + Debug + TypeInfo {} +impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + Debug + TypeInfo {} + +/// A GRANDPA Authority List and ID. +#[derive(Default, Encode, Eq, Decode, RuntimeDebug, PartialEq, Clone, TypeInfo)] +#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] +pub struct AuthoritySet { + /// List of GRANDPA authorities for the current round. + pub authorities: AuthorityList, + /// Monotonic identifier of the current GRANDPA authority set. + pub set_id: SetId, +} + +impl AuthoritySet { + /// Create a new GRANDPA Authority Set. + pub fn new(authorities: AuthorityList, set_id: SetId) -> Self { + Self { authorities, set_id } + } +} + +/// Data required for initializing the GRANDPA bridge pallet. +/// +/// The bridge needs to know where to start its sync from, and this provides that initial context. +#[derive( + Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, Clone, TypeInfo, Serialize, Deserialize, +)] +pub struct InitializationData { + /// The header from which we should start syncing. + pub header: Box, + /// The initial authorities of the pallet. + pub authority_list: AuthorityList, + /// The ID of the initial authority set. + pub set_id: SetId, + /// Pallet operating mode. + pub operating_mode: BasicOperatingMode, +} + +/// Abstract finality proof that is justifying block finality. +pub trait FinalityProof: Clone + Send + Sync + Debug { + /// Return number of header that this proof is generated for. + fn target_header_number(&self) -> Number; +} + +/// A trait that provides helper methods for querying the consensus log. +pub trait ConsensusLogReader { + /// Returns true if digest contains item that schedules authorities set change. + fn schedules_authorities_change(digest: &Digest) -> bool; +} + +/// A struct that provides helper methods for querying the GRANDPA consensus log. +pub struct GrandpaConsensusLogReader(sp_std::marker::PhantomData); + +impl GrandpaConsensusLogReader { + pub fn find_authorities_change( + digest: &Digest, + ) -> Option> { + // find the first consensus digest with the right ID which converts to + // the right kind of consensus log. + digest + .convert_first(|log| log.consensus_try_to(&GRANDPA_ENGINE_ID)) + .and_then(|log| match log { + ConsensusLog::ScheduledChange(change) => Some(change), + _ => None, + }) + } +} + +impl ConsensusLogReader for GrandpaConsensusLogReader { + fn schedules_authorities_change(digest: &Digest) -> bool { + GrandpaConsensusLogReader::::find_authorities_change(digest).is_some() + } +} + +/// A minimized version of `pallet-bridge-grandpa::Call` that can be used without a runtime. +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[allow(non_camel_case_types)] +pub enum BridgeGrandpaCall { + /// `pallet-bridge-grandpa::Call::submit_finality_proof` + #[codec(index = 0)] + submit_finality_proof { + finality_target: Box
, + justification: justification::GrandpaJustification
, + }, + /// `pallet-bridge-grandpa::Call::initialize` + #[codec(index = 1)] + initialize { init_data: InitializationData
}, +} + +/// The `BridgeGrandpaCall` used by a chain. +pub type BridgeGrandpaCallOf = BridgeGrandpaCall>; + +/// Substrate-based chain that is using direct GRANDPA finality. +/// +/// Keep in mind that parachains are relying on relay chain GRANDPA, so they should not implement +/// this trait. +pub trait ChainWithGrandpa: Chain { + /// Name of the bridge GRANDPA pallet (used in `construct_runtime` macro call) that is deployed + /// at some other chain to bridge with this `ChainWithGrandpa`. + /// + /// We assume that all chains that are bridging with this `ChainWithGrandpa` are using + /// the same name. + const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str; + + /// Max number of GRANDPA authorities at the chain. + /// + /// This is a strict constant. If bridged chain will have more authorities than that, + /// the GRANDPA bridge pallet may halt. + const MAX_AUTHORITIES_COUNT: u32; + + /// Max reasonable number of headers in `votes_ancestries` vector of the GRANDPA justification. + /// + /// This isn't a strict limit. The relay may submit justifications with more headers in its + /// ancestry and the pallet will accept such justification. The limit is only used to compute + /// maximal refund amount and submitting justifications which exceed the limit, may be costly + /// to submitter. + const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32; + + /// Maximal size of the chain header. The header may be the header that enacts new GRANDPA + /// authorities set (so it has large digest inside). + /// + /// This isn't a strict limit. The relay may submit larger headers and the pallet will accept + /// the call. The limit is only used to compute maximal refund amount and doing calls which + /// exceed the limit, may be costly to submitter. + const MAX_HEADER_SIZE: u32; + + /// Average size of the chain header from justification ancestry. We don't expect to see there + /// headers that change GRANDPA authorities set (GRANDPA will probably be able to finalize at + /// least one additional header per session on non test chains), so this is average size of + /// headers that aren't changing the set. + /// + /// This isn't a strict limit. The relay may submit justifications with larger headers in its + /// ancestry and the pallet will accept the call. The limit is only used to compute maximal + /// refund amount and doing calls which exceed the limit, may be costly to submitter. + const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32; +} diff --git a/bridges/primitives/header-chain/src/storage_keys.rs b/bridges/primitives/header-chain/src/storage_keys.rs new file mode 100644 index 00000000000..c4dbe53bd9a --- /dev/null +++ b/bridges/primitives/header-chain/src/storage_keys.rs @@ -0,0 +1,104 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Storage keys of bridge GRANDPA pallet. + +/// Name of the `IsHalted` storage value. +pub const PALLET_OPERATING_MODE_VALUE_NAME: &str = "PalletOperatingMode"; +/// Name of the `BestFinalized` storage value. +pub const BEST_FINALIZED_VALUE_NAME: &str = "BestFinalized"; +/// Name of the `CurrentAuthoritySet` storage value. +pub const CURRENT_AUTHORITY_SET_VALUE_NAME: &str = "CurrentAuthoritySet"; + +use sp_core::storage::StorageKey; + +/// Storage key of the `PalletOperatingMode` variable in the runtime storage. +pub fn pallet_operating_mode_key(pallet_prefix: &str) -> StorageKey { + StorageKey( + bp_runtime::storage_value_final_key( + pallet_prefix.as_bytes(), + PALLET_OPERATING_MODE_VALUE_NAME.as_bytes(), + ) + .to_vec(), + ) +} + +/// Storage key of the `CurrentAuthoritySet` variable in the runtime storage. +pub fn current_authority_set_key(pallet_prefix: &str) -> StorageKey { + StorageKey( + bp_runtime::storage_value_final_key( + pallet_prefix.as_bytes(), + CURRENT_AUTHORITY_SET_VALUE_NAME.as_bytes(), + ) + .to_vec(), + ) +} + +/// Storage key of the best finalized header number and hash value in the runtime storage. +pub fn best_finalized_key(pallet_prefix: &str) -> StorageKey { + StorageKey( + bp_runtime::storage_value_final_key( + pallet_prefix.as_bytes(), + BEST_FINALIZED_VALUE_NAME.as_bytes(), + ) + .to_vec(), + ) +} + +#[cfg(test)] +mod tests { + use super::*; + use hex_literal::hex; + + #[test] + fn pallet_operating_mode_key_computed_properly() { + // If this test fails, then something has been changed in module storage that is breaking + // compatibility with previous pallet. + let storage_key = pallet_operating_mode_key("BridgeGrandpa").0; + assert_eq!( + storage_key, + hex!("0b06f475eddb98cf933a12262e0388de0f4cf0917788d791142ff6c1f216e7b3").to_vec(), + "Unexpected storage key: {}", + hex::encode(&storage_key), + ); + } + + #[test] + fn current_authority_set_key_computed_properly() { + // If this test fails, then something has been changed in module storage that is breaking + // compatibility with previous pallet. + let storage_key = current_authority_set_key("BridgeGrandpa").0; + assert_eq!( + storage_key, + hex!("0b06f475eddb98cf933a12262e0388de24a7b8b5717ea33346fa595a66ccbcb0").to_vec(), + "Unexpected storage key: {}", + hex::encode(&storage_key), + ); + } + + #[test] + fn best_finalized_key_computed_properly() { + // If this test fails, then something has been changed in module storage that is breaking + // compatibility with previous pallet. + let storage_key = best_finalized_key("BridgeGrandpa").0; + assert_eq!( + storage_key, + hex!("0b06f475eddb98cf933a12262e0388dea4ebafdd473c549fdb24c5c991c5591c").to_vec(), + "Unexpected storage key: {}", + hex::encode(&storage_key), + ); + } +} diff --git a/bridges/primitives/header-chain/tests/implementation_match.rs b/bridges/primitives/header-chain/tests/implementation_match.rs new file mode 100644 index 00000000000..c70683b173d --- /dev/null +++ b/bridges/primitives/header-chain/tests/implementation_match.rs @@ -0,0 +1,418 @@ +// Copyright 2020-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Tests inside this module are made to ensure that our custom justification verification +//! implementation works similar to the [`finality_grandpa::validate_commit`] and explicitly +//! show where we behave different. +//! +//! Some of tests in this module may partially duplicate tests from `justification.rs`, +//! but their purpose is different. + +use bp_header_chain::justification::{verify_justification, Error, GrandpaJustification}; +use bp_test_utils::{ + header_id, make_justification_for_header, signed_precommit, test_header, Account, + JustificationGeneratorParams, ALICE, BOB, CHARLIE, DAVE, EVE, FERDIE, TEST_GRANDPA_SET_ID, +}; +use finality_grandpa::voter_set::VoterSet; +use sp_consensus_grandpa::{AuthorityId, AuthorityWeight}; +use sp_runtime::traits::Header as HeaderT; + +type TestHeader = sp_runtime::testing::Header; +type TestHash = ::Hash; +type TestNumber = ::Number; + +/// Implementation of `finality_grandpa::Chain` that is used in tests. +struct AncestryChain(bp_header_chain::justification::AncestryChain); + +impl AncestryChain { + fn new(ancestry: &[TestHeader]) -> Self { + Self(bp_header_chain::justification::AncestryChain::new(ancestry)) + } +} + +impl finality_grandpa::Chain for AncestryChain { + fn ancestry( + &self, + base: TestHash, + block: TestHash, + ) -> Result, finality_grandpa::Error> { + let mut route = Vec::new(); + let mut current_hash = block; + loop { + if current_hash == base { + break + } + match self.0.parents.get(¤t_hash).cloned() { + Some(parent_hash) => { + current_hash = parent_hash; + route.push(current_hash); + }, + _ => return Err(finality_grandpa::Error::NotDescendent), + } + } + route.pop(); // remove the base + + Ok(route) + } +} + +/// Get a full set of accounts. +fn full_accounts_set() -> Vec<(Account, AuthorityWeight)> { + vec![(ALICE, 1), (BOB, 1), (CHARLIE, 1), (DAVE, 1), (EVE, 1)] +} + +/// Get a full set of GRANDPA authorities. +fn full_voter_set() -> VoterSet { + VoterSet::new(full_accounts_set().iter().map(|(id, w)| (AuthorityId::from(*id), *w))).unwrap() +} + +/// Get a minimal set of accounts. +fn minimal_accounts_set() -> Vec<(Account, AuthorityWeight)> { + // there are 5 accounts in the full set => we need 2/3 + 1 accounts, which results in 4 accounts + vec![(ALICE, 1), (BOB, 1), (CHARLIE, 1), (DAVE, 1)] +} + +/// Get a minimal subset of GRANDPA authorities that have enough cumulative vote weight to justify a +/// header finality. +pub fn minimal_voter_set() -> VoterSet { + VoterSet::new(minimal_accounts_set().iter().map(|(id, w)| (AuthorityId::from(*id), *w))) + .unwrap() +} + +/// Make a valid GRANDPA justification with sensible defaults. +pub fn make_default_justification(header: &TestHeader) -> GrandpaJustification { + make_justification_for_header(JustificationGeneratorParams { + header: header.clone(), + authorities: minimal_accounts_set(), + ..Default::default() + }) +} + +// the `finality_grandpa::validate_commit` function has two ways to report an unsuccessful +// commit validation: +// +// 1) to return `Err()` (which only may happen if `finality_grandpa::Chain` implementation +// returns an error); +// 2) to return `Ok(validation_result)` if `validation_result.is_valid()` is false. +// +// Our implementation would just return error in both cases. + +#[test] +fn same_result_when_precommit_target_has_lower_number_than_commit_target() { + let mut justification = make_default_justification(&test_header(1)); + // the number of header in precommit (0) is lower than number of header in commit (1) + justification.commit.precommits[0].precommit.target_number = 0; + + // our implementation returns an error + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &full_voter_set(), + &justification, + ), + Err(Error::PrecommitIsNotCommitDescendant), + ); + + // original implementation returns `Ok(validation_result)` + // with `validation_result.is_valid() == false`. + let result = finality_grandpa::validate_commit( + &justification.commit, + &full_voter_set(), + &AncestryChain::new(&justification.votes_ancestries), + ) + .unwrap(); + + assert!(!result.is_valid()); +} + +#[test] +fn same_result_when_precommit_target_is_not_descendant_of_commit_target() { + let not_descendant = test_header::(10); + let mut justification = make_default_justification(&test_header(1)); + // the route from header of commit (1) to header of precommit (10) is missing from + // the votes ancestries + justification.commit.precommits[0].precommit.target_number = *not_descendant.number(); + justification.commit.precommits[0].precommit.target_hash = not_descendant.hash(); + justification.votes_ancestries.push(not_descendant); + + // our implementation returns an error + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &full_voter_set(), + &justification, + ), + Err(Error::PrecommitIsNotCommitDescendant), + ); + + // original implementation returns `Ok(validation_result)` + // with `validation_result.is_valid() == false`. + let result = finality_grandpa::validate_commit( + &justification.commit, + &full_voter_set(), + &AncestryChain::new(&justification.votes_ancestries), + ) + .unwrap(); + + assert!(!result.is_valid()); +} + +#[test] +fn same_result_when_there_are_not_enough_cumulative_weight_to_finalize_commit_target() { + // just remove one authority from the minimal set and we shall not reach the threshold + let mut authorities_set = minimal_accounts_set(); + authorities_set.pop(); + let justification = make_justification_for_header(JustificationGeneratorParams { + header: test_header(1), + authorities: authorities_set, + ..Default::default() + }); + + // our implementation returns an error + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &full_voter_set(), + &justification, + ), + Err(Error::TooLowCumulativeWeight), + ); + // original implementation returns `Ok(validation_result)` + // with `validation_result.is_valid() == false`. + let result = finality_grandpa::validate_commit( + &justification.commit, + &full_voter_set(), + &AncestryChain::new(&justification.votes_ancestries), + ) + .unwrap(); + + assert!(!result.is_valid()); +} + +// tests below are our differences with the original implementation + +#[test] +fn different_result_when_justification_contains_duplicate_vote() { + let mut justification = make_justification_for_header(JustificationGeneratorParams { + header: test_header(1), + authorities: minimal_accounts_set(), + ancestors: 0, + ..Default::default() + }); + // the justification may contain exactly the same vote (i.e. same precommit and same signature) + // multiple times && it isn't treated as an error by original implementation + let last_precommit = justification.commit.precommits.pop().unwrap(); + justification.commit.precommits.push(justification.commit.precommits[0].clone()); + justification.commit.precommits.push(last_precommit); + + // our implementation fails + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &full_voter_set(), + &justification, + ), + Err(Error::DuplicateAuthorityVote), + ); + // original implementation returns `Ok(validation_result)` + // with `validation_result.is_valid() == true`. + let result = finality_grandpa::validate_commit( + &justification.commit, + &full_voter_set(), + &AncestryChain::new(&justification.votes_ancestries), + ) + .unwrap(); + + assert!(result.is_valid()); +} + +#[test] +fn different_results_when_authority_equivocates_once_in_a_round() { + let mut justification = make_justification_for_header(JustificationGeneratorParams { + header: test_header(1), + authorities: minimal_accounts_set(), + ancestors: 0, + ..Default::default() + }); + // the justification original implementation allows authority to submit two different + // votes in a single round, of which only first is 'accepted' + let last_precommit = justification.commit.precommits.pop().unwrap(); + justification.commit.precommits.push(signed_precommit::( + &ALICE, + header_id::(1), + justification.round, + TEST_GRANDPA_SET_ID, + )); + justification.commit.precommits.push(last_precommit); + + // our implementation fails + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &full_voter_set(), + &justification, + ), + Err(Error::DuplicateAuthorityVote), + ); + // original implementation returns `Ok(validation_result)` + // with `validation_result.is_valid() == true`. + let result = finality_grandpa::validate_commit( + &justification.commit, + &full_voter_set(), + &AncestryChain::new(&justification.votes_ancestries), + ) + .unwrap(); + + assert!(result.is_valid()); +} + +#[test] +fn different_results_when_authority_equivocates_twice_in_a_round() { + let mut justification = make_justification_for_header(JustificationGeneratorParams { + header: test_header(1), + authorities: minimal_accounts_set(), + ancestors: 0, + ..Default::default() + }); + // there's some code in the original implementation that should return an error when + // same authority submits more than two different votes in a single round: + // https://github.com/paritytech/finality-grandpa/blob/6aeea2d1159d0f418f0b86e70739f2130629ca09/src/lib.rs#L473 + // but there's also a code that prevents this from happening: + // https://github.com/paritytech/finality-grandpa/blob/6aeea2d1159d0f418f0b86e70739f2130629ca09/src/round.rs#L287 + // => so now we are also just ignoring all votes from the same authority, except the first one + let last_precommit = justification.commit.precommits.pop().unwrap(); + let prev_last_precommit = justification.commit.precommits.pop().unwrap(); + justification.commit.precommits.push(signed_precommit::( + &ALICE, + header_id::(1), + justification.round, + TEST_GRANDPA_SET_ID, + )); + justification.commit.precommits.push(signed_precommit::( + &ALICE, + header_id::(1), + justification.round, + TEST_GRANDPA_SET_ID, + )); + justification.commit.precommits.push(last_precommit); + justification.commit.precommits.push(prev_last_precommit); + + // our implementation fails + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &full_voter_set(), + &justification, + ), + Err(Error::DuplicateAuthorityVote), + ); + // original implementation returns `Ok(validation_result)` + // with `validation_result.is_valid() == true`. + let result = finality_grandpa::validate_commit( + &justification.commit, + &full_voter_set(), + &AncestryChain::new(&justification.votes_ancestries), + ) + .unwrap(); + + assert!(result.is_valid()); +} + +#[test] +fn different_results_when_there_are_more_than_enough_votes() { + let mut justification = make_justification_for_header(JustificationGeneratorParams { + header: test_header(1), + authorities: minimal_accounts_set(), + ancestors: 0, + ..Default::default() + }); + // the reference implementation just keep verifying signatures even if we have + // collected enough votes. We are not + justification.commit.precommits.push(signed_precommit::( + &EVE, + header_id::(1), + justification.round, + TEST_GRANDPA_SET_ID, + )); + + // our implementation fails + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &full_voter_set(), + &justification, + ), + Err(Error::RedundantVotesInJustification), + ); + // original implementation returns `Ok(validation_result)` + // with `validation_result.is_valid() == true`. + let result = finality_grandpa::validate_commit( + &justification.commit, + &full_voter_set(), + &AncestryChain::new(&justification.votes_ancestries), + ) + .unwrap(); + + assert!(result.is_valid()); +} + +#[test] +fn different_results_when_there_is_a_vote_of_unknown_authority() { + let mut justification = make_justification_for_header(JustificationGeneratorParams { + header: test_header(1), + authorities: minimal_accounts_set(), + ancestors: 0, + ..Default::default() + }); + // the reference implementation just keep verifying signatures even if we have + // collected enough votes. We are not + let last_precommit = justification.commit.precommits.pop().unwrap(); + justification.commit.precommits.push(signed_precommit::( + &FERDIE, + header_id::(1), + justification.round, + TEST_GRANDPA_SET_ID, + )); + justification.commit.precommits.push(last_precommit); + + // our implementation fails + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &full_voter_set(), + &justification, + ), + Err(Error::UnknownAuthorityVote), + ); + // original implementation returns `Ok(validation_result)` + // with `validation_result.is_valid() == true`. + let result = finality_grandpa::validate_commit( + &justification.commit, + &full_voter_set(), + &AncestryChain::new(&justification.votes_ancestries), + ) + .unwrap(); + + assert!(result.is_valid()); +} diff --git a/bridges/primitives/header-chain/tests/justification.rs b/bridges/primitives/header-chain/tests/justification.rs new file mode 100644 index 00000000000..3cd63b935d0 --- /dev/null +++ b/bridges/primitives/header-chain/tests/justification.rs @@ -0,0 +1,280 @@ +// Copyright 2020-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Tests for Grandpa Justification code. + +use bp_header_chain::justification::{ + required_justification_precommits, verify_and_optimize_justification, verify_justification, + Error, +}; +use bp_test_utils::*; + +type TestHeader = sp_runtime::testing::Header; + +#[test] +fn valid_justification_accepted() { + let authorities = vec![(ALICE, 1), (BOB, 1), (CHARLIE, 1)]; + let params = JustificationGeneratorParams { + header: test_header(1), + round: TEST_GRANDPA_ROUND, + set_id: TEST_GRANDPA_SET_ID, + authorities: authorities.clone(), + ancestors: 7, + forks: 3, + }; + + let justification = make_justification_for_header::(params.clone()); + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &voter_set(), + &justification, + ), + Ok(()), + ); + + assert_eq!(justification.commit.precommits.len(), authorities.len()); + assert_eq!(justification.votes_ancestries.len(), params.ancestors as usize); +} + +#[test] +fn valid_justification_accepted_with_single_fork() { + let params = JustificationGeneratorParams { + header: test_header(1), + round: TEST_GRANDPA_ROUND, + set_id: TEST_GRANDPA_SET_ID, + authorities: vec![(ALICE, 1), (BOB, 1), (CHARLIE, 1)], + ancestors: 5, + forks: 1, + }; + + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &voter_set(), + &make_justification_for_header::(params) + ), + Ok(()), + ); +} + +#[test] +fn valid_justification_accepted_with_arbitrary_number_of_authorities() { + use finality_grandpa::voter_set::VoterSet; + use sp_consensus_grandpa::AuthorityId; + + let n = 15; + let required_signatures = required_justification_precommits(n as _); + let authorities = accounts(n).iter().map(|k| (*k, 1)).collect::>(); + + let params = JustificationGeneratorParams { + header: test_header(1), + round: TEST_GRANDPA_ROUND, + set_id: TEST_GRANDPA_SET_ID, + authorities: authorities.clone().into_iter().take(required_signatures as _).collect(), + ancestors: n.into(), + forks: required_signatures, + }; + + let authorities = authorities + .iter() + .map(|(id, w)| (AuthorityId::from(*id), *w)) + .collect::>(); + let voter_set = VoterSet::new(authorities).unwrap(); + + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &voter_set, + &make_justification_for_header::(params) + ), + Ok(()), + ); +} + +#[test] +fn justification_with_invalid_target_rejected() { + assert_eq!( + verify_justification::( + header_id::(2), + TEST_GRANDPA_SET_ID, + &voter_set(), + &make_default_justification::(&test_header(1)), + ), + Err(Error::InvalidJustificationTarget), + ); +} + +#[test] +fn justification_with_invalid_commit_rejected() { + let mut justification = make_default_justification::(&test_header(1)); + justification.commit.precommits.clear(); + + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &voter_set(), + &justification, + ), + Err(Error::ExtraHeadersInVotesAncestries), + ); +} + +#[test] +fn justification_with_invalid_authority_signature_rejected() { + let mut justification = make_default_justification::(&test_header(1)); + justification.commit.precommits[0].signature = + sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]); + + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &voter_set(), + &justification, + ), + Err(Error::InvalidAuthoritySignature), + ); +} + +#[test] +fn justification_with_invalid_precommit_ancestry() { + let mut justification = make_default_justification::(&test_header(1)); + justification.votes_ancestries.push(test_header(10)); + + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &voter_set(), + &justification, + ), + Err(Error::ExtraHeadersInVotesAncestries), + ); +} + +#[test] +fn justification_is_invalid_if_we_dont_meet_threshold() { + // Need at least three authorities to sign off or else the voter set threshold can't be reached + let authorities = vec![(ALICE, 1), (BOB, 1)]; + + let params = JustificationGeneratorParams { + header: test_header(1), + round: TEST_GRANDPA_ROUND, + set_id: TEST_GRANDPA_SET_ID, + authorities: authorities.clone(), + ancestors: 2 * authorities.len() as u32, + forks: 2, + }; + + assert_eq!( + verify_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &voter_set(), + &make_justification_for_header::(params) + ), + Err(Error::TooLowCumulativeWeight), + ); +} + +#[test] +fn optimizer_does_noting_with_minimal_justification() { + let justification = make_default_justification::(&test_header(1)); + + let num_precommits_before = justification.commit.precommits.len(); + let justification = verify_and_optimize_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &voter_set(), + justification, + ) + .unwrap(); + let num_precommits_after = justification.commit.precommits.len(); + + assert_eq!(num_precommits_before, num_precommits_after); +} + +#[test] +fn unknown_authority_votes_are_removed_by_optimizer() { + let mut justification = make_default_justification::(&test_header(1)); + justification.commit.precommits.push(signed_precommit::( + &bp_test_utils::Account(42), + header_id::(1), + justification.round, + TEST_GRANDPA_SET_ID, + )); + + let num_precommits_before = justification.commit.precommits.len(); + let justification = verify_and_optimize_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &voter_set(), + justification, + ) + .unwrap(); + let num_precommits_after = justification.commit.precommits.len(); + + assert_eq!(num_precommits_before - 1, num_precommits_after); +} + +#[test] +fn duplicate_authority_votes_are_removed_by_optimizer() { + let mut justification = make_default_justification::(&test_header(1)); + justification + .commit + .precommits + .push(justification.commit.precommits.first().cloned().unwrap()); + + let num_precommits_before = justification.commit.precommits.len(); + let justification = verify_and_optimize_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &voter_set(), + justification, + ) + .unwrap(); + let num_precommits_after = justification.commit.precommits.len(); + + assert_eq!(num_precommits_before - 1, num_precommits_after); +} + +#[test] +fn redundant_authority_votes_are_removed_by_optimizer() { + let mut justification = make_default_justification::(&test_header(1)); + justification.commit.precommits.push(signed_precommit::( + &EVE, + header_id::(1), + justification.round, + TEST_GRANDPA_SET_ID, + )); + + let num_precommits_before = justification.commit.precommits.len(); + let justification = verify_and_optimize_justification::( + header_id::(1), + TEST_GRANDPA_SET_ID, + &voter_set(), + justification, + ) + .unwrap(); + let num_precommits_after = justification.commit.precommits.len(); + + assert_eq!(num_precommits_before - 1, num_precommits_after); +} diff --git a/bridges/primitives/messages/Cargo.toml b/bridges/primitives/messages/Cargo.toml new file mode 100644 index 00000000000..cc439a55ae2 --- /dev/null +++ b/bridges/primitives/messages/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "bp-messages" +description = "Primitives of messages module." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "bit-vec"] } +scale-info = { version = "2.6.0", default-features = false, features = ["bit-vec", "derive"] } +serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } + +# Bridge dependencies + +bp-runtime = { path = "../runtime", default-features = false } +bp-header-chain = { path = "../header-chain", default-features = false } + +# Substrate Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[dev-dependencies] +hex = "0.4" +hex-literal = "0.4" + +[features] +default = ["std"] +std = [ + "bp-runtime/std", + "bp-header-chain/std", + "codec/std", + "frame-support/std", + "scale-info/std", + "serde/std", + "sp-core/std", + "sp-std/std" +] diff --git a/bridges/primitives/messages/src/lib.rs b/bridges/primitives/messages/src/lib.rs new file mode 100644 index 00000000000..3df039d7eb8 --- /dev/null +++ b/bridges/primitives/messages/src/lib.rs @@ -0,0 +1,521 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Primitives of messages module. + +#![cfg_attr(not(feature = "std"), no_std)] +// RuntimeApi generated functions +#![allow(clippy::too_many_arguments)] + +use bp_header_chain::HeaderChainError; +use bp_runtime::{ + messages::MessageDispatchResult, BasicOperatingMode, OperatingMode, RangeInclusiveExt, + StorageProofError, +}; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{PalletError, RuntimeDebug}; +// Weight is reexported to avoid additional frame-support dependencies in related crates. +pub use frame_support::weights::Weight; +use scale_info::TypeInfo; +use source_chain::RelayersRewards; +use sp_core::TypeId; +use sp_std::{collections::vec_deque::VecDeque, ops::RangeInclusive, prelude::*}; + +pub mod source_chain; +pub mod storage_keys; +pub mod target_chain; + +/// Messages pallet operating mode. +#[derive( + Encode, + Decode, + Clone, + Copy, + PartialEq, + Eq, + RuntimeDebug, + TypeInfo, + MaxEncodedLen, + serde::Serialize, + serde::Deserialize, +)] +pub enum MessagesOperatingMode { + /// Basic operating mode (Normal/Halted) + Basic(BasicOperatingMode), + /// The pallet is not accepting outbound messages. Inbound messages and receiving proofs + /// are still accepted. + /// + /// This mode may be used e.g. when bridged chain expects upgrade. Then to avoid dispatch + /// failures, the pallet owner may stop accepting new messages, while continuing to deliver + /// queued messages to the bridged chain. Once upgrade is completed, the mode may be switched + /// back to `Normal`. + RejectingOutboundMessages, +} + +impl Default for MessagesOperatingMode { + fn default() -> Self { + MessagesOperatingMode::Basic(BasicOperatingMode::Normal) + } +} + +impl OperatingMode for MessagesOperatingMode { + fn is_halted(&self) -> bool { + match self { + Self::Basic(operating_mode) => operating_mode.is_halted(), + _ => false, + } + } +} + +/// Lane id which implements `TypeId`. +#[derive( + Clone, Copy, Decode, Default, Encode, Eq, Ord, PartialOrd, PartialEq, TypeInfo, MaxEncodedLen, +)] +pub struct LaneId(pub [u8; 4]); + +impl core::fmt::Debug for LaneId { + fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { + self.0.fmt(fmt) + } +} + +impl AsRef<[u8]> for LaneId { + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + +impl TypeId for LaneId { + const TYPE_ID: [u8; 4] = *b"blan"; +} + +/// Message nonce. Valid messages will never have 0 nonce. +pub type MessageNonce = u64; + +/// Message id as a tuple. +pub type BridgeMessageId = (LaneId, MessageNonce); + +/// Opaque message payload. We only decode this payload when it is dispatched. +pub type MessagePayload = Vec; + +/// Message key (unique message identifier) as it is stored in the storage. +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)] +pub struct MessageKey { + /// ID of the message lane. + pub lane_id: LaneId, + /// Message nonce. + pub nonce: MessageNonce, +} + +/// Message as it is stored in the storage. +#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] +pub struct Message { + /// Message key. + pub key: MessageKey, + /// Message payload. + pub payload: MessagePayload, +} + +/// Inbound lane data. +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)] +pub struct InboundLaneData { + /// Identifiers of relayers and messages that they have delivered to this lane (ordered by + /// message nonce). + /// + /// This serves as a helper storage item, to allow the source chain to easily pay rewards + /// to the relayers who successfully delivered messages to the target chain (inbound lane). + /// + /// It is guaranteed to have at most N entries, where N is configured at the module level. + /// If there are N entries in this vec, then: + /// 1) all incoming messages are rejected if they're missing corresponding + /// `proof-of(outbound-lane.state)`; 2) all incoming messages are rejected if + /// `proof-of(outbound-lane.state).last_delivered_nonce` is equal to + /// `self.last_confirmed_nonce`. Given what is said above, all nonces in this queue are in + /// range: `(self.last_confirmed_nonce; self.last_delivered_nonce()]`. + /// + /// When a relayer sends a single message, both of MessageNonces are the same. + /// When relayer sends messages in a batch, the first arg is the lowest nonce, second arg the + /// highest nonce. Multiple dispatches from the same relayer are allowed. + pub relayers: VecDeque>, + + /// Nonce of the last message that + /// a) has been delivered to the target (this) chain and + /// b) the delivery has been confirmed on the source chain + /// + /// that the target chain knows of. + /// + /// This value is updated indirectly when an `OutboundLane` state of the source + /// chain is received alongside with new messages delivery. + pub last_confirmed_nonce: MessageNonce, +} + +impl Default for InboundLaneData { + fn default() -> Self { + InboundLaneData { relayers: VecDeque::new(), last_confirmed_nonce: 0 } + } +} + +impl InboundLaneData { + /// Returns approximate size of the struct, given a number of entries in the `relayers` set and + /// size of each entry. + /// + /// Returns `None` if size overflows `usize` limits. + pub fn encoded_size_hint(relayers_entries: usize) -> Option + where + RelayerId: MaxEncodedLen, + { + relayers_entries + .checked_mul(UnrewardedRelayer::::max_encoded_len())? + .checked_add(MessageNonce::max_encoded_len()) + } + + /// Returns the approximate size of the struct as u32, given a number of entries in the + /// `relayers` set and the size of each entry. + /// + /// Returns `u32::MAX` if size overflows `u32` limits. + pub fn encoded_size_hint_u32(relayers_entries: usize) -> u32 + where + RelayerId: MaxEncodedLen, + { + Self::encoded_size_hint(relayers_entries) + .and_then(|x| u32::try_from(x).ok()) + .unwrap_or(u32::MAX) + } + + /// Nonce of the last message that has been delivered to this (target) chain. + pub fn last_delivered_nonce(&self) -> MessageNonce { + self.relayers + .back() + .map(|entry| entry.messages.end) + .unwrap_or(self.last_confirmed_nonce) + } + + /// Returns the total number of messages in the `relayers` vector, + /// saturating in case of underflow or overflow. + pub fn total_unrewarded_messages(&self) -> MessageNonce { + let relayers = &self.relayers; + match (relayers.front(), relayers.back()) { + (Some(front), Some(back)) => + (front.messages.begin..=back.messages.end).saturating_len(), + _ => 0, + } + } +} + +/// Outbound message details, returned by runtime APIs. +#[derive(Clone, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)] +pub struct OutboundMessageDetails { + /// Nonce assigned to the message. + pub nonce: MessageNonce, + /// Message dispatch weight. + /// + /// Depending on messages pallet configuration, it may be declared by the message submitter, + /// computed automatically or just be zero if dispatch fee is paid at the target chain. + pub dispatch_weight: Weight, + /// Size of the encoded message. + pub size: u32, +} + +/// Inbound message details, returned by runtime APIs. +#[derive(Clone, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)] +pub struct InboundMessageDetails { + /// Computed message dispatch weight. + /// + /// Runtime API guarantees that it will match the value, returned by + /// `target_chain::MessageDispatch::dispatch_weight`. This means that if the runtime + /// has failed to decode the message, it will be zero - that's because `undecodable` + /// message cannot be dispatched. + pub dispatch_weight: Weight, +} + +/// Unrewarded relayer entry stored in the inbound lane data. +/// +/// This struct represents a continuous range of messages that have been delivered by the same +/// relayer and whose confirmations are still pending. +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] +pub struct UnrewardedRelayer { + /// Identifier of the relayer. + pub relayer: RelayerId, + /// Messages range, delivered by this relayer. + pub messages: DeliveredMessages, +} + +/// Received messages with their dispatch result. +#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)] +pub struct ReceivedMessages { + /// Id of the lane which is receiving messages. + pub lane: LaneId, + /// Result of messages which we tried to dispatch + pub receive_results: Vec<(MessageNonce, ReceivalResult)>, +} + +impl ReceivedMessages { + pub fn new( + lane: LaneId, + receive_results: Vec<(MessageNonce, ReceivalResult)>, + ) -> Self { + ReceivedMessages { lane, receive_results } + } + + pub fn push(&mut self, message: MessageNonce, result: ReceivalResult) { + self.receive_results.push((message, result)); + } +} + +/// Result of single message receival. +#[derive(RuntimeDebug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)] +pub enum ReceivalResult { + /// Message has been received and dispatched. Note that we don't care whether dispatch has + /// been successful or not - in both case message falls into this category. + /// + /// The message dispatch result is also returned. + Dispatched(MessageDispatchResult), + /// Message has invalid nonce and lane has rejected to accept this message. + InvalidNonce, + /// There are too many unrewarded relayer entries at the lane. + TooManyUnrewardedRelayers, + /// There are too many unconfirmed messages at the lane. + TooManyUnconfirmedMessages, +} + +/// Delivered messages with their dispatch result. +#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] +pub struct DeliveredMessages { + /// Nonce of the first message that has been delivered (inclusive). + pub begin: MessageNonce, + /// Nonce of the last message that has been delivered (inclusive). + pub end: MessageNonce, +} + +impl DeliveredMessages { + /// Create new `DeliveredMessages` struct that confirms delivery of single nonce with given + /// dispatch result. + pub fn new(nonce: MessageNonce) -> Self { + DeliveredMessages { begin: nonce, end: nonce } + } + + /// Return total count of delivered messages. + pub fn total_messages(&self) -> MessageNonce { + (self.begin..=self.end).saturating_len() + } + + /// Note new dispatched message. + pub fn note_dispatched_message(&mut self) { + self.end += 1; + } + + /// Returns true if delivered messages contain message with given nonce. + pub fn contains_message(&self, nonce: MessageNonce) -> bool { + (self.begin..=self.end).contains(&nonce) + } +} + +/// Gist of `InboundLaneData::relayers` field used by runtime APIs. +#[derive(Clone, Default, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)] +pub struct UnrewardedRelayersState { + /// Number of entries in the `InboundLaneData::relayers` set. + pub unrewarded_relayer_entries: MessageNonce, + /// Number of messages in the oldest entry of `InboundLaneData::relayers`. This is the + /// minimal number of reward proofs required to push out this entry from the set. + pub messages_in_oldest_entry: MessageNonce, + /// Total number of messages in the relayers vector. + pub total_messages: MessageNonce, + /// Nonce of the latest message that has been delivered to the target chain. + /// + /// This corresponds to the result of the `InboundLaneData::last_delivered_nonce` call + /// at the bridged chain. + pub last_delivered_nonce: MessageNonce, +} + +impl UnrewardedRelayersState { + // Verify that the relayers state corresponds with the `InboundLaneData`. + pub fn is_valid(&self, lane_data: &InboundLaneData) -> bool { + self == &lane_data.into() + } +} + +impl From<&InboundLaneData> for UnrewardedRelayersState { + fn from(lane: &InboundLaneData) -> UnrewardedRelayersState { + UnrewardedRelayersState { + unrewarded_relayer_entries: lane.relayers.len() as _, + messages_in_oldest_entry: lane + .relayers + .front() + .map(|entry| entry.messages.total_messages()) + .unwrap_or(0), + total_messages: lane.total_unrewarded_messages(), + last_delivered_nonce: lane.last_delivered_nonce(), + } + } +} + +/// Outbound lane data. +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] +pub struct OutboundLaneData { + /// Nonce of the oldest message that we haven't yet pruned. May point to not-yet-generated + /// message if all sent messages are already pruned. + pub oldest_unpruned_nonce: MessageNonce, + /// Nonce of the latest message, received by bridged chain. + pub latest_received_nonce: MessageNonce, + /// Nonce of the latest message, generated by us. + pub latest_generated_nonce: MessageNonce, +} + +impl Default for OutboundLaneData { + fn default() -> Self { + OutboundLaneData { + // it is 1 because we're pruning everything in [oldest_unpruned_nonce; + // latest_received_nonce] + oldest_unpruned_nonce: 1, + latest_received_nonce: 0, + latest_generated_nonce: 0, + } + } +} + +/// Calculate the number of messages that the relayers have delivered. +pub fn calc_relayers_rewards( + messages_relayers: VecDeque>, + received_range: &RangeInclusive, +) -> RelayersRewards +where + AccountId: sp_std::cmp::Ord, +{ + // remember to reward relayers that have delivered messages + // this loop is bounded by `T::MaxUnrewardedRelayerEntriesAtInboundLane` on the bridged chain + let mut relayers_rewards = RelayersRewards::new(); + for entry in messages_relayers { + let nonce_begin = sp_std::cmp::max(entry.messages.begin, *received_range.start()); + let nonce_end = sp_std::cmp::min(entry.messages.end, *received_range.end()); + if nonce_end >= nonce_begin { + *relayers_rewards.entry(entry.relayer).or_default() += nonce_end - nonce_begin + 1; + } + } + relayers_rewards +} + +/// A minimized version of `pallet-bridge-messages::Call` that can be used without a runtime. +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[allow(non_camel_case_types)] +pub enum BridgeMessagesCall { + /// `pallet-bridge-messages::Call::receive_messages_proof` + #[codec(index = 2)] + receive_messages_proof { + relayer_id_at_bridged_chain: AccountId, + proof: MessagesProof, + messages_count: u32, + dispatch_weight: Weight, + }, + /// `pallet-bridge-messages::Call::receive_messages_delivery_proof` + #[codec(index = 3)] + receive_messages_delivery_proof { + proof: MessagesDeliveryProof, + relayers_state: UnrewardedRelayersState, + }, +} + +/// Error that happens during message verification. +#[derive(Encode, Decode, RuntimeDebug, PartialEq, Eq, PalletError, TypeInfo)] +pub enum VerificationError { + /// The message proof is empty. + EmptyMessageProof, + /// Error returned by the bridged header chain. + HeaderChain(HeaderChainError), + /// Error returned while reading/decoding inbound lane data from the storage proof. + InboundLaneStorage(StorageProofError), + /// The declared message weight is incorrect. + InvalidMessageWeight, + /// Declared messages count doesn't match actual value. + MessagesCountMismatch, + /// Error returned while reading/decoding message data from the storage proof. + MessageStorage(StorageProofError), + /// The message is too large. + MessageTooLarge, + /// Error returned while reading/decoding outbound lane data from the storage proof. + OutboundLaneStorage(StorageProofError), + /// Storage proof related error. + StorageProof(StorageProofError), + /// Custom error + Other(#[codec(skip)] &'static str), +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn total_unrewarded_messages_does_not_overflow() { + let lane_data = InboundLaneData { + relayers: vec![ + UnrewardedRelayer { relayer: 1, messages: DeliveredMessages::new(0) }, + UnrewardedRelayer { + relayer: 2, + messages: DeliveredMessages::new(MessageNonce::MAX), + }, + ] + .into_iter() + .collect(), + last_confirmed_nonce: 0, + }; + assert_eq!(lane_data.total_unrewarded_messages(), MessageNonce::MAX); + } + + #[test] + fn inbound_lane_data_returns_correct_hint() { + let test_cases = vec![ + // single relayer, multiple messages + (1, 128u8), + // multiple relayers, single message per relayer + (128u8, 128u8), + // several messages per relayer + (13u8, 128u8), + ]; + for (relayer_entries, messages_count) in test_cases { + let expected_size = InboundLaneData::::encoded_size_hint(relayer_entries as _); + let actual_size = InboundLaneData { + relayers: (1u8..=relayer_entries) + .map(|i| UnrewardedRelayer { + relayer: i, + messages: DeliveredMessages::new(i as _), + }) + .collect(), + last_confirmed_nonce: messages_count as _, + } + .encode() + .len(); + let difference = (expected_size.unwrap() as f64 - actual_size as f64).abs(); + assert!( + difference / (std::cmp::min(actual_size, expected_size.unwrap()) as f64) < 0.1, + "Too large difference between actual ({actual_size}) and expected ({expected_size:?}) inbound lane data size. Test case: {relayer_entries}+{messages_count}", + ); + } + } + + #[test] + fn contains_result_works() { + let delivered_messages = DeliveredMessages { begin: 100, end: 150 }; + + assert!(!delivered_messages.contains_message(99)); + assert!(delivered_messages.contains_message(100)); + assert!(delivered_messages.contains_message(150)); + assert!(!delivered_messages.contains_message(151)); + } + + #[test] + fn lane_id_debug_format_matches_inner_array_format() { + assert_eq!(format!("{:?}", LaneId([0, 0, 0, 0])), format!("{:?}", [0, 0, 0, 0]),); + } +} diff --git a/bridges/primitives/messages/src/source_chain.rs b/bridges/primitives/messages/src/source_chain.rs new file mode 100644 index 00000000000..f3c50b84a09 --- /dev/null +++ b/bridges/primitives/messages/src/source_chain.rs @@ -0,0 +1,201 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Primitives of messages module, that are used on the source chain. + +use crate::{InboundLaneData, LaneId, MessageNonce, OutboundLaneData, VerificationError}; + +use crate::UnrewardedRelayer; +use bp_runtime::Size; +use frame_support::{Parameter, RuntimeDebug}; +use sp_std::{ + collections::{btree_map::BTreeMap, vec_deque::VecDeque}, + fmt::Debug, + ops::RangeInclusive, +}; + +/// Number of messages, delivered by relayers. +pub type RelayersRewards = BTreeMap; + +/// Target chain API. Used by source chain to verify target chain proofs. +/// +/// All implementations of this trait should only work with finalized data that +/// can't change. Wrong implementation may lead to invalid lane states (i.e. lane +/// that's stuck) and/or processing messages without paying fees. +/// +/// The `Payload` type here means the payload of the message that is sent from the +/// source chain to the target chain. The `AccountId` type here means the account +/// type used by the source chain. +pub trait TargetHeaderChain { + /// Proof that messages have been received by target chain. + type MessagesDeliveryProof: Parameter + Size; + + /// Verify message payload before we accept it. + /// + /// **CAUTION**: this is very important function. Incorrect implementation may lead + /// to stuck lanes and/or relayers loses. + /// + /// The proper implementation must ensure that the delivery-transaction with this + /// payload would (at least) be accepted into target chain transaction pool AND + /// eventually will be successfully mined. The most obvious incorrect implementation + /// example would be implementation for BTC chain that accepts payloads larger than + /// 1MB. BTC nodes aren't accepting transactions that are larger than 1MB, so relayer + /// will be unable to craft valid transaction => this (and all subsequent) messages will + /// never be delivered. + fn verify_message(payload: &Payload) -> Result<(), VerificationError>; + + /// Verify messages delivery proof and return lane && nonce of the latest received message. + fn verify_messages_delivery_proof( + proof: Self::MessagesDeliveryProof, + ) -> Result<(LaneId, InboundLaneData), VerificationError>; +} + +/// Lane message verifier. +/// +/// Runtime developer may implement any additional validation logic over message-lane mechanism. +/// E.g. if lanes should have some security (e.g. you can only accept Lane1 messages from +/// Submitter1, Lane2 messages for those who has submitted first message to this lane, disable +/// Lane3 until some block, ...), then it may be built using this verifier. +/// +/// Any fee requirements should also be enforced here. +pub trait LaneMessageVerifier { + /// Verify message payload and return Ok(()) if message is valid and allowed to be sent over the + /// lane. + fn verify_message( + submitter: &SenderOrigin, + lane: &LaneId, + outbound_data: &OutboundLaneData, + payload: &Payload, + ) -> Result<(), VerificationError>; +} + +/// Manages payments that are happening at the source chain during delivery confirmation +/// transaction. +pub trait DeliveryConfirmationPayments { + /// Error type. + type Error: Debug + Into<&'static str>; + + /// Pay rewards for delivering messages to the given relayers. + /// + /// The implementation may also choose to pay reward to the `confirmation_relayer`, which is + /// a relayer that has submitted delivery confirmation transaction. + /// + /// Returns number of actually rewarded relayers. + fn pay_reward( + lane_id: LaneId, + messages_relayers: VecDeque>, + confirmation_relayer: &AccountId, + received_range: &RangeInclusive, + ) -> MessageNonce; +} + +impl DeliveryConfirmationPayments for () { + type Error = &'static str; + + fn pay_reward( + _lane_id: LaneId, + _messages_relayers: VecDeque>, + _confirmation_relayer: &AccountId, + _received_range: &RangeInclusive, + ) -> MessageNonce { + // this implementation is not rewarding relayers at all + 0 + } +} + +/// Send message artifacts. +#[derive(Eq, RuntimeDebug, PartialEq)] +pub struct SendMessageArtifacts { + /// Nonce of the message. + pub nonce: MessageNonce, +} + +/// Messages bridge API to be used from other pallets. +pub trait MessagesBridge { + /// Error type. + type Error: Debug; + + /// Send message over the bridge. + /// + /// Returns unique message nonce or error if send has failed. + fn send_message( + sender: SenderOrigin, + lane: LaneId, + message: Payload, + ) -> Result; +} + +/// Bridge that does nothing when message is being sent. +#[derive(Eq, RuntimeDebug, PartialEq)] +pub struct NoopMessagesBridge; + +impl MessagesBridge for NoopMessagesBridge { + type Error = &'static str; + + fn send_message( + _sender: SenderOrigin, + _lane: LaneId, + _message: Payload, + ) -> Result { + Ok(SendMessageArtifacts { nonce: 0 }) + } +} + +/// Structure that may be used in place of `TargetHeaderChain`, `LaneMessageVerifier` and +/// `MessageDeliveryAndDispatchPayment` on chains, where outbound messages are forbidden. +pub struct ForbidOutboundMessages; + +/// Error message that is used in `ForbidOutboundMessages` implementation. +const ALL_OUTBOUND_MESSAGES_REJECTED: &str = + "This chain is configured to reject all outbound messages"; + +impl TargetHeaderChain for ForbidOutboundMessages { + type MessagesDeliveryProof = (); + + fn verify_message(_payload: &Payload) -> Result<(), VerificationError> { + Err(VerificationError::Other(ALL_OUTBOUND_MESSAGES_REJECTED)) + } + + fn verify_messages_delivery_proof( + _proof: Self::MessagesDeliveryProof, + ) -> Result<(LaneId, InboundLaneData), VerificationError> { + Err(VerificationError::Other(ALL_OUTBOUND_MESSAGES_REJECTED)) + } +} + +impl LaneMessageVerifier for ForbidOutboundMessages { + fn verify_message( + _submitter: &SenderOrigin, + _lane: &LaneId, + _outbound_data: &OutboundLaneData, + _payload: &Payload, + ) -> Result<(), VerificationError> { + Err(VerificationError::Other(ALL_OUTBOUND_MESSAGES_REJECTED)) + } +} + +impl DeliveryConfirmationPayments for ForbidOutboundMessages { + type Error = &'static str; + + fn pay_reward( + _lane_id: LaneId, + _messages_relayers: VecDeque>, + _confirmation_relayer: &AccountId, + _received_range: &RangeInclusive, + ) -> MessageNonce { + 0 + } +} diff --git a/bridges/primitives/messages/src/storage_keys.rs b/bridges/primitives/messages/src/storage_keys.rs new file mode 100644 index 00000000000..4edf9828cfd --- /dev/null +++ b/bridges/primitives/messages/src/storage_keys.rs @@ -0,0 +1,128 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Storage keys of bridge messages pallet. + +/// Name of the `OPERATING_MODE_VALUE_NAME` storage value. +pub const OPERATING_MODE_VALUE_NAME: &str = "PalletOperatingMode"; +/// Name of the `OutboundMessages` storage map. +pub const OUTBOUND_MESSAGES_MAP_NAME: &str = "OutboundMessages"; +/// Name of the `OutboundLanes` storage map. +pub const OUTBOUND_LANES_MAP_NAME: &str = "OutboundLanes"; +/// Name of the `InboundLanes` storage map. +pub const INBOUND_LANES_MAP_NAME: &str = "InboundLanes"; + +use crate::{LaneId, MessageKey, MessageNonce}; + +use codec::Encode; +use frame_support::Blake2_128Concat; +use sp_core::storage::StorageKey; + +/// Storage key of the `PalletOperatingMode` value in the runtime storage. +pub fn operating_mode_key(pallet_prefix: &str) -> StorageKey { + StorageKey( + bp_runtime::storage_value_final_key( + pallet_prefix.as_bytes(), + OPERATING_MODE_VALUE_NAME.as_bytes(), + ) + .to_vec(), + ) +} + +/// Storage key of the outbound message in the runtime storage. +pub fn message_key(pallet_prefix: &str, lane: &LaneId, nonce: MessageNonce) -> StorageKey { + bp_runtime::storage_map_final_key::( + pallet_prefix, + OUTBOUND_MESSAGES_MAP_NAME, + &MessageKey { lane_id: *lane, nonce }.encode(), + ) +} + +/// Storage key of the outbound message lane state in the runtime storage. +pub fn outbound_lane_data_key(pallet_prefix: &str, lane: &LaneId) -> StorageKey { + bp_runtime::storage_map_final_key::( + pallet_prefix, + OUTBOUND_LANES_MAP_NAME, + &lane.encode(), + ) +} + +/// Storage key of the inbound message lane state in the runtime storage. +pub fn inbound_lane_data_key(pallet_prefix: &str, lane: &LaneId) -> StorageKey { + bp_runtime::storage_map_final_key::( + pallet_prefix, + INBOUND_LANES_MAP_NAME, + &lane.encode(), + ) +} + +#[cfg(test)] +mod tests { + use super::*; + use hex_literal::hex; + + #[test] + fn operating_mode_key_computed_properly() { + // If this test fails, then something has been changed in module storage that is possibly + // breaking all existing message relays. + let storage_key = operating_mode_key("BridgeMessages").0; + assert_eq!( + storage_key, + hex!("dd16c784ebd3390a9bc0357c7511ed010f4cf0917788d791142ff6c1f216e7b3").to_vec(), + "Unexpected storage key: {}", + hex::encode(&storage_key), + ); + } + + #[test] + fn storage_message_key_computed_properly() { + // If this test fails, then something has been changed in module storage that is breaking + // all previously crafted messages proofs. + let storage_key = message_key("BridgeMessages", &LaneId(*b"test"), 42).0; + assert_eq!( + storage_key, + hex!("dd16c784ebd3390a9bc0357c7511ed018a395e6242c6813b196ca31ed0547ea79446af0e09063bd4a7874aef8a997cec746573742a00000000000000").to_vec(), + "Unexpected storage key: {}", + hex::encode(&storage_key), + ); + } + + #[test] + fn outbound_lane_data_key_computed_properly() { + // If this test fails, then something has been changed in module storage that is breaking + // all previously crafted outbound lane state proofs. + let storage_key = outbound_lane_data_key("BridgeMessages", &LaneId(*b"test")).0; + assert_eq!( + storage_key, + hex!("dd16c784ebd3390a9bc0357c7511ed0196c246acb9b55077390e3ca723a0ca1f44a8995dd50b6657a037a7839304535b74657374").to_vec(), + "Unexpected storage key: {}", + hex::encode(&storage_key), + ); + } + + #[test] + fn inbound_lane_data_key_computed_properly() { + // If this test fails, then something has been changed in module storage that is breaking + // all previously crafted inbound lane state proofs. + let storage_key = inbound_lane_data_key("BridgeMessages", &LaneId(*b"test")).0; + assert_eq!( + storage_key, + hex!("dd16c784ebd3390a9bc0357c7511ed01e5f83cf83f2127eb47afdc35d6e43fab44a8995dd50b6657a037a7839304535b74657374").to_vec(), + "Unexpected storage key: {}", + hex::encode(&storage_key), + ); + } +} diff --git a/bridges/primitives/messages/src/target_chain.rs b/bridges/primitives/messages/src/target_chain.rs new file mode 100644 index 00000000000..385bc4ac373 --- /dev/null +++ b/bridges/primitives/messages/src/target_chain.rs @@ -0,0 +1,198 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Primitives of messages module, that are used on the target chain. + +use crate::{ + LaneId, Message, MessageKey, MessageNonce, MessagePayload, OutboundLaneData, VerificationError, +}; + +use bp_runtime::{messages::MessageDispatchResult, Size}; +use codec::{Decode, Encode, Error as CodecError}; +use frame_support::{weights::Weight, Parameter, RuntimeDebug}; +use scale_info::TypeInfo; +use sp_std::{collections::btree_map::BTreeMap, fmt::Debug, marker::PhantomData, prelude::*}; + +/// Proved messages from the source chain. +pub type ProvedMessages = BTreeMap>; + +/// Proved messages from single lane of the source chain. +#[derive(RuntimeDebug, Encode, Decode, Clone, PartialEq, Eq, TypeInfo)] +pub struct ProvedLaneMessages { + /// Optional outbound lane state. + pub lane_state: Option, + /// Messages sent through this lane. + pub messages: Vec, +} + +/// Message data with decoded dispatch payload. +#[derive(RuntimeDebug)] +pub struct DispatchMessageData { + /// Result of dispatch payload decoding. + pub payload: Result, +} + +/// Message with decoded dispatch payload. +#[derive(RuntimeDebug)] +pub struct DispatchMessage { + /// Message key. + pub key: MessageKey, + /// Message data with decoded dispatch payload. + pub data: DispatchMessageData, +} + +/// Source chain API. Used by target chain, to verify source chain proofs. +/// +/// All implementations of this trait should only work with finalized data that +/// can't change. Wrong implementation may lead to invalid lane states (i.e. lane +/// that's stuck) and/or processing messages without paying fees. +pub trait SourceHeaderChain { + /// Proof that messages are sent from source chain. This may also include proof + /// of corresponding outbound lane states. + type MessagesProof: Parameter + Size; + + /// Verify messages proof and return proved messages. + /// + /// Returns error if either proof is incorrect, or the number of messages in the proof + /// is not matching the `messages_count`. + /// + /// Messages vector is required to be sorted by nonce within each lane. Out-of-order + /// messages will be rejected. + /// + /// The `messages_count` argument verification (sane limits) is supposed to be made + /// outside this function. This function only verifies that the proof declares exactly + /// `messages_count` messages. + fn verify_messages_proof( + proof: Self::MessagesProof, + messages_count: u32, + ) -> Result, VerificationError>; +} + +/// Called when inbound message is received. +pub trait MessageDispatch { + /// Decoded message payload type. Valid message may contain invalid payload. In this case + /// message is delivered, but dispatch fails. Therefore, two separate types of payload + /// (opaque `MessagePayload` used in delivery and this `DispatchPayload` used in dispatch). + type DispatchPayload: Decode; + + /// Fine-grained result of single message dispatch (for better diagnostic purposes) + type DispatchLevelResult: Clone + sp_std::fmt::Debug + Eq; + + /// Estimate dispatch weight. + /// + /// This function must return correct upper bound of dispatch weight. The return value + /// of this function is expected to match return value of the corresponding + /// `FromInboundLaneApi::message_details().dispatch_weight` call. + fn dispatch_weight(message: &mut DispatchMessage) -> Weight; + + /// Called when inbound message is received. + /// + /// It is up to the implementers of this trait to determine whether the message + /// is invalid (i.e. improperly encoded, has too large weight, ...) or not. + fn dispatch( + message: DispatchMessage, + ) -> MessageDispatchResult; +} + +/// Manages payments that are happening at the target chain during message delivery transaction. +pub trait DeliveryPayments { + /// Error type. + type Error: Debug + Into<&'static str>; + + /// Pay rewards for delivering messages to the given relayer. + /// + /// This method is called during message delivery transaction which has been submitted + /// by the `relayer`. The transaction brings `total_messages` messages but only + /// `valid_messages` have been accepted. The post-dispatch transaction weight is the + /// `actual_weight`. + fn pay_reward( + relayer: AccountId, + total_messages: MessageNonce, + valid_messages: MessageNonce, + actual_weight: Weight, + ); +} + +impl Default for ProvedLaneMessages { + fn default() -> Self { + ProvedLaneMessages { lane_state: None, messages: Vec::new() } + } +} + +impl From for DispatchMessage { + fn from(message: Message) -> Self { + DispatchMessage { key: message.key, data: message.payload.into() } + } +} + +impl From for DispatchMessageData { + fn from(payload: MessagePayload) -> Self { + DispatchMessageData { payload: DispatchPayload::decode(&mut &payload[..]) } + } +} + +impl DeliveryPayments for () { + type Error = &'static str; + + fn pay_reward( + _relayer: AccountId, + _total_messages: MessageNonce, + _valid_messages: MessageNonce, + _actual_weight: Weight, + ) { + // this implementation is not rewarding relayer at all + } +} + +/// Structure that may be used in place of `SourceHeaderChain` and `MessageDispatch` on chains, +/// where inbound messages are forbidden. +pub struct ForbidInboundMessages( + PhantomData<(MessagesProof, DispatchPayload)>, +); + +/// Error message that is used in `ForbidInboundMessages` implementation. +const ALL_INBOUND_MESSAGES_REJECTED: &str = + "This chain is configured to reject all inbound messages"; + +impl SourceHeaderChain + for ForbidInboundMessages +{ + type MessagesProof = MessagesProof; + + fn verify_messages_proof( + _proof: Self::MessagesProof, + _messages_count: u32, + ) -> Result, VerificationError> { + Err(VerificationError::Other(ALL_INBOUND_MESSAGES_REJECTED)) + } +} + +impl MessageDispatch + for ForbidInboundMessages +{ + type DispatchPayload = DispatchPayload; + type DispatchLevelResult = (); + + fn dispatch_weight(_message: &mut DispatchMessage) -> Weight { + Weight::MAX + } + + fn dispatch( + _: DispatchMessage, + ) -> MessageDispatchResult { + MessageDispatchResult { unspent_weight: Weight::zero(), dispatch_level_result: () } + } +} diff --git a/bridges/primitives/parachains/Cargo.toml b/bridges/primitives/parachains/Cargo.toml new file mode 100644 index 00000000000..426597a2508 --- /dev/null +++ b/bridges/primitives/parachains/Cargo.toml @@ -0,0 +1,39 @@ +[package] +name = "bp-parachains" +description = "Primitives of parachains module." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } +impl-trait-for-tuples = "0.2" +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } + +# Bridge dependencies + +bp-header-chain = { path = "../header-chain", default-features = false } +bp-polkadot-core = { path = "../polkadot-core", default-features = false } +bp-runtime = { path = "../runtime", default-features = false } + +# Substrate dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-header-chain/std", + "bp-polkadot-core/std", + "bp-runtime/std", + "codec/std", + "frame-support/std", + "scale-info/std", + "sp-core/std", + "sp-runtime/std", + "sp-std/std", +] diff --git a/bridges/primitives/parachains/src/lib.rs b/bridges/primitives/parachains/src/lib.rs new file mode 100644 index 00000000000..e619fc7b641 --- /dev/null +++ b/bridges/primitives/parachains/src/lib.rs @@ -0,0 +1,180 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Primitives of parachains module. + +#![cfg_attr(not(feature = "std"), no_std)] + +pub use bp_header_chain::StoredHeaderData; + +use bp_polkadot_core::{ + parachains::{ParaHash, ParaHead, ParaHeadsProof, ParaId}, + BlockNumber as RelayBlockNumber, Hash as RelayBlockHash, +}; +use bp_runtime::{ + BlockNumberOf, Chain, HashOf, HeaderOf, Parachain, StorageDoubleMapKeyProvider, + StorageMapKeyProvider, +}; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{Blake2_128Concat, RuntimeDebug, Twox64Concat}; +use scale_info::TypeInfo; +use sp_core::storage::StorageKey; +use sp_runtime::traits::Header as HeaderT; +use sp_std::{marker::PhantomData, prelude::*}; + +/// Best known parachain head hash. +#[derive(Clone, Decode, Encode, MaxEncodedLen, PartialEq, RuntimeDebug, TypeInfo)] +pub struct BestParaHeadHash { + /// Number of relay block where this head has been read. + /// + /// Parachain head is opaque to relay chain. So we can't simply decode it as a header of + /// parachains and call `block_number()` on it. Instead, we're using the fact that parachain + /// head is always built on top of previous head (because it is blockchain) and relay chain + /// always imports parachain heads in order. What it means for us is that at any given + /// **finalized** relay block `B`, head of parachain will be ancestor (or the same) of all + /// parachain heads available at descendants of `B`. + pub at_relay_block_number: RelayBlockNumber, + /// Hash of parachain head. + pub head_hash: ParaHash, +} + +/// Best known parachain head as it is stored in the runtime storage. +#[derive(Decode, Encode, MaxEncodedLen, PartialEq, RuntimeDebug, TypeInfo)] +pub struct ParaInfo { + /// Best known parachain head hash. + pub best_head_hash: BestParaHeadHash, + /// Current ring buffer position for this parachain. + pub next_imported_hash_position: u32, +} + +/// Returns runtime storage key of given parachain head at the source chain. +/// +/// The head is stored by the `paras` pallet in the `Heads` map. +pub fn parachain_head_storage_key_at_source( + paras_pallet_name: &str, + para_id: ParaId, +) -> StorageKey { + bp_runtime::storage_map_final_key::(paras_pallet_name, "Heads", ¶_id.encode()) +} + +/// Can be use to access the runtime storage key of the parachains info at the target chain. +/// +/// The info is stored by the `pallet-bridge-parachains` pallet in the `ParasInfo` map. +pub struct ParasInfoKeyProvider; +impl StorageMapKeyProvider for ParasInfoKeyProvider { + const MAP_NAME: &'static str = "ParasInfo"; + + type Hasher = Blake2_128Concat; + type Key = ParaId; + type Value = ParaInfo; +} + +/// Can be use to access the runtime storage key of the parachain head at the target chain. +/// +/// The head is stored by the `pallet-bridge-parachains` pallet in the `ImportedParaHeads` map. +pub struct ImportedParaHeadsKeyProvider; +impl StorageDoubleMapKeyProvider for ImportedParaHeadsKeyProvider { + const MAP_NAME: &'static str = "ImportedParaHeads"; + + type Hasher1 = Blake2_128Concat; + type Key1 = ParaId; + type Hasher2 = Blake2_128Concat; + type Key2 = ParaHash; + type Value = ParaStoredHeaderData; +} + +/// Stored data of the parachain head. It is encoded version of the +/// `bp_runtime::StoredHeaderData` structure. +/// +/// We do not know exact structure of the parachain head, so we always store encoded version +/// of the `bp_runtime::StoredHeaderData`. It is only decoded when we talk about specific parachain. +#[derive(Clone, Decode, Encode, PartialEq, RuntimeDebug, TypeInfo)] +pub struct ParaStoredHeaderData(pub Vec); + +impl ParaStoredHeaderData { + /// Decode stored parachain head data. + pub fn decode_parachain_head_data( + &self, + ) -> Result, HashOf>, codec::Error> { + StoredHeaderData::, HashOf>::decode(&mut &self.0[..]) + } +} + +/// Stored parachain head data builder. +pub trait ParaStoredHeaderDataBuilder { + /// Return number of parachains that are supported by this builder. + fn supported_parachains() -> u32; + + /// Try to build head data from encoded head of parachain with given id. + fn try_build(para_id: ParaId, para_head: &ParaHead) -> Option; +} + +/// Helper for using single parachain as `ParaStoredHeaderDataBuilder`. +pub struct SingleParaStoredHeaderDataBuilder(PhantomData); + +impl ParaStoredHeaderDataBuilder for SingleParaStoredHeaderDataBuilder { + fn supported_parachains() -> u32 { + 1 + } + + fn try_build(para_id: ParaId, para_head: &ParaHead) -> Option { + if para_id == ParaId(C::PARACHAIN_ID) { + let header = HeaderOf::::decode(&mut ¶_head.0[..]).ok()?; + return Some(ParaStoredHeaderData( + StoredHeaderData { number: *header.number(), state_root: *header.state_root() } + .encode(), + )) + } + None + } +} + +// Tries to build header data from each tuple member, short-circuiting on first successful one. +#[impl_trait_for_tuples::impl_for_tuples(1, 30)] +#[tuple_types_custom_trait_bound(Parachain)] +impl ParaStoredHeaderDataBuilder for C { + fn supported_parachains() -> u32 { + let mut result = 0; + for_tuples!( #( + result += SingleParaStoredHeaderDataBuilder::::supported_parachains(); + )* ); + result + } + + fn try_build(para_id: ParaId, para_head: &ParaHead) -> Option { + for_tuples!( #( + let maybe_para_head = SingleParaStoredHeaderDataBuilder::::try_build(para_id, para_head); + if let Some(maybe_para_head) = maybe_para_head { + return Some(maybe_para_head); + } + )* ); + + None + } +} + +/// A minimized version of `pallet-bridge-parachains::Call` that can be used without a runtime. +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +#[allow(non_camel_case_types)] +pub enum BridgeParachainCall { + /// `pallet-bridge-parachains::Call::submit_parachain_heads` + #[codec(index = 0)] + submit_parachain_heads { + at_relay_block: (RelayBlockNumber, RelayBlockHash), + parachains: Vec<(ParaId, ParaHash)>, + parachain_heads_proof: ParaHeadsProof, + }, +} diff --git a/bridges/primitives/polkadot-core/Cargo.toml b/bridges/primitives/polkadot-core/Cargo.toml new file mode 100644 index 00000000000..56c6de04d41 --- /dev/null +++ b/bridges/primitives/polkadot-core/Cargo.toml @@ -0,0 +1,45 @@ +[package] +name = "bp-polkadot-core" +description = "Primitives of Polkadot-like runtime." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } +parity-util-mem = { version = "0.12.0", optional = true } +scale-info = { version = "2.6.0", default-features = false, features = ["derive"] } +serde = { version = "1.0", optional = true, features = ["derive"] } + +# Bridge Dependencies + +bp-messages = { path = "../messages", default-features = false } +bp-runtime = { path = "../runtime", default-features = false } + +# Substrate Based Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[dev-dependencies] +hex = "0.4" + +[features] +default = ["std"] +std = [ + "bp-messages/std", + "bp-runtime/std", + "frame-support/std", + "frame-system/std", + "codec/std", + "parity-util-mem", + "scale-info/std", + "serde", + "sp-core/std", + "sp-runtime/std", + "sp-std/std", +] diff --git a/bridges/primitives/polkadot-core/src/lib.rs b/bridges/primitives/polkadot-core/src/lib.rs new file mode 100644 index 00000000000..3774d283fc4 --- /dev/null +++ b/bridges/primitives/polkadot-core/src/lib.rs @@ -0,0 +1,292 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] + +use bp_messages::MessageNonce; +use bp_runtime::{Chain, EncodedOrDecodedCall, StorageMapKeyProvider}; +use frame_support::{ + dispatch::DispatchClass, + parameter_types, + weights::{ + constants::{BlockExecutionWeight, WEIGHT_REF_TIME_PER_SECOND}, + Weight, + }, + Blake2_128Concat, RuntimeDebug, +}; +use frame_system::limits; +use sp_core::{storage::StorageKey, Hasher as HasherT}; +use sp_runtime::{ + generic, + traits::{BlakeTwo256, IdentifyAccount, Verify}, + MultiAddress, MultiSignature, OpaqueExtrinsic, +}; +use sp_std::prelude::Vec; + +// Re-export's to avoid extra substrate dependencies in chain-specific crates. +pub use frame_support::{weights::constants::ExtrinsicBaseWeight, Parameter}; +pub use sp_runtime::{traits::Convert, Perbill}; + +pub mod parachains; + +/// Maximal number of GRANDPA authorities at Polkadot-like chains. +/// +/// Ideally, we would set it to the value of `MaxAuthorities` constant from bridged runtime +/// configurations. But right now it is set to the `100_000`, which makes PoV size for +/// our bridge hub parachains huge. So let's stick to the real-world value here. +/// +/// Right now both Kusama and Polkadot aim to have around 1000 validators. Let's be safe here and +/// take a bit more here. +pub const MAX_AUTHORITIES_COUNT: u32 = 1_256; + +/// Reasonable number of headers in the `votes_ancestries` on Polkadot-like chains. +/// +/// See [`bp-header-chain::ChainWithGrandpa`] for more details. +/// +/// This value comes from recent (February, 2023) Kusama and Polkadot headers. There are no +/// justifications with any additional headers in votes ancestry, so reasonable headers may +/// be set to zero. But we assume that there may be small GRANDPA lags, so we're leaving some +/// reserve here. +pub const REASONABLE_HEADERS_IN_JUSTIFICATON_ANCESTRY: u32 = 2; + +/// Approximate average header size in `votes_ancestries` field of justification on Polkadot-like +/// chains. +/// +/// See [`bp-header-chain::ChainWithGrandpa`] for more details. +/// +/// This value comes from recent (February, 2023) Kusama headers. Average is `336` there, but some +/// non-mandatory headers has size `40kb` (they contain the BABE epoch descriptor with all +/// authorities - just like our mandatory header). Since we assume `2` headers in justification +/// votes ancestry, let's set average header to `40kb / 2`. +pub const AVERAGE_HEADER_SIZE_IN_JUSTIFICATION: u32 = 20 * 1024; + +/// Approximate maximal header size on Polkadot-like chains. +/// +/// See [`bp-header-chain::ChainWithGrandpa`] for more details. +/// +/// This value comes from recent (February, 2023) Kusama headers. Maximal header is a mandatory +/// header. In its SCALE-encoded form it is `80348` bytes. Let's have some reserve here. +pub const MAX_HEADER_SIZE: u32 = 90_000; + +/// Number of extra bytes (excluding size of storage value itself) of storage proof, built at +/// Polkadot-like chain. This mostly depends on number of entries in the storage trie. +/// Some reserve is reserved to account future chain growth. +/// +/// To compute this value, we've synced Kusama chain blocks [0; 6545733] to see if there were +/// any significant changes of the storage proof size (NO): +/// +/// - at block 3072 the storage proof size overhead was 579 bytes; +/// - at block 2479616 it was 578 bytes; +/// - at block 4118528 it was 711 bytes; +/// - at block 6540800 it was 779 bytes. +/// +/// The number of storage entries at the block 6546170 was 351207 and number of trie nodes in +/// the storage proof was 5 (log(16, 351207) ~ 4.6). +/// +/// So the assumption is that the storage proof size overhead won't be larger than 1024 in the +/// nearest future. If it'll ever break this barrier, then we'll need to update this constant +/// at next runtime upgrade. +pub const EXTRA_STORAGE_PROOF_SIZE: u32 = 1024; + +/// All Polkadot-like chains allow normal extrinsics to fill block up to 75 percent. +/// +/// This is a copy-paste from the Polkadot repo's `polkadot-runtime-common` crate. +const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); + +/// All Polkadot-like chains allow 2 seconds of compute with a 6-second average block time. +/// +/// This is a copy-paste from the Polkadot repo's `polkadot-runtime-common` crate. +pub const MAXIMUM_BLOCK_WEIGHT: Weight = + Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), u64::MAX); + +/// All Polkadot-like chains assume that an on-initialize consumes 1 percent of the weight on +/// average, hence a single extrinsic will not be allowed to consume more than +/// `AvailableBlockRatio - 1 percent`. +/// +/// This is a copy-paste from the Polkadot repo's `polkadot-runtime-common` crate. +pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(1); + +parameter_types! { + /// All Polkadot-like chains have maximal block size set to 5MB. + /// + /// This is a copy-paste from the Polkadot repo's `polkadot-runtime-common` crate. + pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio( + 5 * 1024 * 1024, + NORMAL_DISPATCH_RATIO, + ); + /// All Polkadot-like chains have the same block weights. + /// + /// This is a copy-paste from the Polkadot repo's `polkadot-runtime-common` crate. + pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder() + .base_block(BlockExecutionWeight::get()) + .for_class(DispatchClass::all(), |weights| { + weights.base_extrinsic = ExtrinsicBaseWeight::get(); + }) + .for_class(DispatchClass::Normal, |weights| { + weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); + }) + .for_class(DispatchClass::Operational, |weights| { + weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); + // Operational transactions have an extra reserved space, so that they + // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. + weights.reserved = Some( + MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT, + ); + }) + .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) + .build_or_panic(); +} + +// TODO [#78] may need to be updated after https://github.com/paritytech/parity-bridges-common/issues/78 +/// Maximal number of messages in single delivery transaction. +pub const MAX_MESSAGES_IN_DELIVERY_TRANSACTION: MessageNonce = 128; + +/// Maximal number of bytes, included in the signed Polkadot-like transaction apart from the encoded +/// call itself. +/// +/// Can be computed by subtracting encoded call size from raw transaction size. +pub const TX_EXTRA_BYTES: u32 = 256; + +/// Re-export `time_units` to make usage easier. +pub use time_units::*; + +/// Human readable time units defined in terms of number of blocks. +pub mod time_units { + use super::BlockNumber; + + pub const MILLISECS_PER_BLOCK: u64 = 6000; + pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; + + pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); + pub const HOURS: BlockNumber = MINUTES * 60; + pub const DAYS: BlockNumber = HOURS * 24; +} + +/// Block number type used in Polkadot-like chains. +pub type BlockNumber = u32; + +/// Hash type used in Polkadot-like chains. +pub type Hash = ::Out; + +/// Account Index (a.k.a. nonce). +pub type Index = u32; + +/// Hashing type. +pub type Hashing = BlakeTwo256; + +/// The type of object that can produce hashes on Polkadot-like chains. +pub type Hasher = BlakeTwo256; + +/// The header type used by Polkadot-like chains. +pub type Header = generic::Header; + +/// Signature type used by Polkadot-like chains. +pub type Signature = MultiSignature; + +/// Public key of account on Polkadot-like chains. +pub type AccountPublic = ::Signer; + +/// Id of account on Polkadot-like chains. +pub type AccountId = ::AccountId; + +/// Address of account on Polkadot-like chains. +pub type AccountAddress = MultiAddress; + +/// Index of a transaction on the Polkadot-like chains. +pub type Nonce = u32; + +/// Block type of Polkadot-like chains. +pub type Block = generic::Block; + +/// Polkadot-like block signed with a Justification. +pub type SignedBlock = generic::SignedBlock; + +/// The balance of an account on Polkadot-like chain. +pub type Balance = u128; + +/// Unchecked Extrinsic type. +pub type UncheckedExtrinsic = + generic::UncheckedExtrinsic, Signature, SignedExt>; + +/// Account address, used by the Polkadot-like chain. +pub type Address = MultiAddress; + +/// Polkadot-like chain. +#[derive(RuntimeDebug)] +pub struct PolkadotLike; + +impl Chain for PolkadotLike { + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hasher = Hasher; + type Header = Header; + + type AccountId = AccountId; + type Balance = Balance; + type Index = Index; + type Signature = Signature; + + fn max_extrinsic_size() -> u32 { + *BlockLength::get().max.get(DispatchClass::Normal) + } + + fn max_extrinsic_weight() -> Weight { + BlockWeights::get() + .get(DispatchClass::Normal) + .max_extrinsic + .unwrap_or(Weight::MAX) + } +} + +/// Provides a storage key for account data. +/// +/// We need to use this approach when we don't have access to the runtime. +/// The equivalent command to invoke in case full `Runtime` is known is this: +/// `let key = frame_system::Account::::storage_map_final_key(&account_id);` +pub struct AccountInfoStorageMapKeyProvider; + +impl StorageMapKeyProvider for AccountInfoStorageMapKeyProvider { + const MAP_NAME: &'static str = "Account"; + type Hasher = Blake2_128Concat; + type Key = AccountId; + // This should actually be `AccountInfo`, but we don't use this property in order to decode the + // data. So we use `Vec` as if we would work with encoded data. + type Value = Vec; +} + +impl AccountInfoStorageMapKeyProvider { + const PALLET_NAME: &'static str = "System"; + + pub fn final_key(id: &AccountId) -> StorageKey { + ::final_key(Self::PALLET_NAME, id) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn should_generate_storage_key() { + let acc = [ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, + ] + .into(); + let key = AccountInfoStorageMapKeyProvider::final_key(&acc); + assert_eq!(hex::encode(key), "26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da92dccd599abfe1920a1cff8a7358231430102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20"); + } +} diff --git a/bridges/primitives/polkadot-core/src/parachains.rs b/bridges/primitives/polkadot-core/src/parachains.rs new file mode 100644 index 00000000000..9cac3279c72 --- /dev/null +++ b/bridges/primitives/polkadot-core/src/parachains.rs @@ -0,0 +1,98 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Primitives of polkadot-like chains, that are related to parachains functionality. +//! +//! Even though this (bridges) repository references polkadot repository, we can't +//! reference polkadot crates from pallets. That's because bridges repository is +//! included in the Cumulus repository and included pallets are used by Cumulus +//! parachains. Having pallets that are referencing polkadot, would mean that there may +//! be two versions of polkadot crates included in the runtime. Which is bad. + +use bp_runtime::{RawStorageProof, Size}; +use codec::{CompactAs, Decode, Encode, MaxEncodedLen}; +use frame_support::RuntimeDebug; +use scale_info::TypeInfo; +use sp_core::Hasher; +use sp_std::vec::Vec; + +#[cfg(feature = "std")] +use serde::{Deserialize, Serialize}; + +#[cfg(feature = "std")] +use parity_util_mem::MallocSizeOf; + +/// Parachain id. +/// +/// This is an equivalent of the `polkadot_parachain::Id`, which is a compact-encoded `u32`. +#[derive( + Clone, + CompactAs, + Copy, + Decode, + Default, + Encode, + Eq, + Hash, + MaxEncodedLen, + Ord, + PartialEq, + PartialOrd, + RuntimeDebug, + TypeInfo, +)] +pub struct ParaId(pub u32); + +impl From for ParaId { + fn from(id: u32) -> Self { + ParaId(id) + } +} + +/// Parachain head. +/// +/// This is an equivalent of the `polkadot_parachain::HeadData`. +/// +/// The parachain head means (at least in Cumulus) a SCALE-encoded parachain header. +#[derive( + PartialEq, Eq, Clone, PartialOrd, Ord, Encode, Decode, RuntimeDebug, TypeInfo, Default, +)] +#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, MallocSizeOf))] +pub struct ParaHead(pub Vec); + +impl ParaHead { + /// Returns the hash of this head data. + pub fn hash(&self) -> crate::Hash { + sp_runtime::traits::BlakeTwo256::hash(&self.0) + } +} + +/// Parachain head hash. +pub type ParaHash = crate::Hash; + +/// Parachain head hasher. +pub type ParaHasher = crate::Hasher; + +/// Raw storage proof of parachain heads, stored in polkadot-like chain runtime. +#[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] +pub struct ParaHeadsProof(pub RawStorageProof); + +impl Size for ParaHeadsProof { + fn size(&self) -> u32 { + u32::try_from(self.0.iter().fold(0usize, |sum, node| sum.saturating_add(node.len()))) + .unwrap_or(u32::MAX) + } +} diff --git a/bridges/primitives/relayers/Cargo.toml b/bridges/primitives/relayers/Cargo.toml new file mode 100644 index 00000000000..b84b0393adf --- /dev/null +++ b/bridges/primitives/relayers/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "bp-relayers" +description = "Primitives of relayers module." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "bit-vec"] } +scale-info = { version = "2.6.0", default-features = false, features = ["bit-vec", "derive"] } + +# Bridge Dependencies + +bp-messages = { path = "../messages", default-features = false } +bp-runtime = { path = "../runtime", default-features = false } + +# Substrate Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[dev-dependencies] +hex = "0.4" +hex-literal = "0.4" + +[features] +default = ["std"] +std = [ + "bp-messages/std", + "bp-runtime/std", + "frame-support/std", + "sp-runtime/std", + "sp-std/std", +] diff --git a/bridges/primitives/relayers/src/lib.rs b/bridges/primitives/relayers/src/lib.rs new file mode 100644 index 00000000000..21f66a2ffa1 --- /dev/null +++ b/bridges/primitives/relayers/src/lib.rs @@ -0,0 +1,206 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Primitives of messages module. + +#![warn(missing_docs)] +#![cfg_attr(not(feature = "std"), no_std)] + +pub use registration::{Registration, StakeAndSlash}; + +use bp_messages::LaneId; +use bp_runtime::{ChainId, StorageDoubleMapKeyProvider}; +use frame_support::{traits::tokens::Preservation, Blake2_128Concat, Identity}; +use scale_info::TypeInfo; +use sp_runtime::{ + codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen}, + traits::AccountIdConversion, + TypeId, +}; +use sp_std::{fmt::Debug, marker::PhantomData}; + +mod registration; + +/// The owner of the sovereign account that should pay the rewards. +/// +/// Each of the 2 final points connected by a bridge owns a sovereign account at each end of the +/// bridge. So here, at this end of the bridge there can be 2 sovereign accounts that pay rewards. +#[derive(Copy, Clone, Debug, Decode, Encode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub enum RewardsAccountOwner { + /// The sovereign account of the final chain on this end of the bridge. + ThisChain, + /// The sovereign account of the final chain on the other end of the bridge. + BridgedChain, +} + +/// Structure used to identify the account that pays a reward to the relayer. +/// +/// A bridge connects 2 bridge ends. Each one is located on a separate relay chain. The bridge ends +/// can be the final destinations of the bridge, or they can be intermediary points +/// (e.g. a bridge hub) used to forward messages between pairs of parachains on the bridged relay +/// chains. A pair of such parachains is connected using a bridge lane. Each of the 2 final +/// destinations of a bridge lane must have a sovereign account at each end of the bridge and each +/// of the sovereign accounts will pay rewards for different operations. So we need multiple +/// parameters to identify the account that pays a reward to the relayer. +#[derive(Copy, Clone, Debug, Decode, Encode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub struct RewardsAccountParams { + lane_id: LaneId, + bridged_chain_id: ChainId, + owner: RewardsAccountOwner, +} + +impl RewardsAccountParams { + /// Create a new instance of `RewardsAccountParams`. + pub const fn new( + lane_id: LaneId, + bridged_chain_id: ChainId, + owner: RewardsAccountOwner, + ) -> Self { + Self { lane_id, bridged_chain_id, owner } + } +} + +impl TypeId for RewardsAccountParams { + const TYPE_ID: [u8; 4] = *b"brap"; +} + +/// Reward payment procedure. +pub trait PaymentProcedure { + /// Error that may be returned by the procedure. + type Error: Debug; + + /// Pay reward to the relayer from the account with provided params. + fn pay_reward( + relayer: &Relayer, + rewards_account_params: RewardsAccountParams, + reward: Reward, + ) -> Result<(), Self::Error>; +} + +impl PaymentProcedure for () { + type Error = &'static str; + + fn pay_reward(_: &Relayer, _: RewardsAccountParams, _: Reward) -> Result<(), Self::Error> { + Ok(()) + } +} + +/// Reward payment procedure that does `balances::transfer` call from the account, derived from +/// given params. +pub struct PayRewardFromAccount(PhantomData<(T, Relayer)>); + +impl PayRewardFromAccount +where + Relayer: Decode + Encode, +{ + /// Return account that pays rewards based on the provided parameters. + pub fn rewards_account(params: RewardsAccountParams) -> Relayer { + params.into_sub_account_truncating(b"rewards-account") + } +} + +impl PaymentProcedure for PayRewardFromAccount +where + T: frame_support::traits::fungible::Mutate, + Relayer: Decode + Encode, +{ + type Error = sp_runtime::DispatchError; + + fn pay_reward( + relayer: &Relayer, + rewards_account_params: RewardsAccountParams, + reward: T::Balance, + ) -> Result<(), Self::Error> { + T::transfer( + &Self::rewards_account(rewards_account_params), + relayer, + reward, + Preservation::Expendable, + ) + .map(drop) + } +} + +/// Can be use to access the runtime storage key within the `RelayerRewards` map of the relayers +/// pallet. +pub struct RelayerRewardsKeyProvider(PhantomData<(AccountId, Reward)>); + +impl StorageDoubleMapKeyProvider for RelayerRewardsKeyProvider +where + AccountId: Codec + EncodeLike, + Reward: Codec + EncodeLike, +{ + const MAP_NAME: &'static str = "RelayerRewards"; + + type Hasher1 = Blake2_128Concat; + type Key1 = AccountId; + type Hasher2 = Identity; + type Key2 = RewardsAccountParams; + type Value = Reward; +} + +#[cfg(test)] +mod tests { + use super::*; + use bp_messages::LaneId; + use sp_runtime::testing::H256; + + #[test] + fn different_lanes_are_using_different_accounts() { + assert_eq!( + PayRewardFromAccount::<(), H256>::rewards_account(RewardsAccountParams::new( + LaneId([0, 0, 0, 0]), + *b"test", + RewardsAccountOwner::ThisChain + )), + hex_literal::hex!("62726170000000007465737400726577617264732d6163636f756e7400000000") + .into(), + ); + + assert_eq!( + PayRewardFromAccount::<(), H256>::rewards_account(RewardsAccountParams::new( + LaneId([0, 0, 0, 1]), + *b"test", + RewardsAccountOwner::ThisChain + )), + hex_literal::hex!("62726170000000017465737400726577617264732d6163636f756e7400000000") + .into(), + ); + } + + #[test] + fn different_directions_are_using_different_accounts() { + assert_eq!( + PayRewardFromAccount::<(), H256>::rewards_account(RewardsAccountParams::new( + LaneId([0, 0, 0, 0]), + *b"test", + RewardsAccountOwner::ThisChain + )), + hex_literal::hex!("62726170000000007465737400726577617264732d6163636f756e7400000000") + .into(), + ); + + assert_eq!( + PayRewardFromAccount::<(), H256>::rewards_account(RewardsAccountParams::new( + LaneId([0, 0, 0, 0]), + *b"test", + RewardsAccountOwner::BridgedChain + )), + hex_literal::hex!("62726170000000007465737401726577617264732d6163636f756e7400000000") + .into(), + ); + } +} diff --git a/bridges/primitives/relayers/src/registration.rs b/bridges/primitives/relayers/src/registration.rs new file mode 100644 index 00000000000..7ab20844bdf --- /dev/null +++ b/bridges/primitives/relayers/src/registration.rs @@ -0,0 +1,121 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Bridge relayers registration and slashing scheme. +//! +//! There is an option to add a refund-relayer signed extension that will compensate +//! relayer costs of the message delivery and confirmation transactions (as well as +//! required finality proofs). This extension boosts priority of message delivery +//! transactions, based on the number of bundled messages. So transaction with more +//! messages has larger priority than the transaction with less messages. +//! See `bridge_runtime_common::priority_calculator` for details; +//! +//! This encourages relayers to include more messages to their delivery transactions. +//! At the same time, we are not verifying storage proofs before boosting +//! priority. Instead, we simply trust relayer, when it says that transaction delivers +//! `N` messages. +//! +//! This allows relayers to submit transactions which declare large number of bundled +//! transactions to receive priority boost for free, potentially pushing actual delivery +//! transactions from the block (or even transaction queue). Such transactions are +//! not free, but their cost is relatively small. +//! +//! To alleviate that, we only boost transactions of relayers that have some stake +//! that guarantees that their transactions are valid. Such relayers get priority +//! for free, but they risk to lose their stake. + +use crate::RewardsAccountParams; + +use codec::{Decode, Encode, MaxEncodedLen}; +use scale_info::TypeInfo; +use sp_runtime::{ + traits::{Get, Zero}, + DispatchError, DispatchResult, +}; + +/// Relayer registration. +#[derive(Copy, Clone, Debug, Decode, Encode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +pub struct Registration { + /// The last block number, where this registration is considered active. + /// + /// Relayer has an option to renew his registration (this may be done before it + /// is spoiled as well). Starting from block `valid_till + 1`, relayer may `deregister` + /// himself and get his stake back. + /// + /// Please keep in mind that priority boost stops working some blocks before the + /// registration ends (see [`StakeAndSlash::RequiredRegistrationLease`]). + pub valid_till: BlockNumber, + /// Active relayer stake, which is mapped to the relayer reserved balance. + /// + /// If `stake` is less than the [`StakeAndSlash::RequiredStake`], the registration + /// is considered inactive even if `valid_till + 1` is not yet reached. + pub stake: Balance, +} + +/// Relayer stake-and-slash mechanism. +pub trait StakeAndSlash { + /// The stake that the relayer must have to have its transactions boosted. + type RequiredStake: Get; + /// Required **remaining** registration lease to be able to get transaction priority boost. + /// + /// If the difference between registration's `valid_till` and the current block number + /// is less than the `RequiredRegistrationLease`, it becomes inactive and relayer transaction + /// won't get priority boost. This period exists, because priority is calculated when + /// transaction is placed to the queue (and it is reevaluated periodically) and then some time + /// may pass before transaction will be included into the block. + type RequiredRegistrationLease: Get; + + /// Reserve the given amount at relayer account. + fn reserve(relayer: &AccountId, amount: Balance) -> DispatchResult; + /// `Unreserve` the given amount from relayer account. + /// + /// Returns amount that we have failed to `unreserve`. + fn unreserve(relayer: &AccountId, amount: Balance) -> Balance; + /// Slash up to `amount` from reserved balance of account `relayer` and send funds to given + /// `beneficiary`. + /// + /// Returns `Ok(_)` with non-zero balance if we have failed to repatriate some portion of stake. + fn repatriate_reserved( + relayer: &AccountId, + beneficiary: RewardsAccountParams, + amount: Balance, + ) -> Result; +} + +impl StakeAndSlash for () +where + Balance: Default + Zero, + BlockNumber: Default, +{ + type RequiredStake = (); + type RequiredRegistrationLease = (); + + fn reserve(_relayer: &AccountId, _amount: Balance) -> DispatchResult { + Ok(()) + } + + fn unreserve(_relayer: &AccountId, _amount: Balance) -> Balance { + Zero::zero() + } + + fn repatriate_reserved( + _relayer: &AccountId, + _beneficiary: RewardsAccountParams, + _amount: Balance, + ) -> Result { + Ok(Zero::zero()) + } +} diff --git a/bridges/primitives/runtime/Cargo.toml b/bridges/primitives/runtime/Cargo.toml new file mode 100644 index 00000000000..3e6a30a061c --- /dev/null +++ b/bridges/primitives/runtime/Cargo.toml @@ -0,0 +1,49 @@ +[package] +name = "bp-runtime" +description = "Primitives that may be used at (bridges) runtime level." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } +hash-db = { version = "0.16.0", default-features = false } +impl-trait-for-tuples = "0.2.2" +num-traits = { version = "0.2", default-features = false } +scale-info = { version = "2.6.0", default-features = false, features = ["derive", "serde"] } +serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] } + +# Substrate Dependencies + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["serde"] } +sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +trie-db = { version = "0.27.1", default-features = false } + +[dev-dependencies] +hex-literal = "0.4" + +[features] +default = ["std"] +std = [ + "codec/std", + "frame-support/std", + "frame-system/std", + "hash-db/std", + "num-traits/std", + "scale-info/std", + "serde/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "sp-state-machine/std", + "sp-trie/std", + "trie-db/std", +] diff --git a/bridges/primitives/runtime/src/chain.rs b/bridges/primitives/runtime/src/chain.rs new file mode 100644 index 00000000000..c79058cea90 --- /dev/null +++ b/bridges/primitives/runtime/src/chain.rs @@ -0,0 +1,383 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +use crate::HeaderIdProvider; +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{weights::Weight, Parameter}; +use num_traits::{AsPrimitive, Bounded, CheckedSub, Saturating, SaturatingAdd, Zero}; +use sp_runtime::{ + traits::{ + AtLeast32Bit, AtLeast32BitUnsigned, Hash as HashT, Header as HeaderT, MaybeDisplay, + MaybeSerialize, MaybeSerializeDeserialize, Member, SimpleBitOps, Verify, + }, + FixedPointOperand, +}; +use sp_std::{convert::TryFrom, fmt::Debug, hash::Hash, str::FromStr, vec, vec::Vec}; + +/// Chain call, that is either SCALE-encoded, or decoded. +#[derive(Debug, Clone, PartialEq)] +pub enum EncodedOrDecodedCall { + /// The call that is SCALE-encoded. + /// + /// This variant is used when we the chain runtime is not bundled with the relay, but + /// we still need the represent call in some RPC calls or transactions. + Encoded(Vec), + /// The decoded call. + Decoded(ChainCall), +} + +impl EncodedOrDecodedCall { + /// Returns decoded call. + pub fn to_decoded(&self) -> Result { + match self { + Self::Encoded(ref encoded_call) => + ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into), + Self::Decoded(ref decoded_call) => Ok(decoded_call.clone()), + } + } + + /// Converts self to decoded call. + pub fn into_decoded(self) -> Result { + match self { + Self::Encoded(encoded_call) => + ChainCall::decode(&mut &encoded_call[..]).map_err(Into::into), + Self::Decoded(decoded_call) => Ok(decoded_call), + } + } +} + +impl From for EncodedOrDecodedCall { + fn from(call: ChainCall) -> EncodedOrDecodedCall { + EncodedOrDecodedCall::Decoded(call) + } +} + +impl Decode for EncodedOrDecodedCall { + fn decode(input: &mut I) -> Result { + // having encoded version is better than decoded, because decoding isn't required + // everywhere and for mocked calls it may lead to **unneeded** errors + match input.remaining_len()? { + Some(remaining_len) => { + let mut encoded_call = vec![0u8; remaining_len]; + input.read(&mut encoded_call)?; + Ok(EncodedOrDecodedCall::Encoded(encoded_call)) + }, + None => Ok(EncodedOrDecodedCall::Decoded(ChainCall::decode(input)?)), + } + } +} + +impl Encode for EncodedOrDecodedCall { + fn encode(&self) -> Vec { + match *self { + Self::Encoded(ref encoded_call) => encoded_call.clone(), + Self::Decoded(ref decoded_call) => decoded_call.encode(), + } + } +} + +/// Minimal Substrate-based chain representation that may be used from no_std environment. +pub trait Chain: Send + Sync + 'static { + /// A type that fulfills the abstract idea of what a Substrate block number is. + // Constraits come from the associated Number type of `sp_runtime::traits::Header` + // See here for more info: + // https://crates.parity.io/sp_runtime/traits/trait.Header.html#associatedtype.Number + // + // Note that the `AsPrimitive` trait is required by the GRANDPA justification + // verifier, and is not usually part of a Substrate Header's Number type. + type BlockNumber: Parameter + + Member + + MaybeSerializeDeserialize + + Hash + + Copy + + Default + + MaybeDisplay + + AtLeast32BitUnsigned + + FromStr + + AsPrimitive + + Default + + Saturating + + MaxEncodedLen; + + /// A type that fulfills the abstract idea of what a Substrate hash is. + // Constraits come from the associated Hash type of `sp_runtime::traits::Header` + // See here for more info: + // https://crates.parity.io/sp_runtime/traits/trait.Header.html#associatedtype.Hash + type Hash: Parameter + + Member + + MaybeSerializeDeserialize + + Hash + + Ord + + Copy + + MaybeDisplay + + Default + + SimpleBitOps + + AsRef<[u8]> + + AsMut<[u8]> + + MaxEncodedLen; + + /// A type that fulfills the abstract idea of what a Substrate hasher (a type + /// that produces hashes) is. + // Constraits come from the associated Hashing type of `sp_runtime::traits::Header` + // See here for more info: + // https://crates.parity.io/sp_runtime/traits/trait.Header.html#associatedtype.Hashing + type Hasher: HashT; + + /// A type that fulfills the abstract idea of what a Substrate header is. + // See here for more info: + // https://crates.parity.io/sp_runtime/traits/trait.Header.html + type Header: Parameter + + HeaderT + + HeaderIdProvider + + MaybeSerializeDeserialize; + + /// The user account identifier type for the runtime. + type AccountId: Parameter + + Member + + MaybeSerializeDeserialize + + Debug + + MaybeDisplay + + Ord + + MaxEncodedLen; + /// Balance of an account in native tokens. + /// + /// The chain may support multiple tokens, but this particular type is for token that is used + /// to pay for transaction dispatch, to reward different relayers (headers, messages), etc. + type Balance: AtLeast32BitUnsigned + + FixedPointOperand + + Parameter + + Member + + MaybeSerializeDeserialize + + Clone + + Copy + + Bounded + + CheckedSub + + PartialOrd + + SaturatingAdd + + Zero + + TryFrom + + MaxEncodedLen; + /// Index of a transaction used by the chain. + type Index: Parameter + + Member + + MaybeSerialize + + Debug + + Default + + MaybeDisplay + + MaybeSerializeDeserialize + + AtLeast32Bit + + Copy + + MaxEncodedLen; + /// Signature type, used on this chain. + type Signature: Parameter + Verify; + + /// Get the maximum size (in bytes) of a Normal extrinsic at this chain. + fn max_extrinsic_size() -> u32; + /// Get the maximum weight (compute time) that a Normal extrinsic at this chain can use. + fn max_extrinsic_weight() -> Weight; +} + +/// A trait that provides the type of the underlying chain. +pub trait UnderlyingChainProvider { + /// Underlying chain type. + type Chain: Chain; +} + +impl Chain for T +where + T: Send + Sync + 'static + UnderlyingChainProvider, +{ + type BlockNumber = ::BlockNumber; + type Hash = ::Hash; + type Hasher = ::Hasher; + type Header = ::Header; + type AccountId = ::AccountId; + type Balance = ::Balance; + type Index = ::Index; + type Signature = ::Signature; + + fn max_extrinsic_size() -> u32 { + ::max_extrinsic_size() + } + + fn max_extrinsic_weight() -> Weight { + ::max_extrinsic_weight() + } +} + +/// Minimal parachain representation that may be used from no_std environment. +pub trait Parachain: Chain { + /// Parachain identifier. + const PARACHAIN_ID: u32; +} + +impl Parachain for T +where + T: Chain + UnderlyingChainProvider, + ::Chain: Parachain, +{ + const PARACHAIN_ID: u32 = <::Chain as Parachain>::PARACHAIN_ID; +} + +/// Adapter for `Get` to access `PARACHAIN_ID` from `trait Parachain` +pub struct ParachainIdOf(sp_std::marker::PhantomData); +impl frame_support::traits::Get for ParachainIdOf { + fn get() -> u32 { + Para::PARACHAIN_ID + } +} + +/// Underlying chain type. +pub type UnderlyingChainOf = ::Chain; + +/// Block number used by the chain. +pub type BlockNumberOf = ::BlockNumber; + +/// Hash type used by the chain. +pub type HashOf = ::Hash; + +/// Hasher type used by the chain. +pub type HasherOf = ::Hasher; + +/// Header type used by the chain. +pub type HeaderOf = ::Header; + +/// Account id type used by the chain. +pub type AccountIdOf = ::AccountId; + +/// Balance type used by the chain. +pub type BalanceOf = ::Balance; + +/// Transaction index type used by the chain. +pub type IndexOf = ::Index; + +/// Signature type used by the chain. +pub type SignatureOf = ::Signature; + +/// Account public type used by the chain. +pub type AccountPublicOf = as Verify>::Signer; + +/// Transaction era used by the chain. +pub type TransactionEraOf = crate::TransactionEra, HashOf>; + +/// Convenience macro that declares bridge finality runtime apis and related constants for a chain. +/// This includes: +/// - chain-specific bridge runtime APIs: +/// - `FinalityApi` +/// - constants that are stringified names of runtime API methods: +/// - `BEST_FINALIZED__HEADER_METHOD` +/// The name of the chain has to be specified in snake case (e.g. `rialto_parachain`). +#[macro_export] +macro_rules! decl_bridge_finality_runtime_apis { + ($chain: ident) => { + bp_runtime::paste::item! { + mod [<$chain _finality_api>] { + use super::*; + + /// Name of the `FinalityApi::best_finalized` runtime method. + pub const []: &str = + stringify!([<$chain:camel FinalityApi_best_finalized>]); + + sp_api::decl_runtime_apis! { + /// API for querying information about the finalized chain headers. + /// + /// This API is implemented by runtimes that are receiving messages from this chain, not by this + /// chain's runtime itself. + pub trait [<$chain:camel FinalityApi>] { + /// Returns number and hash of the best finalized header known to the bridge module. + fn best_finalized() -> Option>; + } + } + } + + pub use [<$chain _finality_api>]::*; + } + }; +} + +/// Convenience macro that declares bridge messages runtime apis and related constants for a chain. +/// This includes: +/// - chain-specific bridge runtime APIs: +/// - `ToOutboundLaneApi` +/// - `FromInboundLaneApi` +/// - constants that are stringified names of runtime API methods: +/// - `FROM__MESSAGE_DETAILS_METHOD`, +/// The name of the chain has to be specified in snake case (e.g. `rialto_parachain`). +#[macro_export] +macro_rules! decl_bridge_messages_runtime_apis { + ($chain: ident) => { + bp_runtime::paste::item! { + mod [<$chain _messages_api>] { + use super::*; + + /// Name of the `ToOutboundLaneApi::message_details` runtime method. + pub const []: &str = + stringify!([]); + + /// Name of the `FromInboundLaneApi::message_details` runtime method. + pub const []: &str = + stringify!([]); + + sp_api::decl_runtime_apis! { + /// Outbound message lane API for messages that are sent to this chain. + /// + /// This API is implemented by runtimes that are receiving messages from this chain, not by this + /// chain's runtime itself. + pub trait [] { + /// Returns dispatch weight, encoded payload size and delivery+dispatch fee of all + /// messages in given inclusive range. + /// + /// If some (or all) messages are missing from the storage, they'll also will + /// be missing from the resulting vector. The vector is ordered by the nonce. + fn message_details( + lane: LaneId, + begin: MessageNonce, + end: MessageNonce, + ) -> Vec; + } + + /// Inbound message lane API for messages sent by this chain. + /// + /// This API is implemented by runtimes that are receiving messages from this chain, not by this + /// chain's runtime itself. + /// + /// Entries of the resulting vector are matching entries of the `messages` vector. Entries of the + /// `messages` vector may (and need to) be read using `ToOutboundLaneApi::message_details`. + pub trait [] { + /// Return details of given inbound messages. + fn message_details( + lane: LaneId, + messages: Vec<(MessagePayload, OutboundMessageDetails)>, + ) -> Vec; + } + } + } + + pub use [<$chain _messages_api>]::*; + } + }; +} + +/// Convenience macro that declares bridge finality runtime apis, bridge messages runtime apis +/// and related constants for a chain. +/// The name of the chain has to be specified in snake case (e.g. `rialto_parachain`). +#[macro_export] +macro_rules! decl_bridge_runtime_apis { + ($chain: ident) => { + bp_runtime::decl_bridge_finality_runtime_apis!($chain); + bp_runtime::decl_bridge_messages_runtime_apis!($chain); + }; +} diff --git a/bridges/primitives/runtime/src/extensions.rs b/bridges/primitives/runtime/src/extensions.rs new file mode 100644 index 00000000000..96ee9d1e6ec --- /dev/null +++ b/bridges/primitives/runtime/src/extensions.rs @@ -0,0 +1,144 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Primitives that may be used for creating signed extensions for indirect runtimes. + +use codec::{Compact, Decode, Encode}; +use impl_trait_for_tuples::impl_for_tuples; +use scale_info::{StaticTypeInfo, TypeInfo}; +use sp_runtime::{ + traits::{DispatchInfoOf, SignedExtension}, + transaction_validity::TransactionValidityError, +}; +use sp_std::{fmt::Debug, marker::PhantomData}; + +/// Trait that describes some properties of a `SignedExtension` that are needed in order to send a +/// transaction to the chain. +pub trait SignedExtensionSchema: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo { + /// A type of the data encoded as part of the transaction. + type Payload: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo; + /// Parameters which are part of the payload used to produce transaction signature, + /// but don't end up in the transaction itself (i.e. inherent part of the runtime). + type AdditionalSigned: Encode + Debug + Eq + Clone + StaticTypeInfo; +} + +// An implementation of `SignedExtensionSchema` using generic params. +#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo)] +pub struct GenericSignedExtensionSchema(PhantomData<(P, S)>); + +impl SignedExtensionSchema for GenericSignedExtensionSchema +where + P: Encode + Decode + Debug + Eq + Clone + StaticTypeInfo, + S: Encode + Debug + Eq + Clone + StaticTypeInfo, +{ + type Payload = P; + type AdditionalSigned = S; +} + +/// The `SignedExtensionSchema` for `frame_system::CheckNonZeroSender`. +pub type CheckNonZeroSender = GenericSignedExtensionSchema<(), ()>; + +/// The `SignedExtensionSchema` for `frame_system::CheckSpecVersion`. +pub type CheckSpecVersion = GenericSignedExtensionSchema<(), u32>; + +/// The `SignedExtensionSchema` for `frame_system::CheckTxVersion`. +pub type CheckTxVersion = GenericSignedExtensionSchema<(), u32>; + +/// The `SignedExtensionSchema` for `frame_system::CheckGenesis`. +pub type CheckGenesis = GenericSignedExtensionSchema<(), Hash>; + +/// The `SignedExtensionSchema` for `frame_system::CheckEra`. +pub type CheckEra = GenericSignedExtensionSchema; + +/// The `SignedExtensionSchema` for `frame_system::CheckNonce`. +pub type CheckNonce = GenericSignedExtensionSchema, ()>; + +/// The `SignedExtensionSchema` for `frame_system::CheckWeight`. +pub type CheckWeight = GenericSignedExtensionSchema<(), ()>; + +/// The `SignedExtensionSchema` for `pallet_transaction_payment::ChargeTransactionPayment`. +pub type ChargeTransactionPayment = GenericSignedExtensionSchema, ()>; + +/// The `SignedExtensionSchema` for `BridgeRejectObsoleteHeadersAndMessages`. +pub type BridgeRejectObsoleteHeadersAndMessages = GenericSignedExtensionSchema<(), ()>; + +/// The `SignedExtensionSchema` for `RefundBridgedParachainMessages`. +/// This schema is dedicated for `RefundBridgedParachainMessages` signed extension as +/// wildcard/placeholder, which relies on the scale encoding for `()` or `((), ())`, or `((), (), +/// ())` is the same. So runtime can contains any kind of tuple: +/// `(BridgeRefundBridgeHubRococoMessages)` +/// `(BridgeRefundBridgeHubRococoMessages, BridgeRefundBridgeHubWococoMessages)` +/// `(BridgeRefundParachainMessages1, ..., BridgeRefundParachainMessagesN)` +pub type RefundBridgedParachainMessagesSchema = GenericSignedExtensionSchema<(), ()>; + +#[impl_for_tuples(1, 12)] +impl SignedExtensionSchema for Tuple { + for_tuples!( type Payload = ( #( Tuple::Payload ),* ); ); + for_tuples!( type AdditionalSigned = ( #( Tuple::AdditionalSigned ),* ); ); +} + +/// A simplified version of signed extensions meant for producing signed transactions +/// and signed payloads in the client code. +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +pub struct GenericSignedExtension { + pub payload: S::Payload, + #[codec(skip)] + // It may be set to `None` if extensions are decoded. We are never reconstructing transactions + // (and it makes no sense to do that) => decoded version of `SignedExtensions` is only used to + // read fields of the `payload`. And when resigning transaction, we're reconstructing + // `SignedExtensions` from the scratch. + additional_signed: Option, +} + +impl GenericSignedExtension { + pub fn new(payload: S::Payload, additional_signed: Option) -> Self { + Self { payload, additional_signed } + } +} + +impl SignedExtension for GenericSignedExtension +where + S: SignedExtensionSchema, + S::Payload: Send + Sync, + S::AdditionalSigned: Send + Sync, +{ + const IDENTIFIER: &'static str = "Not needed."; + type AccountId = (); + type Call = (); + type AdditionalSigned = S::AdditionalSigned; + type Pre = (); + + fn additional_signed(&self) -> Result { + // we shall not ever see this error in relay, because we are never signing decoded + // transactions. Instead we're constructing and signing new transactions. So the error code + // is kinda random here + self.additional_signed.clone().ok_or( + frame_support::unsigned::TransactionValidityError::Unknown( + frame_support::unsigned::UnknownTransaction::Custom(0xFF), + ), + ) + } + + fn pre_dispatch( + self, + _who: &Self::AccountId, + _call: &Self::Call, + _info: &DispatchInfoOf, + _len: usize, + ) -> Result { + Ok(()) + } +} diff --git a/bridges/primitives/runtime/src/lib.rs b/bridges/primitives/runtime/src/lib.rs new file mode 100644 index 00000000000..1ce1b7a0eed --- /dev/null +++ b/bridges/primitives/runtime/src/lib.rs @@ -0,0 +1,594 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Primitives that may be used at (bridges) runtime level. + +#![cfg_attr(not(feature = "std"), no_std)] + +use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; +use frame_support::{ + log, pallet_prelude::DispatchResult, weights::Weight, PalletError, RuntimeDebug, StorageHasher, + StorageValue, +}; +use frame_system::RawOrigin; +use scale_info::TypeInfo; +use sp_core::storage::StorageKey; +use sp_runtime::traits::{BadOrigin, Header as HeaderT, UniqueSaturatedInto}; +use sp_std::{convert::TryFrom, fmt::Debug, ops::RangeInclusive, vec, vec::Vec}; + +pub use chain::{ + AccountIdOf, AccountPublicOf, BalanceOf, BlockNumberOf, Chain, EncodedOrDecodedCall, HashOf, + HasherOf, HeaderOf, IndexOf, Parachain, ParachainIdOf, SignatureOf, TransactionEraOf, + UnderlyingChainOf, UnderlyingChainProvider, +}; +pub use frame_support::storage::storage_prefix as storage_value_final_key; +use num_traits::{CheckedAdd, CheckedSub, One, SaturatingAdd, Zero}; +pub use storage_proof::{ + record_all_keys as record_all_trie_keys, Error as StorageProofError, + ProofSize as StorageProofSize, RawStorageProof, StorageProofChecker, +}; +pub use storage_types::BoundedStorageValue; + +#[cfg(feature = "std")] +pub use storage_proof::craft_valid_storage_proof; + +pub mod extensions; +pub mod messages; + +mod chain; +mod storage_proof; +mod storage_types; + +// Re-export macro to aviod include paste dependency everywhere +pub use sp_runtime::paste; + +/// Use this when something must be shared among all instances. +pub const NO_INSTANCE_ID: ChainId = [0, 0, 0, 0]; + +/// Rialto chain id. +pub const RIALTO_CHAIN_ID: ChainId = *b"rlto"; + +/// RialtoParachain chain id. +pub const RIALTO_PARACHAIN_CHAIN_ID: ChainId = *b"rlpa"; + +/// Millau chain id. +pub const MILLAU_CHAIN_ID: ChainId = *b"mlau"; + +/// Polkadot chain id. +pub const POLKADOT_CHAIN_ID: ChainId = *b"pdot"; + +/// Kusama chain id. +pub const KUSAMA_CHAIN_ID: ChainId = *b"ksma"; + +/// Westend chain id. +pub const WESTEND_CHAIN_ID: ChainId = *b"wend"; + +/// AssetHubWestend chain id. +pub const ASSET_HUB_WESTEND_CHAIN_ID: ChainId = *b"ahwe"; + +/// Rococo chain id. +pub const ROCOCO_CHAIN_ID: ChainId = *b"roco"; + +/// Wococo chain id. +pub const WOCOCO_CHAIN_ID: ChainId = *b"woco"; + +/// BridgeHubRococo chain id. +pub const BRIDGE_HUB_ROCOCO_CHAIN_ID: ChainId = *b"bhro"; + +/// BridgeHubWococo chain id. +pub const BRIDGE_HUB_WOCOCO_CHAIN_ID: ChainId = *b"bhwo"; + +/// BridgeHubKusama chain id. +pub const BRIDGE_HUB_KUSAMA_CHAIN_ID: ChainId = *b"bhks"; + +/// BridgeHubPolkadot chain id. +pub const BRIDGE_HUB_POLKADOT_CHAIN_ID: ChainId = *b"bhpd"; + +/// Generic header Id. +#[derive( + RuntimeDebug, + Default, + Clone, + Encode, + Decode, + Copy, + Eq, + Hash, + MaxEncodedLen, + PartialEq, + PartialOrd, + Ord, + TypeInfo, +)] +pub struct HeaderId(pub Number, pub Hash); + +impl HeaderId { + /// Return header number. + pub fn number(&self) -> Number { + self.0 + } + + /// Return header hash. + pub fn hash(&self) -> Hash { + self.1 + } +} + +/// Header id used by the chain. +pub type HeaderIdOf = HeaderId, BlockNumberOf>; + +/// Generic header id provider. +pub trait HeaderIdProvider { + // Get the header id. + fn id(&self) -> HeaderId; + + // Get the header id for the parent block. + fn parent_id(&self) -> Option>; +} + +impl HeaderIdProvider
for Header { + fn id(&self) -> HeaderId { + HeaderId(*self.number(), self.hash()) + } + + fn parent_id(&self) -> Option> { + self.number() + .checked_sub(&One::one()) + .map(|parent_number| HeaderId(parent_number, *self.parent_hash())) + } +} + +/// Unique identifier of the chain. +/// +/// In addition to its main function (identifying the chain), this type may also be used to +/// identify module instance. We have a bunch of pallets that may be used in different bridges. E.g. +/// messages pallet may be deployed twice in the same runtime to bridge ThisChain with Chain1 and +/// Chain2. Sometimes we need to be able to identify deployed instance dynamically. This type may be +/// used for that. +pub type ChainId = [u8; 4]; + +/// Anything that has size. +pub trait Size { + /// Return size of this object (in bytes). + fn size(&self) -> u32; +} + +impl Size for () { + fn size(&self) -> u32 { + 0 + } +} + +impl Size for Vec { + fn size(&self) -> u32 { + self.len() as _ + } +} + +/// Pre-computed size. +pub struct PreComputedSize(pub usize); + +impl Size for PreComputedSize { + fn size(&self) -> u32 { + u32::try_from(self.0).unwrap_or(u32::MAX) + } +} + +/// Era of specific transaction. +#[derive(RuntimeDebug, Clone, Copy, PartialEq)] +pub enum TransactionEra { + /// Transaction is immortal. + Immortal, + /// Transaction is valid for a given number of blocks, starting from given block. + Mortal(HeaderId, u32), +} + +impl, BlockHash: Copy> + TransactionEra +{ + /// Prepare transaction era, based on mortality period and current best block number. + pub fn new( + best_block_id: HeaderId, + mortality_period: Option, + ) -> Self { + mortality_period + .map(|mortality_period| TransactionEra::Mortal(best_block_id, mortality_period)) + .unwrap_or(TransactionEra::Immortal) + } + + /// Create new immortal transaction era. + pub fn immortal() -> Self { + TransactionEra::Immortal + } + + /// Returns mortality period if transaction is mortal. + pub fn mortality_period(&self) -> Option { + match *self { + TransactionEra::Immortal => None, + TransactionEra::Mortal(_, period) => Some(period), + } + } + + /// Returns era that is used by FRAME-based runtimes. + pub fn frame_era(&self) -> sp_runtime::generic::Era { + match *self { + TransactionEra::Immortal => sp_runtime::generic::Era::immortal(), + // `unique_saturated_into` is fine here - mortality `u64::MAX` is not something we + // expect to see on any chain + TransactionEra::Mortal(header_id, period) => + sp_runtime::generic::Era::mortal(period as _, header_id.0.unique_saturated_into()), + } + } + + /// Returns header hash that needs to be included in the signature payload. + pub fn signed_payload(&self, genesis_hash: BlockHash) -> BlockHash { + match *self { + TransactionEra::Immortal => genesis_hash, + TransactionEra::Mortal(header_id, _) => header_id.1, + } + } +} + +/// This is a copy of the +/// `frame_support::storage::generator::StorageMap::storage_map_final_key` for maps based +/// on selected hasher. +/// +/// We're using it because to call `storage_map_final_key` directly, we need access to the runtime +/// and pallet instance, which (sometimes) is impossible. +pub fn storage_map_final_key( + pallet_prefix: &str, + map_name: &str, + key: &[u8], +) -> StorageKey { + let key_hashed = H::hash(key); + let pallet_prefix_hashed = frame_support::Twox128::hash(pallet_prefix.as_bytes()); + let storage_prefix_hashed = frame_support::Twox128::hash(map_name.as_bytes()); + + let mut final_key = Vec::with_capacity( + pallet_prefix_hashed.len() + storage_prefix_hashed.len() + key_hashed.as_ref().len(), + ); + + final_key.extend_from_slice(&pallet_prefix_hashed[..]); + final_key.extend_from_slice(&storage_prefix_hashed[..]); + final_key.extend_from_slice(key_hashed.as_ref()); + + StorageKey(final_key) +} + +/// This is how a storage key of storage parameter (`parameter_types! { storage Param: bool = false; +/// }`) is computed. +/// +/// Copied from `frame_support::parameter_types` macro. +pub fn storage_parameter_key(parameter_name: &str) -> StorageKey { + let mut buffer = Vec::with_capacity(1 + parameter_name.len() + 1); + buffer.push(b':'); + buffer.extend_from_slice(parameter_name.as_bytes()); + buffer.push(b':'); + StorageKey(sp_io::hashing::twox_128(&buffer).to_vec()) +} + +/// This is how a storage key of storage value is computed. +/// +/// Copied from `frame_support::storage::storage_prefix`. +pub fn storage_value_key(pallet_prefix: &str, value_name: &str) -> StorageKey { + let pallet_hash = sp_io::hashing::twox_128(pallet_prefix.as_bytes()); + let storage_hash = sp_io::hashing::twox_128(value_name.as_bytes()); + + let mut final_key = vec![0u8; 32]; + final_key[..16].copy_from_slice(&pallet_hash); + final_key[16..].copy_from_slice(&storage_hash); + + StorageKey(final_key) +} + +/// Can be use to access the runtime storage key of a `StorageMap`. +pub trait StorageMapKeyProvider { + /// The name of the variable that holds the `StorageMap`. + const MAP_NAME: &'static str; + + /// The same as `StorageMap::Hasher1`. + type Hasher: StorageHasher; + /// The same as `StorageMap::Key1`. + type Key: FullCodec; + /// The same as `StorageMap::Value`. + type Value: FullCodec; + + /// This is a copy of the + /// `frame_support::storage::generator::StorageMap::storage_map_final_key`. + /// + /// We're using it because to call `storage_map_final_key` directly, we need access + /// to the runtime and pallet instance, which (sometimes) is impossible. + fn final_key(pallet_prefix: &str, key: &Self::Key) -> StorageKey { + storage_map_final_key::(pallet_prefix, Self::MAP_NAME, &key.encode()) + } +} + +/// Can be use to access the runtime storage key of a `StorageDoubleMap`. +pub trait StorageDoubleMapKeyProvider { + /// The name of the variable that holds the `StorageDoubleMap`. + const MAP_NAME: &'static str; + + /// The same as `StorageDoubleMap::Hasher1`. + type Hasher1: StorageHasher; + /// The same as `StorageDoubleMap::Key1`. + type Key1: FullCodec; + /// The same as `StorageDoubleMap::Hasher2`. + type Hasher2: StorageHasher; + /// The same as `StorageDoubleMap::Key2`. + type Key2: FullCodec; + /// The same as `StorageDoubleMap::Value`. + type Value: FullCodec; + + /// This is a copy of the + /// `frame_support::storage::generator::StorageDoubleMap::storage_double_map_final_key`. + /// + /// We're using it because to call `storage_double_map_final_key` directly, we need access + /// to the runtime and pallet instance, which (sometimes) is impossible. + fn final_key(pallet_prefix: &str, key1: &Self::Key1, key2: &Self::Key2) -> StorageKey { + let key1_hashed = Self::Hasher1::hash(&key1.encode()); + let key2_hashed = Self::Hasher2::hash(&key2.encode()); + let pallet_prefix_hashed = frame_support::Twox128::hash(pallet_prefix.as_bytes()); + let storage_prefix_hashed = frame_support::Twox128::hash(Self::MAP_NAME.as_bytes()); + + let mut final_key = Vec::with_capacity( + pallet_prefix_hashed.len() + + storage_prefix_hashed.len() + + key1_hashed.as_ref().len() + + key2_hashed.as_ref().len(), + ); + + final_key.extend_from_slice(&pallet_prefix_hashed[..]); + final_key.extend_from_slice(&storage_prefix_hashed[..]); + final_key.extend_from_slice(key1_hashed.as_ref()); + final_key.extend_from_slice(key2_hashed.as_ref()); + + StorageKey(final_key) + } +} + +/// Error generated by the `OwnedBridgeModule` trait. +#[derive(Encode, Decode, TypeInfo, PalletError)] +pub enum OwnedBridgeModuleError { + /// All pallet operations are halted. + Halted, +} + +/// Operating mode for a bridge module. +pub trait OperatingMode: Send + Copy + Debug + FullCodec { + // Returns true if the bridge module is halted. + fn is_halted(&self) -> bool; +} + +/// Basic operating modes for a bridges module (Normal/Halted). +#[derive( + Encode, + Decode, + Clone, + Copy, + PartialEq, + Eq, + RuntimeDebug, + TypeInfo, + MaxEncodedLen, + serde::Serialize, + serde::Deserialize, +)] +pub enum BasicOperatingMode { + /// Normal mode, when all operations are allowed. + Normal, + /// The pallet is halted. All operations (except operating mode change) are prohibited. + Halted, +} + +impl Default for BasicOperatingMode { + fn default() -> Self { + Self::Normal + } +} + +impl OperatingMode for BasicOperatingMode { + fn is_halted(&self) -> bool { + *self == BasicOperatingMode::Halted + } +} + +/// Bridge module that has owner and operating mode +pub trait OwnedBridgeModule { + /// The target that will be used when publishing logs related to this module. + const LOG_TARGET: &'static str; + + type OwnerStorage: StorageValue>; + type OperatingMode: OperatingMode; + type OperatingModeStorage: StorageValue; + + /// Check if the module is halted. + fn is_halted() -> bool { + Self::OperatingModeStorage::get().is_halted() + } + + /// Ensure that the origin is either root, or `PalletOwner`. + fn ensure_owner_or_root(origin: T::RuntimeOrigin) -> Result<(), BadOrigin> { + match origin.into() { + Ok(RawOrigin::Root) => Ok(()), + Ok(RawOrigin::Signed(ref signer)) + if Self::OwnerStorage::get().as_ref() == Some(signer) => + Ok(()), + _ => Err(BadOrigin), + } + } + + /// Ensure that the module is not halted. + fn ensure_not_halted() -> Result<(), OwnedBridgeModuleError> { + match Self::is_halted() { + true => Err(OwnedBridgeModuleError::Halted), + false => Ok(()), + } + } + + /// Change the owner of the module. + fn set_owner(origin: T::RuntimeOrigin, maybe_owner: Option) -> DispatchResult { + Self::ensure_owner_or_root(origin)?; + match maybe_owner { + Some(owner) => { + Self::OwnerStorage::put(&owner); + log::info!(target: Self::LOG_TARGET, "Setting pallet Owner to: {:?}", owner); + }, + None => { + Self::OwnerStorage::kill(); + log::info!(target: Self::LOG_TARGET, "Removed Owner of pallet."); + }, + } + + Ok(()) + } + + /// Halt or resume all/some module operations. + fn set_operating_mode( + origin: T::RuntimeOrigin, + operating_mode: Self::OperatingMode, + ) -> DispatchResult { + Self::ensure_owner_or_root(origin)?; + Self::OperatingModeStorage::put(operating_mode); + log::info!(target: Self::LOG_TARGET, "Setting operating mode to {:?}.", operating_mode); + Ok(()) + } +} + +/// All extra operations with weights that we need in bridges. +pub trait WeightExtraOps { + /// Checked division of individual components of two weights. + /// + /// Divides components and returns minimal division result. Returns `None` if one + /// of `other` weight components is zero. + fn min_components_checked_div(&self, other: Weight) -> Option; +} + +impl WeightExtraOps for Weight { + fn min_components_checked_div(&self, other: Weight) -> Option { + Some(sp_std::cmp::min( + self.ref_time().checked_div(other.ref_time())?, + self.proof_size().checked_div(other.proof_size())?, + )) + } +} + +/// Trait that provides a static `str`. +pub trait StaticStrProvider { + const STR: &'static str; +} + +#[macro_export] +macro_rules! generate_static_str_provider { + ($str:expr) => { + $crate::paste::item! { + pub struct []; + + impl $crate::StaticStrProvider for [] { + const STR: &'static str = stringify!($str); + } + } + }; +} + +#[derive(Encode, Decode, Clone, Eq, PartialEq, PalletError, TypeInfo)] +#[scale_info(skip_type_params(T))] +pub struct StrippableError { + _phantom_data: sp_std::marker::PhantomData, + #[codec(skip)] + #[cfg(feature = "std")] + message: String, +} + +impl From for StrippableError { + fn from(_err: T) -> Self { + Self { + _phantom_data: Default::default(), + #[cfg(feature = "std")] + message: format!("{:?}", _err), + } + } +} + +impl Debug for StrippableError { + #[cfg(feature = "std")] + fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { + f.write_str(&self.message) + } + + #[cfg(not(feature = "std"))] + fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { + f.write_str("Stripped error") + } +} + +/// A trait defining helper methods for `RangeInclusive` (start..=end) +pub trait RangeInclusiveExt { + /// Computes the length of the `RangeInclusive`, checking for underflow and overflow. + fn checked_len(&self) -> Option; + /// Computes the length of the `RangeInclusive`, saturating in case of underflow or overflow. + fn saturating_len(&self) -> Idx; +} + +impl RangeInclusiveExt for RangeInclusive +where + Idx: CheckedSub + CheckedAdd + SaturatingAdd + One + Zero, +{ + fn checked_len(&self) -> Option { + self.end() + .checked_sub(self.start()) + .and_then(|len| len.checked_add(&Idx::one())) + } + + fn saturating_len(&self) -> Idx { + let len = match self.end().checked_sub(self.start()) { + Some(len) => len, + None => return Idx::zero(), + }; + len.saturating_add(&Idx::one()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn storage_parameter_key_works() { + assert_eq!( + storage_parameter_key("MillauToRialtoConversionRate"), + StorageKey(hex_literal::hex!("58942375551bb0af1682f72786b59d04").to_vec()), + ); + } + + #[test] + fn storage_value_key_works() { + assert_eq!( + storage_value_key("PalletTransactionPayment", "NextFeeMultiplier"), + StorageKey( + hex_literal::hex!( + "f0e954dfcca51a255ab12c60c789256a3f2edf3bdf381debe331ab7446addfdc" + ) + .to_vec() + ), + ); + } + + #[test] + fn generate_static_str_provider_works() { + generate_static_str_provider!(Test); + assert_eq!(StrTest::STR, "Test"); + } +} diff --git a/bridges/primitives/runtime/src/messages.rs b/bridges/primitives/runtime/src/messages.rs new file mode 100644 index 00000000000..9f7c8ab5ca4 --- /dev/null +++ b/bridges/primitives/runtime/src/messages.rs @@ -0,0 +1,35 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Primitives that may be used by different message delivery and dispatch mechanisms. + +use codec::{Decode, Encode}; +use frame_support::{weights::Weight, RuntimeDebug}; +use scale_info::TypeInfo; + +/// Message dispatch result. +#[derive(Encode, Decode, RuntimeDebug, Clone, PartialEq, Eq, TypeInfo)] +pub struct MessageDispatchResult { + /// Unspent dispatch weight. This weight that will be deducted from total delivery transaction + /// weight, thus reducing the transaction cost. This shall not be zero in (at least) two cases: + /// + /// 1) if message has been dispatched successfully, but post-dispatch weight is less than + /// the weight, declared by the message sender; + /// 2) if message has not been dispatched at all. + pub unspent_weight: Weight, + /// Fine-grained result of single message dispatch (for better diagnostic purposes) + pub dispatch_level_result: DispatchLevelResult, +} diff --git a/bridges/primitives/runtime/src/storage_proof.rs b/bridges/primitives/runtime/src/storage_proof.rs new file mode 100644 index 00000000000..09641376666 --- /dev/null +++ b/bridges/primitives/runtime/src/storage_proof.rs @@ -0,0 +1,272 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Logic for checking Substrate storage proofs. + +use crate::StrippableError; +use codec::{Decode, Encode}; +use frame_support::PalletError; +use hash_db::{HashDB, Hasher, EMPTY_PREFIX}; +use scale_info::TypeInfo; +use sp_std::{boxed::Box, collections::btree_set::BTreeSet, vec::Vec}; +use sp_trie::{ + read_trie_value, LayoutV1, MemoryDB, Recorder, StorageProof, Trie, TrieConfiguration, + TrieDBBuilder, TrieError, TrieHash, +}; + +/// Raw storage proof type (just raw trie nodes). +pub type RawStorageProof = Vec>; + +/// Storage proof size requirements. +/// +/// This is currently used by benchmarks when generating storage proofs. +#[derive(Clone, Copy, Debug)] +pub enum ProofSize { + /// The proof is expected to be minimal. If value size may be changed, then it is expected to + /// have given size. + Minimal(u32), + /// The proof is expected to have at least given size and grow by increasing value that is + /// stored in the trie. + HasLargeLeaf(u32), +} + +/// This struct is used to read storage values from a subset of a Merklized database. The "proof" +/// is a subset of the nodes in the Merkle structure of the database, so that it provides +/// authentication against a known Merkle root as well as the values in the +/// database themselves. +pub struct StorageProofChecker +where + H: Hasher, +{ + proof_nodes_count: usize, + root: H::Out, + db: MemoryDB, + recorder: Recorder>, +} + +impl StorageProofChecker +where + H: Hasher, +{ + /// Constructs a new storage proof checker. + /// + /// This returns an error if the given proof is invalid with respect to the given root. + pub fn new(root: H::Out, proof: RawStorageProof) -> Result { + // 1. we don't want extra items in the storage proof + // 2. `StorageProof` is storing all trie nodes in the `BTreeSet` + // + // => someone could simply add duplicate items to the proof and we won't be + // able to detect that by just using `StorageProof` + // + // => let's check it when we are converting our "raw proof" into `StorageProof` + let proof_nodes_count = proof.len(); + let proof = StorageProof::new(proof); + if proof_nodes_count != proof.iter_nodes().count() { + return Err(Error::DuplicateNodesInProof) + } + + let db = proof.into_memory_db(); + if !db.contains(&root, EMPTY_PREFIX) { + return Err(Error::StorageRootMismatch) + } + + let recorder = Recorder::default(); + let checker = StorageProofChecker { proof_nodes_count, root, db, recorder }; + Ok(checker) + } + + /// Returns error if the proof has some nodes that are left intact by previous `read_value` + /// calls. + pub fn ensure_no_unused_nodes(mut self) -> Result<(), Error> { + let visited_nodes = self + .recorder + .drain() + .into_iter() + .map(|record| record.data) + .collect::>(); + let visited_nodes_count = visited_nodes.len(); + if self.proof_nodes_count == visited_nodes_count { + Ok(()) + } else { + Err(Error::UnusedNodesInTheProof) + } + } + + /// Reads a value from the available subset of storage. If the value cannot be read due to an + /// incomplete or otherwise invalid proof, this function returns an error. + pub fn read_value(&mut self, key: &[u8]) -> Result>, Error> { + // LayoutV1 or LayoutV0 is identical for proof that only read values. + read_trie_value::, _>(&self.db, &self.root, key, Some(&mut self.recorder), None) + .map_err(|_| Error::StorageValueUnavailable) + } + + /// Reads and decodes a value from the available subset of storage. If the value cannot be read + /// due to an incomplete or otherwise invalid proof, this function returns an error. If value is + /// read, but decoding fails, this function returns an error. + pub fn read_and_decode_value(&mut self, key: &[u8]) -> Result, Error> { + self.read_value(key).and_then(|v| { + v.map(|v| T::decode(&mut &v[..]).map_err(|e| Error::StorageValueDecodeFailed(e.into()))) + .transpose() + }) + } + + /// Reads and decodes a value from the available subset of storage. If the value cannot be read + /// due to an incomplete or otherwise invalid proof, or if the value is `None`, this function + /// returns an error. If value is read, but decoding fails, this function returns an error. + pub fn read_and_decode_mandatory_value(&mut self, key: &[u8]) -> Result { + self.read_and_decode_value(key)?.ok_or(Error::StorageValueEmpty) + } + + /// Reads and decodes a value from the available subset of storage. If the value cannot be read + /// due to an incomplete or otherwise invalid proof, this function returns `Ok(None)`. + /// If value is read, but decoding fails, this function returns an error. + pub fn read_and_decode_opt_value(&mut self, key: &[u8]) -> Result, Error> { + match self.read_and_decode_value(key) { + Ok(outbound_lane_data) => Ok(outbound_lane_data), + Err(Error::StorageValueUnavailable) => Ok(None), + Err(e) => Err(e), + } + } +} + +/// Storage proof related errors. +#[derive(Encode, Decode, Clone, Eq, PartialEq, PalletError, Debug, TypeInfo)] +pub enum Error { + /// Duplicate trie nodes are found in the proof. + DuplicateNodesInProof, + /// Unused trie nodes are found in the proof. + UnusedNodesInTheProof, + /// Expected storage root is missing from the proof. + StorageRootMismatch, + /// Unable to reach expected storage value using provided trie nodes. + StorageValueUnavailable, + /// The storage value is `None`. + StorageValueEmpty, + /// Failed to decode storage value. + StorageValueDecodeFailed(StrippableError), +} + +/// Return valid storage proof and state root. +/// +/// NOTE: This should only be used for **testing**. +#[cfg(feature = "std")] +pub fn craft_valid_storage_proof() -> (sp_core::H256, RawStorageProof) { + use sp_state_machine::{backend::Backend, prove_read, InMemoryBackend}; + + let state_version = sp_runtime::StateVersion::default(); + + // construct storage proof + let backend = >::from(( + vec![ + (None, vec![(b"key1".to_vec(), Some(b"value1".to_vec()))]), + (None, vec![(b"key2".to_vec(), Some(b"value2".to_vec()))]), + (None, vec![(b"key3".to_vec(), Some(b"value3".to_vec()))]), + (None, vec![(b"key4".to_vec(), Some((42u64, 42u32, 42u16, 42u8).encode()))]), + // Value is too big to fit in a branch node + (None, vec![(b"key11".to_vec(), Some(vec![0u8; 32]))]), + ], + state_version, + )); + let root = backend.storage_root(std::iter::empty(), state_version).0; + let proof = + prove_read(backend, &[&b"key1"[..], &b"key2"[..], &b"key4"[..], &b"key22"[..]]).unwrap(); + + (root, proof.into_nodes().into_iter().collect()) +} + +/// Record all keys for a given root. +pub fn record_all_keys( + db: &DB, + root: &TrieHash, +) -> Result>> +where + DB: hash_db::HashDBRef, +{ + let mut recorder = Recorder::::new(); + let trie = TrieDBBuilder::::new(db, root).with_recorder(&mut recorder).build(); + for x in trie.iter()? { + let (key, _) = x?; + trie.get(&key)?; + } + + // recorder may record the same trie node multiple times and we don't want duplicate nodes + // in our proofs => let's deduplicate it by collecting to the BTreeSet first + Ok(recorder + .drain() + .into_iter() + .map(|n| n.data.to_vec()) + .collect::>() + .into_iter() + .collect()) +} + +#[cfg(test)] +pub mod tests { + use super::*; + use codec::Encode; + + #[test] + fn storage_proof_check() { + let (root, proof) = craft_valid_storage_proof(); + + // check proof in runtime + let mut checker = + >::new(root, proof.clone()).unwrap(); + assert_eq!(checker.read_value(b"key1"), Ok(Some(b"value1".to_vec()))); + assert_eq!(checker.read_value(b"key2"), Ok(Some(b"value2".to_vec()))); + assert_eq!(checker.read_value(b"key4"), Ok(Some((42u64, 42u32, 42u16, 42u8).encode()))); + assert_eq!(checker.read_value(b"key11111"), Err(Error::StorageValueUnavailable)); + assert_eq!(checker.read_value(b"key22"), Ok(None)); + assert_eq!(checker.read_and_decode_value(b"key4"), Ok(Some((42u64, 42u32, 42u16, 42u8))),); + assert!(matches!( + checker.read_and_decode_value::<[u8; 64]>(b"key4"), + Err(Error::StorageValueDecodeFailed(_)), + )); + + // checking proof against invalid commitment fails + assert_eq!( + >::new(sp_core::H256::random(), proof).err(), + Some(Error::StorageRootMismatch) + ); + } + + #[test] + fn proof_with_duplicate_items_is_rejected() { + let (root, mut proof) = craft_valid_storage_proof(); + proof.push(proof.first().unwrap().clone()); + + assert_eq!( + StorageProofChecker::::new(root, proof).map(drop), + Err(Error::DuplicateNodesInProof), + ); + } + + #[test] + fn proof_with_unused_items_is_rejected() { + let (root, proof) = craft_valid_storage_proof(); + + let mut checker = + StorageProofChecker::::new(root, proof.clone()).unwrap(); + checker.read_value(b"key1").unwrap(); + checker.read_value(b"key2").unwrap(); + checker.read_value(b"key4").unwrap(); + checker.read_value(b"key22").unwrap(); + assert_eq!(checker.ensure_no_unused_nodes(), Ok(())); + + let checker = StorageProofChecker::::new(root, proof).unwrap(); + assert_eq!(checker.ensure_no_unused_nodes(), Err(Error::UnusedNodesInTheProof)); + } +} diff --git a/bridges/primitives/runtime/src/storage_types.rs b/bridges/primitives/runtime/src/storage_types.rs new file mode 100644 index 00000000000..b37f779d00b --- /dev/null +++ b/bridges/primitives/runtime/src/storage_types.rs @@ -0,0 +1,90 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Wrapper for a runtime storage value that checks if value exceeds given maximum +//! during conversion. + +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::{traits::Get, RuntimeDebug}; +use scale_info::{Type, TypeInfo}; +use sp_std::{marker::PhantomData, ops::Deref}; + +/// Error that is returned when the value size exceeds maximal configured size. +#[derive(RuntimeDebug)] +pub struct MaximalSizeExceededError { + /// Size of the value. + pub value_size: usize, + /// Maximal configured size. + pub maximal_size: usize, +} + +/// A bounded runtime storage value. +#[derive(Clone, Decode, Encode, Eq, PartialEq)] +pub struct BoundedStorageValue { + value: V, + _phantom: PhantomData, +} + +impl sp_std::fmt::Debug for BoundedStorageValue { + fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + self.value.fmt(fmt) + } +} + +impl, V: Encode> BoundedStorageValue { + /// Construct `BoundedStorageValue` from the underlying `value` with all required checks. + /// + /// Returns error if value size exceeds given bounds. + pub fn try_from_inner(value: V) -> Result { + // this conversion is heavy (since we do encoding here), so we may want to optimize it later + // (e.g. by introducing custom Encode implementation, and turning `BoundedStorageValue` into + // `enum BoundedStorageValue { Decoded(V), Encoded(Vec) }`) + let value_size = value.encoded_size(); + let maximal_size = B::get() as usize; + if value_size > maximal_size { + Err(MaximalSizeExceededError { value_size, maximal_size }) + } else { + Ok(BoundedStorageValue { value, _phantom: Default::default() }) + } + } + + /// Convert into the inner type + pub fn into_inner(self) -> V { + self.value + } +} + +impl Deref for BoundedStorageValue { + type Target = V; + + fn deref(&self) -> &Self::Target { + &self.value + } +} + +impl TypeInfo for BoundedStorageValue { + type Identity = Self; + + fn type_info() -> Type { + V::type_info() + } +} + +impl, V: Encode> MaxEncodedLen for BoundedStorageValue { + fn max_encoded_len() -> usize { + B::get() as usize + } +} diff --git a/bridges/primitives/test-utils/Cargo.toml b/bridges/primitives/test-utils/Cargo.toml new file mode 100644 index 00000000000..2e2af99332e --- /dev/null +++ b/bridges/primitives/test-utils/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "bp-test-utils" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +bp-header-chain = { path = "../header-chain", default-features = false } +bp-parachains = { path = "../parachains", default-features = false } +bp-polkadot-core = { path = "../polkadot-core", default-features = false } +bp-runtime = { path = "../runtime", default-features = false } +codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false } +ed25519-dalek = { version = "1.0", default-features = false, features = ["u64_backend"] } +finality-grandpa = { version = "0.16.2", default-features = false } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } + +[features] +default = ["std"] +std = [ + "bp-header-chain/std", + "bp-polkadot-core/std", + "codec/std", + "ed25519-dalek/std", + "finality-grandpa/std", + "sp-application-crypto/std", + "sp-consensus-grandpa/std", + "sp-core/std", + "sp-runtime/std", + "sp-std/std", +] diff --git a/bridges/primitives/test-utils/src/keyring.rs b/bridges/primitives/test-utils/src/keyring.rs new file mode 100644 index 00000000000..b1782109668 --- /dev/null +++ b/bridges/primitives/test-utils/src/keyring.rs @@ -0,0 +1,94 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Utilities for working with test accounts. + +use codec::Encode; +use ed25519_dalek::{Keypair, PublicKey, SecretKey, Signature}; +use finality_grandpa::voter_set::VoterSet; +use sp_consensus_grandpa::{AuthorityId, AuthorityList, AuthorityWeight}; +use sp_runtime::RuntimeDebug; +use sp_std::prelude::*; + +/// Set of test accounts with friendly names. +pub const ALICE: Account = Account(0); +pub const BOB: Account = Account(1); +pub const CHARLIE: Account = Account(2); +pub const DAVE: Account = Account(3); +pub const EVE: Account = Account(4); +pub const FERDIE: Account = Account(5); + +/// A test account which can be used to sign messages. +#[derive(RuntimeDebug, Clone, Copy)] +pub struct Account(pub u16); + +impl Account { + pub fn public(&self) -> PublicKey { + (&self.secret()).into() + } + + pub fn secret(&self) -> SecretKey { + let data = self.0.encode(); + let mut bytes = [0_u8; 32]; + bytes[0..data.len()].copy_from_slice(&data); + SecretKey::from_bytes(&bytes) + .expect("A static array of the correct length is a known good.") + } + + pub fn pair(&self) -> Keypair { + let mut pair: [u8; 64] = [0; 64]; + + let secret = self.secret(); + pair[..32].copy_from_slice(&secret.to_bytes()); + + let public = self.public(); + pair[32..].copy_from_slice(&public.to_bytes()); + + Keypair::from_bytes(&pair) + .expect("We expect the SecretKey to be good, so this must also be good.") + } + + pub fn sign(&self, msg: &[u8]) -> Signature { + use ed25519_dalek::Signer; + self.pair().sign(msg) + } +} + +impl From for AuthorityId { + fn from(p: Account) -> Self { + sp_application_crypto::UncheckedFrom::unchecked_from(p.public().to_bytes()) + } +} + +/// Get a valid set of voters for a Grandpa round. +pub fn voter_set() -> VoterSet { + VoterSet::new(authority_list()).unwrap() +} + +/// Convenience function to get a list of Grandpa authorities. +pub fn authority_list() -> AuthorityList { + test_keyring().iter().map(|(id, w)| (AuthorityId::from(*id), *w)).collect() +} + +/// Get the corresponding identities from the keyring for the "standard" authority set. +pub fn test_keyring() -> Vec<(Account, AuthorityWeight)> { + vec![(ALICE, 1), (BOB, 1), (CHARLIE, 1)] +} + +/// Get a list of "unique" accounts. +pub fn accounts(len: u16) -> Vec { + (0..len).map(Account).collect() +} diff --git a/bridges/primitives/test-utils/src/lib.rs b/bridges/primitives/test-utils/src/lib.rs new file mode 100644 index 00000000000..5a7d0cca279 --- /dev/null +++ b/bridges/primitives/test-utils/src/lib.rs @@ -0,0 +1,343 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Parity Bridges Common. + +// Parity Bridges Common 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. + +// Parity Bridges Common 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 Parity Bridges Common. If not, see . + +//! Utilities for testing runtime code. + +#![cfg_attr(not(feature = "std"), no_std)] + +use bp_header_chain::justification::{required_justification_precommits, GrandpaJustification}; +use bp_parachains::parachain_head_storage_key_at_source; +use bp_polkadot_core::parachains::{ParaHash, ParaHead, ParaHeadsProof, ParaId}; +use bp_runtime::record_all_trie_keys; +use codec::Encode; +use sp_consensus_grandpa::{AuthorityId, AuthoritySignature, AuthorityWeight, SetId}; +use sp_runtime::traits::{Header as HeaderT, One, Zero}; +use sp_std::prelude::*; +use sp_trie::{trie_types::TrieDBMutBuilderV1, LayoutV1, MemoryDB, TrieMut}; + +// Re-export all our test account utilities +pub use keyring::*; + +mod keyring; + +pub const TEST_GRANDPA_ROUND: u64 = 1; +pub const TEST_GRANDPA_SET_ID: SetId = 1; +pub const PARAS_PALLET_NAME: &str = "Paras"; + +/// Configuration parameters when generating test GRANDPA justifications. +#[derive(Clone)] +pub struct JustificationGeneratorParams { + /// The header which we want to finalize. + pub header: H, + /// The GRANDPA round number for the current authority set. + pub round: u64, + /// The current authority set ID. + pub set_id: SetId, + /// The current GRANDPA authority set. + /// + /// The size of the set will determine the number of pre-commits in our justification. + pub authorities: Vec<(Account, AuthorityWeight)>, + /// The total number of precommit ancestors in the `votes_ancestries` field our justification. + /// + /// These may be distributed among many forks. + pub ancestors: u32, + /// The number of forks. + /// + /// Useful for creating a "worst-case" scenario in which each authority is on its own fork. + pub forks: u32, +} + +impl Default for JustificationGeneratorParams { + fn default() -> Self { + let required_signatures = required_justification_precommits(test_keyring().len() as _); + Self { + header: test_header(One::one()), + round: TEST_GRANDPA_ROUND, + set_id: TEST_GRANDPA_SET_ID, + authorities: test_keyring().into_iter().take(required_signatures as _).collect(), + ancestors: 2, + forks: 1, + } + } +} + +/// Make a valid GRANDPA justification with sensible defaults +pub fn make_default_justification(header: &H) -> GrandpaJustification { + let params = JustificationGeneratorParams:: { header: header.clone(), ..Default::default() }; + + make_justification_for_header(params) +} + +/// Generate justifications in a way where we are able to tune the number of pre-commits +/// and vote ancestries which are included in the justification. +/// +/// This is useful for benchmarkings where we want to generate valid justifications with +/// a specific number of pre-commits (tuned with the number of "authorities") and/or a specific +/// number of vote ancestries (tuned with the "votes" parameter). +/// +/// Note: This needs at least three authorities or else the verifier will complain about +/// being given an invalid commit. +pub fn make_justification_for_header( + params: JustificationGeneratorParams, +) -> GrandpaJustification { + let JustificationGeneratorParams { header, round, set_id, authorities, mut ancestors, forks } = + params; + let (target_hash, target_number) = (header.hash(), *header.number()); + let mut votes_ancestries = vec![]; + let mut precommits = vec![]; + + assert!(forks != 0, "Need at least one fork to have a chain.."); + assert!( + forks as usize <= authorities.len(), + "If we have more forks than authorities we can't create valid pre-commits for all the forks." + ); + + // Roughly, how many vote ancestries do we want per fork + let target_depth = (ancestors + forks - 1) / forks; + + let mut unsigned_precommits = vec![]; + for i in 0..forks { + let depth = if ancestors >= target_depth { + ancestors -= target_depth; + target_depth + } else { + ancestors + }; + + // Note: Adding 1 to account for the target header + let chain = generate_chain(i, depth + 1, &header); + + // We don't include our finality target header in the vote ancestries + for child in &chain[1..] { + votes_ancestries.push(child.clone()); + } + + // The header we need to use when pre-commiting is the one at the highest height + // on our chain. + let precommit_candidate = chain.last().map(|h| (h.hash(), *h.number())).unwrap(); + unsigned_precommits.push(precommit_candidate); + } + + for (i, (id, _weight)) in authorities.iter().enumerate() { + // Assign authorities to sign pre-commits in a round-robin fashion + let target = unsigned_precommits[i % forks as usize]; + let precommit = signed_precommit::(id, target, round, set_id); + + precommits.push(precommit); + } + + GrandpaJustification { + round, + commit: finality_grandpa::Commit { target_hash, target_number, precommits }, + votes_ancestries, + } +} + +fn generate_chain(fork_id: u32, depth: u32, ancestor: &H) -> Vec { + let mut headers = vec![ancestor.clone()]; + + for i in 1..depth { + let parent = &headers[(i - 1) as usize]; + let (hash, num) = (parent.hash(), *parent.number()); + + let mut header = test_header::(num + One::one()); + header.set_parent_hash(hash); + + // Modifying the digest so headers at the same height but in different forks have different + // hashes + header.digest_mut().logs.push(sp_runtime::DigestItem::Other(fork_id.encode())); + + headers.push(header); + } + + headers +} + +/// Make valid proof for parachain `heads` +pub fn prepare_parachain_heads_proof( + heads: Vec<(u32, ParaHead)>, +) -> (H::Hash, ParaHeadsProof, Vec<(ParaId, ParaHash)>) { + let mut parachains = Vec::with_capacity(heads.len()); + let mut root = Default::default(); + let mut mdb = MemoryDB::default(); + { + let mut trie = TrieDBMutBuilderV1::::new(&mut mdb, &mut root).build(); + for (parachain, head) in heads { + let storage_key = + parachain_head_storage_key_at_source(PARAS_PALLET_NAME, ParaId(parachain)); + trie.insert(&storage_key.0, &head.encode()) + .map_err(|_| "TrieMut::insert has failed") + .expect("TrieMut::insert should not fail in tests"); + parachains.push((ParaId(parachain), head.hash())); + } + } + + // generate storage proof to be delivered to This chain + let storage_proof = record_all_trie_keys::, _>(&mdb, &root) + .map_err(|_| "record_all_trie_keys has failed") + .expect("record_all_trie_keys should not fail in benchmarks"); + + (root, ParaHeadsProof(storage_proof), parachains) +} + +/// Create signed precommit with given target. +pub fn signed_precommit( + signer: &Account, + target: (H::Hash, H::Number), + round: u64, + set_id: SetId, +) -> finality_grandpa::SignedPrecommit { + let precommit = finality_grandpa::Precommit { target_hash: target.0, target_number: target.1 }; + + let encoded = sp_consensus_grandpa::localized_payload( + round, + set_id, + &finality_grandpa::Message::Precommit(precommit.clone()), + ); + + let signature = signer.sign(&encoded); + let raw_signature: Vec = signature.to_bytes().into(); + + // Need to wrap our signature and id types that they match what our `SignedPrecommit` is + // expecting + let signature = AuthoritySignature::try_from(raw_signature).expect( + "We know our Keypair is good, + so our signature must also be good.", + ); + let id = (*signer).into(); + + finality_grandpa::SignedPrecommit { precommit, signature, id } +} + +/// Get a header for testing. +/// +/// The correct parent hash will be used if given a non-zero header. +pub fn test_header(number: H::Number) -> H { + let default = |num| { + H::new(num, Default::default(), Default::default(), Default::default(), Default::default()) + }; + + let mut header = default(number); + if number != Zero::zero() { + let parent_hash = default(number - One::one()).hash(); + header.set_parent_hash(parent_hash); + } + + header +} + +/// Get a header for testing with given `state_root`. +/// +/// The correct parent hash will be used if given a non-zero header. +pub fn test_header_with_root(number: H::Number, state_root: H::Hash) -> H { + let mut header: H = test_header(number); + header.set_state_root(state_root); + header +} + +/// Convenience function for generating a Header ID at a given block number. +pub fn header_id(index: u8) -> (H::Hash, H::Number) { + (test_header::(index.into()).hash(), index.into()) +} + +#[macro_export] +/// Adds methods for testing the `set_owner()` and `set_operating_mode()` for a pallet. +/// Some values are hardcoded like: +/// - `run_test()` +/// - `Pallet::` +/// - `PalletOwner::` +/// - `PalletOperatingMode::` +/// While this is not ideal, all the pallets use the same names, so it works for the moment. +/// We can revisit this in the future if anything changes. +macro_rules! generate_owned_bridge_module_tests { + ($normal_operating_mode: expr, $halted_operating_mode: expr) => { + #[test] + fn test_set_owner() { + run_test(|| { + PalletOwner::::put(1); + + // The root should be able to change the owner. + assert_ok!(Pallet::::set_owner(RuntimeOrigin::root(), Some(2))); + assert_eq!(PalletOwner::::get(), Some(2)); + + // The owner should be able to change the owner. + assert_ok!(Pallet::::set_owner(RuntimeOrigin::signed(2), Some(3))); + assert_eq!(PalletOwner::::get(), Some(3)); + + // Other users shouldn't be able to change the owner. + assert_noop!( + Pallet::::set_owner(RuntimeOrigin::signed(1), Some(4)), + DispatchError::BadOrigin + ); + assert_eq!(PalletOwner::::get(), Some(3)); + }); + } + + #[test] + fn test_set_operating_mode() { + run_test(|| { + PalletOwner::::put(1); + PalletOperatingMode::::put($normal_operating_mode); + + // The root should be able to halt the pallet. + assert_ok!(Pallet::::set_operating_mode( + RuntimeOrigin::root(), + $halted_operating_mode + )); + assert_eq!(PalletOperatingMode::::get(), $halted_operating_mode); + // The root should be able to resume the pallet. + assert_ok!(Pallet::::set_operating_mode( + RuntimeOrigin::root(), + $normal_operating_mode + )); + assert_eq!(PalletOperatingMode::::get(), $normal_operating_mode); + + // The owner should be able to halt the pallet. + assert_ok!(Pallet::::set_operating_mode( + RuntimeOrigin::signed(1), + $halted_operating_mode + )); + assert_eq!(PalletOperatingMode::::get(), $halted_operating_mode); + // The owner should be able to resume the pallet. + assert_ok!(Pallet::::set_operating_mode( + RuntimeOrigin::signed(1), + $normal_operating_mode + )); + assert_eq!(PalletOperatingMode::::get(), $normal_operating_mode); + + // Other users shouldn't be able to halt the pallet. + assert_noop!( + Pallet::::set_operating_mode( + RuntimeOrigin::signed(2), + $halted_operating_mode + ), + DispatchError::BadOrigin + ); + assert_eq!(PalletOperatingMode::::get(), $normal_operating_mode); + // Other users shouldn't be able to resume the pallet. + PalletOperatingMode::::put($halted_operating_mode); + assert_noop!( + Pallet::::set_operating_mode( + RuntimeOrigin::signed(2), + $normal_operating_mode + ), + DispatchError::BadOrigin + ); + assert_eq!(PalletOperatingMode::::get(), $halted_operating_mode); + }); + } + }; +} diff --git a/bridges/rustfmt.toml b/bridges/rustfmt.toml new file mode 100644 index 00000000000..082150daf04 --- /dev/null +++ b/bridges/rustfmt.toml @@ -0,0 +1,24 @@ +# Basic +hard_tabs = true +max_width = 100 +use_small_heuristics = "Max" +# Imports +imports_granularity = "Crate" +reorder_imports = true +# Consistency +newline_style = "Unix" +# Format comments +comment_width = 100 +wrap_comments = true +# Misc +chain_width = 80 +spaces_around_ranges = false +binop_separator = "Back" +reorder_impl_items = false +match_arm_leading_pipes = "Preserve" +match_arm_blocks = false +match_block_trailing_comma = true +trailing_comma = "Vertical" +trailing_semicolon = false +use_field_init_shorthand = true + diff --git a/bridges/scripts/verify-pallets-build.sh b/bridges/scripts/verify-pallets-build.sh new file mode 100755 index 00000000000..2230d68a9c4 --- /dev/null +++ b/bridges/scripts/verify-pallets-build.sh @@ -0,0 +1,136 @@ +#!/bin/bash + +# A script to remove everything from bridges repository/subtree, except: +# +# - modules/grandpa; +# - modules/messages; +# - modules/parachains; +# - modules/relayers; +# - everything required from primitives folder. + +set -eux + +# show CLI help +function show_help() { + set +x + echo " " + echo Error: $1 + echo "Usage:" + echo " ./scripts/verify-pallets-build.sh Exit with code 0 if pallets code is well decoupled from the other code in the repo" + echo "Options:" + echo " --no-revert Leaves only runtime code on exit" + echo " --ignore-git-state Ignores git actual state" + exit 1 +} + +# parse CLI args +NO_REVERT= +IGNORE_GIT_STATE= +for i in "$@" +do + case $i in + --no-revert) + NO_REVERT=true + shift + ;; + --ignore-git-state) + IGNORE_GIT_STATE=true + shift + ;; + *) + show_help "Unknown option: $i" + ;; + esac +done + +# the script is able to work only on clean git copy, unless we want to ignore this check +[[ ! -z "${IGNORE_GIT_STATE}" ]] || [[ -z "$(git status --porcelain)" ]] || { echo >&2 "The git copy must be clean"; exit 1; } + +# let's avoid any restrictions on where this script can be called for - bridges repo may be +# plugged into any other repo folder. So the script (and other stuff that needs to be removed) +# may be located either in call dir, or one of it subdirs. +BRIDGES_FOLDER="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/.." + +# let's leave repository/subtree in its original (clean) state if something fails below +function revert_to_clean_state { + [[ ! -z "${NO_REVERT}" ]] || { echo "Reverting to clean state..."; git checkout .; } +} +trap revert_to_clean_state EXIT + +# remove everything we think is not required for our needs +rm -rf $BRIDGES_FOLDER/.config +rm -rf $BRIDGES_FOLDER/.github +rm -rf $BRIDGES_FOLDER/.maintain +rm -rf $BRIDGES_FOLDER/bin/millau +rm -rf $BRIDGES_FOLDER/bin/rialto +rm -rf $BRIDGES_FOLDER/bin/rialto-parachain +rm -rf $BRIDGES_FOLDER/bin/.keep +rm -rf $BRIDGES_FOLDER/deployments +rm -f $BRIDGES_FOLDER/docs/dockerhub-* +rm -rf $BRIDGES_FOLDER/fuzz +rm -rf $BRIDGES_FOLDER/modules/beefy +rm -rf $BRIDGES_FOLDER/modules/shift-session-manager +rm -rf $BRIDGES_FOLDER/primitives/beefy +rm -rf $BRIDGES_FOLDER/primitives/chain-millau +rm -rf $BRIDGES_FOLDER/primitives/chain-rialto +rm -rf $BRIDGES_FOLDER/primitives/chain-rialto-parachain +rm -rf $BRIDGES_FOLDER/primitives/chain-westend +rm -rf $BRIDGES_FOLDER/relays +rm -rf $BRIDGES_FOLDER/scripts/add_license.sh +rm -rf $BRIDGES_FOLDER/scripts/build-containers.sh +rm -rf $BRIDGES_FOLDER/scripts/ci-cache.sh +rm -rf $BRIDGES_FOLDER/scripts/dump-logs.sh +rm -rf $BRIDGES_FOLDER/scripts/license_header +rm -rf $BRIDGES_FOLDER/scripts/regenerate_runtimes.sh +rm -rf $BRIDGES_FOLDER/scripts/send-message-from-millau-rialto.sh +rm -rf $BRIDGES_FOLDER/scripts/send-message-from-rialto-millau.sh +rm -rf $BRIDGES_FOLDER/scripts/update-weights.sh +rm -rf $BRIDGES_FOLDER/scripts/update-weights-setup.sh +rm -rf $BRIDGES_FOLDER/scripts/update_substrate.sh +rm -rf $BRIDGES_FOLDER/tools +rm -f $BRIDGES_FOLDER/.dockerignore +rm -f $BRIDGES_FOLDER/deny.toml +rm -f $BRIDGES_FOLDER/.gitlab-ci.yml +rm -f $BRIDGES_FOLDER/.editorconfig +rm -f $BRIDGES_FOLDER/Cargo.toml +rm -f $BRIDGES_FOLDER/ci.Dockerfile +rm -f $BRIDGES_FOLDER/CODEOWNERS +rm -f $BRIDGES_FOLDER/Dockerfile + +# let's fix Cargo.toml a bit (it'll be helpful if we are in the bridges repo) +if [[ ! -f "Cargo.toml" ]]; then + cat > Cargo.toml <<-CARGO_TOML + [workspace] + resolver = "2" + + members = [ + "bin/runtime-common", + "modules/*", + "primitives/*", + ] + CARGO_TOML +fi + +# let's test if everything we need compiles + +cargo check -p pallet-bridge-grandpa +cargo check -p pallet-bridge-grandpa --features runtime-benchmarks +cargo check -p pallet-bridge-grandpa --features try-runtime +cargo check -p pallet-bridge-messages +cargo check -p pallet-bridge-messages --features runtime-benchmarks +cargo check -p pallet-bridge-messages --features try-runtime +cargo check -p pallet-bridge-parachains +cargo check -p pallet-bridge-parachains --features runtime-benchmarks +cargo check -p pallet-bridge-parachains --features try-runtime +cargo check -p pallet-bridge-relayers +cargo check -p pallet-bridge-relayers --features runtime-benchmarks +cargo check -p pallet-bridge-relayers --features try-runtime +cargo check -p bridge-runtime-common +cargo check -p bridge-runtime-common --features runtime-benchmarks +cargo check -p bridge-runtime-common --features integrity-test + +# we're removing lock file after all chechs are done. Otherwise we may use different +# Substrate/Polkadot/Cumulus commits and our checks will fail +rm -f $BRIDGES_FOLDER/Cargo.lock + +echo "OK" diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index b6a8804a4a4..747de1b1f4c 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2021" [dependencies] -clap = { version = "4.2.3", features = ["derive"] } +clap = { version = "4.3.1", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0" } url = "2.3.1" diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index edf11d72a0b..d77db6baedf 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -93,7 +93,7 @@ impl PurgeChainCmd { io::stdin().read_line(&mut input)?; let input = input.trim(); - match input.chars().nth(0) { + match input.chars().next() { Some('y') | Some('Y') => {}, _ => { println!("Aborted"); @@ -103,7 +103,7 @@ impl PurgeChainCmd { } for db_path in &db_paths { - match fs::remove_dir_all(&db_path) { + match fs::remove_dir_all(db_path) { Ok(_) => { println!("{:?} removed.", &db_path); }, @@ -387,50 +387,34 @@ impl sc_cli::CliConfiguration for NormalizedRunCmd { self.base.disable_grandpa() } - fn rpc_ws_max_connections(&self) -> sc_cli::Result> { - self.base.rpc_ws_max_connections() + fn rpc_max_connections(&self) -> sc_cli::Result { + self.base.rpc_max_connections() } fn rpc_cors(&self, is_dev: bool) -> sc_cli::Result>> { self.base.rpc_cors(is_dev) } - fn rpc_http(&self, default_listen_port: u16) -> sc_cli::Result> { - self.base.rpc_http(default_listen_port) - } - - fn rpc_ipc(&self) -> sc_cli::Result> { - self.base.rpc_ipc() - } - - fn rpc_ws(&self, default_listen_port: u16) -> sc_cli::Result> { - self.base.rpc_ws(default_listen_port) + fn rpc_addr(&self, default_listen_port: u16) -> sc_cli::Result> { + self.base.rpc_addr(default_listen_port) } fn rpc_methods(&self) -> sc_cli::Result { self.base.rpc_methods() } - fn rpc_max_payload(&self) -> sc_cli::Result> { - self.base.rpc_max_payload() - } - - fn rpc_max_request_size(&self) -> sc_cli::Result> { + fn rpc_max_request_size(&self) -> sc_cli::Result { Ok(self.base.rpc_max_request_size) } - fn rpc_max_response_size(&self) -> sc_cli::Result> { + fn rpc_max_response_size(&self) -> sc_cli::Result { Ok(self.base.rpc_max_response_size) } - fn rpc_max_subscriptions_per_connection(&self) -> sc_cli::Result> { + fn rpc_max_subscriptions_per_connection(&self) -> sc_cli::Result { Ok(self.base.rpc_max_subscriptions_per_connection) } - fn ws_max_out_buffer_capacity(&self) -> sc_cli::Result> { - self.base.ws_max_out_buffer_capacity() - } - fn transaction_pool(&self, is_dev: bool) -> sc_cli::Result { self.base.transaction_pool(is_dev) } diff --git a/client/collator/Cargo.toml b/client/collator/Cargo.toml index b8e05fd37c5..6b04a319dcc 100644 --- a/client/collator/Cargo.toml +++ b/client/collator/Cargo.toml @@ -5,15 +5,15 @@ authors = ["Parity Technologies "] edition = "2021" [dependencies] +parking_lot = "0.12.1" codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ] } futures = "0.3.21" -parking_lot = "0.12.0" tracing = "0.1.25" # Substrate sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/client/collator/src/lib.rs b/client/collator/src/lib.rs index a931201f6cc..aca40b2b342 100644 --- a/client/collator/src/lib.rs +++ b/client/collator/src/lib.rs @@ -16,50 +16,46 @@ //! Cumulus Collator implementation for Substrate. -use cumulus_client_network::WaitToAnnounce; use cumulus_primitives_core::{ - relay_chain::Hash as PHash, CollationInfo, CollectCollationInfo, ParachainBlockData, - PersistedValidationData, + relay_chain::Hash as PHash, CollectCollationInfo, PersistedValidationData, }; use sc_client_api::BlockBackend; -use sp_api::{ApiExt, ProvideRuntimeApi}; -use sp_consensus::BlockStatus; +use sp_api::ProvideRuntimeApi; use sp_core::traits::SpawnNamed; -use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT, Zero}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; use cumulus_client_consensus_common::ParachainConsensus; -use polkadot_node_primitives::{ - BlockData, Collation, CollationGenerationConfig, CollationResult, MaybeCompressedPoV, PoV, -}; -use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage}; +use polkadot_node_primitives::{CollationResult, MaybeCompressedPoV}; use polkadot_overseer::Handle as OverseerHandle; use polkadot_primitives::{CollatorPair, Id as ParaId}; use codec::{Decode, Encode}; -use futures::{channel::oneshot, FutureExt}; -use parking_lot::Mutex; +use futures::prelude::*; use std::sync::Arc; -use tracing::Instrument; + +use crate::service::CollatorService; + +pub mod service; /// The logging target. const LOG_TARGET: &str = "cumulus-collator"; /// The implementation of the Cumulus `Collator`. +/// +/// Note that this implementation is soon to be deprecated and removed, and it is suggested to +/// directly use the [`CollatorService`] instead, so consensus engine implementations +/// live at the top level. pub struct Collator { - block_status: Arc, + service: CollatorService, parachain_consensus: Box>, - wait_to_announce: Arc>>, - runtime_api: Arc, } impl Clone for Collator { fn clone(&self) -> Self { - Self { - block_status: self.block_status.clone(), - wait_to_announce: self.wait_to_announce.clone(), + Collator { + service: self.service.clone(), parachain_consensus: self.parachain_consensus.clone(), - runtime_api: self.runtime_api.clone(), } } } @@ -73,159 +69,10 @@ where { /// Create a new instance. fn new( - block_status: Arc, - spawner: Arc, - announce_block: Arc>) + Send + Sync>, - runtime_api: Arc, + collator_service: CollatorService, parachain_consensus: Box>, ) -> Self { - let wait_to_announce = Arc::new(Mutex::new(WaitToAnnounce::new(spawner, announce_block))); - - Self { block_status, wait_to_announce, runtime_api, parachain_consensus } - } - - /// Checks the status of the given block hash in the Parachain. - /// - /// Returns `true` if the block could be found and is good to be build on. - fn check_block_status(&self, hash: Block::Hash, header: &Block::Header) -> bool { - match self.block_status.block_status(hash) { - Ok(BlockStatus::Queued) => { - tracing::debug!( - target: LOG_TARGET, - block_hash = ?hash, - "Skipping candidate production, because block is still queued for import.", - ); - false - }, - Ok(BlockStatus::InChainWithState) => true, - Ok(BlockStatus::InChainPruned) => { - tracing::error!( - target: LOG_TARGET, - "Skipping candidate production, because block `{:?}` is already pruned!", - hash, - ); - false - }, - Ok(BlockStatus::KnownBad) => { - tracing::error!( - target: LOG_TARGET, - block_hash = ?hash, - "Block is tagged as known bad and is included in the relay chain! Skipping candidate production!", - ); - false - }, - Ok(BlockStatus::Unknown) => { - if header.number().is_zero() { - tracing::error!( - target: LOG_TARGET, - block_hash = ?hash, - "Could not find the header of the genesis block in the database!", - ); - } else { - tracing::debug!( - target: LOG_TARGET, - block_hash = ?hash, - "Skipping candidate production, because block is unknown.", - ); - } - false - }, - Err(e) => { - tracing::error!( - target: LOG_TARGET, - block_hash = ?hash, - error = ?e, - "Failed to get block status.", - ); - false - }, - } - } - - /// Fetch the collation info from the runtime. - /// - /// Returns `Ok(Some(_))` on success, `Err(_)` on error or `Ok(None)` if the runtime api isn't implemented by the runtime. - fn fetch_collation_info( - &self, - block_hash: Block::Hash, - header: &Block::Header, - ) -> Result, sp_api::ApiError> { - let runtime_api = self.runtime_api.runtime_api(); - - let api_version = - match runtime_api.api_version::>(block_hash)? { - Some(version) => version, - None => { - tracing::error!( - target: LOG_TARGET, - "Could not fetch `CollectCollationInfo` runtime api version." - ); - return Ok(None) - }, - }; - - let collation_info = if api_version < 2 { - #[allow(deprecated)] - runtime_api - .collect_collation_info_before_version_2(block_hash)? - .into_latest(header.encode().into()) - } else { - runtime_api.collect_collation_info(block_hash, header)? - }; - - Ok(Some(collation_info)) - } - - fn build_collation( - &self, - block: ParachainBlockData, - block_hash: Block::Hash, - pov: PoV, - ) -> Option { - let collation_info = self - .fetch_collation_info(block_hash, block.header()) - .map_err(|e| { - tracing::error!( - target: LOG_TARGET, - error = ?e, - "Failed to collect collation info.", - ) - }) - .ok() - .flatten()?; - - let upward_messages = collation_info - .upward_messages - .try_into() - .map_err(|e| { - tracing::error!( - target: LOG_TARGET, - error = ?e, - "Number of upward messages should not be greater than `MAX_UPWARD_MESSAGE_NUM`", - ) - }) - .ok()?; - let horizontal_messages = collation_info - .horizontal_messages - .try_into() - .map_err(|e| { - tracing::error!( - target: LOG_TARGET, - error = ?e, - "Number of horizontal messages should not be greater than `MAX_HORIZONTAL_MESSAGE_NUM`", - ) - }) - .ok()?; - - Some(Collation { - upward_messages, - new_validation_code: collation_info.new_validation_code, - processed_downward_messages: collation_info.processed_downward_messages, - horizontal_messages, - hrmp_watermark: collation_info.hrmp_watermark, - head_data: collation_info.head_data, - proof_of_validity: MaybeCompressedPoV::Compressed(pov), - }) + Self { service: collator_service, parachain_consensus } } async fn produce_candidate( @@ -252,7 +99,7 @@ where }; let last_head_hash = last_head.hash(); - if !self.check_block_status(last_head_hash, &last_head) { + if !self.service.check_block_status(last_head_hash, &last_head) { return None } @@ -268,21 +115,9 @@ where .produce_candidate(&last_head, relay_parent, &validation_data) .await?; - let (header, extrinsics) = candidate.block.deconstruct(); + let block_hash = candidate.block.header().hash(); - let compact_proof = match candidate - .proof - .into_compact_proof::>(last_head.state_root().clone()) - { - Ok(proof) => proof, - Err(e) => { - tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e); - return None - }, - }; - - // Create the parachain block data for the validators. - let b = ParachainBlockData::::new(header, extrinsics, compact_proof); + let (collation, b) = self.service.build_collation(&last_head, block_hash, candidate)?; tracing::info!( target: LOG_TARGET, @@ -292,25 +127,109 @@ where b.storage_proof().encode().len() as f64 / 1024f64, ); - let pov = - polkadot_node_primitives::maybe_compress_pov(PoV { block_data: BlockData(b.encode()) }); + if let MaybeCompressedPoV::Compressed(ref pov) = collation.proof_of_validity { + tracing::info!( + target: LOG_TARGET, + "Compressed PoV size: {}kb", + pov.block_data.0.len() as f64 / 1024f64, + ); + } - tracing::info!( - target: LOG_TARGET, - "Compressed PoV size: {}kb", - pov.block_data.0.len() as f64 / 1024f64, - ); + let result_sender = self.service.announce_with_barrier(block_hash); - let block_hash = b.header().hash(); - let collation = self.build_collation(b, block_hash, pov)?; + tracing::info!(target: LOG_TARGET, ?block_hash, "Produced proof-of-validity candidate.",); - let (result_sender, signed_stmt_recv) = oneshot::channel(); + Some(CollationResult { collation, result_sender: Some(result_sender) }) + } +} - self.wait_to_announce.lock().wait_to_announce(block_hash, signed_stmt_recv); +/// Relay-chain-driven collators are those whose block production is driven purely +/// by new relay chain blocks and the most recently included parachain blocks +/// within them. +/// +/// This method of driving collators is not suited to anything but the most simple parachain +/// consensus mechanisms, and this module may soon be deprecated. +pub mod relay_chain_driven { + use futures::{ + channel::{mpsc, oneshot}, + prelude::*, + }; + use polkadot_node_primitives::{CollationGenerationConfig, CollationResult}; + use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage}; + use polkadot_overseer::Handle as OverseerHandle; + use polkadot_primitives::{CollatorPair, Id as ParaId}; - tracing::info!(target: LOG_TARGET, ?block_hash, "Produced proof-of-validity candidate.",); + use cumulus_primitives_core::{relay_chain::Hash as PHash, PersistedValidationData}; - Some(CollationResult { collation, result_sender: Some(result_sender) }) + /// A request to author a collation, based on the advancement of the relay chain. + /// + /// See the module docs for more info on relay-chain-driven collators. + pub struct CollationRequest { + relay_parent: PHash, + pvd: PersistedValidationData, + sender: oneshot::Sender>, + } + + impl CollationRequest { + /// Get the relay parent of the collation request. + pub fn relay_parent(&self) -> &PHash { + &self.relay_parent + } + + /// Get the [`PersistedValidationData`] for the request. + pub fn persisted_validation_data(&self) -> &PersistedValidationData { + &self.pvd + } + + /// Complete the request with a collation, if any. + pub fn complete(self, collation: Option) { + let _ = self.sender.send(collation); + } + } + + /// Initialize the collator with Polkadot's collation-generation + /// subsystem, returning a stream of collation requests to handle. + pub async fn init( + key: CollatorPair, + para_id: ParaId, + overseer_handle: OverseerHandle, + ) -> mpsc::Receiver { + let mut overseer_handle = overseer_handle; + + let (stream_tx, stream_rx) = mpsc::channel(0); + let config = CollationGenerationConfig { + key, + para_id, + collator: Box::new(move |relay_parent, validation_data| { + // Cloning the channel on each usage effectively makes the channel + // unbounded. The channel is actually bounded by the block production + // and consensus systems of Polkadot, which limits the amount of possible + // blocks. + let mut stream_tx = stream_tx.clone(); + let validation_data = validation_data.clone(); + Box::pin(async move { + let (this_tx, this_rx) = oneshot::channel(); + let request = + CollationRequest { relay_parent, pvd: validation_data, sender: this_tx }; + + if stream_tx.send(request).await.is_err() { + return None + } + + this_rx.await.ok().flatten() + }) + }), + }; + + overseer_handle + .send_msg(CollationGenerationMessage::Initialize(config), "StartCollator") + .await; + + overseer_handle + .send_msg(CollatorProtocolMessage::CollateOn(para_id), "StartCollator") + .await; + + stream_rx } } @@ -332,7 +251,7 @@ pub async fn start_collator( para_id, block_status, announce_block, - mut overseer_handle, + overseer_handle, spawner, key, parachain_consensus, @@ -345,34 +264,28 @@ pub async fn start_collator( RA: ProvideRuntimeApi + Send + Sync + 'static, RA::Api: CollectCollationInfo, { - let collator = Collator::new( - block_status, - Arc::new(spawner), - announce_block, - runtime_api, - parachain_consensus, - ); + let collator_service = + CollatorService::new(block_status, Arc::new(spawner.clone()), announce_block, runtime_api); - let span = tracing::Span::current(); - let config = CollationGenerationConfig { - key, - para_id, - collator: Box::new(move |relay_parent, validation_data| { - let collator = collator.clone(); - collator - .produce_candidate(relay_parent, validation_data.clone()) - .instrument(span.clone()) - .boxed() - }), - }; + let collator = Collator::new(collator_service, parachain_consensus); - overseer_handle - .send_msg(CollationGenerationMessage::Initialize(config), "StartCollator") - .await; + let mut request_stream = relay_chain_driven::init(key, para_id, overseer_handle).await; - overseer_handle - .send_msg(CollatorProtocolMessage::CollateOn(para_id), "StartCollator") - .await; + let collation_future = Box::pin(async move { + while let Some(request) = request_stream.next().await { + let collation = collator + .clone() + .produce_candidate( + *request.relay_parent(), + request.persisted_validation_data().clone(), + ) + .await; + + request.complete(collation); + } + }); + + spawner.spawn("cumulus-relay-driven-collator", None, collation_future); } #[cfg(test)] @@ -380,12 +293,14 @@ mod tests { use super::*; use async_trait::async_trait; use cumulus_client_consensus_common::ParachainCandidate; + use cumulus_primitives_core::ParachainBlockData; use cumulus_test_client::{ Client, ClientBlockImportExt, DefaultTestClientBuilderExt, InitBlockBuilder, TestClientBuilder, TestClientBuilderExt, }; use cumulus_test_runtime::{Block, Header}; use futures::{channel::mpsc, executor::block_on, StreamExt}; + use polkadot_node_subsystem::messages::CollationGenerationMessage; use polkadot_node_subsystem_test_helpers::ForwardSubsystem; use polkadot_overseer::{dummy::dummy_overseer_builder, HeadSupportsParachains}; use sp_consensus::BlockOrigin; @@ -451,7 +366,7 @@ mod tests { .build() .expect("Builds overseer"); - spawner.spawn("overseer", None, overseer.run().then(|_| async { () }).boxed()); + spawner.spawn("overseer", None, overseer.run().then(|_| async {}).boxed()); let collator_start = start_collator(StartCollatorParams { runtime_api: client.clone(), @@ -461,7 +376,7 @@ mod tests { spawner, para_id, key: CollatorPair::generate().0, - parachain_consensus: Box::new(DummyParachainConsensus { client: client.clone() }), + parachain_consensus: Box::new(DummyParachainConsensus { client }), }); block_on(collator_start); @@ -469,12 +384,10 @@ mod tests { .0 .expect("message should be send by `start_collator` above."); - let config = match msg { - CollationGenerationMessage::Initialize(config) => config, - }; + let CollationGenerationMessage::Initialize(config) = msg; - let mut validation_data = PersistedValidationData::default(); - validation_data.parent_head = header.encode().into(); + let validation_data = + PersistedValidationData { parent_head: header.encode().into(), ..Default::default() }; let relay_parent = Default::default(); let collation = block_on((config.collator)(relay_parent, &validation_data)) diff --git a/client/collator/src/service.rs b/client/collator/src/service.rs new file mode 100644 index 00000000000..7724b0a68a6 --- /dev/null +++ b/client/collator/src/service.rs @@ -0,0 +1,318 @@ +// Copyright 2023 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! The Cumulus [`CollatorService`] is a utility struct for performing common +//! operations used in parachain consensus/authoring. + +use cumulus_client_network::WaitToAnnounce; +use cumulus_primitives_core::{CollationInfo, CollectCollationInfo, ParachainBlockData}; + +use sc_client_api::BlockBackend; +use sp_api::{ApiExt, ProvideRuntimeApi}; +use sp_consensus::BlockStatus; +use sp_core::traits::SpawnNamed; +use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT, Zero}; + +use cumulus_client_consensus_common::ParachainCandidate; +use polkadot_node_primitives::{ + BlockData, Collation, CollationSecondedSignal, MaybeCompressedPoV, PoV, +}; + +use codec::Encode; +use futures::channel::oneshot; +use parking_lot::Mutex; +use std::sync::Arc; + +/// The logging target. +const LOG_TARGET: &str = "cumulus-collator"; + +/// Utility functions generally applicable to writing collators for Cumulus. +pub trait ServiceInterface { + /// Checks the status of the given block hash in the Parachain. + /// + /// Returns `true` if the block could be found and is good to be build on. + fn check_block_status(&self, hash: Block::Hash, header: &Block::Header) -> bool; + + /// Build a full [`Collation`] from a given [`ParachainCandidate`]. This requires + /// that the underlying block has been fully imported into the underlying client, + /// as implementations will fetch underlying runtime API data. + /// + /// This also returns the unencoded parachain block data, in case that is desired. + fn build_collation( + &self, + parent_header: &Block::Header, + block_hash: Block::Hash, + candidate: ParachainCandidate, + ) -> Option<(Collation, ParachainBlockData)>; + + /// Inform networking systems that the block should be announced after an appropriate + /// signal has been received. This returns the sending half of the signal. + fn announce_with_barrier( + &self, + block_hash: Block::Hash, + ) -> oneshot::Sender; +} + +/// The [`CollatorService`] provides common utilities for parachain consensus and authoring. +/// +/// This includes logic for checking the block status of arbitrary parachain headers +/// gathered from the relay chain state, creating full [`Collation`]s to be shared with validators, +/// and distributing new parachain blocks along the network. +pub struct CollatorService { + block_status: Arc, + wait_to_announce: Arc>>, + runtime_api: Arc, +} + +impl Clone for CollatorService { + fn clone(&self) -> Self { + Self { + block_status: self.block_status.clone(), + wait_to_announce: self.wait_to_announce.clone(), + runtime_api: self.runtime_api.clone(), + } + } +} + +impl CollatorService +where + Block: BlockT, + BS: BlockBackend, + RA: ProvideRuntimeApi, + RA::Api: CollectCollationInfo, +{ + /// Create a new instance. + pub fn new( + block_status: Arc, + spawner: Arc, + announce_block: Arc>) + Send + Sync>, + runtime_api: Arc, + ) -> Self { + let wait_to_announce = Arc::new(Mutex::new(WaitToAnnounce::new(spawner, announce_block))); + + Self { block_status, wait_to_announce, runtime_api } + } + + /// Checks the status of the given block hash in the Parachain. + /// + /// Returns `true` if the block could be found and is good to be build on. + pub fn check_block_status(&self, hash: Block::Hash, header: &Block::Header) -> bool { + match self.block_status.block_status(hash) { + Ok(BlockStatus::Queued) => { + tracing::debug!( + target: LOG_TARGET, + block_hash = ?hash, + "Skipping candidate production, because block is still queued for import.", + ); + false + }, + Ok(BlockStatus::InChainWithState) => true, + Ok(BlockStatus::InChainPruned) => { + tracing::error!( + target: LOG_TARGET, + "Skipping candidate production, because block `{:?}` is already pruned!", + hash, + ); + false + }, + Ok(BlockStatus::KnownBad) => { + tracing::error!( + target: LOG_TARGET, + block_hash = ?hash, + "Block is tagged as known bad and is included in the relay chain! Skipping candidate production!", + ); + false + }, + Ok(BlockStatus::Unknown) => { + if header.number().is_zero() { + tracing::error!( + target: LOG_TARGET, + block_hash = ?hash, + "Could not find the header of the genesis block in the database!", + ); + } else { + tracing::debug!( + target: LOG_TARGET, + block_hash = ?hash, + "Skipping candidate production, because block is unknown.", + ); + } + false + }, + Err(e) => { + tracing::error!( + target: LOG_TARGET, + block_hash = ?hash, + error = ?e, + "Failed to get block status.", + ); + false + }, + } + } + + /// Fetch the collation info from the runtime. + /// + /// Returns `Ok(Some(_))` on success, `Err(_)` on error or `Ok(None)` if the runtime api isn't implemented by the runtime. + pub fn fetch_collation_info( + &self, + block_hash: Block::Hash, + header: &Block::Header, + ) -> Result, sp_api::ApiError> { + let runtime_api = self.runtime_api.runtime_api(); + + let api_version = + match runtime_api.api_version::>(block_hash)? { + Some(version) => version, + None => { + tracing::error!( + target: LOG_TARGET, + "Could not fetch `CollectCollationInfo` runtime api version." + ); + return Ok(None) + }, + }; + + let collation_info = if api_version < 2 { + #[allow(deprecated)] + runtime_api + .collect_collation_info_before_version_2(block_hash)? + .into_latest(header.encode().into()) + } else { + runtime_api.collect_collation_info(block_hash, header)? + }; + + Ok(Some(collation_info)) + } + + /// Build a full [`Collation`] from a given [`ParachainCandidate`]. This requires + /// that the underlying block has been fully imported into the underlying client, + /// as it fetches underlying runtime API data. + /// + /// This also returns the unencoded parachain block data, in case that is desired. + pub fn build_collation( + &self, + parent_header: &Block::Header, + block_hash: Block::Hash, + candidate: ParachainCandidate, + ) -> Option<(Collation, ParachainBlockData)> { + let (header, extrinsics) = candidate.block.deconstruct(); + + let compact_proof = match candidate + .proof + .into_compact_proof::>(*parent_header.state_root()) + { + Ok(proof) => proof, + Err(e) => { + tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e); + return None + }, + }; + + // Create the parachain block data for the validators. + let collation_info = self + .fetch_collation_info(block_hash, &header) + .map_err(|e| { + tracing::error!( + target: LOG_TARGET, + error = ?e, + "Failed to collect collation info.", + ) + }) + .ok() + .flatten()?; + + let block_data = ParachainBlockData::::new(header, extrinsics, compact_proof); + + let pov = polkadot_node_primitives::maybe_compress_pov(PoV { + block_data: BlockData(block_data.encode()), + }); + + let upward_messages = collation_info + .upward_messages + .try_into() + .map_err(|e| { + tracing::error!( + target: LOG_TARGET, + error = ?e, + "Number of upward messages should not be greater than `MAX_UPWARD_MESSAGE_NUM`", + ) + }) + .ok()?; + let horizontal_messages = collation_info + .horizontal_messages + .try_into() + .map_err(|e| { + tracing::error!( + target: LOG_TARGET, + error = ?e, + "Number of horizontal messages should not be greater than `MAX_HORIZONTAL_MESSAGE_NUM`", + ) + }) + .ok()?; + + let collation = Collation { + upward_messages, + new_validation_code: collation_info.new_validation_code, + processed_downward_messages: collation_info.processed_downward_messages, + horizontal_messages, + hrmp_watermark: collation_info.hrmp_watermark, + head_data: collation_info.head_data, + proof_of_validity: MaybeCompressedPoV::Compressed(pov), + }; + + Some((collation, block_data)) + } + + /// Inform the networking systems that the block should be announced after an appropriate + /// signal has been received. This returns the sending half of the signal. + pub fn announce_with_barrier( + &self, + block_hash: Block::Hash, + ) -> oneshot::Sender { + let (result_sender, signed_stmt_recv) = oneshot::channel(); + self.wait_to_announce.lock().wait_to_announce(block_hash, signed_stmt_recv); + result_sender + } +} + +impl ServiceInterface for CollatorService +where + Block: BlockT, + BS: BlockBackend, + RA: ProvideRuntimeApi, + RA::Api: CollectCollationInfo, +{ + fn check_block_status(&self, hash: Block::Hash, header: &Block::Header) -> bool { + CollatorService::check_block_status(self, hash, header) + } + + fn build_collation( + &self, + parent_header: &Block::Header, + block_hash: Block::Hash, + candidate: ParachainCandidate, + ) -> Option<(Collation, ParachainBlockData)> { + CollatorService::build_collation(self, parent_header, block_hash, candidate) + } + + fn announce_with_barrier( + &self, + block_hash: Block::Hash, + ) -> oneshot::Sender { + CollatorService::announce_with_barrier(self, block_hash) + } +} diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index f284391494f..114e2ebed5b 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -27,8 +27,19 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" } # Cumulus cumulus-client-consensus-common = { path = "../common" } +cumulus-relay-chain-interface = { path = "../../relay-chain-interface" } +cumulus-client-consensus-proposer = { path = "../proposer" } cumulus-primitives-core = { path = "../../../primitives/core" } +cumulus-primitives-parachain-inherent = { path = "../../../primitives/parachain-inherent" } +cumulus-client-collator = { path = "../../collator" } + +# Polkadot +polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-node-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-overseer = { git = "https://github.com/paritytech/polkadot", branch = "master" } diff --git a/client/consensus/aura/src/import_queue.rs b/client/consensus/aura/src/import_queue.rs index 862abfb349a..725e841881c 100644 --- a/client/consensus/aura/src/import_queue.rs +++ b/client/consensus/aura/src/import_queue.rs @@ -51,7 +51,7 @@ pub struct ImportQueueParams<'a, I, C, CIDP, S> { } /// Start an import queue for the Aura consensus algorithm. -pub fn import_queue<'a, P, Block, I, C, S, CIDP>( +pub fn import_queue( ImportQueueParams { block_import, client, @@ -59,7 +59,7 @@ pub fn import_queue<'a, P, Block, I, C, S, CIDP>( spawner, registry, telemetry, - }: ImportQueueParams<'a, I, C, CIDP, S>, + }: ImportQueueParams<'_, I, C, CIDP, S>, ) -> Result, sp_consensus::Error> where Block: BlockT, diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index b95b5ecf39d..416ae776da1 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -50,6 +50,8 @@ pub use import_queue::{build_verifier, import_queue, BuildVerifierParams, Import pub use sc_consensus_aura::{slot_duration, AuraVerifier, BuildAuraWorkerParams, SlotProportion}; pub use sc_consensus_slots::InherentDataProviderExt; +pub mod unstable_reimpl; + const LOG_TARGET: &str = "aura::cumulus"; /// The implementation of the AURA consensus for parachains. diff --git a/client/consensus/aura/src/unstable_reimpl.rs b/client/consensus/aura/src/unstable_reimpl.rs new file mode 100644 index 00000000000..f9602a363bf --- /dev/null +++ b/client/consensus/aura/src/unstable_reimpl.rs @@ -0,0 +1,529 @@ +// Copyright 2023 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! The AuRa consensus algorithm for parachains. +//! +//! This extends the Substrate provided AuRa consensus implementation to make it compatible for +//! parachains. This provides the option to run a "bare" relay-chain driven Aura implementation, +//! but also exposes the core functionalities separately to be composed into more complex implementations. +//! +//! For more information about AuRa, the Substrate crate should be checked. + +use codec::{Decode, Encode}; +use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterface; +use cumulus_client_consensus_common::{ParachainBlockImportMarker, ParachainCandidate}; +use cumulus_client_consensus_proposer::ProposerInterface; +use cumulus_primitives_core::{ + relay_chain::Hash as PHash, CollectCollationInfo, PersistedValidationData, +}; +use cumulus_primitives_parachain_inherent::ParachainInherentData; +use cumulus_relay_chain_interface::RelayChainInterface; + +use polkadot_node_primitives::{CollationResult, MaybeCompressedPoV}; +use polkadot_overseer::Handle as OverseerHandle; +use polkadot_primitives::{CollatorPair, Id as ParaId}; + +use futures::prelude::*; +use sc_client_api::{backend::AuxStore, BlockBackend, BlockOf}; +use sc_consensus::{ + import_queue::{BasicQueue, Verifier as VerifierT}, + BlockImport, BlockImportParams, ForkChoiceStrategy, StateAction, +}; +use sc_consensus_aura::standalone as aura_internal; +use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_TRACE}; +use sp_api::ProvideRuntimeApi; +use sp_application_crypto::AppPublic; +use sp_block_builder::BlockBuilder as BlockBuilderApi; +use sp_blockchain::HeaderBackend; +use sp_consensus::{error::Error as ConsensusError, BlockOrigin, SyncOracle}; +use sp_consensus_aura::{AuraApi, Slot, SlotDuration}; +use sp_core::crypto::Pair; +use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider}; +use sp_keystore::KeystorePtr; +use sp_runtime::{ + generic::Digest, + traits::{Block as BlockT, HashFor, Header as HeaderT, Member}, +}; +use sp_state_machine::StorageChanges; +use std::{convert::TryFrom, error::Error, fmt::Debug, hash::Hash, sync::Arc, time::Duration}; + +/// Parameters for [`run_bare_relay_driven`]. +pub struct Params { + pub create_inherent_data_providers: CIDP, + pub block_import: BI, + pub para_client: Arc, + pub relay_client: Arc, + pub sync_oracle: SO, + pub keystore: KeystorePtr, + pub key: CollatorPair, + pub para_id: ParaId, + pub overseer_handle: OverseerHandle, + pub slot_duration: SlotDuration, + pub proposer: Proposer, + pub collator_service: CS, +} + +/// Run bare Aura consensus as a relay-chain-driven collator. +pub async fn run_bare_relay_driven( + params: Params, +) where + Block: BlockT, + Client: ProvideRuntimeApi + + BlockOf + + AuxStore + + HeaderBackend + + BlockBackend + + Send + + Sync + + 'static, + Client::Api: AuraApi + CollectCollationInfo, + RClient: RelayChainInterface, + CIDP: CreateInherentDataProviders + 'static, + BI: BlockImport + ParachainBlockImportMarker + Send + Sync + 'static, + SO: SyncOracle + Send + Sync + Clone + 'static, + Proposer: ProposerInterface, + Proposer::Transaction: Sync, + CS: CollatorServiceInterface, + P: Pair + Send + Sync, + P::Public: AppPublic + Hash + Member + Encode + Decode, + P::Signature: TryFrom> + Hash + Member + Encode + Decode, +{ + let mut proposer = params.proposer; + let mut block_import = params.block_import; + + let mut collation_requests = cumulus_client_collator::relay_chain_driven::init( + params.key, + params.para_id, + params.overseer_handle, + ) + .await; + + while let Some(request) = collation_requests.next().await { + macro_rules! reject_with_error { + ($err:expr) => {{ + request.complete(None); + tracing::error!(target: crate::LOG_TARGET, err = ?{ $err }); + continue; + }}; + } + + let validation_data = request.persisted_validation_data(); + + let parent_header = match Block::Header::decode(&mut &validation_data.parent_head.0[..]) { + Ok(x) => x, + Err(e) => reject_with_error!(e), + }; + + let parent_hash = parent_header.hash(); + + if !params.collator_service.check_block_status(parent_hash, &parent_header) { + continue + } + + let claim = match claim_slot::<_, _, P>( + &*params.para_client, + parent_hash, + params.slot_duration, + ¶ms.keystore, + ) + .await + { + Ok(None) => continue, + Ok(Some(c)) => c, + Err(e) => reject_with_error!(e), + }; + + let (parachain_inherent_data, other_inherent_data) = match create_inherent_data( + *request.relay_parent(), + &validation_data, + parent_hash, + params.para_id, + ¶ms.relay_client, + ¶ms.create_inherent_data_providers, + ) + .await + { + Ok(x) => x, + Err(e) => reject_with_error!(e), + }; + + let proposal = match proposer + .propose( + &parent_header, + ¶chain_inherent_data, + other_inherent_data, + Digest { logs: vec![claim.pre_digest] }, + // TODO [https://github.com/paritytech/cumulus/issues/2439] + // We should call out to a pluggable interface that provides + // the proposal duration. + Duration::from_millis(500), + // Set the block limit to 50% of the maximum PoV size. + // + // TODO: If we got benchmarking that includes the proof size, + // we should be able to use the maximum pov size. + Some((validation_data.max_pov_size / 2) as usize), + ) + .await + { + Ok(p) => p, + Err(e) => reject_with_error!(e), + }; + + let sealed_importable = match seal::<_, _, P>( + proposal.block, + proposal.storage_changes, + &claim.author_pub, + ¶ms.keystore, + ) { + Ok(s) => s, + Err(e) => reject_with_error!(e), + }; + + let post_hash = sealed_importable.post_hash(); + let block = Block::new( + sealed_importable.post_header(), + sealed_importable + .body + .as_ref() + .expect("body always created with this `propose` fn; qed") + .clone(), + ); + + if let Err(e) = block_import.import_block(sealed_importable).await { + reject_with_error!(e); + } + + let response = if let Some((collation, b)) = params.collator_service.build_collation( + &parent_header, + post_hash, + ParachainCandidate { block, proof: proposal.proof }, + ) { + tracing::info!( + target: crate::LOG_TARGET, + "PoV size {{ header: {}kb, extrinsics: {}kb, storage_proof: {}kb }}", + b.header().encode().len() as f64 / 1024f64, + b.extrinsics().encode().len() as f64 / 1024f64, + b.storage_proof().encode().len() as f64 / 1024f64, + ); + + if let MaybeCompressedPoV::Compressed(ref pov) = collation.proof_of_validity { + tracing::info!( + target: crate::LOG_TARGET, + "Compressed PoV size: {}kb", + pov.block_data.0.len() as f64 / 1024f64, + ); + } + + let result_sender = params.collator_service.announce_with_barrier(post_hash); + Some(CollationResult { collation, result_sender: Some(result_sender) }) + } else { + None + }; + + request.complete(response); + } +} + +fn slot_now(slot_duration: SlotDuration) -> Slot { + let timestamp = sp_timestamp::InherentDataProvider::from_system_time().timestamp(); + Slot::from_timestamp(timestamp, slot_duration) +} + +/// A claim on an Aura slot. +struct SlotClaim { + author_pub: Pub, + pre_digest: sp_runtime::DigestItem, +} + +async fn claim_slot( + client: &C, + parent_hash: B::Hash, + slot_duration: SlotDuration, + keystore: &KeystorePtr, +) -> Result>, Box> +where + B: BlockT, + C: ProvideRuntimeApi + Send + Sync + 'static, + C::Api: AuraApi, + P: Pair, + P::Public: Encode + Decode, + P::Signature: Encode + Decode, +{ + // load authorities + let authorities = client.runtime_api().authorities(parent_hash).map_err(Box::new)?; + + // Determine the current slot. + let slot_now = slot_now(slot_duration); + + // Try to claim the slot locally. + let author_pub = { + let res = aura_internal::claim_slot::

(slot_now, &authorities, keystore).await; + match res { + Some(p) => p, + None => return Ok(None), + } + }; + + // Produce the pre-digest. + let pre_digest = aura_internal::pre_digest::

(slot_now); + + Ok(Some(SlotClaim { author_pub, pre_digest })) +} + +async fn create_inherent_data( + relay_parent: PHash, + validation_data: &PersistedValidationData, + parent_hash: B::Hash, + para_id: ParaId, + relay_chain_interface: &impl RelayChainInterface, + create_inherent_data_providers: &impl CreateInherentDataProviders, +) -> Result<(ParachainInherentData, InherentData), Box> { + let paras_inherent_data = ParachainInherentData::create_at( + relay_parent, + relay_chain_interface, + validation_data, + para_id, + ) + .await; + + let paras_inherent_data = match paras_inherent_data { + Some(p) => p, + None => + return Err(format!("Could not create paras inherent data at {:?}", relay_parent).into()), + }; + + let other_inherent_data = create_inherent_data_providers + .create_inherent_data_providers(parent_hash, ()) + .map_err(|e| e as Box) + .await? + .create_inherent_data() + .await + .map_err(Box::new)?; + + Ok((paras_inherent_data, other_inherent_data)) +} + +fn seal( + pre_sealed: B, + storage_changes: StorageChanges>, + author_pub: &P::Public, + keystore: &KeystorePtr, +) -> Result, Box> +where + P: Pair, + P::Signature: Encode + Decode + TryFrom>, + P::Public: AppPublic, +{ + let (pre_header, body) = pre_sealed.deconstruct(); + let pre_hash = pre_header.hash(); + let block_number = *pre_header.number(); + + // seal the block. + let block_import_params = { + let seal_digest = + aura_internal::seal::<_, P>(&pre_hash, &author_pub, keystore).map_err(Box::new)?; + let mut block_import_params = BlockImportParams::new(BlockOrigin::Own, pre_header); + block_import_params.post_digests.push(seal_digest); + block_import_params.body = Some(body.clone()); + block_import_params.state_action = + StateAction::ApplyChanges(sc_consensus::StorageChanges::Changes(storage_changes)); + block_import_params.fork_choice = Some(ForkChoiceStrategy::LongestChain); + block_import_params + }; + let post_hash = block_import_params.post_hash(); + + tracing::info!( + target: crate::LOG_TARGET, + "🔖 Pre-sealed block for proposal at {}. Hash now {:?}, previously {:?}.", + block_number, + post_hash, + pre_hash, + ); + + Ok(block_import_params) +} + +struct Verifier { + client: Arc, + create_inherent_data_providers: CIDP, + slot_duration: SlotDuration, + telemetry: Option, + _marker: std::marker::PhantomData<(Block, P)>, +} + +#[async_trait::async_trait] +impl VerifierT for Verifier +where + P: Pair, + P::Signature: Encode + Decode, + P::Public: Encode + Decode + PartialEq + Clone + Debug, + Block: BlockT, + Client: ProvideRuntimeApi + Send + Sync, + >::Api: BlockBuilderApi + AuraApi, + + CIDP: CreateInherentDataProviders, +{ + async fn verify( + &mut self, + mut block_params: BlockImportParams, + ) -> Result, String> { + // Skip checks that include execution, if being told so, or when importing only state. + // + // This is done for example when gap syncing and it is expected that the block after the gap + // was checked/chosen properly, e.g. by warp syncing to this block using a finality proof. + if block_params.state_action.skip_execution_checks() || block_params.with_state() { + return Ok(block_params) + } + + let post_hash = block_params.header.hash(); + let parent_hash = *block_params.header.parent_hash(); + + // check seal and update pre-hash/post-hash + { + let authorities = aura_internal::fetch_authorities(self.client.as_ref(), parent_hash) + .map_err(|e| { + format!("Could not fetch authorities at {:?}: {}", parent_hash, e) + })?; + + let slot_now = slot_now(self.slot_duration); + let res = aura_internal::check_header_slot_and_seal::( + slot_now, + block_params.header, + &authorities, + ); + + match res { + Ok((pre_header, _slot, seal_digest)) => { + telemetry!( + self.telemetry; + CONSENSUS_TRACE; + "aura.checked_and_importing"; + "pre_header" => ?pre_header, + ); + + block_params.header = pre_header; + block_params.post_digests.push(seal_digest); + block_params.fork_choice = Some(ForkChoiceStrategy::LongestChain); + block_params.post_hash = Some(post_hash); + }, + Err(aura_internal::SealVerificationError::Deferred(hdr, slot)) => { + telemetry!( + self.telemetry; + CONSENSUS_DEBUG; + "aura.header_too_far_in_future"; + "hash" => ?post_hash, + "a" => ?hdr, + "b" => ?slot, + ); + + return Err(format!( + "Rejecting block ({:?}) from future slot {:?}", + post_hash, slot + )) + }, + Err(e) => + return Err(format!( + "Rejecting block ({:?}) with invalid seal ({:?})", + post_hash, e + )), + } + } + + // check inherents. + if let Some(body) = block_params.body.clone() { + let block = Block::new(block_params.header.clone(), body); + let create_inherent_data_providers = self + .create_inherent_data_providers + .create_inherent_data_providers(parent_hash, ()) + .await + .map_err(|e| format!("Could not create inherent data {:?}", e))?; + + let inherent_data = create_inherent_data_providers + .create_inherent_data() + .await + .map_err(|e| format!("Could not create inherent data {:?}", e))?; + + let inherent_res = self + .client + .runtime_api() + .check_inherents_with_context( + parent_hash, + block_params.origin.into(), + block, + inherent_data, + ) + .map_err(|e| format!("Unable to check block inherents {:?}", e))?; + + if !inherent_res.ok() { + for (i, e) in inherent_res.into_errors() { + match create_inherent_data_providers.try_handle_error(&i, &e).await { + Some(res) => res.map_err(|e| format!("Inherent Error {:?}", e))?, + None => + return Err(format!( + "Unknown inherent error, source {:?}", + String::from_utf8_lossy(&i[..]) + )), + } + } + } + } + + Ok(block_params) + } +} + +/// Start an import queue for a Cumulus node which checks blocks' seals and inherent data. +/// +/// Pass in only inherent data providers which don't include aura or parachain consensus inherents, +/// e.g. things like timestamp and custom inherents for the runtime. +/// +/// The others are generated explicitly internally. +/// +/// This should only be used for runtimes where the runtime does not check all inherents and +/// seals in `execute_block` (see ) +pub fn fully_verifying_import_queue( + client: Arc, + block_import: I, + create_inherent_data_providers: CIDP, + slot_duration: SlotDuration, + spawner: &impl sp_core::traits::SpawnEssentialNamed, + registry: Option<&substrate_prometheus_endpoint::Registry>, + telemetry: Option, +) -> BasicQueue +where + P: Pair, + P::Signature: Encode + Decode, + P::Public: Encode + Decode + PartialEq + Clone + Debug, + I: BlockImport + + ParachainBlockImportMarker + + Send + + Sync + + 'static, + I::Transaction: Send, + Client: ProvideRuntimeApi + Send + Sync + 'static, + >::Api: BlockBuilderApi + AuraApi, + CIDP: CreateInherentDataProviders + 'static, +{ + let verifier = Verifier:: { + client, + create_inherent_data_providers, + slot_duration, + telemetry, + _marker: std::marker::PhantomData, + }; + + BasicQueue::new(verifier, Box::new(block_import), None, spawner, registry) +} diff --git a/client/consensus/common/Cargo.toml b/client/consensus/common/Cargo.toml index d0bc28171fb..6523368fe35 100644 --- a/client/consensus/common/Cargo.toml +++ b/client/consensus/common/Cargo.toml @@ -10,7 +10,7 @@ async-trait = "0.1.68" codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ] } dyn-clone = "1.0.11" futures = "0.3.28" -log = "0.4.17" +log = "0.4.18" tracing = "0.1.37" # Substrate @@ -18,8 +18,10 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" } +substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" } # Polkadot polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } diff --git a/client/consensus/common/src/import_queue.rs b/client/consensus/common/src/import_queue.rs new file mode 100644 index 00000000000..948fe065c42 --- /dev/null +++ b/client/consensus/common/src/import_queue.rs @@ -0,0 +1,77 @@ +// Copyright 2019-2023 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! (unstable) Composable utilities for constructing import queues for parachains. +//! +//! Unlike standalone chains, parachains have the requirement that all consensus logic +//! must be checked within the runtime. This property means that work which is normally +//! done in the import queue per-block, such as checking signatures, quorums, and whether +//! inherent extrinsics were constructed faithfully do not need to be done, per se. +//! +//! It may seem that it would be beneficial for the client to do these checks regardless, +//! but in practice this means that clients would just reject blocks which are _valid_ according +//! to their Parachain Validation Function, which is the ultimate source of consensus truth. +//! +//! However, parachain runtimes expose two different access points for executing blocks +//! in full nodes versus executing those blocks in the parachain validation environment. +//! At the time of writing, the inherent and consensus checks in most Cumulus runtimes +//! are only performed during parachain validation, not full node block execution. +//! +//! See for details. + +use sp_consensus::error::Error as ConsensusError; +use sp_runtime::traits::Block as BlockT; + +use sc_consensus::{ + block_import::{BlockImport, BlockImportParams}, + import_queue::{BasicQueue, Verifier}, +}; + +use crate::ParachainBlockImportMarker; + +/// A [`Verifier`] for blocks which verifies absolutely nothing. +/// +/// This should only be used when the runtime is responsible for checking block seals and inherents. +pub struct VerifyNothing; + +#[async_trait::async_trait] +impl Verifier for VerifyNothing { + async fn verify( + &mut self, + params: BlockImportParams, + ) -> Result, String> { + Ok(params) + } +} + +/// An import queue which does no verification. +/// +/// This should only be used when the runtime is responsible for checking block seals and inherents. +pub fn verify_nothing_import_queue( + block_import: I, + spawner: &impl sp_core::traits::SpawnEssentialNamed, + registry: Option<&substrate_prometheus_endpoint::Registry>, +) -> BasicQueue +where + I: BlockImport + + ParachainBlockImportMarker + + Send + + Sync + + 'static, + I::Transaction: Send, +{ + BasicQueue::new(VerifyNothing, Box::new(block_import), None, spawner, registry) +} diff --git a/client/consensus/common/src/level_monitor.rs b/client/consensus/common/src/level_monitor.rs index 3576ced1858..ebdfaaf26ca 100644 --- a/client/consensus/common/src/level_monitor.rs +++ b/client/consensus/common/src/level_monitor.rs @@ -22,7 +22,7 @@ use std::{ sync::Arc, }; -const LOG_TARGET: &'static str = "level-monitor"; +const LOG_TARGET: &str = "level-monitor"; /// Value good enough to be used with parachains using the current backend implementation /// that ships with Substrate. This value may change in the future. diff --git a/client/consensus/common/src/lib.rs b/client/consensus/common/src/lib.rs index 86a781adc01..b74829e191f 100644 --- a/client/consensus/common/src/lib.rs +++ b/client/consensus/common/src/lib.rs @@ -32,6 +32,8 @@ pub use parachain_consensus::run_parachain_consensus; use level_monitor::LevelMonitor; pub use level_monitor::{LevelLimit, MAX_LEAVES_PER_LEVEL_SENSIBLE_DEFAULT}; +pub mod import_queue; + /// The result of [`ParachainConsensus::produce_candidate`]. pub struct ParachainCandidate { /// The block that was built for this candidate. diff --git a/client/consensus/common/src/parachain_consensus.rs b/client/consensus/common/src/parachain_consensus.rs index 734f682d25b..78f4e45cd81 100644 --- a/client/consensus/common/src/parachain_consensus.rs +++ b/client/consensus/common/src/parachain_consensus.rs @@ -325,7 +325,6 @@ async fn handle_new_block_imported( match parachain.block_status(unset_hash) { Ok(BlockStatus::InChainWithState) => { - drop(unset_best_header); let unset_best_header = unset_best_header_opt .take() .expect("We checked above that the value is set; qed"); @@ -433,8 +432,11 @@ async fn handle_new_best_parachain_head( } } -async fn import_block_as_new_best(hash: Block::Hash, header: Block::Header, parachain: &P) -where +async fn import_block_as_new_best( + hash: Block::Hash, + header: Block::Header, + mut parachain: &P, +) where Block: BlockT, P: UsageProvider + Send + Sync + BlockBackend, for<'a> &'a P: BlockImport, @@ -456,7 +458,7 @@ where block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(true)); block_import_params.import_existing = true; - if let Err(err) = (&*parachain).import_block(block_import_params).await { + if let Err(err) = parachain.import_block(block_import_params).await { tracing::warn!( target: LOG_TARGET, block_hash = ?hash, diff --git a/client/consensus/common/src/tests.rs b/client/consensus/common/src/tests.rs index 23516d96388..f1bc4d42b8a 100644 --- a/client/consensus/common/src/tests.rs +++ b/client/consensus/common/src/tests.rs @@ -337,7 +337,7 @@ fn follow_new_best_with_dummy_recovery_works() { Some(recovery_chan_tx), ); - let block = build_block(&*client.clone(), None, None); + let block = build_block(&*client, None, None); let block_clone = block.clone(); let client_clone = client.clone(); @@ -547,7 +547,6 @@ fn do_not_set_best_block_to_older_block() { let client = Arc::new(TestClientBuilder::with_backend(backend).build()); let blocks = (0..NUM_BLOCKS) - .into_iter() .map(|_| build_and_import_block(client.clone(), true)) .collect::>(); @@ -559,7 +558,6 @@ fn do_not_set_best_block_to_older_block() { let consensus = run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {}), None); - let client2 = client.clone(); let work = async move { new_best_heads_sender .unbounded_send(blocks[NUM_BLOCKS - 2].header().clone()) @@ -579,7 +577,7 @@ fn do_not_set_best_block_to_older_block() { }); // Build and import a new best block. - build_and_import_block(client2.clone(), true); + build_and_import_block(client, true); } #[test] @@ -607,7 +605,6 @@ fn prune_blocks_on_level_overflow() { let id0 = block0.header.hash(); let blocks1 = (0..LEVEL_LIMIT) - .into_iter() .map(|i| { build_and_import_block_ext( &*client, @@ -622,7 +619,6 @@ fn prune_blocks_on_level_overflow() { let id10 = blocks1[0].header.hash(); let blocks2 = (0..2) - .into_iter() .map(|i| { build_and_import_block_ext( &*client, @@ -720,7 +716,6 @@ fn restore_limit_monitor() { let id00 = block00.header.hash(); let blocks1 = (0..LEVEL_LIMIT + 1) - .into_iter() .map(|i| { build_and_import_block_ext( &*client, @@ -735,7 +730,6 @@ fn restore_limit_monitor() { let id10 = blocks1[0].header.hash(); let _ = (0..LEVEL_LIMIT) - .into_iter() .map(|i| { build_and_import_block_ext( &*client, diff --git a/client/consensus/proposer/Cargo.toml b/client/consensus/proposer/Cargo.toml new file mode 100644 index 00000000000..7dff8d31950 --- /dev/null +++ b/client/consensus/proposer/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "cumulus-client-consensus-proposer" +description = "A Substrate `Proposer` for building parachain blocks" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" + +[dependencies] +anyhow = "1.0" +async-trait = "0.1.68" +thiserror = "1.0.40" + +# Substrate +sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" } + +# Cumulus +cumulus-primitives-parachain-inherent = { path = "../../../primitives/parachain-inherent" } diff --git a/client/consensus/proposer/src/lib.rs b/client/consensus/proposer/src/lib.rs new file mode 100644 index 00000000000..514ad58da74 --- /dev/null +++ b/client/consensus/proposer/src/lib.rs @@ -0,0 +1,137 @@ +// Copyright 2023 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! The Cumulus [`Proposer`] is a wrapper around a Substrate [`sp_consensus::Environment`] +//! for creating new parachain blocks. +//! +//! This utility is designed to be composed within any collator consensus algorithm. + +use async_trait::async_trait; + +use cumulus_primitives_parachain_inherent::ParachainInherentData; +use sp_consensus::{EnableProofRecording, Environment, Proposal, Proposer as SubstrateProposer}; +use sp_inherents::InherentData; +use sp_runtime::{traits::Block as BlockT, Digest}; +use sp_state_machine::StorageProof; + +use std::{fmt::Debug, time::Duration}; + +/// Errors that can occur when proposing a parachain block. +#[derive(thiserror::Error, Debug)] +#[error(transparent)] +pub struct Error { + inner: anyhow::Error, +} + +impl Error { + /// Create an error tied to the creation of a proposer. + pub fn proposer_creation(err: impl Into) -> Self { + Error { inner: err.into().context("Proposer Creation") } + } + + /// Create an error tied to the proposing logic itself. + pub fn proposing(err: impl Into) -> Self { + Error { inner: err.into().context("Proposing") } + } +} + +/// A type alias for easily referring to the type of a proposal produced by a specific +/// [`Proposer`]. +pub type ProposalOf = Proposal>::Transaction, StorageProof>; + +/// An interface for proposers. +#[async_trait] +pub trait ProposerInterface { + /// The underlying DB transaction type produced with the block proposal. + type Transaction: Default + Send + 'static; + + /// Propose a collation using the supplied `InherentData` and the provided + /// `ParachainInherentData`. + /// + /// Also specify any required inherent digests, the maximum proposal duration, + /// and the block size limit in bytes. See the documentation on [`sp_consensus::Proposer::propose`] + /// for more details on how to interpret these parameters. + /// + /// The `InherentData` and `Digest` are left deliberately general in order to accommodate + /// all possible collator selection algorithms or inherent creation mechanisms, + /// while the `ParachainInherentData` is made explicit so it will be constructed appropriately. + /// + /// If the `InherentData` passed into this function already has a `ParachainInherentData`, + /// this should throw an error. + async fn propose( + &mut self, + parent_header: &Block::Header, + paras_inherent_data: &ParachainInherentData, + other_inherent_data: InherentData, + inherent_digests: Digest, + max_duration: Duration, + block_size_limit: Option, + ) -> Result, Error>; +} + +/// A simple wrapper around a Substrate proposer for creating collations. +pub struct Proposer { + inner: T, + _marker: std::marker::PhantomData, +} + +impl Proposer { + /// Create a new Cumulus [`Proposer`]. + pub fn new(inner: T) -> Self { + Proposer { inner, _marker: std::marker::PhantomData } + } +} + +#[async_trait] +impl ProposerInterface for Proposer +where + B: sp_runtime::traits::Block, + T: Environment + Send, + T::Error: Send + Sync + 'static, + T::Proposer: SubstrateProposer, + >::Error: Send + Sync + 'static, +{ + type Transaction = <>::Proposer as SubstrateProposer>::Transaction; + + async fn propose( + &mut self, + parent_header: &B::Header, + paras_inherent_data: &ParachainInherentData, + other_inherent_data: InherentData, + inherent_digests: Digest, + max_duration: Duration, + block_size_limit: Option, + ) -> Result, Error> { + let proposer = self + .inner + .init(parent_header) + .await + .map_err(|e| Error::proposer_creation(anyhow::Error::new(e)))?; + + let mut inherent_data = other_inherent_data; + inherent_data + .put_data( + cumulus_primitives_parachain_inherent::INHERENT_IDENTIFIER, + ¶s_inherent_data, + ) + .map_err(|e| Error::proposing(anyhow::Error::new(e)))?; + + proposer + .propose(inherent_data, inherent_digests, max_duration, block_size_limit) + .await + .map_err(|e| Error::proposing(anyhow::Error::new(e)).into()) + } +} diff --git a/client/consensus/relay-chain/src/lib.rs b/client/consensus/relay-chain/src/lib.rs index a31a9ec8b2a..529b78c1319 100644 --- a/client/consensus/relay-chain/src/lib.rs +++ b/client/consensus/relay-chain/src/lib.rs @@ -161,7 +161,7 @@ where relay_parent: PHash, validation_data: &PersistedValidationData, ) -> Option> { - let proposer_future = self.proposer_factory.lock().init(&parent); + let proposer_future = self.proposer_factory.lock().init(parent); let proposer = proposer_future .await @@ -171,7 +171,7 @@ where .ok()?; let inherent_data = - self.inherent_data(parent.hash(), &validation_data, relay_parent).await?; + self.inherent_data(parent.hash(), validation_data, relay_parent).await?; let Proposal { block, storage_changes, proof } = proposer .propose( diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 4b7793d0cc4..3554a91225d 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -31,7 +31,7 @@ cumulus-relay-chain-interface = { path = "../relay-chain-interface" } [dev-dependencies] portpicker = "0.1.1" -tokio = { version = "1.27.0", features = ["macros"] } +tokio = { version = "1.28.2", features = ["macros"] } url = "2.3.1" # Substrate diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs index 5a2043ab5f7..e226170d7c5 100644 --- a/client/network/src/lib.rs +++ b/client/network/src/lib.rs @@ -89,14 +89,13 @@ impl BlockAnnounceData { /// /// This will not check the signature, for this you should use [`BlockAnnounceData::check_signature`]. fn validate(&self, encoded_header: Vec) -> Result<(), Validation> { - let candidate_hash = if let CompactStatement::Seconded(h) = - self.statement.unchecked_payload() - { - h - } else { - tracing::debug!(target: LOG_TARGET, "`CompactStatement` isn't the candidate variant!",); - return Err(Validation::Failure { disconnect: true }) - }; + let candidate_hash = + if let CompactStatement::Seconded(h) = self.statement.unchecked_payload() { + h + } else { + tracing::debug!(target: LOG_TARGET, "`CompactStatement` isn't the candidate variant!",); + return Err(Validation::Failure { disconnect: true }) + }; if *candidate_hash != self.receipt.hash() { tracing::debug!( @@ -303,9 +302,9 @@ where Ok(Validation::Success { is_new_best: true }) } else if block_number >= known_best_number { tracing::debug!( - target: LOG_TARGET, - "Validation failed because a justification is needed if the block at the top of the chain." - ); + target: LOG_TARGET, + "Validation failed because a justification is needed if the block at the top of the chain." + ); Ok(Validation::Failure { disconnect: false }) } else { @@ -334,9 +333,9 @@ where let relay_chain_is_syncing = relay_chain_interface .is_major_syncing() .await - .map_err(|e| { - tracing::error!(target: LOG_TARGET, "Unable to determine sync status. {}", e) - }) + .map_err( + |e| tracing::error!(target: LOG_TARGET, "Unable to determine sync status. {}", e), + ) .unwrap_or(false); if relay_chain_is_syncing { diff --git a/client/network/src/tests.rs b/client/network/src/tests.rs index eefb88f2f7b..08127fe390a 100644 --- a/client/network/src/tests.rs +++ b/client/network/src/tests.rs @@ -129,7 +129,7 @@ impl RelayChainInterface for DummyRelayChainInterface { para_id: 0u32.into(), relay_parent: PHash::random(), collator: CollatorPair::generate().0.public(), - persisted_validation_data_hash: PHash::random().into(), + persisted_validation_data_hash: PHash::random(), pov_hash: PHash::random(), erasure_root: PHash::random(), signature: sp_core::sr25519::Signature([0u8; 64]).into(), @@ -293,7 +293,7 @@ async fn make_gossip_message_and_header( para_id: 0u32.into(), relay_parent, collator: CollatorPair::generate().0.public(), - persisted_validation_data_hash: PHash::random().into(), + persisted_validation_data_hash: PHash::random(), pov_hash: PHash::random(), erasure_root: PHash::random(), signature: sp_core::sr25519::Signature([0u8; 64]).into(), @@ -484,7 +484,7 @@ async fn check_statement_seconded() { para_id: 0u32.into(), relay_parent: PHash::random(), collator: CollatorPair::generate().0.public(), - persisted_validation_data_hash: PHash::random().into(), + persisted_validation_data_hash: PHash::random(), pov_hash: PHash::random(), erasure_root: PHash::random(), signature: sp_core::sr25519::Signature([0u8; 64]).into(), diff --git a/client/pov-recovery/Cargo.toml b/client/pov-recovery/Cargo.toml index 542c79d3d78..62922176e25 100644 --- a/client/pov-recovery/Cargo.toml +++ b/client/pov-recovery/Cargo.toml @@ -31,7 +31,7 @@ cumulus-relay-chain-interface = {path = "../relay-chain-interface"} async-trait = "0.1.68" [dev-dependencies] -tokio = { version = "1.27.0", features = ["macros"] } +tokio = { version = "1.28.2", features = ["macros"] } portpicker = "0.1.1" # Cumulus diff --git a/client/pov-recovery/src/lib.rs b/client/pov-recovery/src/lib.rs index 7d92934c784..62f31b6c061 100644 --- a/client/pov-recovery/src/lib.rs +++ b/client/pov-recovery/src/lib.rs @@ -40,7 +40,7 @@ //! 4a. After it is recovered, we restore the block and import it. //! //! 4b. Since we are trying to recover pending candidates, availability is not guaranteed. If the block -//! PoV is not yet available, we retry. +//! PoV is not yet available, we retry. //! //! If we need to recover multiple PoV blocks (which should hopefully not happen in real life), we //! make sure that the blocks are imported in the correct order. @@ -190,7 +190,7 @@ impl RecoveryQueue { /// Get the next hash for block recovery. pub async fn next_recovery(&mut self) -> Block::Hash { loop { - if let Some(_) = self.signaling_queue.next().await { + if self.signaling_queue.next().await.is_some() { if let Some(hash) = self.recovery_queue.pop_front() { return hash } else { @@ -309,10 +309,10 @@ where /// Block is no longer waiting for recovery fn clear_waiting_recovery(&mut self, block_hash: &Block::Hash) { - self.candidates.get_mut(block_hash).map(|candidate| { + if let Some(candidate) = self.candidates.get_mut(block_hash) { // Prevents triggering an already enqueued recovery request candidate.waiting_recovery = false; - }); + } } /// Handle a finalized block with the given `block_number`. diff --git a/client/relay-chain-inprocess-interface/src/lib.rs b/client/relay-chain-inprocess-interface/src/lib.rs index f230a23bd25..c1e19bd20b6 100644 --- a/client/relay-chain-inprocess-interface/src/lib.rs +++ b/client/relay-chain-inprocess-interface/src/lib.rs @@ -241,7 +241,7 @@ where self.full_client .import_notification_stream() .filter_map(|notification| async move { - notification.is_new_best.then(|| notification.header) + notification.is_new_best.then_some(notification.header) }); Ok(Box::pin(notifications_stream)) } @@ -428,7 +428,7 @@ mod tests { ( client.clone(), block, - RelayChainInProcessInterface::new(client, backend.clone(), dummy_network, mock_handle), + RelayChainInProcessInterface::new(client, backend, dummy_network, mock_handle), ) } @@ -483,7 +483,7 @@ mod tests { let hash = block.hash(); let ext = construct_transfer_extrinsic( - &*client, + &client, sp_keyring::Sr25519Keyring::Alice, sp_keyring::Sr25519Keyring::Bob, 1000, diff --git a/client/relay-chain-interface/Cargo.toml b/client/relay-chain-interface/Cargo.toml index 421c9c9aa9c..c4ee9d2fb59 100644 --- a/client/relay-chain-interface/Cargo.toml +++ b/client/relay-chain-interface/Cargo.toml @@ -18,4 +18,4 @@ futures = "0.3.28" async-trait = "0.1.68" thiserror = "1.0.40" jsonrpsee-core = "0.16.2" -parity-scale-codec = "3.4.0" +parity-scale-codec = "3.5.0" diff --git a/client/relay-chain-minimal-node/Cargo.toml b/client/relay-chain-minimal-node/Cargo.toml index ff8d8bc11d3..c9efb6d5e52 100644 --- a/client/relay-chain-minimal-node/Cargo.toml +++ b/client/relay-chain-minimal-node/Cargo.toml @@ -37,9 +37,9 @@ cumulus-relay-chain-interface = { path = "../relay-chain-interface" } cumulus-relay-chain-rpc-interface = { path = "../relay-chain-rpc-interface" } cumulus-primitives-core = { path = "../../primitives/core" } -array-bytes = "6.0" +array-bytes = "6.1" lru = "0.9" tracing = "0.1.37" async-trait = "0.1.68" futures = "0.3.28" -tokio = { version = "1.27.0", features = ["macros"] } +tokio = { version = "1.28.2", features = ["macros"] } diff --git a/client/relay-chain-minimal-node/src/blockchain_rpc_client.rs b/client/relay-chain-minimal-node/src/blockchain_rpc_client.rs index b8939df5fd5..10b48296bff 100644 --- a/client/relay-chain-minimal-node/src/blockchain_rpc_client.rs +++ b/client/relay-chain-minimal-node/src/blockchain_rpc_client.rs @@ -21,6 +21,7 @@ use cumulus_relay_chain_rpc_interface::RelayChainRpcClient; use futures::{Stream, StreamExt}; use polkadot_core_primitives::{Block, BlockNumber, Hash, Header}; use polkadot_overseer::RuntimeApiSubsystemClient; +use polkadot_primitives::vstaging; use sc_authority_discovery::{AuthorityDiscovery, Error as AuthorityDiscoveryError}; use sp_api::{ApiError, RuntimeApiInfo}; @@ -297,7 +298,41 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient { )>, ApiError, > { - Ok(self.rpc_client.parachain_host_staging_get_disputes(at).await?) + Ok(self.rpc_client.parachain_host_disputes(at).await?) + } + + async fn unapplied_slashes( + &self, + at: Hash, + ) -> Result< + Vec<( + polkadot_primitives::SessionIndex, + polkadot_primitives::CandidateHash, + vstaging::slashing::PendingSlashes, + )>, + ApiError, + > { + Ok(self.rpc_client.parachain_host_unapplied_slashes(at).await?) + } + + async fn key_ownership_proof( + &self, + at: Hash, + validator_id: polkadot_primitives::ValidatorId, + ) -> Result, ApiError> { + Ok(self.rpc_client.parachain_host_key_ownership_proof(at, validator_id).await?) + } + + async fn submit_report_dispute_lost( + &self, + at: Hash, + dispute_proof: vstaging::slashing::DisputeProof, + key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof, + ) -> Result, ApiError> { + Ok(self + .rpc_client + .parachain_host_submit_report_dispute_lost(at, dispute_proof, key_ownership_proof) + .await?) } } diff --git a/client/relay-chain-minimal-node/src/collator_overseer.rs b/client/relay-chain-minimal-node/src/collator_overseer.rs index bd3dfa8e0f8..b488db962f3 100644 --- a/client/relay-chain-minimal-node/src/collator_overseer.rs +++ b/client/relay-chain-minimal-node/src/collator_overseer.rs @@ -76,7 +76,7 @@ pub(crate) struct CollatorOverseerGenArgs<'a> { pub peer_set_protocol_names: PeerSetProtocolNames, } -fn build_overseer<'a>( +fn build_overseer( connector: OverseerConnector, CollatorOverseerGenArgs { runtime_client, @@ -90,7 +90,7 @@ fn build_overseer<'a>( collator_pair, req_protocol_names, peer_set_protocol_names, - }: CollatorOverseerGenArgs<'a>, + }: CollatorOverseerGenArgs<'_>, ) -> Result< (Overseer, Arc>, OverseerHandle), RelayChainError, @@ -99,7 +99,7 @@ fn build_overseer<'a>( let network_bridge_metrics: NetworkBridgeMetrics = Metrics::register(registry)?; let builder = Overseer::builder() .availability_distribution(DummySubsystem) - .availability_recovery(AvailabilityRecoverySubsystem::with_chunks_only( + .availability_recovery(AvailabilityRecoverySubsystem::with_availability_store_skip( available_data_req_receiver, Metrics::register(registry)?, )) diff --git a/client/relay-chain-minimal-node/src/lib.rs b/client/relay-chain-minimal-node/src/lib.rs index 102a8582745..6def072913b 100644 --- a/client/relay-chain-minimal-node/src/lib.rs +++ b/client/relay-chain-minimal-node/src/lib.rs @@ -29,7 +29,7 @@ use polkadot_node_subsystem_util::metrics::prometheus::Registry; use polkadot_primitives::CollatorPair; use sc_authority_discovery::Service as AuthorityDiscoveryService; -use sc_network::{Event, NetworkEventStream, NetworkService}; +use sc_network::{config::FullNetworkConfiguration, Event, NetworkEventStream, NetworkService}; use sc_service::{Configuration, TaskManager}; use sp_runtime::{app_crypto::Pair, traits::Block as BlockT}; @@ -119,11 +119,12 @@ pub async fn build_minimal_relay_chain_node( /// - AvailabilityDistribution #[sc_tracing::logging::prefix_logs_with("Relaychain")] async fn new_minimal_relay_chain( - mut config: Configuration, + config: Configuration, collator_pair: CollatorPair, relay_chain_rpc_client: Arc, ) -> Result { let role = config.role.clone(); + let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network); let task_manager = { let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry); @@ -141,22 +142,27 @@ async fn new_minimal_relay_chain( let peer_set_protocol_names = PeerSetProtocolNames::new(genesis_hash, config.chain_spec.fork_id()); let is_authority = if role.is_authority() { IsAuthority::Yes } else { IsAuthority::No }; - config - .network - .extra_sets - .extend(peer_sets_info(is_authority, &peer_set_protocol_names)); + + for config in peer_sets_info(is_authority, &peer_set_protocol_names) { + net_config.add_notification_protocol(config); + } let request_protocol_names = ReqProtocolNames::new(genesis_hash, config.chain_spec.fork_id()); let (collation_req_receiver, available_data_req_receiver) = - build_request_response_protocol_receivers(&request_protocol_names, &mut config); + build_request_response_protocol_receivers(&request_protocol_names, &mut net_config); let best_header = relay_chain_rpc_client .chain_get_header(None) .await? .ok_or_else(|| RelayChainError::RpcCallError("Unable to fetch best header".to_string()))?; - let (network, network_starter, sync_oracle) = - build_collator_network(&config, task_manager.spawn_handle(), genesis_hash, best_header) - .map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?; + let (network, network_starter, sync_oracle) = build_collator_network( + &config, + net_config, + task_manager.spawn_handle(), + genesis_hash, + best_header, + ) + .map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?; let authority_discovery_service = build_authority_discovery_service( &task_manager, @@ -190,18 +196,18 @@ async fn new_minimal_relay_chain( fn build_request_response_protocol_receivers( request_protocol_names: &ReqProtocolNames, - config: &mut Configuration, + config: &mut FullNetworkConfiguration, ) -> ( IncomingRequestReceiver, IncomingRequestReceiver, ) { let (collation_req_receiver, cfg) = IncomingRequest::get_config_receiver(request_protocol_names); - config.network.request_response_protocols.push(cfg); + config.add_request_response_protocol(cfg); let (available_data_req_receiver, cfg) = IncomingRequest::get_config_receiver(request_protocol_names); - config.network.request_response_protocols.push(cfg); + config.add_request_response_protocol(cfg); let cfg = Protocol::ChunkFetchingV1.get_outbound_only_config(request_protocol_names); - config.network.request_response_protocols.push(cfg); + config.add_request_response_protocol(cfg); (collation_req_receiver, available_data_req_receiver) } diff --git a/client/relay-chain-minimal-node/src/network.rs b/client/relay-chain-minimal-node/src/network.rs index 5225fa053cc..022e7e696b7 100644 --- a/client/relay-chain-minimal-node/src/network.rs +++ b/client/relay-chain-minimal-node/src/network.rs @@ -24,6 +24,7 @@ use sc_network::{ NetworkService, }; +use sc_network::config::FullNetworkConfiguration; use sc_network_common::{role::Roles, sync::message::BlockAnnouncesHandshake}; use sc_service::{error::Error, Configuration, NetworkStarter, SpawnTaskHandle}; use sc_utils::mpsc::tracing_unbounded; @@ -33,6 +34,7 @@ use std::{iter, sync::Arc}; /// Build the network service, the network status sinks and an RPC sender. pub(crate) fn build_collator_network( config: &Configuration, + network_config: FullNetworkConfiguration, spawn_handle: SpawnTaskHandle, genesis_hash: Hash, best_header: Header, @@ -61,12 +63,11 @@ pub(crate) fn build_collator_network( }) }, fork_id: None, - network_config: config.network.clone(), + network_config, genesis_hash, protocol_id, metrics_registry: config.prometheus_config.as_ref().map(|config| config.registry.clone()), block_announce_config, - request_response_protocol_configs: Vec::new(), tx, }; diff --git a/client/relay-chain-rpc-interface/Cargo.toml b/client/relay-chain-rpc-interface/Cargo.toml index 655c7c8e74c..ba319ca7f1b 100644 --- a/client/relay-chain-rpc-interface/Cargo.toml +++ b/client/relay-chain-rpc-interface/Cargo.toml @@ -21,15 +21,15 @@ sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "mas sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" } -tokio = { version = "1.27.0", features = ["sync"] } +tokio = { version = "1.28.2", features = ["sync"] } futures = "0.3.28" futures-timer = "3.0.2" -parity-scale-codec = "3.4.0" +parity-scale-codec = "3.5.0" jsonrpsee = { version = "0.16.2", features = ["ws-client"] } tracing = "0.1.37" async-trait = "0.1.68" url = "2.3.1" serde_json = "1.0.96" -serde = "1.0.160" +serde = "1.0.163" lru = "0.9.0" diff --git a/client/relay-chain-rpc-interface/src/reconnecting_ws_client.rs b/client/relay-chain-rpc-interface/src/reconnecting_ws_client.rs index e03525226bc..803a27d00f6 100644 --- a/client/relay-chain-rpc-interface/src/reconnecting_ws_client.rs +++ b/client/relay-chain-rpc-interface/src/reconnecting_ws_client.rs @@ -161,7 +161,9 @@ impl ReconnectingWsClient { } } -/// Worker that should be used in combination with [`RelayChainRpcClient`]. Must be polled to distribute header notifications to listeners. +/// Worker that should be used in combination with [`crate::RelayChainRpcClient`]. +/// +/// Must be polled to distribute header notifications to listeners. struct ReconnectingWebsocketWorker { ws_urls: Vec, /// Communication channel with the RPC client diff --git a/client/relay-chain-rpc-interface/src/rpc_client.rs b/client/relay-chain-rpc-interface/src/rpc_client.rs index 6bd2d33d3a2..70c64eeeffc 100644 --- a/client/relay-chain-rpc-interface/src/rpc_client.rs +++ b/client/relay-chain-rpc-interface/src/rpc_client.rs @@ -30,7 +30,7 @@ use sp_storage::StorageKey; use cumulus_primitives_core::{ relay_chain::{ - BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, + vstaging, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash, CommittedCandidateReceipt, CoreState, DisputeState, ExecutorParams, GroupRotationInfo, Hash as RelayHash, Header as RelayHeader, InboundHrmpMessage, OccupiedCoreAssumption, PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode, @@ -320,15 +320,62 @@ impl RelayChainRpcClient { } /// Returns all onchain disputes. - /// This is a staging method! Do not use on production runtimes! - pub async fn parachain_host_staging_get_disputes( + pub async fn parachain_host_disputes( &self, at: RelayHash, ) -> Result)>, RelayChainError> { - self.call_remote_runtime_function("ParachainHost_staging_get_disputes", at, None::<()>) + self.call_remote_runtime_function("ParachainHost_disputes", at, None::<()>) + .await + } + + /// Returns a list of validators that lost a past session dispute and need to be slashed. + /// + /// This is a staging method! Do not use on production runtimes! + pub async fn parachain_host_unapplied_slashes( + &self, + at: RelayHash, + ) -> Result< + Vec<(SessionIndex, CandidateHash, vstaging::slashing::PendingSlashes)>, + RelayChainError, + > { + self.call_remote_runtime_function("ParachainHost_unapplied_slashes", at, None::<()>) .await } + /// Returns a merkle proof of a validator session key in a past session. + /// + /// This is a staging method! Do not use on production runtimes! + pub async fn parachain_host_key_ownership_proof( + &self, + at: RelayHash, + validator_id: ValidatorId, + ) -> Result, RelayChainError> { + self.call_remote_runtime_function( + "ParachainHost_key_ownership_proof", + at, + Some(validator_id), + ) + .await + } + + /// Submits an unsigned extrinsic to slash validators who lost a dispute about + /// a candidate of a past session. + /// + /// This is a staging method! Do not use on production runtimes! + pub async fn parachain_host_submit_report_dispute_lost( + &self, + at: RelayHash, + dispute_proof: vstaging::slashing::DisputeProof, + key_ownership_proof: vstaging::slashing::OpaqueKeyOwnershipProof, + ) -> Result, RelayChainError> { + self.call_remote_runtime_function( + "ParachainHost_submit_report_dispute_lost", + at, + Some((dispute_proof, key_ownership_proof)), + ) + .await + } + pub async fn authority_discovery_authorities( &self, at: RelayHash, diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index ec6fc5e3c30..42b9916d468 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -125,7 +125,7 @@ where task_manager .spawn_essential_handle() - .spawn("cumulus-consensus", None, consensus); + .spawn_blocking("cumulus-consensus", None, consensus); let pov_recovery = PoVRecovery::new( recovery_handle, @@ -218,7 +218,7 @@ where task_manager .spawn_essential_handle() - .spawn("cumulus-consensus", None, consensus); + .spawn_blocking("cumulus-consensus", None, consensus); let pov_recovery = PoVRecovery::new( recovery_handle, @@ -301,6 +301,7 @@ pub struct BuildNetworkParams< Client::Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue, { pub parachain_config: &'a Configuration, + pub net_config: sc_network::config::FullNetworkConfiguration, pub client: Arc, pub transaction_pool: Arc>, pub para_id: ParaId, @@ -313,6 +314,7 @@ pub struct BuildNetworkParams< pub async fn build_network<'a, Block, Client, RCInterface, IQ>( BuildNetworkParams { parachain_config, + net_config, client, transaction_pool, para_id, @@ -364,6 +366,7 @@ where sc_service::build_network(sc_service::BuildNetworkParams { config: parachain_config, + net_config, client, transaction_pool, spawn_handle, @@ -441,7 +444,7 @@ where ) .await .map_err(|e| format!("{e:?}"))? - .ok_or_else(|| "Could not find parachain head in relay chain")?; + .ok_or("Could not find parachain head in relay chain")?; let target_block = B::Header::decode(&mut &validation_data.parent_head.0[..]) .map_err(|e| format!("Failed to decode parachain head: {e}"))?; diff --git a/docs/release.md b/docs/release.md index 9c0a6acc0e9..b04c4e844c4 100644 --- a/docs/release.md +++ b/docs/release.md @@ -37,8 +37,8 @@ performed during the release process. ### Burn In -Ensure that Parity DevOps has run the new release on Westmint and Statemine collators for 12h prior to publishing the -release. +Ensure that Parity DevOps has run the new release on Westend and Kusama Asset Hub collators for 12h +prior to publishing the release. ### Build Artifacts @@ -84,15 +84,15 @@ To verify the order has not changed, manually start the following [Github Action To run it, in the _Run Workflow_ dropdown: 1. **Use workflow from**: to ignore, leave `master` as default 2. **The WebSocket url of the reference node**: - - Statemint: `wss://statemint-rpc.polkadot.io` - - Statemine: `wss://statemine-rpc.polkadot.io` - - Westmint: `wss://westmint-rpc.polkadot.io` + - Asset Hub Polkadot: `wss://statemint-rpc.polkadot.io` + - Asset Hub Kusama: `wss://statemine-rpc.polkadot.io` + - Asset Hub Westend: `wss://westmint-rpc.polkadot.io` 3. **A url to a Linux binary for the node containing the runtime to test**: Paste the URL of the latest release-candidate binary from the draft-release on Github. The binary has to previously be uploaded to S3 (Github url link to the binary is constantly changing) - E.g: https://releases.parity.io/cumulus/v0.9.270-rc3/polkadot-parachain 4. **The name of the chain under test. Usually, you would pass a local chain**: - - Statemint: `statemint-local` - - Statemine: `statemine-local` - - Westmint: `westmint-local` + - Asset Hub Polkadot: `asset-hub-polkadot-local` + - Asset Hub Kusama: `asset-hub-kusama-local` + - Asset Hub Westend: `asset-hub-westend-local` 5. Click **Run workflow** When the workflow is done, click on it and download the zip artifact, inside you'll find an `output.txt` file. The things to look for in the output are lines like: @@ -114,7 +114,7 @@ The Benchmarks can now be started from the CI. First find the CI pipeline from [ ### Integration Tests Until https://github.com/paritytech/ci_cd/issues/499 is done, tests will have to be run manually. -1. Go to https://github.com/paritytech/parachains-integration-tests and checkout to the release branch. +1. Go to https://github.com/paritytech/parachains-integration-tests and check out the release branch. E.g. https://github.com/paritytech/parachains-integration-tests/tree/release-v9270-v0.9.27 for `release-parachains-v0.9.270` 2. Clone `release-parachains-` branch from Cumulus @@ -126,5 +126,5 @@ In case the branch does not exists (it is a manual process): cherry pick parityt 6. `cargo build --release --features fast-runtime` 7. Copy `./target/polkadot` into `./bin` (in Cumulus) 8. Run the tests: - - Statemint: `yarn zombienet-test -c ./examples/statemint/config.toml -t ./examples/statemint` - - Statemine: `yarn zombienet-test -c ./examples/statemine/config.toml -t ./examples/statemine` + - Asset Hub Polkadot: `yarn zombienet-test -c ./examples/statemint/config.toml -t ./examples/statemint` + - Asset Hub Kusama: `yarn zombienet-test -c ./examples/statemine/config.toml -t ./examples/statemine` diff --git a/pallets/aura-ext/Cargo.toml b/pallets/aura-ext/Cargo.toml index 1db43697511..23f70e4be9b 100644 --- a/pallets/aura-ext/Cargo.toml +++ b/pallets/aura-ext/Cargo.toml @@ -7,7 +7,7 @@ description = "AURA consensus extension pallet for parachains" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } # Substrate frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/pallets/collator-selection/Cargo.toml b/pallets/collator-selection/Cargo.toml index 17bb6fe5579..c62a0a180a9 100644 --- a/pallets/collator-selection/Cargo.toml +++ b/pallets/collator-selection/Cargo.toml @@ -1,6 +1,6 @@ [package] -authors = ["Anonymous"] -description = "Simple staking pallet with a fixed stake." +authors = ["Parity Technologies "] +description = "Simple pallet to select collators for a parachain." edition = "2021" homepage = "https://substrate.io" license = "Apache-2.0" @@ -13,10 +13,10 @@ version = "3.0.0" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -log = { version = "0.4.17", default-features = false } +log = { version = "0.4.18", default-features = false } codec = { default-features = false, features = ["derive"], package = "parity-scale-codec", version = "3.0.0" } rand = { version = "0.8.5", features = ["std_rng"], default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/pallets/collator-selection/src/benchmarking.rs b/pallets/collator-selection/src/benchmarking.rs index 8a222511137..63c9561e7dd 100644 --- a/pallets/collator-selection/src/benchmarking.rs +++ b/pallets/collator-selection/src/benchmarking.rs @@ -110,17 +110,61 @@ benchmarks! { where_clause { where T: pallet_authorship::Config + session::Config } set_invulnerables { + let origin = + T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let b in 1 .. T::MaxInvulnerables::get(); let new_invulnerables = register_validators::(b); + let mut sorted_new_invulnerables = new_invulnerables.clone(); + sorted_new_invulnerables.sort(); + }: { + assert_ok!( + // call the function with the unsorted list + >::set_invulnerables(origin, new_invulnerables.clone()) + ); + } + verify { + // assert that it comes out sorted + assert_last_event::(Event::NewInvulnerables{invulnerables: sorted_new_invulnerables}.into()); + } + + add_invulnerable { let origin = T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + // we're going to add one, so need one less than max set as invulnerables to start + let b in 1 .. T::MaxInvulnerables::get() - 1; + let mut invulnerables = register_validators::(b); + invulnerables.sort(); + let invulnerables: frame_support::BoundedVec<_, T::MaxInvulnerables> = frame_support::BoundedVec::try_from(invulnerables).unwrap(); + >::put(invulnerables); + + // now let's set up a new one to add + let (new, keys) = validator::(b + 1); + >::set_keys(RawOrigin::Signed(new.clone()).into(), keys, Vec::new()).unwrap(); }: { assert_ok!( - >::set_invulnerables(origin, new_invulnerables.clone()) + >::add_invulnerable(origin, new.clone()) + ); + } + verify { + assert_last_event::(Event::InvulnerableAdded{account_id: new}.into()); + } + + remove_invulnerable { + let origin = + T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + let b in 1 .. T::MaxInvulnerables::get(); + let mut invulnerables = register_validators::(b); + invulnerables.sort(); + let invulnerables: frame_support::BoundedVec<_, T::MaxInvulnerables> = frame_support::BoundedVec::try_from(invulnerables).unwrap(); + >::put(invulnerables); + let to_remove = >::get().first().unwrap().clone(); + }: { + assert_ok!( + >::remove_invulnerable(origin, to_remove.clone()) ); } verify { - assert_last_event::(Event::NewInvulnerables{invulnerables: new_invulnerables}.into()); + assert_last_event::(Event::InvulnerableRemoved{account_id: to_remove}.into()); } set_desired_candidates { @@ -129,7 +173,7 @@ benchmarks! { T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: { assert_ok!( - >::set_desired_candidates(origin, max.clone()) + >::set_desired_candidates(origin, max) ); } verify { @@ -142,7 +186,7 @@ benchmarks! { T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: { assert_ok!( - >::set_candidacy_bond(origin, bond_amount.clone()) + >::set_candidacy_bond(origin, bond_amount) ); } verify { @@ -162,7 +206,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let bond: BalanceOf = T::Currency::minimum_balance() * 2u32.into(); - T::Currency::make_free_balance_be(&caller, bond.clone()); + T::Currency::make_free_balance_be(&caller, bond); >::set_keys( RawOrigin::Signed(caller.clone()).into(), diff --git a/pallets/collator-selection/src/lib.rs b/pallets/collator-selection/src/lib.rs index 3dba6846cc3..daccc4ce93c 100644 --- a/pallets/collator-selection/src/lib.rs +++ b/pallets/collator-selection/src/lib.rs @@ -70,8 +70,11 @@ mod tests; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +pub mod migration; pub mod weights; +const LOG_TARGET: &str = "runtime::collator-selection"; + #[frame_support::pallet] pub mod pallet { pub use crate::weights::WeightInfo; @@ -88,13 +91,16 @@ pub mod pallet { Currency, EnsureOrigin, ExistenceRequirement::KeepAlive, ReservableCurrency, ValidatorRegistration, }, - BoundedVec, PalletId, + BoundedVec, DefaultNoBound, PalletId, }; use frame_system::{pallet_prelude::*, Config as SystemConfig}; use pallet_session::SessionManager; use sp_runtime::traits::Convert; use sp_staking::SessionIndex; + /// The current storage version. + const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; @@ -165,9 +171,10 @@ pub mod pallet { } #[pallet::pallet] + #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); - /// The invulnerable, fixed collators. + /// The invulnerable, permissioned collators. This list must be sorted. #[pallet::storage] #[pallet::getter(fn invulnerables)] pub type Invulnerables = @@ -203,34 +210,26 @@ pub mod pallet { pub type CandidacyBond = StorageValue<_, BalanceOf, ValueQuery>; #[pallet::genesis_config] + #[derive(DefaultNoBound)] pub struct GenesisConfig { pub invulnerables: Vec, pub candidacy_bond: BalanceOf, pub desired_candidates: u32, } - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { - invulnerables: Default::default(), - candidacy_bond: Default::default(), - desired_candidates: Default::default(), - } - } - } - #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { - let duplicate_invulnerables = - self.invulnerables.iter().collect::>(); + let duplicate_invulnerables = self + .invulnerables + .iter() + .collect::>(); assert!( duplicate_invulnerables.len() == self.invulnerables.len(), "duplicate invulnerables in genesis." ); - let bounded_invulnerables = + let mut bounded_invulnerables = BoundedVec::<_, T::MaxInvulnerables>::try_from(self.invulnerables.clone()) .expect("genesis invulnerables are more than T::MaxInvulnerables"); assert!( @@ -238,8 +237,10 @@ pub mod pallet { "genesis desired_candidates are more than T::MaxCandidates", ); - >::put(&self.desired_candidates); - >::put(&self.candidacy_bond); + bounded_invulnerables.sort(); + + >::put(self.desired_candidates); + >::put(self.candidacy_bond); >::put(bounded_invulnerables); } } @@ -247,35 +248,41 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { + /// New Invulnerables were set. NewInvulnerables { invulnerables: Vec }, + /// A new Invulnerable was added. + InvulnerableAdded { account_id: T::AccountId }, + /// An Invulnerable was removed. + InvulnerableRemoved { account_id: T::AccountId }, + /// The number of desired candidates was set. NewDesiredCandidates { desired_candidates: u32 }, + /// The candidacy bond was set. NewCandidacyBond { bond_amount: BalanceOf }, + /// A new candidate joined. CandidateAdded { account_id: T::AccountId, deposit: BalanceOf }, + /// A candidate was removed. CandidateRemoved { account_id: T::AccountId }, } - // Errors inform users that something went wrong. #[pallet::error] pub enum Error { - /// Too many candidates + /// The pallet has too many candidates. TooManyCandidates, - /// Too few candidates + /// Leaving would result in too few candidates. TooFewCandidates, - /// Unknown error - Unknown, - /// Permission issue - Permission, - /// User is already a candidate + /// Account is already a candidate. AlreadyCandidate, - /// User is not a candidate + /// Account is not a candidate. NotCandidate, - /// Too many invulnerables + /// There are too many Invulnerables. TooManyInvulnerables, - /// User is already an Invulnerable + /// Account is already an Invulnerable. AlreadyInvulnerable, - /// Account has no associated validator ID + /// Account is not an Invulnerable. + NotInvulnerable, + /// Account has no associated validator ID. NoAssociatedValidatorId, - /// Validator ID is not yet registered + /// Validator ID is not yet registered. ValidatorNotRegistered, } @@ -292,7 +299,7 @@ pub mod pallet { new: Vec, ) -> DispatchResultWithPostInfo { T::UpdateOrigin::ensure_origin(origin)?; - let bounded_invulnerables = BoundedVec::<_, T::MaxInvulnerables>::try_from(new) + let mut bounded_invulnerables = BoundedVec::<_, T::MaxInvulnerables>::try_from(new) .map_err(|_| Error::::TooManyInvulnerables)?; // check if the invulnerables have associated validator keys before they are set @@ -305,6 +312,9 @@ pub mod pallet { ); } + // Invulnerables must be sorted for removal. + bounded_invulnerables.sort(); + >::put(&bounded_invulnerables); Self::deposit_event(Event::NewInvulnerables { invulnerables: bounded_invulnerables.to_vec(), @@ -326,7 +336,7 @@ pub mod pallet { if max > T::MaxCandidates::get() { log::warn!("max > T::MaxCandidates; you might need to run benchmarks again"); } - >::put(&max); + >::put(max); Self::deposit_event(Event::NewDesiredCandidates { desired_candidates: max }); Ok(().into()) } @@ -339,7 +349,7 @@ pub mod pallet { bond: BalanceOf, ) -> DispatchResultWithPostInfo { T::UpdateOrigin::ensure_origin(origin)?; - >::put(&bond); + >::put(bond); Self::deposit_event(Event::NewCandidacyBond { bond_amount: bond }); Ok(().into()) } @@ -406,6 +416,56 @@ pub mod pallet { Ok(Some(T::WeightInfo::leave_intent(current_count as u32)).into()) } + + /// Add a new account `who` to the list of `Invulnerables` collators. + /// + /// The origin for this call must be the `UpdateOrigin`. + #[pallet::call_index(5)] + #[pallet::weight(T::WeightInfo::add_invulnerable(T::MaxInvulnerables::get() - 1))] + pub fn add_invulnerable(origin: OriginFor, who: T::AccountId) -> DispatchResult { + T::UpdateOrigin::ensure_origin(origin)?; + + // ensure `who` has registered a validator key + let validator_key = T::ValidatorIdOf::convert(who.clone()) + .ok_or(Error::::NoAssociatedValidatorId)?; + ensure!( + T::ValidatorRegistration::is_registered(&validator_key), + Error::::ValidatorNotRegistered + ); + + >::try_mutate(|invulnerables| -> DispatchResult { + match invulnerables.binary_search(&who) { + Ok(_) => return Err(Error::::AlreadyInvulnerable)?, + Err(pos) => invulnerables + .try_insert(pos, who.clone()) + .map_err(|_| Error::::TooManyInvulnerables)?, + } + Ok(()) + })?; + + Self::deposit_event(Event::InvulnerableAdded { account_id: who }); + Ok(()) + } + + /// Remove an account `who` from the list of `Invulnerables` collators. `Invulnerables` must + /// be sorted. + /// + /// The origin for this call must be the `UpdateOrigin`. + #[pallet::call_index(6)] + #[pallet::weight(T::WeightInfo::remove_invulnerable(T::MaxInvulnerables::get()))] + pub fn remove_invulnerable(origin: OriginFor, who: T::AccountId) -> DispatchResult { + T::UpdateOrigin::ensure_origin(origin)?; + + >::try_mutate(|invulnerables| -> DispatchResult { + let pos = + invulnerables.binary_search(&who).map_err(|_| Error::::NotInvulnerable)?; + invulnerables.remove(pos); + Ok(()) + })?; + + Self::deposit_event(Event::InvulnerableRemoved { account_id: who }); + Ok(()) + } } impl Pallet { diff --git a/pallets/collator-selection/src/migration.rs b/pallets/collator-selection/src/migration.rs new file mode 100644 index 00000000000..e26d9f08b5b --- /dev/null +++ b/pallets/collator-selection/src/migration.rs @@ -0,0 +1,91 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . + +//! A module that is responsible for migration of storage for Collator Selection. + +use super::*; +use frame_support::{log, traits::OnRuntimeUpgrade}; + +/// Version 1 Migration +/// This migration ensures that any existing `Invulnerables` storage lists are sorted. +pub mod v1 { + use super::*; + use frame_support::pallet_prelude::*; + #[cfg(feature = "try-runtime")] + use sp_std::prelude::*; + + pub struct MigrateToV1(sp_std::marker::PhantomData); + impl OnRuntimeUpgrade for MigrateToV1 { + fn on_runtime_upgrade() -> Weight { + let onchain_version = Pallet::::on_chain_storage_version(); + if onchain_version == 0 { + let invulnerables_len = Invulnerables::::get().to_vec().len(); + >::mutate(|invulnerables| { + invulnerables.sort(); + }); + + StorageVersion::new(1).put::>(); + log::info!( + target: LOG_TARGET, + "Sorted {} Invulnerables, upgraded storage to version 1", + invulnerables_len, + ); + // Similar complexity to `set_invulnerables` (put storage value) + // Plus 1 read for length, 1 read for `onchain_version`, 1 write to put version + T::WeightInfo::set_invulnerables(invulnerables_len as u32) + .saturating_add(T::DbWeight::get().reads_writes(2, 1)) + } else { + log::info!( + target: LOG_TARGET, + "Migration did not execute. This probably should be removed" + ); + T::DbWeight::get().reads(1) + } + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::DispatchError> { + let number_of_invulnerables = Invulnerables::::get().to_vec().len(); + Ok((number_of_invulnerables as u32).encode()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(number_of_invulnerables: Vec) -> Result<(), sp_runtime::DispatchError> { + let stored_invulnerables = Invulnerables::::get().to_vec(); + let mut sorted_invulnerables = stored_invulnerables.clone(); + sorted_invulnerables.sort(); + assert_eq!( + stored_invulnerables, sorted_invulnerables, + "after migration, the stored invulnerables should be sorted" + ); + + let number_of_invulnerables: u32 = Decode::decode( + &mut number_of_invulnerables.as_slice(), + ) + .expect("the state parameter should be something that was generated by pre_upgrade"); + let stored_invulnerables_len = stored_invulnerables.len() as u32; + assert_eq!( + number_of_invulnerables, stored_invulnerables_len, + "after migration, there should be the same number of invulnerables" + ); + + let onchain_version = Pallet::::on_chain_storage_version(); + frame_support::ensure!(onchain_version >= 1, "must_upgrade"); + + Ok(()) + } + } +} diff --git a/pallets/collator-selection/src/mock.rs b/pallets/collator-selection/src/mock.rs index ac776e3d216..d7b9c2bf74d 100644 --- a/pallets/collator-selection/src/mock.rs +++ b/pallets/collator-selection/src/mock.rs @@ -96,7 +96,7 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -152,12 +152,12 @@ pub struct TestSessionHandler; impl pallet_session::SessionHandler for TestSessionHandler { const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID]; fn on_genesis_session(keys: &[(u64, Ks)]) { - SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::>()) + SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::>()) } fn on_new_session(_: bool, keys: &[(u64, Ks)], _: &[(u64, Ks)]) { SessionChangeBlock::set(System::block_number()); dbg!(keys.len()); - SessionHandlerCollators::set(keys.into_iter().map(|(a, _)| *a).collect::>()) + SessionHandlerCollators::set(keys.iter().map(|(a, _)| *a).collect::>()) } fn on_before_session_ending() {} fn on_disabled(_: u32) {} @@ -195,11 +195,7 @@ parameter_types! { pub struct IsRegistered; impl ValidatorRegistration for IsRegistered { fn is_registered(id: &u64) -> bool { - if *id == 7u64 { - false - } else { - true - } + *id != 42u64 } } @@ -221,7 +217,7 @@ impl Config for Test { pub fn new_test_ext() -> sp_io::TestExternalities { sp_tracing::try_init_simple(); let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - let invulnerables = vec![1, 2]; + let invulnerables = vec![2, 1]; // unsorted let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)]; let keys = balances diff --git a/pallets/collator-selection/src/tests.rs b/pallets/collator-selection/src/tests.rs index 459b107ecc5..9014b6eff65 100644 --- a/pallets/collator-selection/src/tests.rs +++ b/pallets/collator-selection/src/tests.rs @@ -20,7 +20,7 @@ use frame_support::{ traits::{Currency, GenesisBuild, OnInitialize}, }; use pallet_balances::Error as BalancesError; -use sp_runtime::traits::BadOrigin; +use sp_runtime::{testing::UintAuthorityId, traits::BadOrigin}; #[test] fn basic_setup_works() { @@ -29,6 +29,7 @@ fn basic_setup_works() { assert_eq!(CollatorSelection::candidacy_bond(), 10); assert!(CollatorSelection::candidates().is_empty()); + // genesis should sort input assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); }); } @@ -36,31 +37,159 @@ fn basic_setup_works() { #[test] fn it_should_set_invulnerables() { new_test_ext().execute_with(|| { - let new_set = vec![1, 2, 3, 4]; + let mut new_set = vec![1, 4, 3, 2]; assert_ok!(CollatorSelection::set_invulnerables( RuntimeOrigin::signed(RootAccount::get()), new_set.clone() )); + new_set.sort(); assert_eq!(CollatorSelection::invulnerables(), new_set); // cannot set with non-root. assert_noop!( - CollatorSelection::set_invulnerables(RuntimeOrigin::signed(1), new_set.clone()), + CollatorSelection::set_invulnerables(RuntimeOrigin::signed(1), new_set), BadOrigin ); // cannot set invulnerables without associated validator keys - let invulnerables = vec![7]; + let invulnerables = vec![42]; assert_noop!( CollatorSelection::set_invulnerables( RuntimeOrigin::signed(RootAccount::get()), - invulnerables.clone() + invulnerables ), Error::::ValidatorNotRegistered ); }); } +#[test] +fn add_invulnerable_works() { + new_test_ext().execute_with(|| { + initialize_to_block(1); + assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); + let new = 3; + + // function runs + assert_ok!(CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + new + )); + + System::assert_last_event(RuntimeEvent::CollatorSelection( + crate::Event::InvulnerableAdded { account_id: new }, + )); + + // same element cannot be added more than once + assert_noop!( + CollatorSelection::add_invulnerable(RuntimeOrigin::signed(RootAccount::get()), new), + Error::::AlreadyInvulnerable + ); + + // new element is now part of the invulnerables list + assert!(CollatorSelection::invulnerables().to_vec().contains(&new)); + + // cannot add with non-root + assert_noop!(CollatorSelection::add_invulnerable(RuntimeOrigin::signed(1), new), BadOrigin); + + // cannot add invulnerable without associated validator keys + let not_validator = 42; + assert_noop!( + CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + not_validator + ), + Error::::ValidatorNotRegistered + ); + }); +} + +#[test] +fn invulnerable_limit_works() { + new_test_ext().execute_with(|| { + assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); + + // MaxInvulnerables: u32 = 20 + for ii in 3..=21 { + // only keys were registered in mock for 1 to 5 + if ii > 5 { + Balances::make_free_balance_be(&ii, 100); + let key = MockSessionKeys { aura: UintAuthorityId(ii) }; + Session::set_keys(RuntimeOrigin::signed(ii).into(), key, Vec::new()).unwrap(); + } + assert_eq!(Balances::free_balance(ii), 100); + if ii < 21 { + assert_ok!(CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + ii + )); + } else { + assert_noop!( + CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + ii + ), + Error::::TooManyInvulnerables + ); + } + } + let expected: Vec = (1..=20).collect(); + assert_eq!(CollatorSelection::invulnerables(), expected); + + // Cannot set too many Invulnerables + let too_many_invulnerables: Vec = (1..=21).collect(); + assert_noop!( + CollatorSelection::set_invulnerables( + RuntimeOrigin::signed(RootAccount::get()), + too_many_invulnerables + ), + Error::::TooManyInvulnerables + ); + assert_eq!(CollatorSelection::invulnerables(), expected); + }); +} + +#[test] +fn remove_invulnerable_works() { + new_test_ext().execute_with(|| { + initialize_to_block(1); + assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); + + assert_ok!(CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + 4 + )); + assert_ok!(CollatorSelection::add_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + 3 + )); + + assert_eq!(CollatorSelection::invulnerables(), vec![1, 2, 3, 4]); + + assert_ok!(CollatorSelection::remove_invulnerable( + RuntimeOrigin::signed(RootAccount::get()), + 2 + )); + + System::assert_last_event(RuntimeEvent::CollatorSelection( + crate::Event::InvulnerableRemoved { account_id: 2 }, + )); + assert_eq!(CollatorSelection::invulnerables(), vec![1, 3, 4]); + + // cannot remove invulnerable not in the list + assert_noop!( + CollatorSelection::remove_invulnerable(RuntimeOrigin::signed(RootAccount::get()), 2), + Error::::NotInvulnerable + ); + + // cannot remove without privilege + assert_noop!( + CollatorSelection::remove_invulnerable(RuntimeOrigin::signed(1), 3), + BadOrigin + ); + }); +} + #[test] fn set_desired_candidates_works() { new_test_ext().execute_with(|| { @@ -157,7 +286,7 @@ fn cannot_register_as_candidate_if_keys_not_registered() { new_test_ext().execute_with(|| { // can't 7 because keys not registered. assert_noop!( - CollatorSelection::register_as_candidate(RuntimeOrigin::signed(7)), + CollatorSelection::register_as_candidate(RuntimeOrigin::signed(42)), Error::::ValidatorNotRegistered ); }) @@ -184,8 +313,8 @@ fn cannot_register_dupe_candidate() { #[test] fn cannot_register_as_candidate_if_poor() { new_test_ext().execute_with(|| { - assert_eq!(Balances::free_balance(&3), 100); - assert_eq!(Balances::free_balance(&33), 0); + assert_eq!(Balances::free_balance(3), 100); + assert_eq!(Balances::free_balance(33), 0); // works assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3))); @@ -208,14 +337,14 @@ fn register_as_candidate_works() { assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]); // take two endowed, non-invulnerables accounts. - assert_eq!(Balances::free_balance(&3), 100); - assert_eq!(Balances::free_balance(&4), 100); + assert_eq!(Balances::free_balance(3), 100); + assert_eq!(Balances::free_balance(4), 100); assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(3))); assert_ok!(CollatorSelection::register_as_candidate(RuntimeOrigin::signed(4))); - assert_eq!(Balances::free_balance(&3), 90); - assert_eq!(Balances::free_balance(&4), 90); + assert_eq!(Balances::free_balance(3), 90); + assert_eq!(Balances::free_balance(4), 90); assert_eq!(CollatorSelection::candidates().len(), 2); }); diff --git a/pallets/collator-selection/src/weights.rs b/pallets/collator-selection/src/weights.rs index 32e816b5dbe..6b02d28d673 100644 --- a/pallets/collator-selection/src/weights.rs +++ b/pallets/collator-selection/src/weights.rs @@ -27,6 +27,8 @@ use sp_std::marker::PhantomData; // The weight info trait for `pallet_collator_selection`. pub trait WeightInfo { fn set_invulnerables(_b: u32) -> Weight; + fn add_invulnerable(_b: u32) -> Weight; + fn remove_invulnerable(_b: u32) -> Weight; fn set_desired_candidates() -> Weight; fn set_candidacy_bond() -> Weight; fn register_as_candidate(_c: u32) -> Weight; @@ -39,93 +41,157 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn set_invulnerables(b: u32) -> Weight { - Weight::from_parts(18_563_000 as u64, 0) + Weight::from_parts(18_563_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(68_000 as u64, 0).saturating_mul(b as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(Weight::from_parts(68_000_u64, 0).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } fn set_desired_candidates() -> Weight { - Weight::from_parts(16_363_000 as u64, 0).saturating_add(T::DbWeight::get().writes(1 as u64)) + Weight::from_parts(16_363_000_u64, 0).saturating_add(T::DbWeight::get().writes(1_u64)) } fn set_candidacy_bond() -> Weight { - Weight::from_parts(16_840_000 as u64, 0).saturating_add(T::DbWeight::get().writes(1 as u64)) + Weight::from_parts(16_840_000_u64, 0).saturating_add(T::DbWeight::get().writes(1_u64)) } fn register_as_candidate(c: u32) -> Weight { - Weight::from_parts(71_196_000 as u64, 0) + Weight::from_parts(71_196_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(198_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_parts(198_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } fn leave_intent(c: u32) -> Weight { - Weight::from_parts(55_336_000 as u64, 0) + Weight::from_parts(55_336_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(151_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_parts(151_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } fn note_author() -> Weight { - Weight::from_parts(71_461_000 as u64, 0) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + Weight::from_parts(71_461_000_u64, 0) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } fn new_session(r: u32, c: u32) -> Weight { - Weight::from_parts(0 as u64, 0) + Weight::from_parts(0_u64, 0) // Standard Error: 1_010_000 - .saturating_add(Weight::from_parts(109_961_000 as u64, 0).saturating_mul(r as u64)) + .saturating_add(Weight::from_parts(109_961_000_u64, 0).saturating_mul(r as u64)) // Standard Error: 1_010_000 - .saturating_add(Weight::from_parts(151_952_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(c as u64))) - .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(c as u64))) + .saturating_add(Weight::from_parts(151_952_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1_u64.saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().reads(2_u64.saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(2_u64.saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(2_u64.saturating_mul(c as u64))) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } } // For backwards compatibility and tests impl WeightInfo for () { fn set_invulnerables(b: u32) -> Weight { - Weight::from_parts(18_563_000 as u64, 0) + Weight::from_parts(18_563_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(68_000 as u64, 0).saturating_mul(b as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + .saturating_add(Weight::from_parts(68_000_u64, 0).saturating_mul(b as u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn set_desired_candidates() -> Weight { - Weight::from_parts(16_363_000 as u64, 0) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + Weight::from_parts(16_363_000_u64, 0).saturating_add(RocksDbWeight::get().writes(1_u64)) } fn set_candidacy_bond() -> Weight { - Weight::from_parts(16_840_000 as u64, 0) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + Weight::from_parts(16_840_000_u64, 0).saturating_add(RocksDbWeight::get().writes(1_u64)) } fn register_as_candidate(c: u32) -> Weight { - Weight::from_parts(71_196_000 as u64, 0) + Weight::from_parts(71_196_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(198_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_parts(198_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } fn leave_intent(c: u32) -> Weight { - Weight::from_parts(55_336_000 as u64, 0) + Weight::from_parts(55_336_000_u64, 0) // Standard Error: 0 - .saturating_add(Weight::from_parts(151_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_parts(151_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } fn note_author() -> Weight { - Weight::from_parts(71_461_000 as u64, 0) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + Weight::from_parts(71_461_000_u64, 0) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } fn new_session(r: u32, c: u32) -> Weight { - Weight::from_parts(0 as u64, 0) + Weight::from_parts(0_u64, 0) // Standard Error: 1_010_000 - .saturating_add(Weight::from_parts(109_961_000 as u64, 0).saturating_mul(r as u64)) + .saturating_add(Weight::from_parts(109_961_000_u64, 0).saturating_mul(r as u64)) // Standard Error: 1_010_000 - .saturating_add(Weight::from_parts(151_952_000 as u64, 0).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(c as u64))) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(c as u64))) + .saturating_add(Weight::from_parts(151_952_000_u64, 0).saturating_mul(c as u64)) + .saturating_add(RocksDbWeight::get().reads(1_u64.saturating_mul(r as u64))) + .saturating_add(RocksDbWeight::get().reads(2_u64.saturating_mul(c as u64))) + .saturating_add(RocksDbWeight::get().writes(2_u64.saturating_mul(r as u64))) + .saturating_add(RocksDbWeight::get().writes(2_u64.saturating_mul(c as u64))) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) } } diff --git a/pallets/parachain-system/Cargo.toml b/pallets/parachain-system/Cargo.toml index 66270339d54..217b71db850 100644 --- a/pallets/parachain-system/Cargo.toml +++ b/pallets/parachain-system/Cargo.toml @@ -10,8 +10,8 @@ bytes = { version = "1.4.0", default-features = false } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } environmental = { version = "1.1.4", default-features = false } impl-trait-for-tuples = "0.2.1" -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } # Substrate frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master", optional = true } diff --git a/pallets/parachain-system/proc-macro/Cargo.toml b/pallets/parachain-system/proc-macro/Cargo.toml index 2eb35fe4f0b..cd47fef9e09 100644 --- a/pallets/parachain-system/proc-macro/Cargo.toml +++ b/pallets/parachain-system/proc-macro/Cargo.toml @@ -9,9 +9,9 @@ description = "Proc macros provided by the parachain-system pallet" proc-macro = true [dependencies] -syn = "2.0.15" -proc-macro2 = "1.0.54" -quote = "1.0.26" +syn = "2.0.18" +proc-macro2 = "1.0.59" +quote = "1.0.28" proc-macro-crate = "1.3.1" [features] diff --git a/pallets/parachain-system/src/lib.rs b/pallets/parachain-system/src/lib.rs index ecfd8bd69b3..5d219f328b2 100644 --- a/pallets/parachain-system/src/lib.rs +++ b/pallets/parachain-system/src/lib.rs @@ -248,13 +248,13 @@ pub mod pallet { }; >::mutate(|up| { - let (count, size) = relevant_messaging_state.relay_dispatch_queue_size; + let queue_size = relevant_messaging_state.relay_dispatch_queue_size; let available_capacity = cmp::min( - host_config.max_upward_queue_count.saturating_sub(count), - host_config.max_upward_message_num_per_candidate, + queue_size.remaining_count, + host_config.max_upward_message_num_per_candidate.into(), ); - let available_size = host_config.max_upward_queue_size.saturating_sub(size); + let available_size = queue_size.remaining_size; // Count the number of messages we can possibly fit in the given constraints, i.e. // available_capacity and available_size. @@ -400,6 +400,16 @@ pub mod pallet { ) .expect("Invalid relay chain state proof"); + // Deposit a log indicating the relay-parent storage root. + // TODO: remove this in favor of the relay-parent's hash after + // https://github.com/paritytech/cumulus/issues/303 + frame_system::Pallet::::deposit_log( + cumulus_primitives_core::rpsr_digest::relay_parent_storage_root_item( + vfp.relay_parent_storage_root, + vfp.relay_parent_number, + ), + ); + // initialization logic: we know that this runs exactly once every block, // which means we can put the initialization logic here to remove the // sequencing problem. @@ -436,7 +446,7 @@ pub mod pallet { .read_abridged_host_configuration() .expect("Invalid host configuration in relay chain state proof"); let relevant_messaging_state = relay_state_proof - .read_messaging_state_snapshot() + .read_messaging_state_snapshot(&host_config) .expect("Invalid messaging state in relay chain state proof"); >::put(&vfp); @@ -488,10 +498,7 @@ pub mod pallet { check_version: bool, ) -> DispatchResult { ensure_root(origin)?; - AuthorizedUpgrade::::put(CodeUpgradeAuthorization { - code_hash: code_hash.clone(), - check_version, - }); + AuthorizedUpgrade::::put(CodeUpgradeAuthorization { code_hash, check_version }); Self::deposit_event(Event::UpgradeAuthorized { code_hash }); Ok(()) @@ -561,10 +568,8 @@ pub mod pallet { /// In case of a scheduled upgrade, this storage field contains the validation code to be applied. /// - /// As soon as the relay chain gives us the go-ahead signal, we will overwrite the [`:code`][well_known_keys::CODE] + /// As soon as the relay chain gives us the go-ahead signal, we will overwrite the [`:code`][sp_core::storage::well_known_keys::CODE] /// which will result the next block process with the new validation code. This concludes the upgrade process. - /// - /// [well_known_keys::CODE]: sp_core::storage::well_known_keys::CODE #[pallet::storage] #[pallet::getter(fn new_validation_function)] pub(super) type PendingValidationCode = StorageValue<_, Vec, ValueQuery>; @@ -702,7 +707,7 @@ pub mod pallet { /// A custom head data that should be returned as result of `validate_block`. /// - /// See [`Pallet::set_custom_validation_head_data`] for more information. + /// See `Pallet::set_custom_validation_head_data` for more information. #[pallet::storage] pub(super) type CustomValidationHeadData = StorageValue<_, Vec, OptionQuery>; @@ -768,7 +773,7 @@ impl Pallet { let authorization = AuthorizedUpgrade::::get().ok_or(Error::::NothingAuthorized)?; // ensure that the actual hash matches the authorized hash - let actual_hash = T::Hashing::hash(&code[..]); + let actual_hash = T::Hashing::hash(code); ensure!(actual_hash == authorization.code_hash, Error::::Unauthorized); // check versions if required as part of the authorization @@ -881,12 +886,13 @@ impl Pallet { /// Process all inbound horizontal messages relayed by the collator. /// /// This is similar to [`enqueue_inbound_downward_messages`], but works on multiple inbound - /// channels. It immediately dispatches signals and queues all other XCM. Blob messages are ignored. + /// channels. It immediately dispatches signals and queues all other XCM. Blob messages are + /// ignored. /// - /// **Panics** if either any of horizontal messages submitted by the collator was sent from - /// a para which has no open channel to this parachain or if after processing - /// messages across all inbound channels MQCs were obtained which do not - /// correspond to the ones found on the relay-chain. + /// **Panics** if either any of horizontal messages submitted by the collator was sent from a + /// para which has no open channel to this parachain or if after processing messages + /// across all inbound channels MQCs were obtained which do not correspond to the + /// ones found on the relay-chain. fn enqueue_inbound_horizontal_messages( ingress_channels: &[(ParaId, cumulus_primitives_core::AbridgedHrmpChannel)], horizontal_messages: BTreeMap>, @@ -954,10 +960,10 @@ impl Pallet { // `running_mqc_heads`. Otherwise, in a block where no messages were sent in a channel // it won't get into next block's `last_mqc_heads` and thus will be all zeros, which // would corrupt the message queue chain. - for &(ref sender, ref channel) in ingress_channels { + for (sender, channel) in ingress_channels { let cur_head = running_mqc_heads .entry(sender) - .or_insert_with(|| last_mqc_heads.get(&sender).cloned().unwrap_or_default()) + .or_insert_with(|| last_mqc_heads.get(sender).cloned().unwrap_or_default()) .head(); let target_head = channel.mqc_head.unwrap_or_default(); @@ -1055,6 +1061,30 @@ impl Pallet { pub fn set_custom_validation_head_data(head_data: Vec) { CustomValidationHeadData::::put(head_data); } + + /// Open HRMP channel for using it in benchmarks. + /// + /// The caller assumes that the pallet will accept regular outbound message to the sibling + /// `target_parachain` after this call. No other assumptions are made. + #[cfg(feature = "runtime-benchmarks")] + pub fn open_outbound_hrmp_channel_for_benchmarks(target_parachain: ParaId) { + RelevantMessagingState::::put(MessagingStateSnapshot { + dmq_mqc_head: Default::default(), + relay_dispatch_queue_size: Default::default(), + ingress_channels: Default::default(), + egress_channels: vec![( + target_parachain, + cumulus_primitives_core::AbridgedHrmpChannel { + max_capacity: 10, + max_total_size: 10_000_000_u32, + max_message_size: 10_000_000_u32, + msg_count: 5, + total_size: 5_000_000_u32, + mqc_head: None, + }, + )], + }) + } } pub struct ParachainSetCode(sp_std::marker::PhantomData); @@ -1079,22 +1109,20 @@ impl Pallet { // may change so that the message is no longer valid. // // However, changing this setting is expected to be rare. - match Self::host_configuration() { - Some(cfg) => - if message.len() > cfg.max_upward_message_size as usize { - return Err(MessageSendError::TooBig) - }, - None => { - // This storage field should carry over from the previous block. So if it's None - // then it must be that this is an edge-case where a message is attempted to be - // sent at the first block. - // - // Let's pass this message through. I think it's not unreasonable to expect that - // the message is not huge and it comes through, but if it doesn't it can be - // returned back to the sender. - // - // Thus fall through here. - }, + if let Some(cfg) = Self::host_configuration() { + if message.len() > cfg.max_upward_message_size as usize { + return Err(MessageSendError::TooBig) + } + } else { + // This storage field should carry over from the previous block. So if it's None + // then it must be that this is an edge-case where a message is attempted to be + // sent at the first block. + // + // Let's pass this message through. I think it's not unreasonable to expect that + // the message is not huge and it comes through, but if it doesn't it can be + // returned back to the sender. + // + // Thus fall through here. }; >::append(message.clone()); diff --git a/pallets/parachain-system/src/mock.rs b/pallets/parachain-system/src/mock.rs index c8c08aa7229..2a8d9300275 100644 --- a/pallets/parachain-system/src/mock.rs +++ b/pallets/parachain-system/src/mock.rs @@ -178,6 +178,7 @@ impl ProcessMessage for SaveIntoThreadLocal { message: &[u8], origin: Self::Origin, _meter: &mut WeightMeter, + _id: &mut [u8; 32], ) -> Result { assert_eq!(origin, Self::Origin::Parent); // FAIL-CI use transformed origin diff --git a/pallets/parachain-system/src/relay_state_snapshot.rs b/pallets/parachain-system/src/relay_state_snapshot.rs index 0a6426a8012..e3763549d44 100644 --- a/pallets/parachain-system/src/relay_state_snapshot.rs +++ b/pallets/parachain-system/src/relay_state_snapshot.rs @@ -24,6 +24,17 @@ use sp_state_machine::{Backend, TrieBackend, TrieBackendBuilder}; use sp_std::vec::Vec; use sp_trie::{HashDBT, MemoryDB, StorageProof, EMPTY_PREFIX}; +/// The capacity of the upward message queue of a parachain on the relay chain. +// The field order should stay the same as the data can be found in the proof to ensure both are +// have the same encoded representation. +#[derive(Clone, Encode, Decode, TypeInfo, Default)] +pub struct RelayDispachQueueSize { + /// The number of additional messages that can be enqueued. + pub remaining_count: u32, + /// The total size of additional messages that can be enqueued. + pub remaining_size: u32, +} + /// A snapshot of some messaging related state of relay chain pertaining to the current parachain. /// /// This data is essential for making sure that the parachain is aware of current resource use on @@ -37,10 +48,7 @@ pub struct MessagingStateSnapshot { pub dmq_mqc_head: relay_chain::Hash, /// The current capacity of the upward message queue of the current parachain on the relay chain. - /// - /// The capacity is represented by a tuple that consist of the `count` of the messages and the - /// `total_size` expressed as the sum of byte sizes of all messages in the queue. - pub relay_dispatch_queue_size: (u32, u32), + pub relay_dispatch_queue_size: RelayDispachQueueSize, /// Information about all the inbound HRMP channels. /// @@ -164,7 +172,10 @@ impl RelayChainStateProof { /// Read the [`MessagingStateSnapshot`] from the relay chain state proof. /// /// Returns an error if anything failed at reading or decoding. - pub fn read_messaging_state_snapshot(&self) -> Result { + pub fn read_messaging_state_snapshot( + &self, + host_config: &AbridgedHostConfiguration, + ) -> Result { let dmq_mqc_head: relay_chain::Hash = read_entry( &self.trie_backend, &relay_chain::well_known_keys::dmq_mqc_head(self.para_id), @@ -172,12 +183,35 @@ impl RelayChainStateProof { ) .map_err(Error::DmqMqcHead)?; - let relay_dispatch_queue_size: (u32, u32) = read_entry( + let relay_dispatch_queue_size = read_optional_entry::( &self.trie_backend, - &relay_chain::well_known_keys::relay_dispatch_queue_size(self.para_id), - Some((0, 0)), - ) - .map_err(Error::RelayDispatchQueueSize)?; + &relay_chain::well_known_keys::relay_dispatch_queue_remaining_capacity(self.para_id) + .key, + ); + + // TODO paritytech/polkadot#6283: Remove all usages of `relay_dispatch_queue_size` + // + // When the relay chain and all parachains support `relay_dispatch_queue_remaining_capacity`, + // this code here needs to be removed and above needs to be changed to `read_entry` that + // returns an error if `relay_dispatch_queue_remaining_capacity` can not be found/decoded. + // + // For now we just fallback to the old dispatch queue size if there is an error. + let relay_dispatch_queue_size = match relay_dispatch_queue_size { + Ok(Some(r)) => r, + _ => { + let res = read_entry::<(u32, u32), _>( + &self.trie_backend, + #[allow(deprecated)] + &relay_chain::well_known_keys::relay_dispatch_queue_size(self.para_id), + Some((0, 0)), + ) + .map_err(Error::RelayDispatchQueueSize)?; + + let remaining_count = host_config.max_upward_queue_count.saturating_sub(res.0); + let remaining_size = host_config.max_upward_queue_size.saturating_sub(res.1); + RelayDispachQueueSize { remaining_count, remaining_size } + }, + }; let ingress_channel_index: Vec = read_entry( &self.trie_backend, diff --git a/pallets/parachain-system/src/tests.rs b/pallets/parachain-system/src/tests.rs index e886040aea3..e190cded74d 100755 --- a/pallets/parachain-system/src/tests.rs +++ b/pallets/parachain-system/src/tests.rs @@ -53,7 +53,7 @@ fn events() { let events = System::events(); assert_eq!( events[0].event, - RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionStored.into()) + RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionStored) ); }, ) @@ -64,10 +64,9 @@ fn events() { let events = System::events(); assert_eq!( events[0].event, - RuntimeEvent::ParachainSystem( - crate::Event::ValidationFunctionApplied { relay_chain_block_num: 1234 } - .into() - ) + RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionApplied { + relay_chain_block_num: 1234 + }) ); }, ); @@ -140,7 +139,7 @@ fn aborted_upgrade() { let events = System::events(); assert_eq!( events[0].event, - RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionDiscarded.into()) + RuntimeEvent::ParachainSystem(crate::Event::ValidationFunctionDiscarded) ); }, ); @@ -165,7 +164,7 @@ fn send_upward_message_num_per_candidate() { BlockTests::new() .with_relay_sproof_builder(|_, _, sproof| { sproof.host_config.max_upward_message_num_per_candidate = 1; - sproof.relay_dispatch_queue_size = None; + sproof.relay_dispatch_queue_remaining_capacity = None; }) .add_with_post_test( 1, @@ -196,8 +195,8 @@ fn send_upward_message_relay_bottleneck() { sproof.host_config.max_upward_queue_count = 5; match relay_block_num { - 1 => sproof.relay_dispatch_queue_size = Some((5, 0)), - 2 => sproof.relay_dispatch_queue_size = Some((4, 0)), + 1 => sproof.relay_dispatch_queue_remaining_capacity = Some((0, 2048)), + 2 => sproof.relay_dispatch_queue_remaining_capacity = Some((1, 2048)), _ => unreachable!(), } }) @@ -731,3 +730,18 @@ fn upgrade_version_checks_should_work() { }); } } + +#[test] +fn deposits_relay_parent_storage_root() { + BlockTests::new().add_with_post_test( + 123, + || {}, + || { + let digest = System::digest(); + assert!(cumulus_primitives_core::rpsr_digest::extract_relay_parent_storage_root( + &digest + ) + .is_some()); + }, + ); +} diff --git a/pallets/parachain-system/src/validate_block/tests.rs b/pallets/parachain-system/src/validate_block/tests.rs index 2c39188a085..4801b62e7b5 100644 --- a/pallets/parachain-system/src/validate_block/tests.rs +++ b/pallets/parachain-system/src/validate_block/tests.rs @@ -41,7 +41,7 @@ fn call_validate_block_encoded_header( relay_parent_number: 1, relay_parent_storage_root, }, - &WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"), + WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"), ) .map(|v| v.head_data.0) } @@ -191,7 +191,7 @@ fn validate_block_invalid_parent_hash() { .unwrap_err(); } else { let output = Command::new(env::current_exe().unwrap()) - .args(&["validate_block_invalid_parent_hash", "--", "--nocapture"]) + .args(["validate_block_invalid_parent_hash", "--", "--nocapture"]) .env("RUN_TEST", "1") .output() .expect("Runs the test"); @@ -213,7 +213,7 @@ fn validate_block_fails_on_invalid_validation_data() { call_validate_block(parent_head, block, Hash::random()).unwrap_err(); } else { let output = Command::new(env::current_exe().unwrap()) - .args(&["validate_block_fails_on_invalid_validation_data", "--", "--nocapture"]) + .args(["validate_block_fails_on_invalid_validation_data", "--", "--nocapture"]) .env("RUN_TEST", "1") .output() .expect("Runs the test"); @@ -242,7 +242,7 @@ fn check_inherent_fails_on_validate_block_as_expected() { .unwrap_err(); } else { let output = Command::new(env::current_exe().unwrap()) - .args(&["check_inherent_fails_on_validate_block_as_expected", "--", "--nocapture"]) + .args(["check_inherent_fails_on_validate_block_as_expected", "--", "--nocapture"]) .env("RUN_TEST", "1") .output() .expect("Runs the test"); @@ -276,7 +276,7 @@ fn check_inherents_are_unsigned_and_before_all_other_extrinsics() { .unwrap_err(); } else { let output = Command::new(env::current_exe().unwrap()) - .args(&[ + .args([ "check_inherents_are_unsigned_and_before_all_other_extrinsics", "--", "--nocapture", diff --git a/pallets/session-benchmarking/Cargo.toml b/pallets/session-benchmarking/Cargo.toml index 11f985633e0..6bc7d845d70 100644 --- a/pallets/session-benchmarking/Cargo.toml +++ b/pallets/session-benchmarking/Cargo.toml @@ -6,14 +6,14 @@ edition = "2021" license = "Apache-2.0" homepage = "https://substrate.io" repository = "https://github.com/paritytech/cumulus/" -description = "FRAME sessions pallet benchmarking for statemint" +description = "FRAME sessions pallet benchmarking" readme = "README.md" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies] -parity-scale-codec = { version = "3.4.0", default-features = false } +parity-scale-codec = { version = "3.5.0", default-features = false } sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/pallets/solo-to-para/Cargo.toml b/pallets/solo-to-para/Cargo.toml index d092fac6ea7..c7398391b7f 100644 --- a/pallets/solo-to-para/Cargo.toml +++ b/pallets/solo-to-para/Cargo.toml @@ -7,7 +7,7 @@ description = "Adds functionality to migrate from a Solo to a Parachain" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } # Substrate frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/pallets/xcm/Cargo.toml b/pallets/xcm/Cargo.toml index 59a751dde09..80436a841ea 100644 --- a/pallets/xcm/Cargo.toml +++ b/pallets/xcm/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/pallets/xcmp-queue/Cargo.toml b/pallets/xcmp-queue/Cargo.toml index 170b4d373cc..8626d758ed0 100644 --- a/pallets/xcmp-queue/Cargo.toml +++ b/pallets/xcmp-queue/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ], default-features = false } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } # Substrate frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/pallets/xcmp-queue/src/lib.rs b/pallets/xcmp-queue/src/lib.rs index d41a0d7c46f..37e10efe65f 100644 --- a/pallets/xcmp-queue/src/lib.rs +++ b/pallets/xcmp-queue/src/lib.rs @@ -21,7 +21,7 @@ //! //! Also provides an implementation of `SendXcm` which can be placed in a router tuple for relaying //! XCM over XCMP if the destination is `Parent/Parachain`. It requires an implementation of -//! `XcmExecutor` for dispatching incoming XCM messages. +//! `XcmExecutor` for dispatching incoming XCM messages. // TODO: update this. #![cfg_attr(not(feature = "std"), no_std)] @@ -217,15 +217,15 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Some XCM was executed ok. - Success { message_hash: Option, weight: Weight }, + Success { message_hash: XcmHash, message_id: XcmHash, weight: Weight }, /// Some XCM failed. - Fail { message_hash: Option, error: XcmError, weight: Weight }, + Fail { message_hash: XcmHash, message_id: XcmHash, error: XcmError, weight: Weight }, /// Bad XCM version used. - BadVersion { message_hash: Option }, + BadVersion { message_hash: XcmHash }, /// Bad XCM format used. - BadFormat { message_hash: Option }, + BadFormat { message_hash: XcmHash }, /// An HRMP message was sent to a sibling parachain. - XcmpMessageSent { message_hash: Option }, + XcmpMessageSent { message_hash: XcmHash }, } #[pallet::error] @@ -457,7 +457,7 @@ impl Pallet { return false } s.extend_from_slice(&data[..]); - return true + true }); if appended { Ok((details.last_index - details.first_index - 1) as u32) @@ -620,6 +620,7 @@ impl ProcessMessage for Pallet { message: &[u8], origin: Self::Origin, meter: &mut WeightMeter, + id: &mut [u8; 32], ) -> Result { if !meter.check_accrue(T::WeightInfo::process_message()) { return Err(ProcessMessageError::Overweight(T::WeightInfo::process_message())) @@ -638,7 +639,7 @@ impl ProcessMessage for Pallet { return Err(ProcessMessageError::Yield) } - T::XcmpProcessor::process_message(message, origin, meter) + T::XcmpProcessor::process_message(message, origin, meter, id) } } @@ -861,7 +862,7 @@ impl SendXcm for Pallet { match Self::send_fragment(id, XcmpMessageFormat::ConcatenatedVersionedXcm, xcm) { Ok(_) => { - Self::deposit_event(Event::XcmpMessageSent { message_hash: Some(hash) }); + Self::deposit_event(Event::XcmpMessageSent { message_hash: hash }); Ok(hash) }, Err(e) => Err(SendError::Transport(<&'static str>::from(e))), diff --git a/pallets/xcmp-queue/src/migration.rs b/pallets/xcmp-queue/src/migration.rs index 8714f507bc2..96e9ec57730 100644 --- a/pallets/xcmp-queue/src/migration.rs +++ b/pallets/xcmp-queue/src/migration.rs @@ -95,7 +95,7 @@ pub fn migrate_to_v2() -> Weight { } }; - if let Err(_) = QueueConfig::::translate(|pre| pre.map(translate)) { + if QueueConfig::::translate(|pre| pre.map(translate)).is_err() { log::error!( target: super::LOG_TARGET, "unexpected error when performing translation of the QueueConfig type during storage upgrade to v2" diff --git a/pallets/xcmp-queue/src/mock.rs b/pallets/xcmp-queue/src/mock.rs index 0fce9732145..4db90178df8 100644 --- a/pallets/xcmp-queue/src/mock.rs +++ b/pallets/xcmp-queue/src/mock.rs @@ -100,7 +100,7 @@ impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -121,7 +121,7 @@ impl cumulus_pallet_parachain_system::Config for Test { parameter_types! { pub const RelayChain: MultiLocation = MultiLocation::parent(); - pub UniversalLocation: InteriorMultiLocation = X1(Parachain(1u32.into())).into(); + pub UniversalLocation: InteriorMultiLocation = X1(Parachain(1u32)); pub UnitWeightCost: Weight = Weight::from_parts(1_000_000, 1024); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; diff --git a/pallets/xcmp-queue/src/tests.rs b/pallets/xcmp-queue/src/tests.rs index 77f3fc62397..e4fcc7d9774 100644 --- a/pallets/xcmp-queue/src/tests.rs +++ b/pallets/xcmp-queue/src/tests.rs @@ -281,7 +281,7 @@ fn xcmp_queue_does_not_consume_dest_or_msg_on_not_applicable() { // XcmpQueue - check dest is really not applicable let dest = (Parent, Parent, Parent); - let mut dest_wrapper = Some(dest.clone().into()); + let mut dest_wrapper = Some(dest.into()); let mut msg_wrapper = Some(message.clone()); assert_eq!( Err(SendError::NotApplicable), @@ -289,7 +289,7 @@ fn xcmp_queue_does_not_consume_dest_or_msg_on_not_applicable() { ); // check wrapper were not consumed - assert_eq!(Some(dest.clone().into()), dest_wrapper.take()); + assert_eq!(Some(dest.into()), dest_wrapper.take()); assert_eq!(Some(message.clone()), msg_wrapper.take()); // another try with router chain with asserting sender @@ -309,7 +309,7 @@ fn xcmp_queue_consumes_dest_and_msg_on_ok_validate() { // XcmpQueue - check dest/msg is valid let dest = (Parent, X1(Parachain(5555))); - let mut dest_wrapper = Some(dest.clone().into()); + let mut dest_wrapper = Some(dest.into()); let mut msg_wrapper = Some(message.clone()); assert!(::validate(&mut dest_wrapper, &mut msg_wrapper).is_ok()); diff --git a/parachain-template/node/Cargo.toml b/parachain-template/node/Cargo.toml index 6b350d6ba0f..fb3d619335a 100644 --- a/parachain-template/node/Cargo.toml +++ b/parachain-template/node/Cargo.toml @@ -10,10 +10,10 @@ edition = "2021" build = "build.rs" [dependencies] -clap = { version = "4.2.3", features = ["derive"] } -log = "0.4.17" +clap = { version = "4.3.1", features = ["derive"] } +log = "0.4.18" codec = { package = "parity-scale-codec", version = "3.0.0" } -serde = { version = "1.0.160", features = ["derive"] } +serde = { version = "1.0.163", features = ["derive"] } jsonrpsee = { version = "0.16.2", features = ["server"] } # Local diff --git a/parachain-template/node/src/cli.rs b/parachain-template/node/src/cli.rs index 2e64a53e96a..b72579c86b9 100644 --- a/parachain-template/node/src/cli.rs +++ b/parachain-template/node/src/cli.rs @@ -105,7 +105,11 @@ impl RelayChainCli { ) -> Self { let extension = crate::chain_spec::Extensions::try_get(&*para_config.chain_spec); let chain_id = extension.map(|e| e.relay_chain.clone()); - let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot")); - Self { base_path, chain_id, base: clap::Parser::parse_from(relay_chain_args) } + let base_path = para_config.base_path.path().join("polkadot"); + Self { + base_path: Some(base_path), + chain_id, + base: clap::Parser::parse_from(relay_chain_args), + } } } diff --git a/parachain-template/node/src/command.rs b/parachain-template/node/src/command.rs index 36e5ab635ac..c3e79ebe387 100644 --- a/parachain-template/node/src/command.rs +++ b/parachain-template/node/src/command.rs @@ -268,13 +268,13 @@ pub fn run() -> Result<()> { runner.run_node_until_exit(|config| async move { let hwbench = (!cli.no_hardware_benchmarks).then_some( config.database.path().map(|database_path| { - let _ = std::fs::create_dir_all(&database_path); + let _ = std::fs::create_dir_all(database_path); sc_sysinfo::gather_hwbench(Some(database_path)) })).flatten(); let para_id = chain_spec::Extensions::try_get(&*config.chain_spec) .map(|e| e.para_id) - .ok_or_else(|| "Could not find parachain ID in chain-spec.")?; + .ok_or("Could not find parachain ID in chain-spec.")?; let polkadot_cli = RelayChainCli::new( &config, @@ -301,7 +301,7 @@ pub fn run() -> Result<()> { info!("Parachain genesis state: {}", genesis_state); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); - if !collator_options.relay_chain_rpc_urls.is_empty() && cli.relay_chain_args.len() > 0 { + if !collator_options.relay_chain_rpc_urls.is_empty() && !cli.relay_chain_args.is_empty() { warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options."); } @@ -325,14 +325,10 @@ impl DefaultConfigurationValues for RelayChainCli { 30334 } - fn rpc_ws_listen_port() -> u16 { + fn rpc_listen_port() -> u16 { 9945 } - fn rpc_http_listen_port() -> u16 { - 9934 - } - fn prometheus_listen_port() -> u16 { 9616 } @@ -362,16 +358,8 @@ impl CliConfiguration for RelayChainCli { .or_else(|| self.base_path.clone().map(Into::into))) } - fn rpc_http(&self, default_listen_port: u16) -> Result> { - self.base.base.rpc_http(default_listen_port) - } - - fn rpc_ipc(&self) -> Result> { - self.base.base.rpc_ipc() - } - - fn rpc_ws(&self, default_listen_port: u16) -> Result> { - self.base.base.rpc_ws(default_listen_port) + fn rpc_addr(&self, default_listen_port: u16) -> Result> { + self.base.base.rpc_addr(default_listen_port) } fn prometheus_config( @@ -417,8 +405,8 @@ impl CliConfiguration for RelayChainCli { self.base.base.rpc_methods() } - fn rpc_ws_max_connections(&self) -> Result> { - self.base.base.rpc_ws_max_connections() + fn rpc_max_connections(&self) -> Result { + self.base.base.rpc_max_connections() } fn rpc_cors(&self, is_dev: bool) -> Result>> { diff --git a/parachain-template/node/src/service.rs b/parachain-template/node/src/service.rs index 4c9e1febf70..fb311a48b48 100644 --- a/parachain-template/node/src/service.rs +++ b/parachain-template/node/src/service.rs @@ -157,6 +157,7 @@ async fn start_node_impl( let params = new_partial(¶chain_config)?; let (block_import, mut telemetry, telemetry_worker_handle) = params.other; + let net_config = sc_network::config::FullNetworkConfiguration::new(¶chain_config.network); let client = params.client.clone(); let backend = params.backend.clone(); @@ -182,6 +183,7 @@ async fn start_node_impl( let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = build_network(BuildNetworkParams { parachain_config: ¶chain_config, + net_config, client: client.clone(), transaction_pool: transaction_pool.clone(), para_id, diff --git a/parachain-template/pallets/template/Cargo.toml b/parachain-template/pallets/template/Cargo.toml index ca574f6c8d5..1ccdc6622ba 100644 --- a/parachain-template/pallets/template/Cargo.toml +++ b/parachain-template/pallets/template/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pallet-template" +name = "pallet-parachain-template" authors = ["Anonymous"] description = "FRAME pallet template for defining custom runtime logic." version = "0.1.0" @@ -21,7 +21,7 @@ frame-support = { git = "https://github.com/paritytech/substrate", default-featu frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } [dev-dependencies] -serde = { version = "1.0.132" } +serde = { version = "1.0.163" } # Substrate sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/parachain-template/pallets/template/src/benchmarking.rs b/parachain-template/pallets/template/src/benchmarking.rs index fea9e65969b..8bba2a09867 100644 --- a/parachain-template/pallets/template/src/benchmarking.rs +++ b/parachain-template/pallets/template/src/benchmarking.rs @@ -1,4 +1,4 @@ -//! Benchmarking setup for pallet-template +//! Benchmarking setup for pallet-parachain-template use super::*; diff --git a/parachain-template/pallets/template/src/mock.rs b/parachain-template/pallets/template/src/mock.rs index 4a7ebac0fa8..099c0af8acd 100644 --- a/parachain-template/pallets/template/src/mock.rs +++ b/parachain-template/pallets/template/src/mock.rs @@ -1,4 +1,3 @@ -use crate as pallet_template; use frame_support::{parameter_types, traits::Everything}; use frame_system as system; use sp_core::H256; @@ -18,7 +17,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - TemplateModule: pallet_template::{Pallet, Call, Storage, Event}, + TemplateModule: crate::{Pallet, Call, Storage, Event}, } ); @@ -54,7 +53,7 @@ impl system::Config for Test { type MaxConsumers = frame_support::traits::ConstU32<16>; } -impl pallet_template::Config for Test { +impl crate::Config for Test { type RuntimeEvent = RuntimeEvent; } diff --git a/parachain-template/runtime/Cargo.toml b/parachain-template/runtime/Cargo.toml index dd3c78f8702..a9ec416e7e3 100644 --- a/parachain-template/runtime/Cargo.toml +++ b/parachain-template/runtime/Cargo.toml @@ -17,12 +17,12 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } hex-literal = { version = "0.4.1", optional = true } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } smallvec = "1.10.0" # Local -pallet-template = { path = "../pallets/template", default-features = false } +pallet-parachain-template = { path = "../pallets/template", default-features = false } # Substrate frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "master" } @@ -100,7 +100,7 @@ std = [ "pallet-message-queue/std", "pallet-session/std", "pallet-sudo/std", - "pallet-template/std", + "pallet-parachain-template/std", "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", @@ -135,7 +135,7 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", "pallet-message-queue/runtime-benchmarks", - "pallet-template/runtime-benchmarks", + "pallet-parachain-template/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "sp-runtime/runtime-benchmarks", @@ -160,7 +160,7 @@ try-runtime = [ "pallet-message-queue/try-runtime", "pallet-session/try-runtime", "pallet-sudo/try-runtime", - "pallet-template/try-runtime", + "pallet-parachain-template/try-runtime", "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-xcm/try-runtime", diff --git a/parachain-template/runtime/src/lib.rs b/parachain-template/runtime/src/lib.rs index 7816a1969a6..32a1f3b82fa 100644 --- a/parachain-template/runtime/src/lib.rs +++ b/parachain-template/runtime/src/lib.rs @@ -42,11 +42,10 @@ use frame_system::{ EnsureRoot, }; use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; -use parachains_common::process_xcm_message::{ - ParaIdToSibling, ProcessFromSibling, ProcessXcmMessage, -}; +use parachains_common::process_xcm_message::{ParaIdToSibling, ProcessFromSibling}; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; +use xcm_builder::ProcessXcmMessage; use xcm_config::{RelayLocation, XcmOriginToTransactDispatchOrigin}; #[cfg(any(feature = "std", test))] @@ -61,7 +60,7 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use xcm::latest::prelude::BodyId; /// Import the template pallet. -pub use pallet_template; +pub use pallet_parachain_template; /// Alias to 512-bit hash when used in the context of a transaction signature on the chain. pub type Signature = MultiSignature; @@ -343,7 +342,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -495,7 +494,7 @@ impl pallet_collator_selection::Config for Runtime { } /// Configure the pallet template in pallets/template. -impl pallet_template::Config for Runtime { +impl pallet_parachain_template::Config for Runtime { type RuntimeEvent = RuntimeEvent; } @@ -531,7 +530,7 @@ construct_runtime!( MessageQueue: pallet_message_queue = 34, // Template - TemplatePallet: pallet_template = 40, + TemplatePallet: pallet_parachain_template = 40, } ); @@ -727,13 +726,13 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch}; use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime {} diff --git a/parachain-template/runtime/src/xcm_config.rs b/parachain-template/runtime/src/xcm_config.rs index bd395c83d38..9eea16068d0 100644 --- a/parachain-template/runtime/src/xcm_config.rs +++ b/parachain-template/runtime/src/xcm_config.rs @@ -2,10 +2,9 @@ use super::{ AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue, }; -use core::{marker::PhantomData, ops::ControlFlow}; use frame_support::{ - log, match_types, parameter_types, - traits::{ConstU32, Everything, Nothing, ProcessMessageError}, + match_types, parameter_types, + traits::{ConstU32, Everything, Nothing}, weights::Weight, }; use frame_system::EnsureRoot; @@ -15,12 +14,13 @@ use polkadot_runtime_common::impls::ToAuthor; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, - CreateMatcher, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, MatchXcm, - NativeAsset, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WithComputedOrigin, + CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, + FixedWeightBounds, IsConcrete, NativeAsset, ParentIsPreset, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, + UsingComponents, WithComputedOrigin, WithUniqueTopic, }; -use xcm_executor::{traits::ShouldExecute, XcmExecutor}; +use xcm_executor::XcmExecutor; parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); @@ -63,7 +63,7 @@ pub type XcmOriginToTransactDispatchOrigin = ( // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for // foreign chains who want to have a local sovereign account on this chain which they control. SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when + // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when // recognized. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when @@ -90,88 +90,22 @@ match_types! { }; } -//TODO: move DenyThenTry to polkadot's xcm module. -/// Deny executing the xcm message if it matches any of the Deny filter regardless of anything else. -/// If it passes the Deny, and matches one of the Allow cases then it is let through. -pub struct DenyThenTry(PhantomData, PhantomData) -where - Deny: ShouldExecute, - Allow: ShouldExecute; - -impl ShouldExecute for DenyThenTry -where - Deny: ShouldExecute, - Allow: ShouldExecute, -{ - fn should_execute( - origin: &MultiLocation, - message: &mut [Instruction], - max_weight: Weight, - weight_credit: &mut Weight, - ) -> Result<(), ProcessMessageError> { - Deny::should_execute(origin, message, max_weight, weight_credit)?; - Allow::should_execute(origin, message, max_weight, weight_credit) - } -} - -// See issue -pub struct DenyReserveTransferToRelayChain; -impl ShouldExecute for DenyReserveTransferToRelayChain { - fn should_execute( - origin: &MultiLocation, - message: &mut [Instruction], - _max_weight: Weight, - _weight_credit: &mut Weight, - ) -> Result<(), ProcessMessageError> { - message.matcher().match_next_inst_while( - |_| true, - |inst| match inst { - InitiateReserveWithdraw { - reserve: MultiLocation { parents: 1, interior: Here }, - .. - } | - DepositReserveAsset { - dest: MultiLocation { parents: 1, interior: Here }, .. - } | - TransferReserveAsset { - dest: MultiLocation { parents: 1, interior: Here }, .. - } => { - Err(ProcessMessageError::Unsupported) // Deny - }, - // An unexpected reserve transfer has arrived from the Relay Chain. Generally, - // `IsReserve` should not allow this, but we just log it here. - ReserveAssetDeposited { .. } - if matches!(origin, MultiLocation { parents: 1, interior: Here }) => - { - log::warn!( - target: "xcm::barrier", - "Unexpected ReserveAssetDeposited from the Relay Chain", - ); - Ok(ControlFlow::Continue(())) - }, - _ => Ok(ControlFlow::Continue(())), - }, - )?; - - // Permit everything else - Ok(()) - } -} - -pub type Barrier = DenyThenTry< - DenyReserveTransferToRelayChain, - ( - TakeWeightCredit, - WithComputedOrigin< - ( - AllowTopLevelPaidExecutionFrom, - AllowExplicitUnpaidExecutionFrom, - // ^^^ Parent and its exec plurality get free execution - ), - UniversalLocation, - ConstU32<8>, - >, - ), +pub type Barrier = TrailingSetTopicAsId< + DenyThenTry< + DenyReserveTransferToRelayChain, + ( + TakeWeightCredit, + WithComputedOrigin< + ( + AllowTopLevelPaidExecutionFrom, + AllowExplicitUnpaidExecutionFrom, + // ^^^ Parent and its exec plurality get free execution + ), + UniversalLocation, + ConstU32<8>, + >, + ), + >, >; pub struct XcmConfig; @@ -208,12 +142,12 @@ pub type LocalOriginToLocation = SignedToAccountId32, // ..and XCMP to communicate with the sibling chains. XcmpQueue, -); +)>; #[cfg(feature = "runtime-benchmarks")] parameter_types! { @@ -248,6 +182,8 @@ impl pallet_xcm::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/parachains/chain-specs/statemine_genesis_values.json b/parachains/chain-specs/asset-hub-kusama-genesis-values.json similarity index 100% rename from parachains/chain-specs/statemine_genesis_values.json rename to parachains/chain-specs/asset-hub-kusama-genesis-values.json diff --git a/parachains/chain-specs/statemine_genesis.json b/parachains/chain-specs/asset-hub-kusama-genesis.json similarity index 99% rename from parachains/chain-specs/statemine_genesis.json rename to parachains/chain-specs/asset-hub-kusama-genesis.json index 8b0dee2f8cf..d6eeb567c25 100644 --- a/parachains/chain-specs/statemine_genesis.json +++ b/parachains/chain-specs/asset-hub-kusama-genesis.json @@ -1,6 +1,6 @@ { - "name": "Statemine", - "id": "statemine", + "name": "Kusama Asset Hub", + "id": "asset-hub-kusama", "chainType": "Live", "bootNodes": [ "/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWHGksh2JFMaW8AkZvyhVpmiXUJnCQbngExTLMdq753ZQR" diff --git a/parachains/chain-specs/statemine.json b/parachains/chain-specs/asset-hub-kusama.json similarity index 99% rename from parachains/chain-specs/statemine.json rename to parachains/chain-specs/asset-hub-kusama.json index dd32b21adb5..ccbe8f0326c 100644 --- a/parachains/chain-specs/statemine.json +++ b/parachains/chain-specs/asset-hub-kusama.json @@ -1,6 +1,6 @@ { - "name": "Statemine", - "id": "statemine", + "name": "Kusama Asset Hub", + "id": "asset-hub-kusama", "chainType": "Live", "bootNodes": [ "/ip4/34.77.217.152/tcp/30334/p2p/12D3KooWF63ZxKtZMYs5247WQA8fcTiGJb2osXykc31cmjwNLwem", @@ -25,7 +25,9 @@ "/dns/boot-node.helikon.io/tcp/10210/p2p/12D3KooWFXRQce3aMgZMn5SxvHtYH4PsR63TZLf8LrnBsEVTyzdr", "/dns/boot-node.helikon.io/tcp/10212/wss/p2p/12D3KooWFXRQce3aMgZMn5SxvHtYH4PsR63TZLf8LrnBsEVTyzdr", "/dns/statemine.bootnode.amforc.com/tcp/30336/p2p/12D3KooWHmSyrBWsc6fdpq8HtCFWasmLVLYGKWA2a78m4xAHKyBq", - "/dns/statemine.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWHmSyrBWsc6fdpq8HtCFWasmLVLYGKWA2a78m4xAHKyBq" + "/dns/statemine.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWHmSyrBWsc6fdpq8HtCFWasmLVLYGKWA2a78m4xAHKyBq", + "/dns/statemine-boot-ng.dwellir.com/tcp/30343/p2p/12D3KooWQNJKBaNfW6Nn7HZDi5pSSEFmHL2Qz7chr9RksQUDR1Wk", + "/dns/statemine-boot-ng.dwellir.com/tcp/443/wss/p2p/12D3KooWQNJKBaNfW6Nn7HZDi5pSSEFmHL2Qz7chr9RksQUDR1Wk" ], "telemetryEndpoints": null, "protocolId": null, @@ -56,4 +58,4 @@ "childrenDefault": {} } } -} \ No newline at end of file +} diff --git a/parachains/chain-specs/statemint_genesis_values.json b/parachains/chain-specs/asset-hub-polkadot-genesis-values.json similarity index 100% rename from parachains/chain-specs/statemint_genesis_values.json rename to parachains/chain-specs/asset-hub-polkadot-genesis-values.json diff --git a/parachains/chain-specs/statemint_genesis_values.scale b/parachains/chain-specs/asset-hub-polkadot-genesis-values.scale similarity index 100% rename from parachains/chain-specs/statemint_genesis_values.scale rename to parachains/chain-specs/asset-hub-polkadot-genesis-values.scale diff --git a/parachains/chain-specs/statemint_genesis.json b/parachains/chain-specs/asset-hub-polkadot-genesis.json similarity index 99% rename from parachains/chain-specs/statemint_genesis.json rename to parachains/chain-specs/asset-hub-polkadot-genesis.json index 2763994949e..fff9bbe1ea1 100644 --- a/parachains/chain-specs/statemint_genesis.json +++ b/parachains/chain-specs/asset-hub-polkadot-genesis.json @@ -1,6 +1,6 @@ { - "name": "Statemint", - "id": "statemint", + "name": "Polkadot Asset Hub", + "id": "asset-hub-polkadot", "chainType": "Live", "bootNodes": [ "/ip4/34.65.251.121/tcp/30334/p2p/12D3KooWG3GrM6XKMM4gp3cvemdwUvu96ziYoJmqmetLZBXE8bSa", diff --git a/parachains/chain-specs/statemint.json b/parachains/chain-specs/asset-hub-polkadot.json similarity index 99% rename from parachains/chain-specs/statemint.json rename to parachains/chain-specs/asset-hub-polkadot.json index 12d655ae7df..5c18f90f70a 100644 --- a/parachains/chain-specs/statemint.json +++ b/parachains/chain-specs/asset-hub-polkadot.json @@ -1,6 +1,6 @@ { - "name": "Statemint", - "id": "statemint", + "name": "Polkadot Asset Hub", + "id": "asset-hub-polkadot", "chainType": "Live", "bootNodes": [ "/ip4/34.65.251.121/tcp/30334/p2p/12D3KooWG3GrM6XKMM4gp3cvemdwUvu96ziYoJmqmetLZBXE8bSa", @@ -25,7 +25,9 @@ "/dns/boot-node.helikon.io/tcp/10220/p2p/12D3KooW9uybhguhDjVJc3U3kgZC3i8rWmAnSpbnJkmuR7C6ZsRW", "/dns/boot-node.helikon.io/tcp/10222/wss/p2p/12D3KooW9uybhguhDjVJc3U3kgZC3i8rWmAnSpbnJkmuR7C6ZsRW", "/dns/statemint.bootnode.amforc.com/tcp/30341/p2p/12D3KooWByohP9FXn7ao8syS167qJsbFdpa7fY2Y24xbKtt3r7Ls", - "/dns/statemint.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWByohP9FXn7ao8syS167qJsbFdpa7fY2Y24xbKtt3r7Ls" + "/dns/statemint.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWByohP9FXn7ao8syS167qJsbFdpa7fY2Y24xbKtt3r7Ls", + "/dns/statemint-boot-ng.dwellir.com/tcp/30344/p2p/12D3KooWEFrNuNk8fPdQS2hf34Gmqi6dGSvrETshGJUrqrvfRDZr", + "/dns/statemint-boot-ng.dwellir.com/tcp/443/wss/p2p/12D3KooWEFrNuNk8fPdQS2hf34Gmqi6dGSvrETshGJUrqrvfRDZr" ], "telemetryEndpoints": null, "protocolId": null, @@ -58,4 +60,4 @@ "childrenDefault": {} } } -} \ No newline at end of file +} diff --git a/parachains/chain-specs/rockmine.json b/parachains/chain-specs/asset-hub-rococo.json similarity index 99% rename from parachains/chain-specs/rockmine.json rename to parachains/chain-specs/asset-hub-rococo.json index d774da8744a..1a9e63a1cb8 100644 --- a/parachains/chain-specs/rockmine.json +++ b/parachains/chain-specs/asset-hub-rococo.json @@ -1,6 +1,6 @@ { - "name": "Rockmine", - "id": "statemine-rococo", + "name": "Rococo Asset Hub", + "id": "asset-hub-rococo", "chainType": "Live", "bootNodes": [ "/dns/rococo-rockmine-collator-node-0.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWRrZMndHAopzao34uGsN7srjS3gh9nAjTGKLSyJeU31Lg", diff --git a/parachains/chain-specs/westmint_genesis_values.json b/parachains/chain-specs/asset-hub-westend-genesis-values.json similarity index 100% rename from parachains/chain-specs/westmint_genesis_values.json rename to parachains/chain-specs/asset-hub-westend-genesis-values.json diff --git a/parachains/chain-specs/westmint_genesis.json b/parachains/chain-specs/asset-hub-westend-genesis.json similarity index 99% rename from parachains/chain-specs/westmint_genesis.json rename to parachains/chain-specs/asset-hub-westend-genesis.json index ffd30fbe2de..09d07277c41 100644 --- a/parachains/chain-specs/westmint_genesis.json +++ b/parachains/chain-specs/asset-hub-westend-genesis.json @@ -1,6 +1,6 @@ { - "name": "Westmint", - "id": "westmint", + "name": "Westend Asset Hub", + "id": "asset-hub-westend", "chainType": "Live", "bootNodes": [ "/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWQWfQ6EBNgik1sW5by9vYagzrdsohc6NafeGPU4upnLRp" diff --git a/parachains/chain-specs/westmint.json b/parachains/chain-specs/asset-hub-westend.json similarity index 99% rename from parachains/chain-specs/westmint.json rename to parachains/chain-specs/asset-hub-westend.json index 3516fbfaa56..14aaea348e9 100644 --- a/parachains/chain-specs/westmint.json +++ b/parachains/chain-specs/asset-hub-westend.json @@ -1,12 +1,12 @@ { - "name": "Westmint", - "id": "westmint", + "name": "Westend Asset Hub", + "id": "asset-hub-westend", "chainType": "Live", "bootNodes": [ - "/ip4/35.204.21.205/tcp/30334/p2p/12D3KooWLjaXWhNTSiRVFbTJCKLRWt9XXHLGVnAFtxvnExKkVPqn", - "/ip4/34.141.171.170/tcp/30334/p2p/12D3KooWBNy2Jdrjv2P7sdfb1mzH1AGzwjip5rW4N2Ft1T3Hdq5c", - "/ip4/34.141.221.252/tcp/30334/p2p/12D3KooWC9YYdjQLwxTNVda6t4nmjAZG37gaRZLNi4Zuhr9xUveW", - "/ip4/34.90.92.174/tcp/30334/p2p/12D3KooWQcXpUyVqwC2zJkwECCC7ttLCUCLTjnbGxTVfhSgmH2sD", + "/dns/westend-westmint-collator-node-0.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWJaAfPyiye7ZQBuHengTJJoMrcaz7Jj1UzHiKdNxA1Nkd", + "/dns/westend-westmint-collator-node-1.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWGL3hpWycWyeqyL9gHNnmmsL474WkPZdqraBHu4L6fQrW", + "/dns/westend-westmint-collator-node-2.parity-testnet.parity.io./tcp/30333/p2p/12D3KooWBkKDWhHzu6Hhe492adEpVV7wzuaWGxUfEnr6g5JCr7Gr", + "/dns/westend-westmint-collator-node-3.parity-testnet.parity.io./tcp/30333/p2p/12D3KooWMGpzCmhD6np6eKqxL7AAunKn1dN86Dr7a9E2xgZ2rt6G", "/dns/boot.stake.plus/tcp/33333/p2p/12D3KooWNiB27rpXX7EYongoWWUeRKzLQxWGms6MQU2B9LX7Ztzo", "/dns/boot.stake.plus/tcp/33334/wss/p2p/12D3KooWNiB27rpXX7EYongoWWUeRKzLQxWGms6MQU2B9LX7Ztzo", "/dns/boot.metaspan.io/tcp/36052/p2p/12D3KooWBCqfNb6Y39DXTr4UBWXyjuS3hcZM1qTbHhDXxF6HkAJJ", @@ -19,7 +19,9 @@ "/dns/boot-node.helikon.io/tcp/10200/p2p/12D3KooWMRY8wb7rMT81LLuivvsy6ahUxKHQgYJw4zm1hC1uYLxb", "/dns/boot-node.helikon.io/tcp/10202/wss/p2p/12D3KooWMRY8wb7rMT81LLuivvsy6ahUxKHQgYJw4zm1hC1uYLxb", "/dns/westmint.bootnode.amforc.com/tcp/30339/p2p/12D3KooWNjKeaANaeZxBAPctmx8jugSYzuw4vnSCJmEDPB5mtRd6", - "/dns/westmint.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWNjKeaANaeZxBAPctmx8jugSYzuw4vnSCJmEDPB5mtRd6" + "/dns/westmint.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWNjKeaANaeZxBAPctmx8jugSYzuw4vnSCJmEDPB5mtRd6", + "/dns/westmint-boot-ng.dwellir.com/tcp/30345/p2p/12D3KooWFZ9xqApB1wnFYkbe1qJ5Jqwxe2f3i8W25F3tKNXy59ux", + "/dns/westmint-boot-ng.dwellir.com/tcp/443/wss/p2p/12D3KooWFZ9xqApB1wnFYkbe1qJ5Jqwxe2f3i8W25F3tKNXy59ux" ], "telemetryEndpoints": null, "protocolId": null, @@ -49,4 +51,4 @@ "childrenDefault": {} } } -} \ No newline at end of file +} diff --git a/parachains/chain-specs/bridge-hub-kusama.json b/parachains/chain-specs/bridge-hub-kusama.json index f49420b1747..0b95abcb24b 100644 --- a/parachains/chain-specs/bridge-hub-kusama.json +++ b/parachains/chain-specs/bridge-hub-kusama.json @@ -27,7 +27,9 @@ "/dns/boot-node.helikon.io/tcp/10250/p2p/12D3KooWDJLkhqQdXcVKWX7CqJHnpAY6PzrPc4ZG2CUWnARbmguy", "/dns/boot-node.helikon.io/tcp/10252/wss/p2p/12D3KooWDJLkhqQdXcVKWX7CqJHnpAY6PzrPc4ZG2CUWnARbmguy", "/dns/bridge-hub-kusama.bootnode.amforc.com/tcp/30337/p2p/12D3KooWGNeQJ5rXnEJkVUuQqwHd8aV5GkTAheaRoCaK8ZwW94id", - "/dns/bridge-hub-kusama.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWGNeQJ5rXnEJkVUuQqwHd8aV5GkTAheaRoCaK8ZwW94id" + "/dns/bridge-hub-kusama.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWGNeQJ5rXnEJkVUuQqwHd8aV5GkTAheaRoCaK8ZwW94id", + "/dns/kusama-bridge-hub-boot-ng.dwellir.com/tcp/30337/p2p/12D3KooWBFskNCQDVjuUeBh6vrszWrUvYMBBhtZRLnoTZDdLYbW5", + "/dns/kusama-bridge-hub-boot-ng.dwellir.com/tcp/443/wss/p2p/12D3KooWBFskNCQDVjuUeBh6vrszWrUvYMBBhtZRLnoTZDdLYbW5" ], "telemetryEndpoints": null, "protocolId": null, diff --git a/parachains/chain-specs/bridge-hub-polkadot.json b/parachains/chain-specs/bridge-hub-polkadot.json index 4c28b9d419d..cf366c37794 100644 --- a/parachains/chain-specs/bridge-hub-polkadot.json +++ b/parachains/chain-specs/bridge-hub-polkadot.json @@ -10,7 +10,9 @@ "/dns/polkadot-bridge-hub-connect-a-0.polkadot.io/tcp/443/wss/p2p/12D3KooWAVQMhkXmc5ueSYasdsRWQbKus2YGZ6HDZUB4ViJMCxXy", "/dns/polkadot-bridge-hub-connect-a-1.polkadot.io/tcp/443/wss/p2p/12D3KooWG4ypDHLKGCv4BZ6PuaGUwQHKAH6p2D6arR2uQ1eiR1T3", "/dns/polkadot-bridge-hub-connect-b-0.polkadot.io/tcp/443/wss/p2p/12D3KooWCwGKxjpJXnx1mwXKvaxGQm769EM3b6Pg5vbU33wbhsNw", - "/dns/polkadot-bridge-hub-connect-b-1.polkadot.io/tcp/443/wss/p2p/12D3KooWLiSEdhriJUPdZKFtAjZrQncxN2ssEoDKVrt5mGM4Qu4J" + "/dns/polkadot-bridge-hub-connect-b-1.polkadot.io/tcp/443/wss/p2p/12D3KooWLiSEdhriJUPdZKFtAjZrQncxN2ssEoDKVrt5mGM4Qu4J", + "/dns/polkadot-bridge-hub-boot-ng.dwellir.com/tcp/30339/p2p/12D3KooWPZ38PL3PhRVcUVYDNn7nRcZF8MykmWWLBKeDV2yna1vV", + "/dns/polkadot-bridge-hub-boot-ng.dwellir.com/tcp/443/wss/p2p/12D3KooWPZ38PL3PhRVcUVYDNn7nRcZF8MykmWWLBKeDV2yna1vV" ], "telemetryEndpoints": null, "protocolId": null, diff --git a/parachains/chain-specs/bridge-hub-rococo.json b/parachains/chain-specs/bridge-hub-rococo.json index 999837a5a42..ff20d8fb482 100644 --- a/parachains/chain-specs/bridge-hub-rococo.json +++ b/parachains/chain-specs/bridge-hub-rococo.json @@ -82,4 +82,4 @@ "childrenDefault": {} } } -} \ No newline at end of file +} diff --git a/parachains/chain-specs/bridge-hub-westend.json b/parachains/chain-specs/bridge-hub-westend.json index 460c25e8f50..3428695c309 100644 --- a/parachains/chain-specs/bridge-hub-westend.json +++ b/parachains/chain-specs/bridge-hub-westend.json @@ -6,7 +6,9 @@ "/dns/westend-bridge-hub-collator-node-0.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWKyEuqkkWvFSrwZWKWBAsHgLV3HGfHj7yH3LNJLAVhmxY", "/dns/westend-bridge-hub-collator-node-1.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWBpvudthz61XC4oP2YYFFJdhWohBeQ1ffn1BMSGWhapjd", "/dns/westend-bridge-hub-collator-node-2.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWPXqdRRthjKAMPFtaXUK7yBxsvh83QsmzXzALA3inoJfo", - "/dns/westend-bridge-hub-collator-node-3.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWAp2YpVaiNBy7rozEHJGocDpaLFt3VFZsGMBEYh4BoEz7" + "/dns/westend-bridge-hub-collator-node-3.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWAp2YpVaiNBy7rozEHJGocDpaLFt3VFZsGMBEYh4BoEz7", + "/dns/westend-bridge-hub-boot-ng.dwellir.com/tcp/30338/p2p/12D3KooWJWWRYTAwBLqYkh7iMBGDr5ouJ3MHj7M3fZ7zWS4zEk6F", + "/dns/westend-bridge-hub-boot-ng.dwellir.com/tcp/443/wss/p2p/12D3KooWJWWRYTAwBLqYkh7iMBGDr5ouJ3MHj7M3fZ7zWS4zEk6F" ], "telemetryEndpoints": null, "protocolId": null, diff --git a/parachains/chain-specs/bridge-hub-wococo.json b/parachains/chain-specs/bridge-hub-wococo.json index 06837cc0d63..7024789b8cc 100644 --- a/parachains/chain-specs/bridge-hub-wococo.json +++ b/parachains/chain-specs/bridge-hub-wococo.json @@ -86,4 +86,4 @@ "childrenDefault": {} } } -} \ No newline at end of file +} diff --git a/parachains/chain-specs/collectives-polkadot.json b/parachains/chain-specs/collectives-polkadot.json index 99fc78ea4a6..084a92713ce 100644 --- a/parachains/chain-specs/collectives-polkadot.json +++ b/parachains/chain-specs/collectives-polkadot.json @@ -27,7 +27,9 @@ "/dns/boot-node.helikon.io/tcp/10230/p2p/12D3KooWS8CBz4P5CBny9aBy2EQUvAExFo9PUVT57X8r3zWMFkXT", "/dns/boot-node.helikon.io/tcp/10232/wss/p2p/12D3KooWS8CBz4P5CBny9aBy2EQUvAExFo9PUVT57X8r3zWMFkXT", "/dns/collectives-polkadot.bootnode.amforc.com/tcp/30335/p2p/12D3KooWQeAjDnGkrPe5vtpfnB6ydZfWyMxyrXLkBFmA6o4k9aiU", - "/dns/collectives-polkadot.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWQeAjDnGkrPe5vtpfnB6ydZfWyMxyrXLkBFmA6o4k9aiU" + "/dns/collectives-polkadot.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWQeAjDnGkrPe5vtpfnB6ydZfWyMxyrXLkBFmA6o4k9aiU", + "/dns/polkadot-collectives-boot-ng.dwellir.com/tcp/30341/p2p/12D3KooWDMFYCNRAQcSRNV7xu2xv8319goSEbSHW4TnXRz6EpPKc", + "/dns/polkadot-collectives-boot-ng.dwellir.com/tcp/443/wss/p2p/12D3KooWDMFYCNRAQcSRNV7xu2xv8319goSEbSHW4TnXRz6EpPKc" ], "telemetryEndpoints": null, "protocolId": null, diff --git a/parachains/chain-specs/collectives-westend.json b/parachains/chain-specs/collectives-westend.json index db4552e046b..e93611ee028 100644 --- a/parachains/chain-specs/collectives-westend.json +++ b/parachains/chain-specs/collectives-westend.json @@ -31,7 +31,9 @@ "/dns/boot-node.helikon.io/tcp/10260/p2p/12D3KooWMzfnt29VAmrJHQcJU6Vfn4RsMbqPqgyWHqt9VTTAbSrL", "/dns/boot-node.helikon.io/tcp/10262/wss/p2p/12D3KooWMzfnt29VAmrJHQcJU6Vfn4RsMbqPqgyWHqt9VTTAbSrL", "/dns/collectives-westend.bootnode.amforc.com/tcp/30340/p2p/12D3KooWERPzUhHau6o2XZRUi3tn7544rYiaHL418Nw5t8fYWP1F", - "/dns/collectives-westend.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWERPzUhHau6o2XZRUi3tn7544rYiaHL418Nw5t8fYWP1F" + "/dns/collectives-westend.bootnode.amforc.com/tcp/30333/wss/p2p/12D3KooWERPzUhHau6o2XZRUi3tn7544rYiaHL418Nw5t8fYWP1F", + "/dns/westend-collectives-boot-ng.dwellir.com/tcp/30340/p2p/12D3KooWPFM93jgm4pgxx8PM8WJKAJF49qia8jRB95uciUQwYh7m", + "/dns/westend-collectives-boot-ng.dwellir.com/tcp/443/wss/p2p/12D3KooWPFM93jgm4pgxx8PM8WJKAJF49qia8jRB95uciUQwYh7m" ], "telemetryEndpoints": null, "protocolId": null, diff --git a/parachains/chain-specs/contracts-rococo.json b/parachains/chain-specs/contracts-rococo.json index a74ab22e05d..09108e9c099 100644 --- a/parachains/chain-specs/contracts-rococo.json +++ b/parachains/chain-specs/contracts-rococo.json @@ -3,11 +3,16 @@ "id": "contracts-rococo", "chainType": "Live", "bootNodes": [ - "/dns/contracts-collator-0.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWKg3Rpxcr9oJ8n6khoxpGKWztCZydtUZk2cojHqnfLrpj", - "/dns/contracts-collator-1.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWPEXYrz8tHU3nDtPoPw4V7ou5dzMEWSTuUj7vaWiYVAVh", - "/dns/contracts-collator-2.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWEVU8AFNary4nP4qEnEcwJaRuy59Wefekzdu9pKbnVEhk", - "/dns/contracts-collator-3.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWP6pV3ZmcXzGDjv8ZMgA6nZxfAKDxSz4VNiLx6vVCQgJX" + "/dns/rococo-contracts-collator-node-0.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWKg3Rpxcr9oJ8n6khoxpGKWztCZydtUZk2cojHqnfLrpj", + "/dns/rococo-contracts-collator-node-1.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWPEXYrz8tHU3nDtPoPw4V7ou5dzMEWSTuUj7vaWiYVAVh", + "/dns/rococo-contracts-collator-node-2.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWEVU8AFNary4nP4qEnEcwJaRuy59Wefekzdu9pKbnVEhk", + "/dns/rococo-contracts-collator-node-3.parity-testnet.parity.io/tcp/30333/p2p/12D3KooWP6pV3ZmcXzGDjv8ZMgA6nZxfAKDxSz4VNiLx6vVCQgJX", + "/dns/rococo-contracts-collator-node-0.polkadot.io/tcp/443/wss/p2p/12D3KooWKg3Rpxcr9oJ8n6khoxpGKWztCZydtUZk2cojHqnfLrpj", + "/dns/rococo-contracts-collator-node-1.polkadot.io/tcp/443/wss/p2p/12D3KooWPEXYrz8tHU3nDtPoPw4V7ou5dzMEWSTuUj7vaWiYVAVh", + "/dns/rococo-contracts-collator-node-2.polkadot.io/tcp/443/wss/p2p/12D3KooWEVU8AFNary4nP4qEnEcwJaRuy59Wefekzdu9pKbnVEhk", + "/dns/rococo-contracts-collator-node-3.polkadot.io/tcp/443/wss/p2p/12D3KooWP6pV3ZmcXzGDjv8ZMgA6nZxfAKDxSz4VNiLx6vVCQgJX" ], + "telemetryEndpoints": null, "protocolId": null, "properties": { @@ -80,4 +85,4 @@ "childrenDefault": {} } } -} \ No newline at end of file +} diff --git a/parachains/chain-specs/shell-statemint-head-data b/parachains/chain-specs/shell-head-data similarity index 100% rename from parachains/chain-specs/shell-statemint-head-data rename to parachains/chain-specs/shell-head-data diff --git a/parachains/chain-specs/shell-statemint.json b/parachains/chain-specs/shell.json similarity index 100% rename from parachains/chain-specs/shell-statemint.json rename to parachains/chain-specs/shell.json diff --git a/parachains/common/Cargo.toml b/parachains/common/Cargo.toml index ff539ed3143..378c78c8dca 100644 --- a/parachains/common/Cargo.toml +++ b/parachains/common/Cargo.toml @@ -10,7 +10,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } # Substrate frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "master" } diff --git a/parachains/common/src/impls.rs b/parachains/common/src/impls.rs index cc89a248e2e..75ddf230408 100644 --- a/parachains/common/src/impls.rs +++ b/parachains/common/src/impls.rs @@ -91,7 +91,7 @@ where Assets: fungibles::Inspect, { fn contains(id: &>::AssetId) -> bool { - !Assets::total_issuance(*id).is_zero() + !Assets::total_issuance(id.clone()).is_zero() } } @@ -103,7 +103,7 @@ where Assets: fungibles::Inspect, { fn contains(id: &>::AssetId) -> bool { - Assets::asset_exists(*id) + Assets::asset_exists(id.clone()) } } @@ -197,7 +197,7 @@ mod tests { type WeightInfo = (); type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<1>; type MaxFreezes = ConstU32<1>; @@ -278,7 +278,6 @@ mod tests { } let asset_location = SomeSiblingParachain::get() - .clone() .pushed_with_interior(GeneralIndex(42)) .expect("multilocation will only have 2 junctions; qed"); let asset = MultiAsset { id: Concrete(asset_location), fun: 1_000_000u128.into() }; diff --git a/parachains/common/src/lib.rs b/parachains/common/src/lib.rs index 349e50c5bcd..775e5b9c388 100644 --- a/parachains/common/src/lib.rs +++ b/parachains/common/src/lib.rs @@ -23,7 +23,7 @@ pub use opaque::*; pub use types::*; /// Common types of parachains. -mod types { +pub mod types { use sp_runtime::traits::{IdentifyAccount, Verify}; /// An index to a block. @@ -55,12 +55,12 @@ mod types { // Aura consensus authority. pub type AuraId = sp_consensus_aura::sr25519::AuthorityId; - // Aura consensus authority used by Statemint. + // Aura consensus authority used by Asset Hub Polkadot. // // Because of registering the authorities with an ed25519 key before switching from Shell - // to Statemint, we were required to deploy a hotfix that changed Statemint to ed22519. - // In the future that may change again. - pub type StatemintAuraId = sp_consensus_aura::ed25519::AuthorityId; + // to Asset Hub Polkadot, we were required to deploy a hotfix that changed Asset Hub Polkadot's + // Aura keys to ed22519. In the future that may change again. + pub type AssetHubPolkadotAuraId = sp_consensus_aura::ed25519::AuthorityId; // Id used for identifying assets. pub type AssetIdForTrustBackedAssets = u32; diff --git a/parachains/common/src/process_xcm_message.rs b/parachains/common/src/process_xcm_message.rs index 0b91adcf15a..9a8b7645a64 100644 --- a/parachains/common/src/process_xcm_message.rs +++ b/parachains/common/src/process_xcm_message.rs @@ -16,17 +16,11 @@ //! Implementation of `ProcessMessage` for an `ExecuteXcm` implementation. -use codec::{Decode, FullCodec, MaxEncodedLen}; use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; -use frame_support::{ - ensure, - traits::{ProcessMessage, ProcessMessageError}, -}; -use scale_info::TypeInfo; -use sp_io::hashing::blake2_256; -use sp_std::{fmt::Debug, marker::PhantomData}; -use sp_weights::{Weight, WeightMeter}; -use xcm::prelude::*; +use frame_support::traits::{ProcessMessage, ProcessMessageError}; + +use sp_std::marker::PhantomData; +use sp_weights::WeightMeter; /// Transform a `ProcessMessage` implementation to assume that the origin is a sibling chain. /// @@ -39,8 +33,9 @@ impl> ProcessMessage for Proc message: &[u8], origin: Self::Origin, meter: &mut WeightMeter, + id: &mut [u8; 32], ) -> Result { - P::process_message(message, AggregateMessageOrigin::Sibling(origin), meter) + P::process_message(message, AggregateMessageOrigin::Sibling(origin), meter, id) } } @@ -57,13 +52,14 @@ where message: &[u8], origin: Self::Origin, meter: &mut WeightMeter, + id: &mut [u8; 32], ) -> Result { use AggregateMessageOrigin::*; match origin { // DMP and local messages can be directly forwarded to the XCM executor since there is no flow control. - o @ Parent | o @ Loopback => XcmProcessor::process_message(message, o, meter), + o @ Parent | o @ Loopback => XcmProcessor::process_message(message, o, meter, id), // XCMoHRMP need to be tunneled back through the XCMP queue pallet to respect the suspension logic. - Sibling(para) => XcmpQueue::process_message(message, para, meter), + Sibling(para) => XcmpQueue::process_message(message, para, meter, id), } } } @@ -75,44 +71,3 @@ impl sp_runtime::traits::Convert for ParaIdToSib AggregateMessageOrigin::Sibling(para_id) } } - -/// A message processor that delegates execution to an [`ExecuteXcm`]. -/// -/// FAIL-CI Delete this once merges. -pub struct ProcessXcmMessage( - PhantomData<(MessageOrigin, XcmExecutor, Call)>, -); -impl< - MessageOrigin: Into + FullCodec + MaxEncodedLen + Clone + Eq + PartialEq + TypeInfo + Debug, - XcmExecutor: ExecuteXcm, - Call, - > ProcessMessage for ProcessXcmMessage -{ - type Origin = MessageOrigin; - - /// Process the given message, using no more than the remaining `weight` to do so. - fn process_message( - message: &[u8], - origin: Self::Origin, - meter: &mut WeightMeter, - ) -> Result { - let hash = blake2_256(message); - let versioned_message = VersionedXcm::::decode(&mut &message[..]) - .map_err(|_| ProcessMessageError::Corrupt)?; - let message = Xcm::::try_from(versioned_message) - .map_err(|_| ProcessMessageError::Unsupported)?; - let pre = XcmExecutor::prepare(message).map_err(|_| ProcessMessageError::Unsupported)?; - let required = pre.weight_of(); - ensure!(meter.can_accrue(required), ProcessMessageError::Overweight(required)); - - let (consumed, result) = - match XcmExecutor::execute(origin.into(), pre, hash, Weight::zero()) { - Outcome::Complete(w) => (w, Ok(true)), - Outcome::Incomplete(w, _) => (w, Ok(false)), - // In the error-case we assume the worst case and consume all possible weight. - Outcome::Error(_) => (required, Err(ProcessMessageError::Unsupported)), - }; - meter.defensive_saturating_accrue(consumed); - result - } -} diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index 61e6f389e6d..529822cff16 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -1,86 +1,12 @@ use crate::impls::AccountIdOf; -use core::{marker::PhantomData, ops::ControlFlow}; +use core::marker::PhantomData; use frame_support::{ log, - traits::{ - fungibles::Inspect, tokens::ConversionToAssetBalance, ContainsPair, ProcessMessageError, - }, + traits::{fungibles::Inspect, tokens::ConversionToAssetBalance, ContainsPair}, weights::Weight, }; use sp_runtime::traits::Get; use xcm::latest::prelude::*; -use xcm_builder::{CreateMatcher, MatchXcm}; -use xcm_executor::traits::ShouldExecute; - -//TODO: move DenyThenTry to polkadot's xcm module. -/// Deny executing the XCM if it matches any of the Deny filter regardless of anything else. -/// If it passes the Deny, and matches one of the Allow cases then it is let through. -pub struct DenyThenTry(PhantomData, PhantomData) -where - Deny: ShouldExecute, - Allow: ShouldExecute; - -impl ShouldExecute for DenyThenTry -where - Deny: ShouldExecute, - Allow: ShouldExecute, -{ - fn should_execute( - origin: &MultiLocation, - message: &mut [Instruction], - max_weight: Weight, - weight_credit: &mut Weight, - ) -> Result<(), ProcessMessageError> { - Deny::should_execute(origin, message, max_weight, weight_credit)?; - Allow::should_execute(origin, message, max_weight, weight_credit) - } -} - -// See issue -pub struct DenyReserveTransferToRelayChain; -impl ShouldExecute for DenyReserveTransferToRelayChain { - fn should_execute( - origin: &MultiLocation, - message: &mut [Instruction], - _max_weight: Weight, - _weight_credit: &mut Weight, - ) -> Result<(), ProcessMessageError> { - message.matcher().match_next_inst_while( - |_| true, - |inst| match inst { - InitiateReserveWithdraw { - reserve: MultiLocation { parents: 1, interior: Here }, - .. - } | - DepositReserveAsset { - dest: MultiLocation { parents: 1, interior: Here }, .. - } | - TransferReserveAsset { - dest: MultiLocation { parents: 1, interior: Here }, .. - } => { - Err(ProcessMessageError::Unsupported) // Deny - }, - - // An unexpected reserve transfer has arrived from the Relay Chain. Generally, - // `IsReserve` should not allow this, but we just log it here. - ReserveAssetDeposited { .. } - if matches!(origin, MultiLocation { parents: 1, interior: Here }) => - { - log::warn!( - target: "xcm::barrier", - "Unexpected ReserveAssetDeposited from the Relay Chain", - ); - Ok(ControlFlow::Continue(())) - }, - - _ => Ok(ControlFlow::Continue(())), - }, - )?; - - // Permit everything else - Ok(()) - } -} /// A `ChargeFeeInFungibles` implementation that converts the output of /// a given WeightToFee implementation an amount charged in diff --git a/parachains/integration-tests/collectives/0_xcm/2_reserve.yml b/parachains/integration-tests/collectives/0_xcm/2_reserve.yml deleted file mode 100644 index 0af20ba7daa..00000000000 --- a/parachains/integration-tests/collectives/0_xcm/2_reserve.yml +++ /dev/null @@ -1,84 +0,0 @@ ---- -settings: - chains: - relay_chain: &relay_chain - wsPort: 9700 - collectives_parachain: &collectives_parachain - wsPort: 9710 - paraId: &cp_id 1001 - variables: - xcm_version: &xcm_version '2' - weight_to_send_reserve: &weight_to_send_reserve 1,000,000,000 # must be same for both chains - chains: - accounts: - alice_signer: &alice_signer //Alice - alice_account32: &alice_acc32 '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' - alice_ss58: &acc_alice_ss58 '15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5' - -tests: - - name: Reserve assets from Relay Chain to Collectives Parachain fails - its: - - name: Reserve assets from Relay Chain to Collectives Parachain - actions: - - extrinsics: - - chain: *relay_chain - signer: *alice_signer - pallet: xcmPallet - call: reserveTransferAssets - args: [ - { v1: { 0, interior: { x1: { parachain: *cp_id }}}}, # destination - { v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *alice_acc32 }}}}}, # beneficiary - { - v1: [ - { - id: { concrete: { 0, interior: { here: true }}}, - fun: { fungible: 20000000000000 } # 20_000_000_000_000 - } - ] - }, # assets - 0, # feeAssetItem - ] - events: - - name: xcmPallet.Attempted - chain: *relay_chain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # the weight must be static - value: *weight_to_send_reserve - - name: dmpQueue.ExecutedDownward - chain: *collectives_parachain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Incomplete - # the weight must be static - value: [1000000000, UntrustedReserveLocation] - - - name: Reserve assets from Collectives Parachain to Relay Chain fails - actions: - - extrinsics: - - chain: *collectives_parachain - signer: *alice_signer - pallet: polkadotXcm - call: reserveTransferAssets - args: [ - { v1: { parents: 1, interior: { here: true }}}, # destination - { v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *alice_acc32 }}}}}, # beneficiary - { - v1: [ - { - id: { concrete: { parents: 1, interior: { here: true }}}, - fun: { fungible: 10000000000000 } # 10_000_000_000_000 - } - ] - }, # assets - 0, # feeAssetItem - ] - events: - - name: system.ExtrinsicFailed - attributes: - - type: SpRuntimeDispatchError - key: dispatchError - # TODO assert variant - # issue - https://github.com/paritytech/parachains-integration-tests/issues/59 - value: {"Module":{"index":"31","error":"0x02000000"}} diff --git a/parachains/integration-tests/statemint/xcm/0_init.yml b/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/0_init.yml similarity index 67% rename from parachains/integration-tests/statemint/xcm/0_init.yml rename to parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/0_init.yml index b9640517719..ebcbe417bbb 100644 --- a/parachains/integration-tests/statemint/xcm/0_init.yml +++ b/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/0_init.yml @@ -11,12 +11,13 @@ settings: paraId: &pp_id 2000 variables: common: - xcm_verison: &xcm_version '2' - require_weight_at_most: &weight_at_most 1000000000 + xcm_version: &xcm_version 3 + require_weight_at_most: &weight_at_most {refTime: 1000000000, proofSize: 200000} + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } chains: relay_chain: signer: &rc_signer //Alice - assets_parachain_destination: &ap_dest { v1: { 0, interior: { x1: { parachain: *ap_id }}}} + assets_parachain_destination: &ap_dest { v3: { 0, interior: { x1: { parachain: *ap_id }}}} penpal_parachain: signer: &pp_signer //Alice decodedCalls: @@ -37,7 +38,7 @@ tests: its: - name: XCM supported versions between chains actions: - - extrinsics: # Relay Chain sets supported version for Assset Parachain + - extrinsics: # Relay Chain sets supported version for Asset Parachain - chain: *relay_chain sudo: true signer: *rc_signer @@ -56,13 +57,9 @@ tests: ] events: - name: sudo.Sudid - attribute: - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.SupportedVersionChanged - attribute: - type: u32 - value: *xcm_version + result: [{ parents: 0, interior: { X1: { Parachain: *ap_id }}}, *xcm_version ] - extrinsics: # Relay Chain sets supported version for Penpal Parachain - chain: *relay_chain sudo: true @@ -82,14 +79,10 @@ tests: ] events: - name: sudo.Sudid - attribute: - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.SupportedVersionChanged - attribute: - type: u32 - value: *xcm_version - - extrinsics: # Assset Parachain sets supported version for Relay Chain through it + result: [{ parents: 0, interior: { X1: { Parachain: *pp_id }}}, *xcm_version ] + - extrinsics: # Asset Parachain sets supported version for Relay Chain through it - chain: *relay_chain signer: *rc_signer sudo: true @@ -98,10 +91,20 @@ tests: args: [ *ap_dest, # destination { - v2: [ #message + v3: [ #message + { + UnpaidExecution: { + weightLimit: { + limited: { + refTime: 2200000000, + proofSize: 200000 + } + } + } + }, { Transact: { - originType: Superuser, + originKind: Superuser, requireWeightAtMost: *weight_at_most, call: $ap_force_xcm_version } @@ -111,15 +114,17 @@ tests: ] events: - name: sudo.Sudid - attribute: - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.Sent + - name: dmpQueue.ExecutedDownward + chain: *assets_parachain + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '1,019,210,000', proofSize: '200,000' }} + } - name: polkadotXcm.SupportedVersionChanged chain: *assets_parachain - attribute: - type: u32 - value: *xcm_version + result: [{ parents: 1, interior: Here }, *xcm_version ] - extrinsics: # Penpal Parachain sets supported version for Relay Chain - chain: *penpal_parachain signer: *pp_signer @@ -135,10 +140,6 @@ tests: ] events: - name: sudo.Sudid - attribute: - type: Result - value: Ok + result: { sudoResult: Ok } - name: polkadotXcm.SupportedVersionChanged - attribute: - type: u32 - value: *xcm_version + result: [{ parents: 1, interior: Here }, *xcm_version ] diff --git a/parachains/integration-tests/statemine/xcm/1_dmp.yml b/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/1_dmp.yml similarity index 72% rename from parachains/integration-tests/statemine/xcm/1_dmp.yml rename to parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/1_dmp.yml index 9b08555a251..1fb4a8abb84 100644 --- a/parachains/integration-tests/statemine/xcm/1_dmp.yml +++ b/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/1_dmp.yml @@ -7,20 +7,23 @@ settings: wsPort: 9910 paraId: &ap_id 1000 variables: - relay_chain: - signer: &rc_signer //Alice - wallet: &rc_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F - assets_parachain_destination: &ap_dest { v1: { parents: 0, interior: { x1: { parachain: *ap_id }}}} - assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' - assets_parachain_beneficiary: &ap_benf {v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *ap_acc }}}}} - ksm: &rc_ksm { concrete: { parents: 0, interior: { here: true }}} - amount: &amount 1000000000000 - ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }} - require_weight_at_most: &rc_weight_at_most 1000000000 - assets_parachain_account: - wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F - asset_id: &asset_id 1 - asset_min_balance: &asset_ed 1000 + common: + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } + chains: + relay_chain: + signer: &rc_signer //Alice + wallet: &rc_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F + assets_parachain_destination: &ap_dest { v3: { parents: 0, interior: { x1: { parachain: *ap_id }}}} + assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' + assets_parachain_beneficiary: &ap_benf { v3: { parents: 0, interior: { x1: { accountId32: { id: *ap_acc }}}}} + ksm: &rc_ksm { concrete: { parents: 0, interior: { here: true }}} + amount: &amount 1000000000000 + ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }} + require_weight_at_most: &rc_weight_at_most { refTime: 1000000000, proofSize: 200000 } + assets_parachain_account: + wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F + asset_id: &asset_id 1 + asset_min_balance: &asset_ed 1000 decodedCalls: force_create_asset: chain: *assets_parachain @@ -63,22 +66,20 @@ tests: args: [ *ap_dest, # destination *ap_benf, # beneficiary - { v1: [ *rc_ksm_fungible ] }, # assets + { v3: [ *rc_ksm_fungible ] }, 0, # feeAssetItem { unlimited: true } # weightLimit ] events: - name: xcmPallet.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true + threshold: *weight_threshold + result: [{ Complete: { refTime: '764,772,000', proofSize: 0 }}] - name: dmpQueue.ExecutedDownward chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,021,973,000 + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '166,944,000', proofSize: 0 }} + } - queries: balance_rc_sender_after: chain: *relay_chain @@ -131,10 +132,15 @@ tests: args: [ *ap_dest, # destination { - v2: [ #message + v3: [ #message + { + UnpaidExecution: { + weightLimit: Unlimited + } + }, { Transact: { - originType: Superuser, + originKind: Superuser, requireWeightAtMost: *rc_weight_at_most, call: $force_create_asset } @@ -146,11 +152,10 @@ tests: - name: xcmPallet.Sent - name: dmpQueue.ExecutedDownward chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,021,258,000 + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '1,014,103,000', proofSize: '200,000' }} + } - queries: forced_created_asset: chain: *assets_parachain @@ -173,10 +178,15 @@ tests: args: [ *ap_dest, # destination { - v2: [ #message + v3: [ #message + { + UnpaidExecution: { + weightLimit: Unlimited + } + }, { Transact: { - originType: Native, + originKind: Native, requireWeightAtMost: *rc_weight_at_most, call: $force_create_asset } @@ -186,9 +196,7 @@ tests: ] events: - name: system.ExtrinsicFailed - attribute: - type: SpRuntimeDispatchError - value: BadOrigin + result: { dispatchError: BadOrigin } - name: xcmPallet.limitedReserveTransferAssets before: *before_get_balances @@ -203,23 +211,25 @@ tests: args: [ *ap_dest, # destination *ap_benf, # beneficiary - { v1: [ *rc_ksm_fungible ] }, # assets + { v3: [ *rc_ksm_fungible ] }, # assets 0, # feeAssetItem { unlimited: true } # weightLimit ] events: - name: xcmPallet.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 750,645,000 + threshold: *weight_threshold + result: [{ Complete: { refTime: '750,645,000', proofSize: 0 }}] - name: dmpQueue.ExecutedDownward chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isError: true - value: "WeightNotComputable" + threshold: *weight_threshold + result: { + outcome: { + Incomplete: [ + { refTime: '1,000,000,000', proofSize: 0 }, + UntrustedReserveLocation + ] + } + } - queries: balance_rc_sender_after: chain: *relay_chain diff --git a/parachains/integration-tests/statemine/xcm/2_ump.yml b/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/2_ump.yml similarity index 65% rename from parachains/integration-tests/statemine/xcm/2_ump.yml rename to parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/2_ump.yml index daddf927931..3cdb9547c35 100644 --- a/parachains/integration-tests/statemine/xcm/2_ump.yml +++ b/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/2_ump.yml @@ -9,23 +9,25 @@ settings: variables: common: amount: &amount 1000000000000 - require_weight_at_most: &weight_at_most 1000000000 - relay_chain: - signer: &rc_signer //Alice - wallet: &rc_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F #Alice - assets_parachain_destination: &ap_dest { v1: { 0, interior: { x1: { parachain: *ap_id }}}} - assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' - assets_parachain_beneficiary: &ap_benf {v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *ap_acc }}}}} - ksm: &rc_ksm { concrete: { 0, interior: { here: true }}} - ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }} - assets_parachain_account: - signer: &ap_signer //Alice - wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F - relay_chain_destination: &rc_dest { v1: { parents: 1, interior: { here: true }}} - assets_parachain_account: &rc_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' #Alice - relay_chain_beneficiary: &rc_benf {v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *rc_acc }}}}} - ksm: &ap_ksm { concrete: { parents: 1, interior: { here: true }}} - ksm_fungible: &ap_ksm_fungible { id: *ap_ksm, fun: { fungible: *amount }} + require_weight_at_most: &weight_at_most {refTime: 1000000000, proofSize: 0} + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } + chains: + relay_chain: + signer: &rc_signer //Alice + wallet: &rc_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F #Alice + assets_parachain_destination: &ap_dest { v3: { 0, interior: { x1: { parachain: *ap_id }}}} + assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' + assets_parachain_beneficiary: &ap_benf {v3: { parents: 0, interior: { x1: { accountId32: { id: *ap_acc }}}}} + ksm: &rc_ksm { concrete: { 0, interior: { here: true }}} + ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }} + assets_parachain_account: + signer: &ap_signer //Alice + wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F + relay_chain_destination: &rc_dest { v3: { parents: 1, interior: { here: true }}} + assets_parachain_account: &rc_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' #Alice + relay_chain_beneficiary: &rc_benf {v3: { parents: 0, interior: { x1: { accountId32: { id: *rc_acc }}}}} + ksm: &ap_ksm { concrete: { parents: 1, interior: { here: true }}} + ksm_fungible: &ap_ksm_fungible { id: *ap_ksm, fun: { fungible: *amount }} decodedCalls: system_remark: chain: *relay_chain @@ -38,7 +40,7 @@ tests: describes: - name: polkadotXcm.limitedTeleportAssets before: - - name: DEPENDANCY | Do a 'limitedTeleportAssets' from the Relay Chain to the Assets Parachain to have funds to send them back + - name: DEPENDENCY | Do a 'limitedTeleportAssets' from the Relay Chain to the Assets Parachain to have funds to send them back actions: - extrinsics: - chain: *relay_chain @@ -48,22 +50,20 @@ tests: args: [ *ap_dest, # destination *ap_benf, # beneficiary - { v1: [ *rc_ksm_fungible ] }, # assets + { v3: [ *rc_ksm_fungible ] }, # assets 0, # feeAssetItem { unlimited: true } # weightLimit ] events: - name: xcmPallet.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true + threshold: *weight_threshold + result: [{ Complete: { refTime: '761,173,000', proofSize: 0 }}] - name: dmpQueue.ExecutedDownward chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,021,973,000 + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '166,944,000', proofSize: 0 }} + } - name: Get the balances of the Assets Parachain's sender & Relay Chain's receiver actions: @@ -89,24 +89,18 @@ tests: args: [ *rc_dest, # destination *rc_benf, # beneficiary - { v1: [ *ap_ksm_fungible ] }, # assets + { v3: [ *ap_ksm_fungible ] }, # assets 0, # feeAssetItem { unlimited: true } # weightLimit ] events: - name: polkadotXcm.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 360,315,000 + threshold: *weight_threshold + result: [{ Complete: { refTime: '539,494,000', proofSize: '7,133' }}] - name: ump.ExecutedUpward chain: *relay_chain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 297,578,000 + threshold: *weight_threshold + result: [{ Complete: { refTime: '298,716,000', proofSize: 0 }}] - queries: balance_ap_sender_after: chain: *assets_parachain @@ -148,7 +142,7 @@ tests: - name: polkadotXcm.send | Native - Transact(system.remark) its: - - name: Assets Parachain SHOULD NOT be able to dipatch 'send' call + - name: Assets Parachain SHOULD NOT be able to dispatch 'send' call actions: - extrinsics: - chain: *assets_parachain @@ -158,10 +152,15 @@ tests: args: [ *rc_dest, # destination { - v2: [ #message + v3: [ #message + { + UnpaidExecution: { + weightLimit: Unlimited + } + }, { Transact: { - originType: Native, + originKind: Native, requireWeightAtMost: *weight_at_most, call: $system_remark } @@ -171,9 +170,7 @@ tests: ] events: - name: system.ExtrinsicFailed - attribute: - type: SpRuntimeDispatchError - value: BadOrigin + result: { dispatchError: BadOrigin } - name: polkadotXcm.limitedReserveTransferAssets its: @@ -187,13 +184,10 @@ tests: args: [ *rc_dest, # destination *rc_benf, # beneficiary - { v1: [ *ap_ksm_fungible ] }, # assets + { v3: [ *ap_ksm_fungible ] }, # assets 0, # feeAssetItem { unlimited: true } # weightLimit ] events: - name: polkadotXcm.Attempted - attribute: - type: XcmV2TraitsOutcome - isError: true - value: Barrier + result: [{ Error: Barrier }] diff --git a/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/3_force_hrmp-open-channels.yml b/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/3_force_hrmp-open-channels.yml new file mode 100644 index 00000000000..dfdae028f00 --- /dev/null +++ b/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/3_force_hrmp-open-channels.yml @@ -0,0 +1,122 @@ +--- +settings: + chains: + relay_chain: &relay_chain + wsPort: 9900 + assets_parachain: + wsPort: 9910 + paraId: &ap_id 1000 + penpal_parachain: + wsPort: 9920 + paraId: &pp_id 2000 + variables: + common: + amount: &amount 2000000000000 + hrmp_channels: + proposed_max_capacity: &max_capacity 8 + proposed_max_message_size: &max_message_size 8192 + channel: &channel { + maxCapacity: *max_capacity, + maxTotalSize: *max_message_size, + maxMessageSize: *max_message_size, + msgCount: 0, + totalSize: 0, + mqcHead: null, + senderDeposit: 0, + recipientDeposit: 0 + } + chains: + relay_chain: + signer: &rc_signer //Alice + assets_parachain_account: + sovereign_account: &ap_sovereign F7fq1jSNVTPfJmaHaXCMtatT1EZefCUsa7rRiQVNR5efcah + penpal_parachain: + sovereign_account: &pp_sovereign F7fq1jMZkfuCuoMTyiEVAP2DMpMt18WopgBqTJznLihLNbZ + +tests: + - name: HRMP + beforeEach: + - name: DEPENDENCY | Penpal Parachain Sovereign account in the Relay Chain needs to be funded + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + pallet: balances + call: transfer + args: [ + *pp_sovereign, # destination + *amount, # value + ] + events: + - name: balances.Transfer + + - name: DEPENDENCY | Assets Parachain Sovereign account in the Relay Chain needs to be funded + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + pallet: balances + call: transfer + args: [ + *ap_sovereign, # destination + *amount, # value + ] + events: + - name: balances.Transfer + describes: + - name: hrmp.forceOpenHrmpChannel (Penpal Parachain → Assets Parachain) + its: + - name: Open Penpal Parachain to Assets Parachain + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + sudo: true + pallet: hrmp + call: forceOpenHrmpChannel + args: [ + *pp_id, + *ap_id, + *max_capacity, + *max_message_size + ] + events: + - name: sudo.Sudid + result: { sudoResult: Ok } + - name: hrmp.HrmpChannelForceOpened + + - name: hrmp.forceOpenHrmpChannel (Assets Parachain → PenPal Parachain) + its: + - name: Open Assets Parachain to PenPal Parachain + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + sudo: true + pallet: hrmp + call: forceOpenHrmpChannel + args: [ + *ap_id, + *pp_id, + *max_capacity, + *max_message_size + ] + events: + - name: sudo.Sudid + result: { sudoResult: Ok } + - name: hrmp.HrmpChannelForceOpened + + - name: hrmp.forceProcessHrmpOpen (make sure all the channels are open) + its: + - name: Make sure all the pending channels are open + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + sudo: true + pallet: hrmp + call: forceProcessHrmpOpen + args: [ 2 ] + events: + - name: sudo.Sudid + result: { sudoResult: Ok } diff --git a/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/4_hrmp.yml b/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/4_hrmp.yml new file mode 100644 index 00000000000..9e2decffe15 --- /dev/null +++ b/parachains/integration-tests/e2e/assets/asset-hub-kusama/0_xcm/4_hrmp.yml @@ -0,0 +1,390 @@ +--- +# Note: This tests depends on the 3_hrmp-open-channels.yml for opening channels, otherwise teleports aren't going to +# work. +settings: + chains: + relay_chain: &relay_chain + wsPort: 9900 + assets_parachain: &assets_parachain + wsPort: 9910 + paraId: &ap_id 1000 + penpal_parachain: &penpal_parachain + wsPort: 9920 + paraId: &pp_id 2000 + variables: + common: + mint_amount: &mint_amount 1000000000000 + amount: &amount 100000000000 + require_weight_at_most: &weight_at_most {refTime: 1200000000, proofSize: 20000} + amount_to_send: &amount_to_send 500000000000 + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } + chains: + relay_chain: + signer: &rc_signer //Alice + assets_parachain_destination: &ap_dest { v3: { 0, interior: { x1: { parachain: *ap_id }}}} + assets_parachain_dest_routed: &ap_dest_routed { v3: { parents: 1, interior: { x1: { parachain: *ap_id } }}} + assets_parachain_account: + signer: &ap_signer //Alice + wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F + asset_id: &asset_id 2 + assets_pallet_id: &assets_pallet_id 50 + asset_min_balance: &asset_ed 1000 + penpal_parachain_destination: &pp_dest { v3: { parents: 1, interior: { x1: { parachain: *pp_id } }}} + ksm: &ap_ksm { concrete: { parents: 1, interior: { here: true }}} + ksm_fungible: &ap_ksm_fungible { id: *ap_ksm, fun: { fungible: *amount }} + suff_asset: &suff_asset { concrete: { parents: 0, interior: { x2: [ { PalletInstance: *assets_pallet_id }, { GeneralIndex: *asset_id } ] }}} + suff_asset_fail: &suff_asset_fail { concrete: { parents: 0, interior: { x2: [ { PalletInstance: *assets_pallet_id }, { GeneralIndex: 3 } ] }}} + suff_asset_fungible_fail: &ap_suff_asset_fungible_fail { id: *suff_asset_fail, fun: { fungible: 200000000000 }} + penpal_parachain: + sovereign_account: &pp_sovereign_sibl FBeL7EAeUroLWXW1yfKboiqTqVfbRBcsUKd6QqVf4kGBySS + signer: &pp_signer //Alice + penpal_parachain_account: &pp_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' + decodedCalls: + force_create_asset: + chain: *assets_parachain + pallet: assets + call: forceCreate + args: [ + *asset_id, + { Id: *ap_wallet }, # owner + true, # isSufficient + *asset_ed # minBalance + ] + force_create_asset2: + chain: *assets_parachain + pallet: assets + call: forceCreate + args: [ + *asset_id, + { Id: *ap_wallet }, # owner + true, # isSufficient + *asset_ed # minBalance + ] + +tests: + - name: HRMP + describes: + - name: polkadotXcm.limitedReserveTransferAssets (Asset) | Assets Parachain -> Penpal Parachain + before: + - name: DEPENDENCY | A sufficient Asset should exist in the Assets Parachain + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + sudo: true + pallet: xcmPallet + call: send + args: [ + *ap_dest, # destination + { + v3: [ #message + { + UnpaidExecution: { + weightLimit: Unlimited + } + }, + { + SetTopic: '0x0123456789012345678901234567891201234567890123456789012345678912' + }, + { + Transact: { + originKind: Superuser, + requireWeightAtMost: *weight_at_most, + call: $force_create_asset + } + } + ] + } + ] + events: + - name: xcmPallet.Sent + - name: dmpQueue.ExecutedDownward + chain: *assets_parachain + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '1,216,703,000', proofSize: '20,000' }} + } + - queries: + forced_created_asset: + chain: *assets_parachain + pallet: assets + call: asset + args: [ *asset_id ] + - asserts: + isSome: + args: [ $forced_created_asset ] + + - name: DEPENDENCY | Some Assets should be minted for the sender + actions: + - extrinsics: + - chain: *assets_parachain + signer: *ap_signer + pallet: assets + call: mint + args: [ + *asset_id, + *ap_wallet, + *mint_amount + ] + events: + - name: assets.Issued + result: { assetId: *asset_id, owner: *ap_wallet, amount: *mint_amount } + + its: + - name: Assets Parachain should be able to reserve transfer an Asset to Penpal Parachain + actions: + - extrinsics: + - chain: *assets_parachain + signer: *ap_signer + pallet: polkadotXcm + call: limitedReserveTransferAssets + args: [ + *pp_dest, # destination + { # beneficiary + V3: { + parents: 0, + interior: { + X1: { + AccountId32: { + id: *pp_acc + } + } + } + } + }, + { # assets + V3: [ + { + id: { + Concrete: { + parents: 0, + interior: { + X2: [ + { + PalletInstance: *assets_pallet_id + }, + { + GeneralIndex: *asset_id + } + ] + } + } + }, + fun: { + Fungible: *amount_to_send + } + } + ] + }, + 0, # feeAssetItem + Unlimited # weightLimit + ] + events: + - name: polkadotXcm.Attempted + threshold: *weight_threshold + result: [{ Complete: { refTime: '679,150,000', proofSize: '6,196' }}] + - name: assets.Transferred + result: { + assetId: *asset_id, + from: *ap_wallet, + to: *pp_sovereign_sibl, + amount: *amount_to_send + } + + - name: polkadotXcm.limitedReserveTransferAssets (KSM) | Assets Parachain -> Penpal Parachain + its: + - name: Assets Parachain should be able to reserve transfer KSM to Penpal Parachain + actions: + - extrinsics: + - chain: *assets_parachain + signer: *ap_signer + pallet: polkadotXcm + call: limitedReserveTransferAssets + args: [ + *pp_dest, # destination + { # beneficiary + V3: { + parents: 0, + interior: { + X1: { + AccountId32: { + id: *pp_acc + } + } + } + } + }, + { # assets + V3: [ + *ap_ksm_fungible + ] + }, + 0, # feeAssetItem + Unlimited # weightLimit + ] + events: + - name: polkadotXcm.Attempted + threshold: *weight_threshold + result: [{ Complete: { refTime: '679,150,000', proofSize: '6,196' }}] + - name: balances.Endowed + result: { + account: *pp_sovereign_sibl, + freeBalance: *amount + } + + - name: polkadotXcm.send( assets.forceCreateAsset ) | Penpal Parachain -> Assets Parachain + before: + - name: Get the asset balance of the Penpal Parachain Sovereign account in Assets Parachain + actions: + - queries: + assets_balance_pp_sovereign_before: + chain: *assets_parachain + pallet: assets + call: account + args: [ + *asset_id, + *pp_sovereign_sibl + ] + its: + - name: Penpal Parachain should be able to send XCM message paying its fee with sufficient asset in Assets Parachain + actions: + - extrinsics: + - chain: *penpal_parachain + signer: *pp_signer + sudo: true + pallet: polkadotXcm + call: send + args: [ + *ap_dest_routed, # destination + { + v3: [ #message + { + WithdrawAsset: [ + { + id: { + concrete: { + parents: 0, + interior: { + X2: [ + { PalletInstance: *assets_pallet_id }, + { GeneralIndex: *asset_id } + ] + } + } + }, + fun: { fungible: *amount }} + ] + }, + { + BuyExecution: { + fees: { id: *suff_asset, fun: { fungible: *amount }}, + weightLimit: Unlimited + } + }, + { + Transact: { + originKind: SovereignAccount, + requireWeightAtMost: *weight_at_most, + call: $force_create_asset2 + } + }, + { + RefundSurplus + }, + { + DepositAsset: { + assets: { Wild: All }, + beneficiary: { + parents: 0, + interior: { + X1: { + AccountId32: { + network: , # None + id: *pp_acc + } + } + }} + } + } + ] + } + ] + events: + - name: sudo.Sudid + result: { sudoResult: Ok } + - name: polkadotXcm.Sent + - name: assets.Burned + chain: *assets_parachain + result: { assetId: *asset_id, owner: *pp_sovereign_sibl } + - name: assets.Issued + chain: *assets_parachain + result: { assetId: *asset_id } + - queries: + assets_balance_pp_sovereign_after: + chain: *assets_parachain + pallet: assets + call: account + args: [ + *asset_id, + *pp_sovereign_sibl + ] + forced_created_asset2: + chain: *assets_parachain + pallet: assets + call: asset + args: [ 3 ] + - asserts: + isSome: + args: [ $forced_created_asset2 ] + - name: Should reduce the assets balance of the Penpal Parachain's SovereignAccount in the Assets Parachain + actions: + - asserts: + assetsDecreased: + args: [ + { + balances: { + before: $assets_balance_pp_sovereign_before, + after: $assets_balance_pp_sovereign_after, + }, + } + ] + + - name: Penpal Parachain SHOULD NOT be able to send XCM message paying its fee with sufficient assets if not enough balance + actions: + - extrinsics: + - chain: *penpal_parachain + signer: *pp_signer + sudo: true + pallet: polkadotXcm + call: send + args: [ + *ap_dest_routed, # destination + { + v3: [ #message + { + WithdrawAsset: [*ap_suff_asset_fungible_fail] + }, + { + BuyExecution: { + fees: *ap_suff_asset_fungible_fail, + weightLimit: Unlimited + } + }, + { + Transact: { + originKind: SovereignAccount, + requireWeightAtMost: *weight_at_most, + call: $force_create_asset2 + } + } + ] + } + ] + events: + - name: xcmpQueue.Fail + chain: *assets_parachain + threshold: *weight_threshold + result: { + error: FailedToTransactAsset, + weight: { refTime: '152,426,000', proofSize: '3,593' } + } diff --git a/parachains/integration-tests/e2e/assets/asset-hub-kusama/config.toml b/parachains/integration-tests/e2e/assets/asset-hub-kusama/config.toml new file mode 100644 index 00000000000..1ec06b3fa10 --- /dev/null +++ b/parachains/integration-tests/e2e/assets/asset-hub-kusama/config.toml @@ -0,0 +1,71 @@ +[relaychain] +default_command = "./bin/polkadot" +default_args = [ "-lparachain=debug", "-lxcm=trace" ] +chain = "kusama-local" + + [[relaychain.nodes]] + name = "alice" + ws_port = 9900 + validator = true + args = ["--state-cache-size=0"] + + [[relaychain.nodes]] + name = "bob" + ws_port = 9901 + validator = true + + [[relaychain.nodes]] + name = "charlie" + ws_port = 9902 + validator = true + + [[relaychain.nodes]] + name = "dave" + ws_port = 9903 + validator = true + +[[parachains]] +id = 1000 +chain = "asset-hub-kusama-local" +cumulus_based = true + + [[parachains.collators]] + name = "collator1" + ws_port = 9910 + command = "./bin/polkadot-parachain" + args = [ "-lxcm=trace", "--state-cache-size=0" ] + + [[parachains.collators]] + name = "collator2" + ws_port = 9911 + command = "./bin/polkadot-parachain" + args = [ "-lxcm=trace" ] + +[[parachains]] +id = 2000 +chain = "penpal-kusama-2000" +cumulus_based = true + + [[parachains.collators]] + name = "collator3" + ws_port = 9920 + command = "./bin/polkadot-parachain" + args = [ "-lxcm=trace", "--state-cache-size=0" ] + + [[parachains.collators]] + name = "collator4" + ws_port = 9921 + command = "./bin/polkadot-parachain" + args = [ "-lxcm=trace" ] + +# [[hrmpChannels]] +# sender = 1000 +# recipient = 2000 +# maxCapacity = 8 +# maxMessageSize = 8192 + +# [[hrmpChannels]] +# sender = 2000 +# recipient = 1000 +# maxCapacity = 8 +# maxMessageSize = 8192 diff --git a/parachains/integration-tests/statemine/xcm/0_init.yml b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/0_init.yml similarity index 66% rename from parachains/integration-tests/statemine/xcm/0_init.yml rename to parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/0_init.yml index b9640517719..55dbab6ba4c 100644 --- a/parachains/integration-tests/statemine/xcm/0_init.yml +++ b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/0_init.yml @@ -2,21 +2,22 @@ settings: chains: relay_chain: &relay_chain - wsPort: 9900 + wsPort: 9800 assets_parachain: &assets_parachain - wsPort: 9910 + wsPort: 9810 paraId: &ap_id 1000 penpal_parachain: &penpal_parachain - wsPort: 9920 + wsPort: 9820 paraId: &pp_id 2000 variables: common: - xcm_verison: &xcm_version '2' - require_weight_at_most: &weight_at_most 1000000000 + xcm_version: &xcm_version '3' + require_weight_at_most: &weight_at_most {refTime: 1000000000, proofSize: 200000} + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } chains: relay_chain: signer: &rc_signer //Alice - assets_parachain_destination: &ap_dest { v1: { 0, interior: { x1: { parachain: *ap_id }}}} + assets_parachain_destination: &ap_dest { v3: { 0, interior: { x1: { parachain: *ap_id }}}} penpal_parachain: signer: &pp_signer //Alice decodedCalls: @@ -37,7 +38,7 @@ tests: its: - name: XCM supported versions between chains actions: - - extrinsics: # Relay Chain sets supported version for Assset Parachain + - extrinsics: # Relay Chain sets supported version for Asset Parachain - chain: *relay_chain sudo: true signer: *rc_signer @@ -56,13 +57,9 @@ tests: ] events: - name: sudo.Sudid - attribute: - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.SupportedVersionChanged - attribute: - type: u32 - value: *xcm_version + result: [{ parents: 0, interior: { X1: { Parachain: *ap_id }}}, *xcm_version ] - extrinsics: # Relay Chain sets supported version for Penpal Parachain - chain: *relay_chain sudo: true @@ -82,14 +79,10 @@ tests: ] events: - name: sudo.Sudid - attribute: - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.SupportedVersionChanged - attribute: - type: u32 - value: *xcm_version - - extrinsics: # Assset Parachain sets supported version for Relay Chain through it + result: [{ parents: 0, interior: { X1: { Parachain: *pp_id }}}, *xcm_version ] + - extrinsics: # Asset Parachain sets supported version for Relay Chain through it - chain: *relay_chain signer: *rc_signer sudo: true @@ -98,10 +91,20 @@ tests: args: [ *ap_dest, # destination { - v2: [ #message + v3: [ #message + { + UnpaidExecution: { + weightLimit: { + limited: { + refTime: 3200000000, + proofSize: 200000 + } + } + } + }, { Transact: { - originType: Superuser, + originKind: Superuser, requireWeightAtMost: *weight_at_most, call: $ap_force_xcm_version } @@ -111,15 +114,17 @@ tests: ] events: - name: sudo.Sudid - attribute: - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.Sent + - name: dmpQueue.ExecutedDownward + chain: *assets_parachain + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '1,019,210,000', proofSize: '200,000' }} + } - name: polkadotXcm.SupportedVersionChanged chain: *assets_parachain - attribute: - type: u32 - value: *xcm_version + result: [{ parents: 1, interior: Here }, *xcm_version ] - extrinsics: # Penpal Parachain sets supported version for Relay Chain - chain: *penpal_parachain signer: *pp_signer @@ -135,10 +140,6 @@ tests: ] events: - name: sudo.Sudid - attribute: - type: Result - value: Ok + result: { sudoResult: Ok } - name: polkadotXcm.SupportedVersionChanged - attribute: - type: u32 - value: *xcm_version + result: [{ parents: 1, interior: Here }, *xcm_version ] diff --git a/parachains/integration-tests/statemint/xcm/1_dmp.yml b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/1_dmp.yml similarity index 72% rename from parachains/integration-tests/statemint/xcm/1_dmp.yml rename to parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/1_dmp.yml index 5f0fa349072..823974ad806 100644 --- a/parachains/integration-tests/statemint/xcm/1_dmp.yml +++ b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/1_dmp.yml @@ -2,25 +2,28 @@ settings: chains: relay_chain: &relay_chain - wsPort: 9900 + wsPort: 9800 assets_parachain: &assets_parachain - wsPort: 9910 + wsPort: 9810 paraId: &ap_id 1000 variables: - relay_chain: - signer: &rc_signer //Alice - wallet: &rc_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F - assets_parachain_destination: &ap_dest { v1: { parents: 0, interior: { x1: { parachain: *ap_id }}}} - assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' - assets_parachain_beneficiary: &ap_benf {v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *ap_acc }}}}} - ksm: &rc_ksm { concrete: { parents: 0, interior: { here: true }}} - amount: &amount 1000000000000 - ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }} - require_weight_at_most: &rc_weight_at_most 1000000000 - assets_parachain_account: - wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F - asset_id: &asset_id 1 - asset_min_balance: &asset_ed 1000 + common: + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } + chains: + relay_chain: + signer: &rc_signer //Alice + wallet: &rc_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F + assets_parachain_destination: &ap_dest { v3: { parents: 0, interior: { x1: { parachain: *ap_id }}}} + assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' + assets_parachain_beneficiary: &ap_benf {v3: { parents: 0, interior: { x1: { accountId32: { id: *ap_acc }}}}} + ksm: &rc_ksm { concrete: { parents: 0, interior: { here: true }}} + amount: &amount 1000000000000 + ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }} + require_weight_at_most: &rc_weight_at_most {refTime: 1000000000, proofSize: 200000} + assets_parachain_account: + wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F + asset_id: &asset_id 1 + asset_min_balance: &asset_ed 1000 decodedCalls: force_create_asset: chain: *assets_parachain @@ -63,22 +66,20 @@ tests: args: [ *ap_dest, # destination *ap_benf, # beneficiary - { v1: [ *rc_ksm_fungible ] }, # assets + { v3: [ *rc_ksm_fungible ] }, # assets 0, # feeAssetItem { unlimited: true } # weightLimit ] events: - name: xcmPallet.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true + threshold: *weight_threshold + result: [{ Complete: { refTime: '3,000,000,000', proofSize: 0 }}] - name: dmpQueue.ExecutedDownward chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,021,635,000 + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '166,944,000', proofSize: 0 }} + } - queries: balance_rc_sender_after: chain: *relay_chain @@ -131,7 +132,12 @@ tests: args: [ *ap_dest, # destination { - v2: [ #message + v3: [ #message + { + UnpaidExecution: { + weightLimit: Unlimited + } + }, { Transact: { originType: Superuser, @@ -146,11 +152,10 @@ tests: - name: xcmPallet.Sent - name: dmpQueue.ExecutedDownward chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,020,807,000 + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '1,014,103,000', proofSize: '200,000' }} + } - queries: forced_created_asset: chain: *assets_parachain @@ -173,7 +178,12 @@ tests: args: [ *ap_dest, # destination { - v2: [ #message + v3: [ #message + { + UnpaidExecution: { + weightLimit: Unlimited + } + }, { Transact: { originType: Native, @@ -186,9 +196,7 @@ tests: ] events: - name: system.ExtrinsicFailed - attribute: - type: SpRuntimeDispatchError - value: BadOrigin + result: { dispatchError: BadOrigin } - name: xcmPallet.limitedReserveTransferAssets before: *before_get_balances @@ -203,22 +211,25 @@ tests: args: [ *ap_dest, # destination *ap_benf, # beneficiary - { v1: [ *rc_ksm_fungible ] }, # assets + { v3: [ *rc_ksm_fungible ] }, # assets 0, # feeAssetItem { unlimited: true } # weightLimit ] events: - name: xcmPallet.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true - value: 1,000,000,000 + threshold: *weight_threshold + result: [{ Complete: { refTime: '2,000,000,000', proofSize: 0 }}] - name: dmpQueue.ExecutedDownward chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isError: true - value: "WeightNotComputable" + threshold: *weight_threshold + result: { + outcome: { + Incomplete: [ + { refTime: '1,000,000,000', proofSize: 0 }, + UntrustedReserveLocation + ] + } + } - queries: balance_rc_sender_after: chain: *relay_chain diff --git a/parachains/integration-tests/statemint/xcm/2_ump.yml b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/2_ump.yml similarity index 65% rename from parachains/integration-tests/statemint/xcm/2_ump.yml rename to parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/2_ump.yml index f51823eb3e8..4bdeceb765c 100644 --- a/parachains/integration-tests/statemint/xcm/2_ump.yml +++ b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/2_ump.yml @@ -2,30 +2,32 @@ settings: chains: relay_chain: &relay_chain - wsPort: 9900 + wsPort: 9800 assets_parachain: &assets_parachain - wsPort: 9910 + wsPort: 9810 paraId: &ap_id 1000 variables: common: amount: &amount 1000000000000 - require_weight_at_most: &weight_at_most 1000000000 - relay_chain: - signer: &rc_signer //Alice - wallet: &rc_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F - assets_parachain_destination: &ap_dest { v1: { 0, interior: { x1: { parachain: *ap_id }}}} - assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' - assets_parachain_beneficiary: &ap_benf {v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *ap_acc }}}}} - ksm: &rc_ksm { concrete: { 0, interior: { here: true }}} - ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }} - assets_parachain_account: - signer: &ap_signer //Alice - wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F - relay_chain_destination: &rc_dest { v1: { parents: 1, interior: { here: true }}} - assets_parachain_account: &rc_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' - relay_chain_beneficiary: &rc_benf {v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *rc_acc }}}}} - ksm: &ap_ksm { concrete: { parents: 1, interior: { here: true }}} - ksm_fungible: &ap_ksm_fungible { id: *ap_ksm, fun: { fungible: *amount }} + require_weight_at_most: &weight_at_most {refTime: 1000000000, proofSize: 0} + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } + chains: + relay_chain: + signer: &rc_signer //Alice + wallet: &rc_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F + assets_parachain_destination: &ap_dest { v3: { 0, interior: { x1: { parachain: *ap_id }}}} + assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' + assets_parachain_beneficiary: &ap_benf {v3: { parents: 0, interior: { x1: { accountId32: { id: *ap_acc }}}}} + ksm: &rc_ksm { concrete: { 0, interior: { here: true }}} + ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }} + assets_parachain_account: + signer: &ap_signer //Alice + wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F + relay_chain_destination: &rc_dest { v3: { parents: 1, interior: { here: true }}} + assets_parachain_account: &rc_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' + relay_chain_beneficiary: &rc_benf {v3: { parents: 0, interior: { x1: { accountId32: { id: *rc_acc }}}}} + ksm: &ap_ksm { concrete: { parents: 1, interior: { here: true }}} + ksm_fungible: &ap_ksm_fungible { id: *ap_ksm, fun: { fungible: *amount }} decodedCalls: system_remark: chain: *relay_chain @@ -38,7 +40,7 @@ tests: describes: - name: polkadotXcm.limitedTeleportAssets before: - - name: DEPENDANCY | Do a 'limitedTeleportAssets' from the Relay Chain to the Assets Parachain to have funds to send them back + - name: DEPENDENCY | Do a 'limitedTeleportAssets' from the Relay Chain to the Assets Parachain to have funds to send them back actions: - extrinsics: - chain: *relay_chain @@ -48,22 +50,20 @@ tests: args: [ *ap_dest, # destination *ap_benf, # beneficiary - { v1: [ *rc_ksm_fungible ] }, # assets + { v3: [ *rc_ksm_fungible ] }, # assets 0, # feeAssetItem { unlimited: true } # weightLimit ] events: - name: xcmPallet.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true + threshold: *weight_threshold + result: [{ Complete: { refTime: '3,000,000,000', proofSize: 0 }}] - name: dmpQueue.ExecutedDownward chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,021,635,000 + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '166,944,000', proofSize: 0 }} + } - name: Get the balances of the Assets Parachain's sender & Relay Chain's receiver actions: @@ -90,23 +90,18 @@ tests: args: [ *rc_dest, # destination *rc_benf, # beneficiary - { v1: [ *ap_ksm_fungible ] }, # assets + { v3: [ *ap_ksm_fungible ] }, # assets 0, # feeAssetItem { unlimited: true } # weightLimit ] events: - name: polkadotXcm.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 358,878,000 + threshold: *weight_threshold + result: [{ Complete: { refTime: '533,283,000', proofSize: '7,096' }}] - name: ump.ExecutedUpward chain: *relay_chain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - value: 4,000,000,000 + threshold: *weight_threshold + result: [{ Complete: { refTime: '4,000,000,000', proofSize: 0 }}] - queries: balance_ap_sender_after: chain: *assets_parachain @@ -148,7 +143,7 @@ tests: - name: polkadotXcm.send | Native - Transact(system.remark) its: - - name: Assets Parachain SHOULD NOT be able to dipatch 'send' call + - name: Assets Parachain SHOULD NOT be able to dispatch 'send' call actions: - extrinsics: - chain: *assets_parachain @@ -158,7 +153,12 @@ tests: args: [ *rc_dest, # destination { - v2: [ #message + v3: [ #message + { + UnpaidExecution: { + weightLimit: Unlimited + } + }, { Transact: { originType: Native, @@ -171,9 +171,9 @@ tests: ] events: - name: system.ExtrinsicFailed - attribute: - type: SpRuntimeDispatchError - value: BadOrigin + attributes: + - type: SpRuntimeDispatchError + value: BadOrigin - name: polkadotXcm.limitedReserveTransferAssets its: @@ -187,13 +187,10 @@ tests: args: [ *rc_dest, # destination *rc_benf, # beneficiary - { v1: [ *ap_ksm_fungible ] }, # assets + { v3: [ *ap_ksm_fungible ] }, # assets 0, # feeAssetItem { unlimited: true } # weightLimit ] events: - name: polkadotXcm.Attempted - attribute: - type: XcmV2TraitsOutcome - isError: true - value: Barrier + result: [{ Error: Barrier }] diff --git a/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/3_force_hrmp-open-channels.yml b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/3_force_hrmp-open-channels.yml new file mode 100644 index 00000000000..ecf344a073b --- /dev/null +++ b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/3_force_hrmp-open-channels.yml @@ -0,0 +1,120 @@ +--- +settings: + chains: + relay_chain: &relay_chain + wsPort: 9800 + assets_parachain: + wsPort: 9810 + paraId: &ap_id 1000 + penpal_parachain: + wsPort: 9820 + paraId: &pp_id 2000 + variables: + common: + amount: &amount 2000000000000 + hrmp_channels: + proposed_max_capacity: &max_capacity 8 + proposed_max_message_size: &max_message_size 8192 + channel: &channel { + maxCapacity: *max_capacity, + maxTotalSize: *max_message_size, + maxMessageSize: *max_message_size, + msgCount: 0, + totalSize: 0, + mqcHead: null, + senderDeposit: 0, + recipientDeposit: 0 + } + chains: + relay_chain: + signer: &rc_signer //Alice + assets_parachain_account: + sovereign_account: &ap_sovereign 5Ec4AhPZk8STuex8Wsi9TwDtJQxKqzPJRCH7348Xtcs9vZLJ + penpal_parachain: + sovereign_account: &pp_sovereign F7fq1jMZkfuCuoMTyiEVAP2DMpMt18WopgBqTJznLihLNbZ + +tests: + - name: HRMP + beforeEach: + - name: DEPENDENCY | Penpal Parachain Sovereign account in the Relay Chain needs to be funded + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + pallet: balances + call: transfer + args: [ + *pp_sovereign, # destination + *amount, # value + ] + events: + - name: balances.Transfer + + - name: DEPENDENCY | Assets Parachain Sovereign account in the Relay Chain needs to be funded + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + pallet: balances + call: transfer + args: [ + *ap_sovereign, # destination + *amount, # value + ] + events: + - name: balances.Transfer + describes: + - name: hrmp.hrmpInitOpenChannel (Penpal Parachain → Assets Parachain) + its: + - name: Open Penpal Parachain to Assets Parachain + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + sudo: true + pallet: hrmp + call: forceOpenHrmpChannel + args: [ + *pp_id, + *ap_id, + *max_capacity, + *max_message_size + ] + events: + - name: sudo.Sudid + result: { sudoResult: Ok } + - name: hrmp.HrmpChannelForceOpened + - name: hrmp.hrmpInitOpenChannel (Assets Parachain → PenPal Parachain) + its: + - name: Open Assets Parachain to PenPal Parachain + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + sudo: true + pallet: hrmp + call: forceOpenHrmpChannel + args: [ + *ap_id, + *pp_id, + *max_capacity, + *max_message_size + ] + events: + - name: sudo.Sudid + result: { sudoResult: Ok } + - name: hrmp.HrmpChannelForceOpened + - name: hrmp.forceProcessHrmpOpen (make sure all the channels are open) + its: + - name: Make sure all the pending channels are open + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + sudo: true + pallet: hrmp + call: forceProcessHrmpOpen + args: [ 2 ] + events: + - name: sudo.Sudid + result: { sudoResult: Ok } diff --git a/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/4_hrmp.yml b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/4_hrmp.yml new file mode 100644 index 00000000000..4ff2fbc59a4 --- /dev/null +++ b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/0_xcm/4_hrmp.yml @@ -0,0 +1,390 @@ +--- +# Note: This tests depends on the 3_hrmp-open-channels.yml for opening channels, otherwise teleports aren't going to +# work. +settings: + chains: + relay_chain: &relay_chain + wsPort: 9800 + assets_parachain: &assets_parachain + wsPort: 9810 + paraId: &ap_id 1000 + penpal_parachain: &penpal_parachain + wsPort: 9820 + paraId: &pp_id 2000 + variables: + common: + mint_amount: &mint_amount 1000000000000 + amount: &amount 1000000000000 + require_weight_at_most: &weight_at_most {refTime: 1200000000, proofSize: 20000} + amount_to_send: &amount_to_send 500000000000 + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } + chains: + relay_chain: + signer: &rc_signer //Alice + assets_parachain_destination: &ap_dest { v3: { 0, interior: { x1: { parachain: *ap_id }}}} + assets_parachain_dest_routed: &ap_dest_routed { v3: { parents: 1, interior: { x1: { parachain: *ap_id } }}} + assets_parachain_account: + signer: &ap_signer //Alice + wallet: &ap_wallet 15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5 + asset_id: &asset_id 2 + assets_pallet_id: &assets_pallet_id 50 + asset_min_balance: &asset_ed 1000 + penpal_parachain_destination: &pp_dest { v3: { parents: 1, interior: { x1: { parachain: *pp_id } }}} + ksm: &ap_ksm { concrete: { parents: 1, interior: { here: true }}} + ksm_fungible: &ap_ksm_fungible { id: *ap_ksm, fun: { fungible: *amount }} + suff_asset: &suff_asset { concrete: { parents: 0, interior: { x2: [ { PalletInstance: *assets_pallet_id }, { GeneralIndex: *asset_id } ] }}} + suff_asset_fail: &suff_asset_fail { concrete: { parents: 0, interior: { x2: [ { PalletInstance: *assets_pallet_id }, { GeneralIndex: 3 } ] }}} + suff_asset_fungible_fail: &ap_suff_asset_fungible_fail { id: *suff_asset_fail, fun: { fungible: 200000000000 }} + penpal_parachain: + sovereign_account: &pp_sovereign_sibl 13cKp89Msu7M2PiaCuuGr1BzAsD5V3vaVbDMs3YtjMZHdGwR + signer: &pp_signer //Alice + penpal_parachain_account: &pp_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' + decodedCalls: + force_create_asset: + chain: *assets_parachain + pallet: assets + call: forceCreate + args: [ + *asset_id, + { Id: *ap_wallet }, # owner + true, # isSufficient + *asset_ed # minBalance + ] + force_create_asset2: + chain: *assets_parachain + pallet: assets + call: forceCreate + args: [ + *asset_id, + { Id: *ap_wallet }, # owner + true, # isSufficient + *asset_ed # minBalance + ] + +tests: + - name: HRMP + describes: + - name: polkadotXcm.limitedReserveTransferAssets (Asset) | Assets Parachain -> Penpal Parachain + before: + - name: DEPENDENCY | A sufficient Asset should exist in the Assets Parachain + actions: + - extrinsics: + - chain: *relay_chain + signer: *rc_signer + sudo: true + pallet: xcmPallet + call: send + args: [ + *ap_dest, # destination + { + v3: [ #message + { + UnpaidExecution: { + weightLimit: Unlimited + } + }, + { + SetTopic: '0x0123456789012345678901234567891201234567890123456789012345678912' + }, + { + Transact: { + originKind: Superuser, + requireWeightAtMost: *weight_at_most, + call: $force_create_asset + } + } + ] + } + ] + events: + - name: xcmPallet.Sent + - name: dmpQueue.ExecutedDownward + chain: *assets_parachain + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '1,216,703,000', proofSize: '20,000' }} + } + - queries: + forced_created_asset: + chain: *assets_parachain + pallet: assets + call: asset + args: [ *asset_id ] + - asserts: + isSome: + args: [ $forced_created_asset ] + + - name: DEPENDENCY | Some Assets should be minted for the sender + actions: + - extrinsics: + - chain: *assets_parachain + signer: *ap_signer + pallet: assets + call: mint + args: [ + *asset_id, + *ap_wallet, + *mint_amount + ] + events: + - name: assets.Issued + result: { assetId: *asset_id, owner: *ap_wallet, amount: *mint_amount } + + its: + - name: Assets Parachain should be able to reserve transfer an Asset to Penpal Parachain + actions: + - extrinsics: + - chain: *assets_parachain + signer: *ap_signer + pallet: polkadotXcm + call: limitedReserveTransferAssets + args: [ + *pp_dest, # destination + { # beneficiary + V3: { + parents: 0, + interior: { + X1: { + AccountId32: { + id: *pp_acc + } + } + } + } + }, + { # assets + V3: [ + { + id: { + Concrete: { + parents: 0, + interior: { + X2: [ + { + PalletInstance: *assets_pallet_id + }, + { + GeneralIndex: *asset_id + } + ] + } + } + }, + fun: { + Fungible: *amount_to_send + } + } + ] + }, + 0, # feeAssetItem + Unlimited # weightLimit + ] + events: + - name: polkadotXcm.Attempted + threshold: *weight_threshold + result: [{ Complete: { refTime: '673,627,000', proofSize: '6,196' }}] + - name: assets.Transferred + result: { + assetId: *asset_id, + from: *ap_wallet, + to: *pp_sovereign_sibl, + amount: *amount_to_send + } + + - name: polkadotXcm.limitedReserveTransferAssets (KSM) | Assets Parachain -> Penpal Parachain + its: + - name: Assets Parachain should be able to reserve transfer KSM to Penpal Parachain + actions: + - extrinsics: + - chain: *assets_parachain + signer: *ap_signer + pallet: polkadotXcm + call: limitedReserveTransferAssets + args: [ + *pp_dest, # destination + { # beneficiary + V3: { + parents: 0, + interior: { + X1: { + AccountId32: { + id: *pp_acc + } + } + } + } + }, + { # assets + V3: [ + *ap_ksm_fungible + ] + }, + 0, # feeAssetItem + Unlimited # weightLimit + ] + events: + - name: polkadotXcm.Attempted + threshold: *weight_threshold + result: [{ Complete: { refTime: '679,150,000', proofSize: '6,196' }}] + - name: balances.Endowed + result: { + account: *pp_sovereign_sibl, + freeBalance: *amount + } + + - name: polkadotXcm.send( assets.forceCreateAsset ) | Penpal Parachain -> Assets Parachain + before: + - name: Get the asset balance of the Penpal Parachain Sovereign account in Assets Parachain + actions: + - queries: + assets_balance_pp_sovereign_before: + chain: *assets_parachain + pallet: assets + call: account + args: [ + *asset_id, + *pp_sovereign_sibl + ] + its: + - name: Penpal Parachain should be able to send XCM message paying its fee with sufficient asset in Assets Parachain + actions: + - extrinsics: + - chain: *penpal_parachain + signer: *pp_signer + sudo: true + pallet: polkadotXcm + call: send + args: [ + *ap_dest_routed, # destination + { + v3: [ #message + { + WithdrawAsset: [ + { + id: { + concrete: { + parents: 0, + interior: { + X2: [ + { PalletInstance: *assets_pallet_id }, + { GeneralIndex: *asset_id } + ] + } + } + }, + fun: { fungible: *amount_to_send }} + ] + }, + { + BuyExecution: { + fees: { id: *suff_asset, fun: { fungible: *amount_to_send }}, + weightLimit: Unlimited + } + }, + { + Transact: { + originKind: SovereignAccount, + requireWeightAtMost: *weight_at_most, + call: $force_create_asset2 + } + }, + { + RefundSurplus + }, + { + DepositAsset: { + assets: { Wild: All }, + beneficiary: { + parents: 0, + interior: { + X1: { + AccountId32: { + network: , # None + id: *pp_acc + } + } + }} + } + } + ] + } + ] + events: + - name: sudo.Sudid + result: { sudoResult: Ok } + - name: polkadotXcm.Sent + - name: assets.Burned + chain: *assets_parachain + result: { assetId: *asset_id, owner: *pp_sovereign_sibl } + - name: assets.Issued + chain: *assets_parachain + result: { assetId: *asset_id } + - queries: + assets_balance_pp_sovereign_after: + chain: *assets_parachain + pallet: assets + call: account + args: [ + *asset_id, + *pp_sovereign_sibl + ] + forced_created_asset2: + chain: *assets_parachain + pallet: assets + call: asset + args: [ 3 ] + - asserts: + isSome: + args: [ $forced_created_asset2 ] + - name: Should reduce the assets balance of the Penpal Parachain's SovereignAccount in the Assets Parachain + actions: + - asserts: + assetsDecreased: + args: [ + { + balances: { + before: $assets_balance_pp_sovereign_before, + after: $assets_balance_pp_sovereign_after, + }, + } + ] + + - name: Penpal Parachain SHOULD NOT be able to send XCM message paying its fee with sufficient assets if not enough balance + actions: + - extrinsics: + - chain: *penpal_parachain + signer: *pp_signer + sudo: true + pallet: polkadotXcm + call: send + args: [ + *ap_dest_routed, # destination + { + v3: [ #message + { + WithdrawAsset: [*ap_suff_asset_fungible_fail] + }, + { + BuyExecution: { + fees: *ap_suff_asset_fungible_fail, + weightLimit: Unlimited + } + }, + { + Transact: { + originKind: SovereignAccount, + requireWeightAtMost: *weight_at_most, + call: $force_create_asset2 + } + } + ] + } + ] + events: + - name: xcmpQueue.Fail + chain: *assets_parachain + threshold: *weight_threshold + result: { + error: FailedToTransactAsset, + weight: { refTime: '152,426,000', proofSize: '3,593' } + } diff --git a/parachains/integration-tests/e2e/assets/asset-hub-polkadot/config.toml b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/config.toml new file mode 100644 index 00000000000..da53cd0ad4f --- /dev/null +++ b/parachains/integration-tests/e2e/assets/asset-hub-polkadot/config.toml @@ -0,0 +1,72 @@ +[relaychain] +default_command = "./bin/polkadot" +default_args = [ "-lparachain=debug", "-lxcm=trace" ] +chain = "polkadot-local" + + [[relaychain.nodes]] + name = "alice" + ws_port = 9800 + validator = true + args = ["--state-cache-size=0"] + + [[relaychain.nodes]] + name = "bob" + ws_port = 9801 + validator = true + + [[relaychain.nodes]] + name = "charlie" + ws_port = 9802 + validator = true + + [[relaychain.nodes]] + name = "dave" + ws_port = 9803 + validator = true + +[[parachains]] +id = 1000 +chain = "asset-hub-polkadot-local" +cumulus_based = true + + [[parachains.collators]] + name = "collator1" + ws_port = 9810 + command = "./bin/polkadot-parachain" + args = [ "-lxcm=trace", "--state-cache-size=0" ] + + [[parachains.collators]] + name = "collator2" + ws_port = 9811 + command = "./bin/polkadot-parachain" + args = [ "-lxcm=trace" ] + + +[[parachains]] +id = 2000 +chain = "penpal-polkadot-2000" +cumulus_based = true + + [[parachains.collators]] + name = "collator3" + ws_port = 9820 + command = "./bin/polkadot-parachain" + args = [ "-lxcm=trace", "--state-cache-size=0" ] + + [[parachains.collators]] + name = "collator4" + ws_port = 9821 + command = "./bin/polkadot-parachain" + args = [ "-lxcm=trace" ] + +# [[hrmpChannels]] +# sender = 1000 +# recipient = 2000 +# maxCapacity = 8 +# maxMessageSize = 8192 + +# [[hrmpChannels]] +# sender = 2000 +# recipient = 1000 +# maxCapacity = 8 +# maxMessageSize = 8192 diff --git a/parachains/integration-tests/collectives/0_xcm/0_init.yml b/parachains/integration-tests/e2e/collectives/collectives-polkadot/0_xcm/0_init.yml similarity index 60% rename from parachains/integration-tests/collectives/0_xcm/0_init.yml rename to parachains/integration-tests/e2e/collectives/collectives-polkadot/0_xcm/0_init.yml index 8c03348025d..d4824469523 100644 --- a/parachains/integration-tests/collectives/0_xcm/0_init.yml +++ b/parachains/integration-tests/e2e/collectives/collectives-polkadot/0_xcm/0_init.yml @@ -7,12 +7,13 @@ settings: wsPort: 9710 paraId: &cp_id 1001 variables: - xcm_version: &xcm_version '2' + xcm_version: &xcm_version 3 + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } chains: accounts: alice_signer: &alice_signer //Alice decodedCalls: - ap_force_xcm_version: + cp_force_xcm_version: chain: *collectives_parachain pallet: polkadotXcm call: forceXcmVersion @@ -48,13 +49,9 @@ tests: ] events: - name: sudo.Sudid - attributes: - - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.SupportedVersionChanged - attributes: - - type: u32 - value: *xcm_version + result: [{ parents: 0, interior: { X1: { Parachain: *cp_id }}}, *xcm_version ] - extrinsics: # Collectives Parachain sets supported version for Relay Chain through it - chain: *relay_chain signer: *alice_signer @@ -62,14 +59,27 @@ tests: pallet: xcmPallet call: send args: [ - { v1: { 0, interior: { x1: { parachain: *cp_id }}}}, # destination + { v3: { 0, interior: { x1: { parachain: *cp_id }}}}, # destination { - v2: [ # message + v3: [ # message + { + UnpaidExecution: { + weightLimit: { + limited: { + refTime: 2200000000, # 2_200_000_000 + proofSize: 200000, # 200_000 + }, + } + } + }, { Transact: { - originType: Superuser, - requireWeightAtMost: 1000000000, # 1_000_000_000 - call: $ap_force_xcm_version + originKind: Superuser, + requireWeightAtMost: { + refTime: 200000000, # 200_000_000 + proofSize: 0, + }, + call: $cp_force_xcm_version } } ] @@ -77,19 +87,14 @@ tests: ] events: - name: sudo.Sudid - attributes: - - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.Sent - - name: polkadotXcm.SupportedVersionChanged - chain: *collectives_parachain - attributes: - - type: u32 - value: *xcm_version - name: dmpQueue.ExecutedDownward chain: *collectives_parachain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # the weight must be static - value: 2,000,000,000 + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '2,200,000,000', proofSize: 0 }} + } + - name: polkadotXcm.SupportedVersionChanged + chain: *collectives_parachain + result: [{ parents: 1, interior: Here }, *xcm_version ] diff --git a/parachains/integration-tests/collectives/0_xcm/1_teleport.yml b/parachains/integration-tests/e2e/collectives/collectives-polkadot/0_xcm/1_teleport.yml similarity index 69% rename from parachains/integration-tests/collectives/0_xcm/1_teleport.yml rename to parachains/integration-tests/e2e/collectives/collectives-polkadot/0_xcm/1_teleport.yml index cedd08438ad..2cd1fa68168 100644 --- a/parachains/integration-tests/collectives/0_xcm/1_teleport.yml +++ b/parachains/integration-tests/e2e/collectives/collectives-polkadot/0_xcm/1_teleport.yml @@ -7,12 +7,13 @@ settings: wsPort: 9710 paraId: &cp_id 1001 variables: - weight_to_send_teleport: &weight_to_send_teleport 2,000,000,000 # must be same for both chains - weight_to_receive_teleport: &weight_to_receive_teleport 4,000,000,000 # must be same for both chains + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } accounts: alice_signer: &acc_alice_signer //Alice alice_account32: &acc_alice_acc32 '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' alice_ss58: &acc_alice_ss58 '15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5' + checking_account: &checking_account '13UVJyLnbVp9x5XDyJv8g8r3UddNwBrdaH7AADCmw9XQWvYW' + tests: - name: Teleport assets from Relay Chain to Collectives Parachain successful. @@ -39,39 +40,34 @@ tests: pallet: xcmPallet call: teleportAssets args: [ - { v1: { 0, interior: { x1: { parachain: *cp_id }}}}, # destination - { v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *acc_alice_acc32 }}}}}, # beneficiary - { - v1: [ - # { + { v3: { 0, interior: { x1: { parachain: *cp_id }}}}, # destination + { v3: { parents: 0, interior: { x1: { accountId32: { id: *acc_alice_acc32 }}}}}, # beneficiary + { + v3: [ + # { # # TODO use a separate Assets to pay a fee, to receive an exact amount of assets on beneficiary account. # # a call with two assets fails with an error right now. - # id: { concrete: { 0, interior: { here: true }}}, - # fun: { fungible: 1000000000000 } # 1_000_000_000_000 + # id: { concrete: { 0, interior: { here: true }}}, + # fun: { fungible: 1000000000000 } # 1_000_000_000_000 # }, - { - id: { concrete: { 0, interior: { here: true }}}, + { + id: { concrete: { 0, interior: { here: true }}}, fun: { fungible: 20000000000000 } # 20_000_000_000_000 } - ] + ] }, # assets 0, # feeAssetItem ] events: - name: xcmPallet.Attempted - chain: *relay_chain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # the weight must be static - value: *weight_to_send_teleport + threshold: *weight_threshold + result: [{ Complete: { refTime: '3,000,000,000', proofSize: 0 }}] - name: dmpQueue.ExecutedDownward chain: *collectives_parachain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # the weight must be static - value: *weight_to_receive_teleport + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '4,000,000,000', proofSize: 0 }} + } - queries: balance_rc_alice_2: chain: *relay_chain @@ -113,46 +109,31 @@ tests: pallet: polkadotXcm call: teleportAssets args: [ - { v1: { parents: 1, interior: { here: true }}}, # destination - { v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *acc_alice_acc32 }}}}}, # beneficiary - { - v1: [ - { - id: { concrete: { parents: 1, interior: { here: true }}}, + { v3: { parents: 1, interior: { here: true }}}, # destination + { v3: { parents: 0, interior: { x1: { accountId32: { id: *acc_alice_acc32 }}}}}, # beneficiary + { + v3: [ + { + id: { concrete: { parents: 1, interior: { here: true }}}, fun: { fungible: 10000000000000 } # 10_000_000_000_000 } - ] + ] }, # assets 0, # feeAssetItem ] events: - name: balances.Withdraw - attributes: - - type: AccountId32 - key: who - value: *acc_alice_ss58 - - type: u128 - key: amount - value: 10000000000000 + result: { who: *acc_alice_ss58, amount: 10000000000000 } - name: polkadotXcm.Attempted - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # the weight must be static - value: *weight_to_send_teleport + threshold: *weight_threshold + result: [{ Complete: { refTime: '3,000,000,000', proofSize: 0 }}] - name: balances.Withdraw chain: *relay_chain - attributes: - - type: u128 - key: amount - value: 10000000000000 # amount received and withdrawn from registry account + result: { who: *checking_account, amount: 10000000000000 } # amount received and withdrawn from registry account - name: ump.ExecutedUpward chain: *relay_chain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # the weight must be static - value: *weight_to_receive_teleport + threshold: *weight_threshold + result: [{ Complete: { refTime: '4,000,000,000', proofSize: 0 }}] - queries: balance_rc_alice_3: chain: *relay_chain diff --git a/parachains/integration-tests/e2e/collectives/collectives-polkadot/0_xcm/2_reserve.yml b/parachains/integration-tests/e2e/collectives/collectives-polkadot/0_xcm/2_reserve.yml new file mode 100644 index 00000000000..0695f1201b0 --- /dev/null +++ b/parachains/integration-tests/e2e/collectives/collectives-polkadot/0_xcm/2_reserve.yml @@ -0,0 +1,53 @@ +--- +settings: + chains: + relay_chain: &relay_chain + wsPort: 9700 + collectives_parachain: &collectives_parachain + wsPort: 9710 + paraId: &cp_id 1001 + variables: + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } + chains: + accounts: + alice_signer: &alice_signer //Alice + alice_account32: &alice_acc32 '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' + +tests: + - name: Reserve assets from Relay Chain to Collectives Parachain fails + its: + - name: Reserve assets from Relay Chain to Collectives Parachain + actions: + - extrinsics: + - chain: *relay_chain + signer: *alice_signer + pallet: xcmPallet + call: reserveTransferAssets + args: [ + { v3: { 0, interior: { x1: { parachain: *cp_id }}}}, # destination + { v3: { parents: 0, interior: { x1: { accountId32: { id: *alice_acc32 }}}}}, # beneficiary + { + v3: [ + { + id: { concrete: { 0, interior: { here: true }}}, + fun: { fungible: 20000000000000 } # 20_000_000_000_000 + } + ] + }, # assets + 0, # feeAssetItem + ] + events: + - name: xcmPallet.Attempted + threshold: *weight_threshold + result: [{ Complete: { refTime: '2,000,000,000', proofSize: 0 }}] + - name: dmpQueue.ExecutedDownward + chain: *collectives_parachain + threshold: *weight_threshold + result: { + outcome: { + Incomplete: [ + { refTime: '1,000,000,000', proofSize: 0 }, + UntrustedReserveLocation + ] + } + } diff --git a/parachains/integration-tests/collectives/1_alliance/0_join_alliance_fails.yml b/parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/0_join_alliance_fails.yml similarity index 53% rename from parachains/integration-tests/collectives/1_alliance/0_join_alliance_fails.yml rename to parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/0_join_alliance_fails.yml index 11778830562..9aff8b1db10 100644 --- a/parachains/integration-tests/collectives/1_alliance/0_join_alliance_fails.yml +++ b/parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/0_join_alliance_fails.yml @@ -1,15 +1,13 @@ --- settings: chains: - relay_chain: &relay_chain + relay_chain: wsPort: 9700 collectives_parachain: &collectives_parachain wsPort: 9710 - paraId: &cp_id 1001 variables: accounts: alice_signer: &alice_signer //Alice - alice_account32: &cp_alice_acc32 '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' tests: - name: Alice fails to join an the Alliance, since it is not initialized yet. @@ -24,11 +22,8 @@ tests: args: [] events: - name: system.ExtrinsicFailed - attributes: - - type: SpRuntimeDispatchError - key: dispatchError - # TODO assert with Alliance Error variant - alliance.AllianceNotYetInitialized - # issue - https://github.com/paritytech/parachains-integration-tests/issues/59 - value: {"Module":{"index":"50","error":"0x00000000"}} - - + result: { + dispatchError: { Module: { index: 50, error: '0x00000000' }} + } + # TODO assert with Alliance Error variant - alliance.AllianceNotYetInitialized + # issue - https://github.com/paritytech/parachains-integration-tests/issues/59 diff --git a/parachains/integration-tests/collectives/1_alliance/1_init_alliance.yml b/parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/1_init_alliance.yml similarity index 55% rename from parachains/integration-tests/collectives/1_alliance/1_init_alliance.yml rename to parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/1_init_alliance.yml index 2891d01ca02..15140e6946c 100644 --- a/parachains/integration-tests/collectives/1_alliance/1_init_alliance.yml +++ b/parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/1_init_alliance.yml @@ -7,24 +7,17 @@ settings: wsPort: 9710 paraId: &coll_para_id 1001 variables: + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } accounts: alice_signer: &acc_alice_signer //Alice - alice_account32: &acc_alice_acc32 "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d" - liam_signer: &acc_liam_signer //Liam - liam_account32: &acc_liam_acc32 "0x3614671a5de540d891eb8c4939c8153a4aa790602b347c18177b86d0fc546221" - olivia_signer: &acc_olivia_signer //Olivia - olivia_account32: &acc_olivia_acc32 "0x24ee8a659c6716fe9f7cb4e9e028602aa12867654ca02737da9171b7ff697d5c" - noah_signer: &acc_noah_signer //Noah - noah_account32: &acc_noah_acc32 "0x9c6ad3bc3aa2f1b2e837898e6da9980445f7ef8b3eee0b8c8e305f8cfae68517" - emma_signer: &acc_emma_signer //Emma - emma_account32: &acc_emma_acc32 "0x8ac272b333ba1127c8db57fa777ec820b24598a236efa648caf0d26d86f64572" - james_signer: &acc_james_signer //James - james_account32: &acc_james_acc32 "0x9a52805151a0b5effc084af9264011139872a21a3950cb9ae0b2955c4bf92c18" - ava_signer: &acc_ava_signer //Ava - ava_account32: &acc_ava_acc32 "0x348ef0b8776adbc09c862ddc29b1d193b9e24738e54eea3b0609c83856dc101c" - mia_signer: &acc_mia_signer //Mia - mia_account32: &acc_mia_acc32 "0xaebf15374cf7e758d10232514c569a7abf81cc1b8f1e81a73dbc608a0e335264" - decodedCalls: + liam_account32: &acc_liam_acc32 "0x3614671a5de540d891eb8c4939c8153a4aa790602b347c18177b86d0fc546221" # //Liam + olivia_account32: &acc_olivia_acc32 "0x24ee8a659c6716fe9f7cb4e9e028602aa12867654ca02737da9171b7ff697d5c" # //Olivia + noah_account32: &acc_noah_acc32 "0x9c6ad3bc3aa2f1b2e837898e6da9980445f7ef8b3eee0b8c8e305f8cfae68517" # //Noah + emma_account32: &acc_emma_acc32 "0x8ac272b333ba1127c8db57fa777ec820b24598a236efa648caf0d26d86f64572" # //Emma + james_account32: &acc_james_acc32 "0x9a52805151a0b5effc084af9264011139872a21a3950cb9ae0b2955c4bf92c18" # //James + ava_account32: &acc_ava_acc32 "0x348ef0b8776adbc09c862ddc29b1d193b9e24738e54eea3b0609c83856dc101c" # //Ava + mia_account32: &acc_mia_acc32 "0xaebf15374cf7e758d10232514c569a7abf81cc1b8f1e81a73dbc608a0e335264" # //Mia + decodedCalls: init_alliance_members: chain: *collectives_parachain pallet: alliance @@ -81,13 +74,26 @@ tests: pallet: xcmPallet call: send args: [ - { v1: { parents: 0, interior: { x1: { parachain: *coll_para_id }}}}, # destination + { v3: { parents: 0, interior: { x1: { parachain: *coll_para_id }}}}, # destination { - v2: [ # message + v3: [ # message + { + UnpaidExecution: { + weightLimit: { + limited: { + refTime: 3000000000, # 3_000_000_000 + proofSize: 2000000, # 2_000_000 + }, + } + } + }, { Transact: { - originType: Superuser, - requireWeightAtMost: 1000000000, # 1_000_000_000 + originKind: Superuser, + requireWeightAtMost: { + refTime: 1000000000, # 1_000_000_000 + proofSize: 1000000, # 1_000_000 + }, call: $init_alliance_members } } @@ -96,20 +102,17 @@ tests: ] events: - name: sudo.Sudid - attributes: - - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.Sent - name: alliance.MembersInitialized chain: *collectives_parachain - name: dmpQueue.ExecutedDownward chain: *collectives_parachain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # we don't know how much weight will be spent for custom call within Transact operation - # value: skipping the assertion - + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '3,000,000,000', proofSize: '1,000,000' }} + } + - name: Alliance init call fails. actions: - extrinsics: @@ -119,13 +122,26 @@ tests: pallet: xcmPallet call: send args: [ - { v1: { parents: 0, interior: { x1: { parachain: *coll_para_id }}}}, # destination + { v3: { parents: 0, interior: { x1: { parachain: *coll_para_id }}}}, # destination { - v2: [ # message + v3: [ # message + { + UnpaidExecution: { + weightLimit: { + limited: { + refTime: 3000000000, # 3_000_000_000 + proofSize: 2000000, # 2_000_000 + }, + } + } + }, { Transact: { - originType: Superuser, - requireWeightAtMost: 1000000000, # 1_000_000_000 + originKind: Superuser, + requireWeightAtMost: { + refTime: 1000000000, # 1_000_000_000 + proofSize: 1000000, # 1_000_000 + }, call: $init_alliance_voting_members } } @@ -138,17 +154,14 @@ tests: # Next test with a disband call will fail, if this call does not fail, # since a witness data from a disband call will be invalid. - name: sudo.Sudid - attributes: - - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.Sent - name: dmpQueue.ExecutedDownward chain: *collectives_parachain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # the call must fail, the weight spent is static - value: 2,000,000,000 + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '3,000,000,000', proofSize: '1,000,000' }} + } - name: Alliance disbanded and initialized again. actions: @@ -159,13 +172,26 @@ tests: pallet: xcmPallet call: send args: [ - { v1: { parents: 0, interior: { x1: { parachain: *coll_para_id }}}}, # destination + { v3: { parents: 0, interior: { x1: { parachain: *coll_para_id }}}}, # destination { - v2: [ # message + v3: [ # message + { + UnpaidExecution: { + weightLimit: { + limited: { + refTime: 5000000000, # 3_000_000_000 + proofSize: 1000000, # 1_000_000 + }, + } + } + }, { Transact: { - originType: Superuser, - requireWeightAtMost: 100000000000, # 100_000_000_000 + originKind: Superuser, + requireWeightAtMost: { + refTime: 3000000000, # 3_000_000_000 + proofSize: 200000, # 200_000 + }, call: $disband } } @@ -174,29 +200,17 @@ tests: ] events: - name: sudo.Sudid - attributes: - - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.Sent - name: alliance.AllianceDisbanded chain: *collectives_parachain - attributes: - - type: u32 - key: fellowMembers - value: 6 - - type: u32 - key: allyMembers - value: 1 - - type: u32 - key: unreserved - value: 0 + result: { fellowMembers: 6, allyMembers: 1, unreserved: 0 } - name: dmpQueue.ExecutedDownward chain: *collectives_parachain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # we don't know how much weight will be spent for custom call within Transact operation - # value: skipping the assertion + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '3,321,495,872', proofSize: '181,779' }} + } - name: Alliance initiated, founders and fellows are set. actions: - extrinsics: @@ -206,13 +220,26 @@ tests: pallet: xcmPallet call: send args: [ - { v1: { parents: 0, interior: { x1: { parachain: *coll_para_id }}}}, # destination + { v3: { parents: 0, interior: { x1: { parachain: *coll_para_id }}}}, # destination { - v2: [ # message + v3: [ # message + { + UnpaidExecution: { + weightLimit: { + limited: { + refTime: 3000000000, # 3_000_000_000 + proofSize: 2000000, # 2_000_000 + }, + } + } + }, { Transact: { - originType: Superuser, - requireWeightAtMost: 1000000000, # 1_000_000_000 + originKind: Superuser, + requireWeightAtMost: { + refTime: 1000000000, # 1_000_000_000 + proofSize: 1000000, # 1_000_000 + }, call: $init_alliance_members } } @@ -221,17 +248,13 @@ tests: ] events: - name: sudo.Sudid - attributes: - - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.Sent - name: alliance.MembersInitialized chain: *collectives_parachain - name: dmpQueue.ExecutedDownward chain: *collectives_parachain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # we don't know how much weight will be spent for custom call within Transact operation - # value: skipping the assertion - + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '3,000,000,000', proofSize: '1,000,000' }} + } diff --git a/parachains/integration-tests/collectives/1_alliance/2_join_alliance_fails.yml b/parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/2_join_alliance_fails.yml similarity index 53% rename from parachains/integration-tests/collectives/1_alliance/2_join_alliance_fails.yml rename to parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/2_join_alliance_fails.yml index 574df004512..2afdadae602 100644 --- a/parachains/integration-tests/collectives/1_alliance/2_join_alliance_fails.yml +++ b/parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/2_join_alliance_fails.yml @@ -1,15 +1,14 @@ --- settings: chains: - relay_chain: &relay_chain + relay_chain: wsPort: 9700 collectives_parachain: &collectives_parachain wsPort: 9710 - paraId: &cp_id 1001 + paraId: 1001 variables: accounts: liam_signer: &acc_liam_signer //Liam - liam_account32: &acc_liam_acc32 "0x3614671a5de540d891eb8c4939c8153a4aa790602b347c18177b86d0fc546221" tests: - name: Liam fails to join an the Alliance, Liam is already a member. @@ -24,11 +23,8 @@ tests: args: [] events: - name: system.ExtrinsicFailed - attributes: - - type: SpRuntimeDispatchError - key: dispatchError - # TODO assert with Alliance Error variant - alliance.AllianceNotYetInitialized - # issue - https://github.com/paritytech/parachains-integration-tests/issues/59 - value: {"Module":{"index":"50","error":"0x02000000"}} - - + result: { + dispatchError: { Module: { index: 50, error: '0x02000000' }} + } + # TODO assert with Alliance Error variant - alliance.AllianceNotYetInitialized + # issue - https://github.com/paritytech/parachains-integration-tests/issues/59 diff --git a/parachains/integration-tests/collectives/1_alliance/3_kick_member.yml b/parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/3_kick_member.yml similarity index 67% rename from parachains/integration-tests/collectives/1_alliance/3_kick_member.yml rename to parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/3_kick_member.yml index 6283bacfdb9..0c07a281e14 100644 --- a/parachains/integration-tests/collectives/1_alliance/3_kick_member.yml +++ b/parachains/integration-tests/e2e/collectives/collectives-polkadot/1_alliance/3_kick_member.yml @@ -7,10 +7,8 @@ settings: wsPort: 9710 paraId: &cp_id 1001 variables: + weight_threshold: &weight_threshold { refTime: [10, 10], proofSize: [10, 10] } init_teleport_amount: &init_teleport_amount 20000000000000 # 20_000_000_000_000 - weight_to_send_teleport: &weight_to_send_teleport 2,000,000,000 # must be same for both chains - weight_to_receive_teleport: &weight_to_receive_teleport 4,000,000,000 # must be same for both chains - weight_to_receive_transact: &weight_to_receive_transact 3,000,000,000 # must be same for both chains accounts: alice_signer: &acc_alice_signer //Alice treasury_account32: &acc_treasury_acc32 '0x6d6f646c70792f74727372790000000000000000000000000000000000000000' @@ -36,34 +34,25 @@ tests: pallet: xcmPallet call: limitedTeleportAssets args: [ - { v1: { 0, interior: { x1: { parachain: *cp_id }}}}, # destination - { v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *acc_alice_acc32 }}}}}, # beneficiary - { v1: [ { id: { concrete: { 0, interior: { here: true }}}, fun: { fungible: *init_teleport_amount }} ] }, # assets + { v3: { 0, interior: { x1: { parachain: *cp_id }}}}, # destination + { v3: { parents: 0, interior: { x1: { accountId32: { id: *acc_alice_acc32 }}}}}, # beneficiary + { v3: [ { id: { concrete: { 0, interior: { here: true }}}, fun: { fungible: *init_teleport_amount }} ] }, # assets 0, # feeAssetItem { unlimited: true } # weightLimit ] events: - name: xcmPallet.Attempted - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - value: *weight_to_send_teleport + threshold: *weight_threshold + result: [{ Complete: { refTime: '3,000,000,000', proofSize: 0 }}] - name: balances.Deposit chain: *collectives_parachain - attributes: - - type: AccountId32 - key: who - value: *acc_alice_ss58 - - type: u128 - key: amount - value: 20,000,000,000,000 + result: { who: *acc_alice_ss58 } - name: dmpQueue.ExecutedDownward chain: *collectives_parachain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # must be static - value: *weight_to_receive_teleport + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '4,000,000,000', proofSize: 0 }} + } - name: Get the balances of the Relay Chain's treasury & Collectives parachain's future alliance member actions: - queries: @@ -89,18 +78,9 @@ tests: events: - name: balances.Reserved chain: *collectives_parachain - attributes: - - type: AccountId32 - key: who - value: *acc_alice_ss58 - - type: u128 - key: amount - value: 10,000,000,000,000 + result: { who: *acc_alice_ss58, amount: '10,000,000,000,000' } - name: alliance.NewAllyJoined - attributes: - - type: AccountId32 - key: ally - value: *acc_alice_ss58 + result: { ally: *acc_alice_ss58 } - queries: balance_cp_alice_after: chain: *collectives_parachain @@ -129,13 +109,26 @@ tests: pallet: xcmPallet call: send args: [ - { v1: { parents: 0, interior: { x1: { parachain: *cp_id }}}}, # destination + { v3: { parents: 0, interior: { x1: { parachain: *cp_id }}}}, # destination { - v2: [ #message + v3: [ #message + { + UnpaidExecution: { + weightLimit: { + limited: { + refTime: 4000000000, # 4_000_000_000 + proofSize: 2000000, # 2_000_000 + }, + } + } + }, { Transact: { - originType: Superuser, - requireWeightAtMost: 2000000000, + originKind: Superuser, + requireWeightAtMost: { + refTime: 2000000000, # 2_000_000_000 + proofSize: 1000000, # 1_000_000 + }, call: $alliance_kick_member } } @@ -144,23 +137,17 @@ tests: ] events: - name: sudo.Sudid - attributes: - - type: Result - value: Ok + result: { sudoResult: Ok } - name: xcmPallet.Sent - name: alliance.MemberKicked chain: *collectives_parachain - attributes: - - type: AccountId32 - key: member - value: *acc_alice_ss58 + result: { member: *acc_alice_ss58 } - name: dmpQueue.ExecutedDownward chain: *collectives_parachain - attributes: - - type: XcmV2TraitsOutcome - xcmOutcome: Complete - # must be static - value: *weight_to_receive_transact + threshold: *weight_threshold + result: { + outcome: { Complete: { refTime: '4,000,000,000', proofSize: '1,000,000' }} + } - queries: balance_rc_treasury_after: diff --git a/parachains/integration-tests/collectives/config.toml b/parachains/integration-tests/e2e/collectives/collectives-polkadot/config.toml similarity index 74% rename from parachains/integration-tests/collectives/config.toml rename to parachains/integration-tests/e2e/collectives/collectives-polkadot/config.toml index 9d138be11ba..20fda92bd08 100644 --- a/parachains/integration-tests/collectives/config.toml +++ b/parachains/integration-tests/e2e/collectives/collectives-polkadot/config.toml @@ -7,13 +7,21 @@ chain = "polkadot-local" name = "alice" ws_port = 9700 validator = true + args = ["--state-cache-size=0"] [[relaychain.nodes]] name = "bob" + ws_port = 9701 validator = true [[relaychain.nodes]] name = "charlie" + ws_port = 9702 + validator = true + + [[relaychain.nodes]] + name = "dave" + ws_port = 9703 validator = true [[parachains]] @@ -25,9 +33,10 @@ cumulus_based = true name = "collator1" ws_port = 9710 command = "./bin/polkadot-parachain" - args = ["-lxcm=trace"] + args = [ "-lxcm=trace", "--state-cache-size=0" ] [[parachains.collators]] name = "collator2" + ws_port = 9711 command = "./bin/polkadot-parachain" args = ["-lxcm=trace"] diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml b/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml new file mode 100644 index 00000000000..a25e2116873 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "asset-hub-kusama-integration-tests" +version = "1.0.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Asset Hub Kusama runtime integration tests with xcm-emulator" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } + +# Substrate +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } + +# Polkadot +polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-parachain = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } + +# Cumulus +parachains-common = { path = "../../../../common" } +penpal-runtime = { path = "../../../../runtimes/testing/penpal" } +asset-hub-kusama-runtime = { path = "../../../../runtimes/assets/asset-hub-kusama" } + +# Local +xcm-emulator = { default-features = false, path = "../../../../../xcm/xcm-emulator" } +integration-tests-common = { default-features = false, path = "../../common" } diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs new file mode 100644 index 00000000000..44a8f8a469c --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/lib.rs @@ -0,0 +1,30 @@ +pub use codec::Encode; +pub use frame_support::{ + assert_ok, instances::Instance1, pallet_prelude::Weight, traits::fungibles::Inspect, +}; +pub use integration_tests_common::{ + constants::{ + accounts::{ALICE, BOB}, + kusama::ED as KUSAMA_ED, + PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, + }, + AccountId, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, + BHKusama, BHKusamaPallet, BHKusamaReceiver, BHKusamaSender, BHPolkadot, BHPolkadotPallet, + BHPolkadotReceiver, BHPolkadotSender, Collectives, CollectivesPallet, CollectivesReceiver, + CollectivesSender, Kusama, KusamaMockNet, KusamaPallet, KusamaReceiver, KusamaSender, + PenpalKusama, PenpalKusamaReceiver, PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver, + PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver, + PolkadotSender, +}; +pub use polkadot_core_primitives::InboundDownwardMessage; +pub use xcm::{ + prelude::*, + v3::{Error, NetworkId::Kusama as KusamaId}, +}; +pub use xcm_emulator::{ + assert_expected_events, bx, helpers::weight_within_threshold, Parachain as Para, + RelayChain as Relay, TestExt, +}; + +#[cfg(test)] +mod tests; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/mod.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/mod.rs new file mode 100644 index 00000000000..996f9fd0aae --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/mod.rs @@ -0,0 +1,3 @@ +mod reserve_transfer; +mod teleport; +mod transact; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs new file mode 100644 index 00000000000..e0d51f742d4 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/reserve_transfer.rs @@ -0,0 +1,58 @@ +use crate::*; + +#[test] +fn reserve_transfer_native_asset_from_relay_to_assets() { + // Init tests variables + let amount = KUSAMA_ED * 1000; + let relay_sender_balance_before = Kusama::account_data_of(KusamaSender::get()).free; + let para_receiver_balance_before = + AssetHubKusama::account_data_of(AssetHubKusamaReceiver::get()).free; + + let origin = ::RuntimeOrigin::signed(KusamaSender::get()); + let assets_para_destination: VersionedMultiLocation = + Kusama::child_location_of(AssetHubKusama::para_id()).into(); + let beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: AssetHubKusamaReceiver::get().into() }.into(); + let native_assets: VersionedMultiAssets = (Here, amount).into(); + let fee_asset_item = 0; + let weight_limit = WeightLimit::Unlimited; + + // Send XCM message from Relay Chain + Kusama::execute_with(|| { + assert_ok!(::XcmPallet::limited_reserve_transfer_assets( + origin, + bx!(assets_para_destination), + bx!(beneficiary), + bx!(native_assets), + fee_asset_item, + weight_limit, + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Kusama, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete(weight) }) => { + weight: weight_within_threshold((REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), Weight::from_parts(754_244_000, 0), *weight), + }, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubKusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + // TODO: This used to emit an event at the DmpQueue pallet which is not gone.. does it have a replacement? + assert_expected_events!(AssetHubKusama, vec![]); + }); + + // Check if balances are updated accordingly in Relay Chain and Assets Parachain + let relay_sender_balance_after = Kusama::account_data_of(KusamaSender::get()).free; + let para_sender_balance_after = + AssetHubKusama::account_data_of(AssetHubKusamaReceiver::get()).free; + + assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after); + assert_eq!(para_sender_balance_after, para_receiver_balance_before); +} diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs new file mode 100644 index 00000000000..92849523d45 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/teleport.rs @@ -0,0 +1,64 @@ +use crate::*; + +#[test] +fn teleport_native_assets_from_relay_to_assets_para() { + // Init tests variables + let amount = KUSAMA_ED * 1000; + let relay_sender_balance_before = Kusama::account_data_of(KusamaSender::get()).free; + let para_receiver_balance_before = + AssetHubKusama::account_data_of(AssetHubKusamaReceiver::get()).free; + + let origin = ::RuntimeOrigin::signed(KusamaSender::get()); + let assets_para_destination: VersionedMultiLocation = + Kusama::child_location_of(AssetHubKusama::para_id()).into(); + let beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: AssetHubKusamaReceiver::get().into() }.into(); + let native_assets: VersionedMultiAssets = (Here, amount).into(); + let fee_asset_item = 0; + let weight_limit = WeightLimit::Unlimited; + + // Send XCM message from Relay Chain + Kusama::execute_with(|| { + assert_ok!(::XcmPallet::limited_teleport_assets( + origin, + bx!(assets_para_destination), + bx!(beneficiary), + bx!(native_assets), + fee_asset_item, + weight_limit, + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Kusama, + vec![ + RuntimeEvent::XcmPallet( + pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } } + ) => {}, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubKusama::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubKusama, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { + who: *who == AssetHubKusamaReceiver::get().into(), + }, + ] + ); + }); + + // Check if balances are updated accordingly in Relay Chain and Assets Parachain + let relay_sender_balance_after = Kusama::account_data_of(KusamaSender::get()).free; + let para_sender_balance_after = + AssetHubKusama::account_data_of(AssetHubKusamaReceiver::get()).free; + + assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after); + assert!(para_sender_balance_after > para_receiver_balance_before); +} diff --git a/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/transact.rs b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/transact.rs new file mode 100644 index 00000000000..79542395e74 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-kusama/src/tests/transact.rs @@ -0,0 +1,58 @@ +use crate::*; + +#[test] +fn transact_sudo_from_relay_to_assets_para() { + // Init tests variables + // Call to be executed in Assets Parachain + const ASSET_ID: u32 = 1; + + let call = ::RuntimeCall::Assets(pallet_assets::Call::< + ::Runtime, + Instance1, + >::force_create { + id: ASSET_ID.into(), + is_sufficient: true, + min_balance: 1000, + owner: AssetHubKusamaSender::get().into(), + }) + .encode() + .into(); + + // XcmPallet send arguments + let sudo_origin = ::RuntimeOrigin::root(); + let assets_para_destination: VersionedMultiLocation = + Kusama::child_location_of(AssetHubKusama::para_id()).into(); + + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1000000000, 200000); + let origin_kind = OriginKind::Superuser; + let check_origin = None; + + let xcm = VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit, check_origin }, + Transact { require_weight_at_most, origin_kind, call }, + ])); + + // Send XCM message from Relay Chain + Kusama::execute_with(|| { + assert_ok!(::XcmPallet::send( + sudo_origin, + bx!(assets_para_destination), + bx!(xcm), + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Kusama, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubKusama::execute_with(|| { + assert!(::Assets::asset_exists(ASSET_ID)); + }); +} diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml new file mode 100644 index 00000000000..b518257b1a5 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "asset-hub-polkadot-integration-tests" +version = "1.0.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Asset Hub Polkadot runtime integration tests with xcm-emulator" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } + +# Substrate +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } + +# Polkadot +polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-parachain = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } + +# Cumulus +parachains-common = { path = "../../../../common" } +penpal-runtime = { path = "../../../../runtimes/testing/penpal" } +asset-hub-polkadot-runtime = { path = "../../../../runtimes/assets/asset-hub-polkadot" } + +# Local +xcm-emulator = { default-features = false, path = "../../../../../xcm/xcm-emulator" } +integration-tests-common = { default-features = false, path = "../../common" } diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs new file mode 100644 index 00000000000..889308dfff5 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/lib.rs @@ -0,0 +1,34 @@ +pub use codec::Encode; +pub use frame_support::{ + assert_ok, instances::Instance1, pallet_prelude::Weight, traits::fungibles::Inspect, +}; +pub use integration_tests_common::{ + constants::{ + accounts::{ALICE, BOB}, + polkadot::ED as POLKADOT_ED, + PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, + }, + AccountId, AssetHubKusama, AssetHubKusamaPallet, AssetHubKusamaReceiver, AssetHubKusamaSender, + AssetHubPolkadot, AssetHubPolkadotPallet, AssetHubPolkadotReceiver, AssetHubPolkadotSender, + BHKusama, BHKusamaPallet, BHKusamaReceiver, BHKusamaSender, BHPolkadot, BHPolkadotPallet, + BHPolkadotReceiver, BHPolkadotSender, Collectives, CollectivesPallet, CollectivesReceiver, + CollectivesSender, Kusama, KusamaMockNet, KusamaPallet, KusamaReceiver, KusamaSender, + PenpalKusama, PenpalKusamaReceiver, PenpalKusamaSender, PenpalPolkadot, PenpalPolkadotReceiver, + PenpalPolkadotSender, Polkadot, PolkadotMockNet, PolkadotPallet, PolkadotReceiver, + PolkadotSender, +}; +pub use polkadot_core_primitives::InboundDownwardMessage; +pub use xcm::{ + prelude::*, + v3::{ + Error, + NetworkId::{Kusama as KusamaId, Polkadot as PolkadotId}, + }, +}; +pub use xcm_emulator::{ + assert_expected_events, bx, helpers::weight_within_threshold, Parachain as Para, + RelayChain as Relay, TestExt, +}; + +#[cfg(test)] +mod tests; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/mod.rs b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/mod.rs new file mode 100644 index 00000000000..996f9fd0aae --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/mod.rs @@ -0,0 +1,3 @@ +mod reserve_transfer; +mod teleport; +mod transact; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs new file mode 100644 index 00000000000..08effb6d811 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/reserve_transfer.rs @@ -0,0 +1,58 @@ +use crate::*; + +#[test] +fn reserve_transfer_native_asset_from_relay_to_assets() { + // Init tests variables + let amount = POLKADOT_ED * 1000; + let relay_sender_balance_before = Polkadot::account_data_of(PolkadotSender::get()).free; + let para_receiver_balance_before = + AssetHubPolkadot::account_data_of(AssetHubPolkadotReceiver::get()).free; + + let origin = ::RuntimeOrigin::signed(PolkadotSender::get()); + let assets_para_destination: VersionedMultiLocation = + Polkadot::child_location_of(AssetHubPolkadot::para_id()).into(); + let beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: AssetHubPolkadotReceiver::get().into() }.into(); + let native_assets: VersionedMultiAssets = (Here, amount).into(); + let fee_asset_item = 0; + let weight_limit = WeightLimit::Unlimited; + + // Send XCM message from Relay Chain + Polkadot::execute_with(|| { + assert_ok!(::XcmPallet::limited_reserve_transfer_assets( + origin, + bx!(assets_para_destination), + bx!(beneficiary), + bx!(native_assets), + fee_asset_item, + weight_limit, + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Polkadot, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete(weight) }) => { + weight: weight_within_threshold((REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), Weight::from_parts(2_000_000_000, 0), *weight), + }, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubPolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + // TODO: This used to emit an event at the DmpQueue pallet which is not gone.. does it have a replacement? + assert_expected_events!(AssetHubPolkadot, vec![]); + }); + + // Check if balances are updated accordingly in Relay Chain and Assets Parachain + let relay_sender_balance_after = Polkadot::account_data_of(PolkadotSender::get()).free; + let para_sender_balance_after = + AssetHubPolkadot::account_data_of(AssetHubPolkadotReceiver::get()).free; + + assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after); + assert_eq!(para_sender_balance_after, para_receiver_balance_before); +} diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs new file mode 100644 index 00000000000..eebdddfe506 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/teleport.rs @@ -0,0 +1,62 @@ +use crate::*; + +#[test] +fn teleport_native_assets_from_relay_to_assets_para() { + // Init tests variables + let amount = POLKADOT_ED * 1000; + let relay_sender_balance_before = Polkadot::account_data_of(PolkadotSender::get()).free; + let para_receiver_balance_before = + AssetHubPolkadot::account_data_of(AssetHubPolkadotReceiver::get()).free; + + let origin = ::RuntimeOrigin::signed(PolkadotSender::get()); + let assets_para_destination: VersionedMultiLocation = + Polkadot::child_location_of(AssetHubPolkadot::para_id()).into(); + let beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: AssetHubPolkadotReceiver::get().into() }.into(); + let native_assets: VersionedMultiAssets = (Here, amount).into(); + let fee_asset_item = 0; + let weight_limit = WeightLimit::Unlimited; + + // Send XCM message from Relay Chain + Polkadot::execute_with(|| { + assert_ok!(::XcmPallet::limited_teleport_assets( + origin, + bx!(assets_para_destination), + bx!(beneficiary), + bx!(native_assets), + fee_asset_item, + weight_limit, + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Polkadot, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } }) => {}, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubPolkadot::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubPolkadot, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { + who: *who == AssetHubPolkadotReceiver::get().into(), + }, + ] + ); + }); + + // Check if balances are updated accordingly in Relay Chain and Assets Parachain + let relay_sender_balance_after = Polkadot::account_data_of(PolkadotSender::get()).free; + let para_sender_balance_after = + AssetHubPolkadot::account_data_of(AssetHubPolkadotReceiver::get()).free; + + assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after); + assert!(para_sender_balance_after > para_receiver_balance_before); +} diff --git a/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/transact.rs b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/transact.rs new file mode 100644 index 00000000000..759e063dd93 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-polkadot/src/tests/transact.rs @@ -0,0 +1,58 @@ +use crate::*; + +#[test] +fn transact_sudo_from_relay_to_assets_para() { + // Init tests variables + // Call to be executed in Assets Parachain + const ASSET_ID: u32 = 1; + + let call = ::RuntimeCall::Assets(pallet_assets::Call::< + ::Runtime, + Instance1, + >::force_create { + id: ASSET_ID.into(), + is_sufficient: true, + min_balance: 1000, + owner: AssetHubPolkadotSender::get().into(), + }) + .encode() + .into(); + + // XcmPallet send arguments + let sudo_origin = ::RuntimeOrigin::root(); + let assets_para_destination: VersionedMultiLocation = + Polkadot::child_location_of(AssetHubPolkadot::para_id()).into(); + + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1000000000, 200000); + let origin_kind = OriginKind::Superuser; + let check_origin = None; + + let xcm = VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit, check_origin }, + Transact { require_weight_at_most, origin_kind, call }, + ])); + + // Send XCM message from Relay Chain + Polkadot::execute_with(|| { + assert_ok!(::XcmPallet::send( + sudo_origin, + bx!(assets_para_destination), + bx!(xcm), + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Polkadot, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubPolkadot::execute_with(|| { + assert!(::Assets::asset_exists(ASSET_ID)); + }); +} diff --git a/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml b/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml new file mode 100644 index 00000000000..c216a84191f --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "asset-hub-westend-integration-tests" +version = "1.0.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Asset Hub Westend runtime integration tests with xcm-emulator" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } + +# Substrate +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } + +# Polkadot +polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-parachain = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +westend-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } + +# Cumulus +parachains-common = { path = "../../../../common" } +penpal-runtime = { path = "../../../../runtimes/testing/penpal" } +asset-hub-westend-runtime = { path = "../../../../runtimes/assets/asset-hub-westend" } + +# Local +xcm-emulator = { default-features = false, path = "../../../../../xcm/xcm-emulator" } +integration-tests-common = { default-features = false, path = "../../common" } diff --git a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs new file mode 100644 index 00000000000..74d6ad2f018 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/lib.rs @@ -0,0 +1,29 @@ +pub use codec::Encode; +pub use frame_support::{ + assert_ok, instances::Instance1, pallet_prelude::Weight, traits::fungibles::Inspect, +}; +pub use integration_tests_common::{ + constants::{ + accounts::{ALICE, BOB}, + polkadot::ED as POLKADOT_ED, + PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, + }, + AccountId, AssetHubWestend, AssetHubWestendPallet, AssetHubWestendReceiver, + AssetHubWestendSender, Collectives, CollectivesPallet, CollectivesReceiver, CollectivesSender, + PenpalWestend, Westend, WestendPallet, WestendReceiver, WestendSender, +}; +pub use polkadot_core_primitives::InboundDownwardMessage; +pub use xcm::{ + prelude::*, + v3::{ + Error, + NetworkId::{Kusama as KusamaId, Polkadot as PolkadotId}, + }, +}; +pub use xcm_emulator::{ + assert_expected_events, bx, helpers::weight_within_threshold, Parachain as Para, + RelayChain as Relay, TestExt, +}; + +#[cfg(test)] +mod tests; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs new file mode 100644 index 00000000000..996f9fd0aae --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/mod.rs @@ -0,0 +1,3 @@ +mod reserve_transfer; +mod teleport; +mod transact; diff --git a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs new file mode 100644 index 00000000000..39130974c38 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/reserve_transfer.rs @@ -0,0 +1,58 @@ +use crate::*; + +#[test] +fn reserve_transfer_native_asset_from_relay_to_assets() { + // Init tests variables + let amount = POLKADOT_ED * 1000; + let relay_sender_balance_before = Westend::account_data_of(WestendSender::get()).free; + let para_receiver_balance_before = + AssetHubWestend::account_data_of(AssetHubWestendReceiver::get()).free; + + let origin = ::RuntimeOrigin::signed(WestendSender::get()); + let assets_para_destination: VersionedMultiLocation = + Westend::child_location_of(AssetHubWestend::para_id()).into(); + let beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: AssetHubWestendReceiver::get().into() }.into(); + let native_assets: VersionedMultiAssets = (Here, amount).into(); + let fee_asset_item = 0; + let weight_limit = WeightLimit::Unlimited; + + // Send XCM message from Relay Chain + Westend::execute_with(|| { + assert_ok!(::XcmPallet::limited_reserve_transfer_assets( + origin, + bx!(assets_para_destination), + bx!(beneficiary), + bx!(native_assets), + fee_asset_item, + weight_limit, + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete(weight) }) => { + weight: weight_within_threshold((REF_TIME_THRESHOLD, PROOF_SIZE_THRESHOLD), Weight::from_parts(731_495_000, 0), *weight), + }, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + // TODO: This used to emit an event at the DmpQueue pallet which is not gone.. does it have a replacement? + assert_expected_events!(AssetHubWestend, vec![]); + }); + + // Check if balances are updated accordingly in Relay Chain and Assets Parachain + let relay_sender_balance_after = Westend::account_data_of(WestendSender::get()).free; + let para_sender_balance_after = + AssetHubWestend::account_data_of(AssetHubWestendReceiver::get()).free; + + assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after); + assert_eq!(para_sender_balance_after, para_receiver_balance_before); +} diff --git a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs new file mode 100644 index 00000000000..f17ea755785 --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/teleport.rs @@ -0,0 +1,62 @@ +use crate::*; + +#[test] +fn teleport_native_assets_from_relay_to_assets_para() { + // Init tests variables + let amount = POLKADOT_ED * 1000; + let relay_sender_balance_before = Westend::account_data_of(WestendSender::get()).free; + let para_receiver_balance_before = + AssetHubWestend::account_data_of(AssetHubWestendReceiver::get()).free; + + let origin = ::RuntimeOrigin::signed(WestendSender::get()); + let assets_para_destination: VersionedMultiLocation = + Westend::child_location_of(AssetHubWestend::para_id()).into(); + let beneficiary: VersionedMultiLocation = + AccountId32 { network: None, id: AssetHubWestendReceiver::get().into() }.into(); + let native_assets: VersionedMultiAssets = (Here, amount).into(); + let fee_asset_item = 0; + let weight_limit = WeightLimit::Unlimited; + + // Send XCM message from Relay Chain + Westend::execute_with(|| { + assert_ok!(::XcmPallet::limited_teleport_assets( + origin, + bx!(assets_para_destination), + bx!(beneficiary), + bx!(native_assets), + fee_asset_item, + weight_limit, + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Attempted { outcome: Outcome::Complete { .. } }) => {}, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubWestend::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubWestend, + vec![ + RuntimeEvent::Balances(pallet_balances::Event::Deposit { who, .. }) => { + who: *who == AssetHubWestendReceiver::get().into(), + }, + ] + ); + }); + + // Check if balances are updated accordingly in Relay Chain and Assets Parachain + let relay_sender_balance_after = Westend::account_data_of(WestendSender::get()).free; + let para_sender_balance_after = + AssetHubWestend::account_data_of(AssetHubWestendReceiver::get()).free; + + assert_eq!(relay_sender_balance_before - amount, relay_sender_balance_after); + assert!(para_sender_balance_after > para_receiver_balance_before); +} diff --git a/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/transact.rs b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/transact.rs new file mode 100644 index 00000000000..3453ea6991f --- /dev/null +++ b/parachains/integration-tests/emulated/assets/asset-hub-westend/src/tests/transact.rs @@ -0,0 +1,58 @@ +use crate::*; + +#[test] +fn transact_sudo_from_relay_to_assets_para() { + // Init tests variables + // Call to be executed in Assets Parachain + const ASSET_ID: u32 = 1; + + let call = ::RuntimeCall::Assets(pallet_assets::Call::< + ::Runtime, + Instance1, + >::force_create { + id: ASSET_ID.into(), + is_sufficient: true, + min_balance: 1000, + owner: AssetHubWestendSender::get().into(), + }) + .encode() + .into(); + + // XcmPallet send arguments + let sudo_origin = ::RuntimeOrigin::root(); + let assets_para_destination: VersionedMultiLocation = + Westend::child_location_of(AssetHubWestend::para_id()).into(); + + let weight_limit = WeightLimit::Unlimited; + let require_weight_at_most = Weight::from_parts(1000000000, 200000); + let origin_kind = OriginKind::Superuser; + let check_origin = None; + + let xcm = VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit, check_origin }, + Transact { require_weight_at_most, origin_kind, call }, + ])); + + // Send XCM message from Relay Chain + Westend::execute_with(|| { + assert_ok!(::XcmPallet::send( + sudo_origin, + bx!(assets_para_destination), + bx!(xcm), + )); + + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + Westend, + vec![ + RuntimeEvent::XcmPallet(pallet_xcm::Event::Sent { .. }) => {}, + ] + ); + }); + + // Receive XCM message in Assets Parachain + AssetHubWestend::execute_with(|| { + assert!(::Assets::asset_exists(ASSET_ID)); + }); +} diff --git a/parachains/integration-tests/emulated/common/Cargo.toml b/parachains/integration-tests/emulated/common/Cargo.toml new file mode 100644 index 00000000000..340ca874993 --- /dev/null +++ b/parachains/integration-tests/emulated/common/Cargo.toml @@ -0,0 +1,59 @@ +[package] +name = "integration-tests-common" +version = "1.0.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Common resources for integration testing with xcm-emulator" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } + +# Substrate +grandpa = { package = "sc-consensus-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" } +sp-authority-discovery = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +sp-consensus-babe = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-assets = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-im-online = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } + +# Polkadot +polkadot-core-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-parachain = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-service = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-primitives = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot", branch = "master" } +kusama-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", branch = "master" } +westend-runtime = { git = "https://github.com/paritytech/polkadot", branch = "master" } +westend-runtime-constants = { git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm-executor = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } +pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "master" } + +# Cumulus +parachains-common = { path = "../../../common" } +parachain-info = { path = "../../../pallets/parachain-info" } +cumulus-primitives-core = { path = "../../../../primitives/core" } +penpal-runtime = { path = "../../../runtimes/testing/penpal" } +asset-hub-polkadot-runtime = { path = "../../../runtimes/assets/asset-hub-polkadot" } +asset-hub-kusama-runtime = { path = "../../../runtimes/assets/asset-hub-kusama" } +asset-hub-westend-runtime = { path = "../../../runtimes/assets/asset-hub-westend" } +collectives-polkadot-runtime = { path = "../../../runtimes/collectives/collectives-polkadot" } +bridge-hub-kusama-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-kusama" } +bridge-hub-polkadot-runtime = { path = "../../../runtimes/bridge-hubs/bridge-hub-polkadot" } +xcm-emulator = { default-features = false, path = "../../../../xcm/xcm-emulator" } + +[features] +runtime-benchmarks = [ + "kusama-runtime/runtime-benchmarks", + "polkadot-runtime/runtime-benchmarks", + "westend-runtime/runtime-benchmarks", +] diff --git a/parachains/integration-tests/emulated/common/src/constants.rs b/parachains/integration-tests/emulated/common/src/constants.rs new file mode 100644 index 00000000000..cd4d321457e --- /dev/null +++ b/parachains/integration-tests/emulated/common/src/constants.rs @@ -0,0 +1,797 @@ +use grandpa::AuthorityId as GrandpaId; +use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber}; +use polkadot_primitives::{AssignmentId, ValidatorId}; +pub use polkadot_runtime_parachains::configuration::HostConfiguration; +use polkadot_service::chain_spec::get_authority_keys_from_seed_no_beefy; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::AuthorityId as BabeId; +use sp_core::{sr25519, storage::Storage, Pair, Public}; +use sp_runtime::{ + traits::{IdentifyAccount, Verify}, + BuildStorage, MultiSignature, Perbill, +}; +pub use xcm; + +pub const XCM_V2: u32 = 3; +pub const XCM_V3: u32 = 2; +pub const REF_TIME_THRESHOLD: u64 = 33; +pub const PROOF_SIZE_THRESHOLD: u64 = 33; + +type AccountPublic = ::Signer; + +/// Helper function to generate a crypto pair from seed +fn get_from_seed(seed: &str) -> ::Public { + TPublic::Pair::from_string(&format!("//{}", seed), None) + .expect("static values are valid; qed") + .public() +} + +/// Helper function to generate an account ID from seed. +fn get_account_id_from_seed(seed: &str) -> AccountId +where + AccountPublic: From<::Public>, +{ + AccountPublic::from(get_from_seed::(seed)).into_account() +} + +pub mod accounts { + use super::*; + pub const ALICE: &str = "Alice"; + pub const BOB: &str = "Bob"; + pub const CHARLIE: &str = "Charlie"; + pub const DAVE: &str = "Dave"; + pub const EVE: &str = "Eve"; + pub const FERDIE: &str = "Ferdei"; + pub const ALICE_STASH: &str = "Alice//stash"; + pub const BOB_STASH: &str = "Bob//stash"; + pub const CHARLIE_STASH: &str = "Charlie//stash"; + pub const DAVE_STASH: &str = "Dave//stash"; + pub const EVE_STASH: &str = "Eve//stash"; + pub const FERDIE_STASH: &str = "Ferdie//stash"; + + pub fn init_balances() -> Vec { + vec![ + get_account_id_from_seed::(ALICE), + get_account_id_from_seed::(BOB), + get_account_id_from_seed::(CHARLIE), + get_account_id_from_seed::(DAVE), + get_account_id_from_seed::(EVE), + get_account_id_from_seed::(FERDIE), + get_account_id_from_seed::(ALICE_STASH), + get_account_id_from_seed::(BOB_STASH), + get_account_id_from_seed::(CHARLIE_STASH), + get_account_id_from_seed::(DAVE_STASH), + get_account_id_from_seed::(EVE_STASH), + get_account_id_from_seed::(FERDIE_STASH), + ] + } +} + +pub mod collators { + use super::*; + + pub fn invulnerables_asset_hub_polkadot() -> Vec<(AccountId, AssetHubPolkadotAuraId)> { + vec![ + ( + get_account_id_from_seed::("Alice"), + get_from_seed::("Alice"), + ), + ( + get_account_id_from_seed::("Bob"), + get_from_seed::("Bob"), + ), + ] + } + + pub fn invulnerables() -> Vec<(AccountId, AuraId)> { + vec![ + ( + get_account_id_from_seed::("Alice"), + get_from_seed::("Alice"), + ), + (get_account_id_from_seed::("Bob"), get_from_seed::("Bob")), + ] + } +} + +pub mod validators { + use super::*; + + pub fn initial_authorities() -> Vec<( + AccountId, + AccountId, + BabeId, + GrandpaId, + ImOnlineId, + ValidatorId, + AssignmentId, + AuthorityDiscoveryId, + )> { + vec![get_authority_keys_from_seed_no_beefy("Alice")] + } +} + +/// The default XCM version to set in genesis config. +const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; +// Polkadot +pub mod polkadot { + use super::*; + pub const ED: Balance = polkadot_runtime_constants::currency::EXISTENTIAL_DEPOSIT; + const STASH: u128 = 100 * polkadot_runtime_constants::currency::UNITS; + + pub fn get_host_config() -> HostConfiguration { + HostConfiguration { + max_upward_queue_count: 10, + max_upward_queue_size: 51200, + max_upward_message_size: 51200, + max_upward_message_num_per_candidate: 10, + max_downward_message_size: 51200, + ..Default::default() + } + } + + fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + im_online: ImOnlineId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + ) -> polkadot_runtime::SessionKeys { + polkadot_runtime::SessionKeys { + babe, + grandpa, + im_online, + para_validator, + para_assignment, + authority_discovery, + } + } + + pub fn genesis() -> Storage { + let genesis_config = polkadot_runtime::GenesisConfig { + system: polkadot_runtime::SystemConfig { + code: polkadot_runtime::WASM_BINARY.unwrap().to_vec(), + }, + balances: polkadot_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + session: polkadot_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + polkadot::session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + x.7.clone(), + ), + ) + }) + .collect::>(), + }, + staking: polkadot_runtime::StakingConfig { + validator_count: validators::initial_authorities().len() as u32, + minimum_validator_count: 1, + stakers: validators::initial_authorities() + .iter() + .map(|x| { + (x.0.clone(), x.1.clone(), STASH, polkadot_runtime::StakerStatus::Validator) + }) + .collect(), + invulnerables: validators::initial_authorities() + .iter() + .map(|x| x.0.clone()) + .collect(), + force_era: pallet_staking::Forcing::ForceNone, + slash_reward_fraction: Perbill::from_percent(10), + ..Default::default() + }, + babe: polkadot_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: Some(polkadot_runtime::BABE_GENESIS_EPOCH_CONFIG), + }, + configuration: polkadot_runtime::ConfigurationConfig { config: get_host_config() }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} + +pub mod westend { + use super::*; + use westend_runtime_constants::currency::UNITS as WND; + pub const ED: Balance = westend_runtime_constants::currency::EXISTENTIAL_DEPOSIT; + const ENDOWMENT: u128 = 1_000_000 * WND; + const STASH: u128 = 100 * WND; + + pub fn get_host_config() -> HostConfiguration { + HostConfiguration { + max_upward_queue_count: 10, + max_upward_queue_size: 51200, + max_upward_message_size: 51200, + max_upward_message_num_per_candidate: 10, + max_downward_message_size: 51200, + ..Default::default() + } + } + + fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + im_online: ImOnlineId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + ) -> westend_runtime::SessionKeys { + westend_runtime::SessionKeys { + babe, + grandpa, + im_online, + para_validator, + para_assignment, + authority_discovery, + } + } + + pub fn genesis() -> Storage { + let genesis_config = westend_runtime::GenesisConfig { + system: westend_runtime::SystemConfig { + code: westend_runtime::WASM_BINARY.unwrap().to_vec(), + }, + balances: westend_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ENDOWMENT)) + .collect(), + }, + session: westend_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + westend::session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + x.7.clone(), + ), + ) + }) + .collect::>(), + }, + staking: westend_runtime::StakingConfig { + validator_count: validators::initial_authorities().len() as u32, + minimum_validator_count: 1, + stakers: validators::initial_authorities() + .iter() + .map(|x| { + (x.0.clone(), x.1.clone(), STASH, westend_runtime::StakerStatus::Validator) + }) + .collect(), + invulnerables: validators::initial_authorities() + .iter() + .map(|x| x.0.clone()) + .collect(), + force_era: pallet_staking::Forcing::ForceNone, + slash_reward_fraction: Perbill::from_percent(10), + ..Default::default() + }, + babe: westend_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: Some(westend_runtime::BABE_GENESIS_EPOCH_CONFIG), + }, + configuration: westend_runtime::ConfigurationConfig { config: get_host_config() }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} + +// Kusama +pub mod kusama { + use super::*; + pub const ED: Balance = kusama_runtime_constants::currency::EXISTENTIAL_DEPOSIT; + use kusama_runtime_constants::currency::UNITS as KSM; + const ENDOWMENT: u128 = 1_000_000 * KSM; + const STASH: u128 = 100 * KSM; + + pub fn get_host_config() -> HostConfiguration { + HostConfiguration { + max_upward_queue_count: 10, + max_upward_queue_size: 51200, + max_upward_message_size: 51200, + max_upward_message_num_per_candidate: 10, + max_downward_message_size: 51200, + ..Default::default() + } + } + + fn session_keys( + babe: BabeId, + grandpa: GrandpaId, + im_online: ImOnlineId, + para_validator: ValidatorId, + para_assignment: AssignmentId, + authority_discovery: AuthorityDiscoveryId, + ) -> kusama_runtime::SessionKeys { + kusama_runtime::SessionKeys { + babe, + grandpa, + im_online, + para_validator, + para_assignment, + authority_discovery, + } + } + + pub fn genesis() -> Storage { + let genesis_config = kusama_runtime::GenesisConfig { + system: kusama_runtime::SystemConfig { + code: kusama_runtime::WASM_BINARY.unwrap().to_vec(), + }, + balances: kusama_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .map(|k: &AccountId| (k.clone(), ENDOWMENT)) + .collect(), + }, + session: kusama_runtime::SessionConfig { + keys: validators::initial_authorities() + .iter() + .map(|x| { + ( + x.0.clone(), + x.0.clone(), + kusama::session_keys( + x.2.clone(), + x.3.clone(), + x.4.clone(), + x.5.clone(), + x.6.clone(), + x.7.clone(), + ), + ) + }) + .collect::>(), + }, + staking: kusama_runtime::StakingConfig { + validator_count: validators::initial_authorities().len() as u32, + minimum_validator_count: 1, + stakers: validators::initial_authorities() + .iter() + .map(|x| { + (x.0.clone(), x.1.clone(), STASH, kusama_runtime::StakerStatus::Validator) + }) + .collect(), + invulnerables: validators::initial_authorities() + .iter() + .map(|x| x.0.clone()) + .collect(), + force_era: pallet_staking::Forcing::NotForcing, + slash_reward_fraction: Perbill::from_percent(10), + ..Default::default() + }, + babe: kusama_runtime::BabeConfig { + authorities: Default::default(), + epoch_config: Some(kusama_runtime::BABE_GENESIS_EPOCH_CONFIG), + }, + configuration: kusama_runtime::ConfigurationConfig { config: get_host_config() }, + ..Default::default() + }; + + genesis_config.build_storage().unwrap() + } +} + +// Asset Hub Polkadot +pub mod asset_hub_polkadot { + use super::*; + pub const PARA_ID: u32 = 1000; + pub const ED: Balance = asset_hub_polkadot_runtime::constants::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = asset_hub_polkadot_runtime::GenesisConfig { + system: asset_hub_polkadot_runtime::SystemConfig { + code: asset_hub_polkadot_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + balances: asset_hub_polkadot_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: asset_hub_polkadot_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + }, + collator_selection: asset_hub_polkadot_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables_asset_hub_polkadot() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: asset_hub_polkadot_runtime::SessionConfig { + keys: collators::invulnerables_asset_hub_polkadot() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + asset_hub_polkadot_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + polkadot_xcm: asset_hub_polkadot_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + }; + + genesis_config.build_storage().unwrap() + } +} + +// Asset Hub Westend +pub mod asset_hub_westend { + use super::*; + pub const PARA_ID: u32 = 1000; + pub const ED: Balance = asset_hub_westend_runtime::constants::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = asset_hub_westend_runtime::GenesisConfig { + system: asset_hub_westend_runtime::SystemConfig { + code: asset_hub_westend_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + balances: asset_hub_westend_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: asset_hub_westend_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + }, + collator_selection: asset_hub_westend_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: asset_hub_westend_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + asset_hub_westend_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + polkadot_xcm: asset_hub_westend_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + }; + + genesis_config.build_storage().unwrap() + } +} + +// Asset Hub Kusama +pub mod asset_hub_kusama { + use super::*; + pub const PARA_ID: u32 = 1000; + pub const ED: Balance = asset_hub_kusama_runtime::constants::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = asset_hub_kusama_runtime::GenesisConfig { + system: asset_hub_kusama_runtime::SystemConfig { + code: asset_hub_kusama_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + balances: asset_hub_kusama_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: asset_hub_kusama_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + }, + collator_selection: asset_hub_kusama_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: asset_hub_kusama_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + asset_hub_kusama_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + polkadot_xcm: asset_hub_kusama_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + }; + + genesis_config.build_storage().unwrap() + } +} + +// Penpal +pub mod penpal { + use super::*; + pub const PARA_ID: u32 = 2000; + pub const ED: Balance = penpal_runtime::EXISTENTIAL_DEPOSIT; + + pub fn genesis(para_id: u32) -> Storage { + let genesis_config = penpal_runtime::GenesisConfig { + system: penpal_runtime::SystemConfig { + code: penpal_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + balances: penpal_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: penpal_runtime::ParachainInfoConfig { parachain_id: para_id.into() }, + collator_selection: penpal_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: penpal_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + penpal_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + polkadot_xcm: penpal_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + sudo: penpal_runtime::SudoConfig { + key: Some(get_account_id_from_seed::("Alice")), + }, + }; + + genesis_config.build_storage().unwrap() + } +} + +// Collectives +pub mod collectives { + use super::*; + pub const PARA_ID: u32 = 1001; + pub const ED: Balance = collectives_polkadot_runtime::constants::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = collectives_polkadot_runtime::GenesisConfig { + system: collectives_polkadot_runtime::SystemConfig { + code: collectives_polkadot_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + balances: collectives_polkadot_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: collectives_polkadot_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + }, + collator_selection: collectives_polkadot_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: collectives_polkadot_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + collectives_polkadot_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + // no need to pass anything to aura, in fact it will panic if we do. Session will take care + // of this. + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + polkadot_xcm: collectives_polkadot_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + alliance: Default::default(), + alliance_motion: Default::default(), + }; + + genesis_config.build_storage().unwrap() + } +} + +pub mod bridge_hub_kusama { + use super::*; + pub const PARA_ID: u32 = 1002; + pub const ED: Balance = bridge_hub_kusama_runtime::constants::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = bridge_hub_kusama_runtime::GenesisConfig { + system: bridge_hub_kusama_runtime::SystemConfig { + code: bridge_hub_kusama_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + balances: bridge_hub_kusama_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: bridge_hub_kusama_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + }, + collator_selection: bridge_hub_kusama_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: bridge_hub_kusama_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + bridge_hub_kusama_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + polkadot_xcm: bridge_hub_kusama_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + }; + + genesis_config.build_storage().unwrap() + } +} + +pub mod bridge_hub_polkadot { + use super::*; + pub const PARA_ID: u32 = 1002; + pub const ED: Balance = bridge_hub_polkadot_runtime::constants::currency::EXISTENTIAL_DEPOSIT; + + pub fn genesis() -> Storage { + let genesis_config = bridge_hub_polkadot_runtime::GenesisConfig { + system: bridge_hub_polkadot_runtime::SystemConfig { + code: bridge_hub_polkadot_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + balances: bridge_hub_polkadot_runtime::BalancesConfig { + balances: accounts::init_balances() + .iter() + .cloned() + .map(|k| (k, ED * 4096)) + .collect(), + }, + parachain_info: bridge_hub_polkadot_runtime::ParachainInfoConfig { + parachain_id: PARA_ID.into(), + }, + collator_selection: bridge_hub_polkadot_runtime::CollatorSelectionConfig { + invulnerables: collators::invulnerables() + .iter() + .cloned() + .map(|(acc, _)| acc) + .collect(), + candidacy_bond: ED * 16, + ..Default::default() + }, + session: bridge_hub_polkadot_runtime::SessionConfig { + keys: collators::invulnerables() + .into_iter() + .map(|(acc, aura)| { + ( + acc.clone(), // account id + acc, // validator id + bridge_hub_polkadot_runtime::SessionKeys { aura }, // session keys + ) + }) + .collect(), + }, + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + polkadot_xcm: bridge_hub_polkadot_runtime::PolkadotXcmConfig { + safe_xcm_version: Some(SAFE_XCM_VERSION), + }, + }; + + genesis_config.build_storage().unwrap() + } +} diff --git a/parachains/integration-tests/emulated/common/src/lib.rs b/parachains/integration-tests/emulated/common/src/lib.rs new file mode 100644 index 00000000000..c053710b3d9 --- /dev/null +++ b/parachains/integration-tests/emulated/common/src/lib.rs @@ -0,0 +1,329 @@ +pub mod constants; + +pub use constants::{ + accounts::{ALICE, BOB}, + asset_hub_kusama, asset_hub_polkadot, asset_hub_westend, bridge_hub_kusama, + bridge_hub_polkadot, collectives, kusama, penpal, polkadot, westend, +}; +use frame_support::{parameter_types, sp_io, sp_tracing}; +pub use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance, BlockNumber}; +pub use sp_core::{sr25519, storage::Storage, Get}; +use xcm::prelude::*; +use xcm_emulator::{ + decl_test_networks, decl_test_parachains, decl_test_relay_chains, Parachain, RelayChain, + TestExt, +}; +use xcm_executor::traits::Convert; + +decl_test_relay_chains! { + #[api_version(5)] + pub struct Westend { + genesis = westend::genesis(), + on_init = (), + runtime = { + Runtime: westend_runtime::Runtime, + RuntimeOrigin: westend_runtime::RuntimeOrigin, + RuntimeCall: westend_runtime::RuntimeCall, + RuntimeEvent: westend_runtime::RuntimeEvent, + MessageQueue: westend_runtime::MessageQueue, + XcmConfig: westend_runtime::xcm_config::XcmConfig, + SovereignAccountOf: westend_runtime::xcm_config::LocationConverter, //TODO: rename to SovereignAccountOf, + System: westend_runtime::System, + Balances: westend_runtime::Balances, + }, + pallets_extra = { + XcmPallet: westend_runtime::XcmPallet, + Sudo: westend_runtime::Sudo, + } + }, + #[api_version(4)] + 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(4)] + pub struct Kusama { + genesis = kusama::genesis(), + on_init = (), + runtime = { + Runtime: kusama_runtime::Runtime, + RuntimeOrigin: kusama_runtime::RuntimeOrigin, + RuntimeCall: kusama_runtime::RuntimeCall, + RuntimeEvent: kusama_runtime::RuntimeEvent, + MessageQueue: kusama_runtime::MessageQueue, + XcmConfig: kusama_runtime::xcm_config::XcmConfig, + SovereignAccountOf: kusama_runtime::xcm_config::SovereignAccountOf, + System: kusama_runtime::System, + Balances: kusama_runtime::Balances, + }, + pallets_extra = { + XcmPallet: kusama_runtime::XcmPallet, + } + } +} + +decl_test_parachains! { + // Westend + pub struct AssetHubWestend { + genesis = asset_hub_westend::genesis(), + on_init = (), + runtime = { + Runtime: asset_hub_westend_runtime::Runtime, + RuntimeOrigin: asset_hub_westend_runtime::RuntimeOrigin, + RuntimeCall: asset_hub_westend_runtime::RuntimeCall, + RuntimeEvent: asset_hub_westend_runtime::RuntimeEvent, + XcmpMessageHandler: asset_hub_westend_runtime::XcmpQueue, + LocationToAccountId: asset_hub_westend_runtime::xcm_config::LocationToAccountId, + System: asset_hub_westend_runtime::System, + Balances: asset_hub_westend_runtime::Balances, + ParachainSystem: asset_hub_westend_runtime::ParachainSystem, + ParachainInfo: asset_hub_westend_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: asset_hub_westend_runtime::PolkadotXcm, + Assets: asset_hub_westend_runtime::Assets, + ForeignAssets: asset_hub_westend_runtime::ForeignAssets, + } + }, + // Polkadot + 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, + 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 PenpalPolkadot { + genesis = penpal::genesis(penpal::PARA_ID), + on_init = (), + runtime = { + Runtime: penpal_runtime::Runtime, + RuntimeOrigin: penpal_runtime::RuntimeOrigin, + RuntimeCall: penpal_runtime::RuntimeCall, + RuntimeEvent: penpal_runtime::RuntimeEvent, + XcmpMessageHandler: penpal_runtime::XcmpQueue, + LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId, + System: penpal_runtime::System, + Balances: penpal_runtime::Balances, + ParachainSystem: penpal_runtime::ParachainSystem, + ParachainInfo: penpal_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: penpal_runtime::PolkadotXcm, + Assets: penpal_runtime::Assets, + } + }, + pub struct PenpalWestend { + genesis = penpal::genesis(penpal::PARA_ID), + on_init = (), + runtime = { + Runtime: asset_hub_westend_runtime::Runtime, + RuntimeOrigin: asset_hub_westend_runtime::RuntimeOrigin, + RuntimeCall: asset_hub_westend_runtime::RuntimeCall, + RuntimeEvent: asset_hub_westend_runtime::RuntimeEvent, + XcmpMessageHandler: asset_hub_westend_runtime::XcmpQueue, + LocationToAccountId: asset_hub_westend_runtime::xcm_config::LocationToAccountId, + System: asset_hub_westend_runtime::System, + Balances: asset_hub_westend_runtime::Balances, + ParachainSystem: asset_hub_westend_runtime::ParachainSystem, + ParachainInfo: asset_hub_westend_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: penpal_runtime::PolkadotXcm, + Assets: penpal_runtime::Assets, + } + }, + + // Kusama + pub struct AssetHubKusama { + genesis = asset_hub_kusama::genesis(), + on_init = (), + runtime = { + Runtime: asset_hub_kusama_runtime::Runtime, + RuntimeOrigin: asset_hub_kusama_runtime::RuntimeOrigin, + RuntimeCall: asset_hub_kusama_runtime::RuntimeCall, + RuntimeEvent: asset_hub_kusama_runtime::RuntimeEvent, + XcmpMessageHandler: asset_hub_kusama_runtime::XcmpQueue, + LocationToAccountId: asset_hub_kusama_runtime::xcm_config::LocationToAccountId, + System: asset_hub_kusama_runtime::System, + Balances: asset_hub_kusama_runtime::Balances, + ParachainSystem: asset_hub_kusama_runtime::ParachainSystem, + ParachainInfo: asset_hub_kusama_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm, + Assets: asset_hub_kusama_runtime::Assets, + ForeignAssets: asset_hub_kusama_runtime::Assets, + } + }, + pub struct PenpalKusama { + genesis = penpal::genesis(penpal::PARA_ID), + on_init = (), + runtime = { + Runtime: penpal_runtime::Runtime, + RuntimeOrigin: penpal_runtime::RuntimeOrigin, + RuntimeCall: penpal_runtime::RuntimeCall, + RuntimeEvent: penpal_runtime::RuntimeEvent, + XcmpMessageHandler: penpal_runtime::XcmpQueue, + LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId, + System: penpal_runtime::System, + Balances: penpal_runtime::Balances, + ParachainSystem: penpal_runtime::ParachainSystem, + ParachainInfo: penpal_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: penpal_runtime::PolkadotXcm, + Assets: penpal_runtime::Assets, + } + }, + pub struct Collectives { + genesis = collectives::genesis(), + on_init = (), + runtime = { + Runtime: collectives_polkadot_runtime::Runtime, + RuntimeOrigin: collectives_polkadot_runtime::RuntimeOrigin, + RuntimeCall: collectives_polkadot_runtime::RuntimeCall, + RuntimeEvent: collectives_polkadot_runtime::RuntimeEvent, + XcmpMessageHandler: collectives_polkadot_runtime::XcmpQueue, + LocationToAccountId: collectives_polkadot_runtime::xcm_config::LocationToAccountId, + System: collectives_polkadot_runtime::System, + Balances: collectives_polkadot_runtime::Balances, + ParachainSystem: collectives_polkadot_runtime::ParachainSystem, + ParachainInfo: collectives_polkadot_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: collectives_polkadot_runtime::PolkadotXcm, + } + }, + pub struct BHKusama { + genesis = bridge_hub_kusama::genesis(), + on_init = (), + runtime = { + Runtime: bridge_hub_kusama_runtime::Runtime, + RuntimeOrigin: bridge_hub_kusama_runtime::RuntimeOrigin, + RuntimeCall: bridge_hub_kusama_runtime::RuntimeCall, + RuntimeEvent: bridge_hub_kusama_runtime::RuntimeEvent, + XcmpMessageHandler: bridge_hub_kusama_runtime::XcmpQueue, + LocationToAccountId: bridge_hub_kusama_runtime::xcm_config::LocationToAccountId, + System: bridge_hub_kusama_runtime::System, + Balances: bridge_hub_kusama_runtime::Balances, + ParachainSystem: bridge_hub_kusama_runtime::ParachainSystem, + ParachainInfo:bridge_hub_kusama_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: bridge_hub_kusama_runtime::PolkadotXcm, + } + }, + pub struct BHPolkadot { + genesis = bridge_hub_polkadot::genesis(), + on_init = (), + runtime = { + Runtime: bridge_hub_polkadot_runtime::Runtime, + RuntimeOrigin: bridge_hub_polkadot_runtime::RuntimeOrigin, + RuntimeCall: bridge_hub_polkadot_runtime::RuntimeCall, + RuntimeEvent: bridge_hub_polkadot_runtime::RuntimeEvent, + XcmpMessageHandler: bridge_hub_polkadot_runtime::XcmpQueue, + LocationToAccountId: bridge_hub_polkadot_runtime::xcm_config::LocationToAccountId, + System: bridge_hub_polkadot_runtime::System, + Balances: bridge_hub_polkadot_runtime::Balances, + ParachainSystem: bridge_hub_polkadot_runtime::ParachainSystem, + ParachainInfo:bridge_hub_polkadot_runtime::ParachainInfo, + }, + pallets_extra = { + PolkadotXcm: bridge_hub_polkadot_runtime::PolkadotXcm, + } + } +} + +decl_test_networks! { + pub struct PolkadotMockNet { + relay_chain = Polkadot, + parachains = vec![ + AssetHubPolkadot, + PenpalPolkadot, + Collectives, + BHPolkadot, + ], + }, + pub struct KusamaMockNet { + relay_chain = Kusama, + parachains = vec![ + AssetHubKusama, + PenpalKusama, + BHKusama, + ], + }, + pub struct WestendMockNet { + relay_chain = Westend, + parachains = vec![ + AssetHubWestend, + PenpalWestend, + ], + } +} + +parameter_types! { + // Polkadot + pub PolkadotSender: AccountId = Polkadot::account_id_of(ALICE); + pub PolkadotReceiver: AccountId = Polkadot::account_id_of(BOB); + // Kusama + pub KusamaSender: AccountId = Kusama::account_id_of(ALICE); + pub KusamaReceiver: AccountId = Kusama::account_id_of(BOB); + // Westend + pub WestendSender: AccountId = Westend::account_id_of(ALICE); + pub WestendReceiver: AccountId = Westend::account_id_of(BOB); + // Asset Hub Westend + pub AssetHubWestendSender: AccountId = AssetHubWestend::account_id_of(ALICE); + pub AssetHubWestendReceiver: AccountId = AssetHubWestend::account_id_of(BOB); + // Asset Hub Polkadot + pub AssetHubPolkadotSender: AccountId = AssetHubPolkadot::account_id_of(ALICE); + pub AssetHubPolkadotReceiver: AccountId = AssetHubPolkadot::account_id_of(BOB); + // Asset Hub Kusama + pub AssetHubKusamaSender: AccountId = AssetHubKusama::account_id_of(ALICE); + pub AssetHubKusamaReceiver: AccountId = AssetHubKusama::account_id_of(BOB); + // Penpal Polkadot + pub PenpalPolkadotSender: AccountId = PenpalPolkadot::account_id_of(ALICE); + pub PenpalPolkadotReceiver: AccountId = PenpalPolkadot::account_id_of(BOB); + // Penpal Kusama + pub PenpalKusamaSender: AccountId = PenpalKusama::account_id_of(ALICE); + pub PenpalKusamaReceiver: AccountId = PenpalKusama::account_id_of(BOB); + // Penpal Westend + pub PenpalWestendSender: AccountId = PenpalWestend::account_id_of(ALICE); + pub PenpalWestendReceiver: AccountId = PenpalWestend::account_id_of(BOB); + // Collectives + pub CollectivesSender: AccountId = Collectives::account_id_of(ALICE); + pub CollectivesReceiver: AccountId = Collectives::account_id_of(BOB); + // Bridge Hub Polkadot + pub BHPolkadotSender: AccountId = BHPolkadot::account_id_of(ALICE); + pub BHPolkadotReceiver: AccountId = BHPolkadot::account_id_of(BOB); + // Bridge Hub Kusama + pub BHKusamaSender: AccountId = BHKusama::account_id_of(ALICE); + pub BHKusamaReceiver: AccountId = BHKusama::account_id_of(BOB); +} diff --git a/parachains/integration-tests/statemine/config.toml b/parachains/integration-tests/statemine/config.toml deleted file mode 100644 index 510f3cd3b04..00000000000 --- a/parachains/integration-tests/statemine/config.toml +++ /dev/null @@ -1,49 +0,0 @@ -[relaychain] -default_command = "./bin/polkadot" -default_args = [ "-lparachain=debug" ] -chain = "kusama-local" - - [[relaychain.nodes]] - name = "alice" - ws_port = 9900 - validator = true - - [[relaychain.nodes]] - name = "bob" - validator = true - - [[relaychain.nodes]] - name = "charlie" - validator = true - - [[relaychain.nodes]] - name = "dave" - validator = true - -[[parachains]] -id = 1000 -chain = "statemine-local" -cumulus_based = true - - [[parachains.collators]] - name = "collator1" - ws_port = 9910 - command = "./bin/polkadot-parachain" - - [[parachains.collators]] - name = "collator2" - command = "./bin/polkadot-parachain" - -[[parachains]] -id = 2000 -chain = "penpal-kusama-2000" -cumulus_based = true - - [[parachains.collators]] - name = "collator3" - ws_port = 9920 - command = "./bin/polkadot-parachain" - - [[parachains.collators]] - name = "collator4" - command = "./bin/polkadot-parachain" diff --git a/parachains/integration-tests/statemine/xcm/3_hrmp-open-channels.yml b/parachains/integration-tests/statemine/xcm/3_hrmp-open-channels.yml deleted file mode 100644 index 45bf89e2b05..00000000000 --- a/parachains/integration-tests/statemine/xcm/3_hrmp-open-channels.yml +++ /dev/null @@ -1,408 +0,0 @@ ---- -settings: - chains: - relay_chain: &relay_chain - wsPort: 9900 - assets_parachain: &assets_parachain - wsPort: 9910 - paraId: &ap_id 1000 - penpal_parachain: &penpal_parachain - wsPort: 9920 - paraId: &pp_id 2000 - variables: - common: - amount: &amount 2000000000000 - require_weight_at_most: &weight_at_most 1000000000 - hrmp_channels: - proposed_max_capacity: &max_capacity 8 - proposed_max_message_size: &max_message_size 8192 - channel: &channel { - maxCapacity: 8, - maxTotalSize: 8192, - maxMessageSize: 8192, - msgCount: 0, - totalSize: 0, - mqcHead: null, - senderDeposit: 0, - recipientDeposit: 0 - } - chains: - relay_chain: - signer: &rc_signer //Alice - assets_parachain_destination: &ap_dest { v1: { 0, interior: { x1: { parachain: *ap_id }}}} - assets_parachain_account: &ap_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' - assets_parachain_beneficiary: &ap_benf {v1: { parents: 0, interior: { x1: { accountId32: { network: { any: true }, id: *ap_acc }}}}} - ksm: &rc_ksm { concrete: { 0, interior: { here: true }}} - ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }} - assets_parachain_account: - sovereign_account: &ap_sovereign F7fq1jSNVTPfJmaHaXCMtatT1EZefCUsa7rRiQVNR5efcah - relay_chain_destination: &rc_dest { v1: { parents: 1, interior: { here: true }}} - penpal_parachain: - sovereign_account: &pp_sovereign F7fq1jMZkfuCuoMTyiEVAP2DMpMt18WopgBqTJznLihLNbZ - signer: &pp_signer //Alice - decodedCalls: - init_open_channel_with_ap: - chain: *relay_chain - pallet: hrmp - call: hrmpInitOpenChannel - args: [ - *ap_id, # recipient - *max_capacity, # proposedMaxCapacity - *max_message_size # proposedMaxMessageSize - ] - init_open_channel_with_cp: - chain: *relay_chain - pallet: hrmp - call: hrmpInitOpenChannel - args: [ - *pp_id, # recipient - *max_capacity, # proposedMaxCapacity - *max_message_size # proposedMaxMessageSize - ] - accept_open_channel_with_ap: - chain: *relay_chain - pallet: hrmp - call: hrmpAcceptOpenChannel - args: [ - *ap_id, # recipient - ] - accept_init_open_request_from_cp: - chain: *relay_chain - pallet: hrmp - call: hrmpAcceptOpenChannel - args: [ - *pp_id, # sender - ] - xcm_accept_init_open_request_from_cp: - chain: *assets_parachain - pallet: polkadotXcm - call: send - args: [ - *rc_dest, # destination - { - v2: [ #message - { - WithdrawAsset: [*rc_ksm_fungible] - }, - { - BuyExecution: { - fees: *rc_ksm_fungible, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: Native, - requireWeightAtMost: *weight_at_most, - call: $accept_init_open_request_from_cp - } - } - ] - } - ] - xcm_init_open_channel_with_cp: - chain: *assets_parachain - pallet: polkadotXcm - call: send - args: [ - *rc_dest, # destination - { - v2: [ #message - { - WithdrawAsset: [*rc_ksm_fungible] - }, - { - BuyExecution: { - fees: *rc_ksm_fungible, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: Native, - requireWeightAtMost: *weight_at_most, - call: $init_open_channel_with_cp - } - } - ] - } - ] - -tests: - - name: HRMP - beforeEach: - - name: DEPENDANCY | Penpal Parachain Sovereign account in the Relay Chain needs to be funded - actions: - - extrinsics: - - chain: *relay_chain - signer: *rc_signer - pallet: balances - call: transfer - args: [ - *pp_sovereign, # destination - *amount, # value - ] - events: - - name: balances.Transfer - - - name: DEPENDANCY | Assets Parachain Sovereign account in the Relay Chain needs to be funded - actions: - - extrinsics: - - chain: *relay_chain - signer: *rc_signer - pallet: balances - call: transfer - args: [ - *ap_sovereign, # destination - *amount, # value - ] - events: - - name: balances.Transfer - describes: - - name: hrmp.hrmpInitOpenChannel (Penpal Parachain → Assets Parachain) - its: - - name: Penpal Parachain sends a request to the Relay Chain to open a channel with the Assets Parchain - actions: - - extrinsics: - - chain: *penpal_parachain - signer: *pp_signer - sudo: true - pallet: polkadotXcm - call: send - args: [ - *rc_dest, # destination - { - v2: [ #message - { - WithdrawAsset: [*rc_ksm_fungible] - }, - { - BuyExecution: { - fees: *rc_ksm_fungible, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: Native, - requireWeightAtMost: *weight_at_most, - call: $init_open_channel_with_ap - } - } - ] - } - ] - events: - - name: sudo.Sudid - attribute: - type: Result - value: Ok - - name: polkadotXcm.Sent - - name: ump.ExecutedUpward - chain: *relay_chain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,160,892,000 - - name: hrmp.OpenChannelRequested - chain: *relay_chain - - queries: - requested_channels: - chain: *relay_chain - pallet: hrmp - call: hrmpOpenChannelRequestsList - args: [] - - asserts: - equal: - args: [ - $requested_channels, - [ - { - sender: *pp_id, - recipient: *ap_id - } - ] - ] - - - name: hrmp.hrmpAcceptOpenChannel (Assets Parachain → Penpal Parachain) - its: - - name: Assets Parachain sends a response to the Relay Chain accepting the Penpal Parachain's request for openning a HRMP channel - actions: - - extrinsics: - - chain: *relay_chain - signer: *rc_signer - sudo: true - pallet: xcmPallet - call: send - args: [ - *ap_dest, # destination - { - v2: [ #message - { - Transact: { - originType: Superuser, - requireWeightAtMost: *weight_at_most, - call: $xcm_accept_init_open_request_from_cp - } - } - ] - } - ] - events: - - name: sudo.Sudid - attribute: - type: Result - value: Ok - - name: xcmPallet.Sent - - name: dmpQueue.ExecutedDownward - chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,021,258,000 - - name: polkadotXcm.Sent - chain: *assets_parachain - - name: ump.ExecutedUpward - timeout: 40000 - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,160,892,000 - - name: hrmp.OpenChannelAccepted - timeout: 40000 - - queries: - open_channels: - chain: *relay_chain - pallet: hrmp - call: hrmpChannels - delay: 80000 - args: [ - { - sender: *pp_id, - recipient: *ap_id - } - ] - - asserts: - equal: - args: [ - $open_channels, - *channel - ] - - - name: hrmp.hrmpInitOpenChannel (Assets Parachain → Penpal Parachain) - its: - - name: Assets Parchain sends a request to the Relay Chain to open a channel with a Penpal Parachain - actions: - - extrinsics: - - chain: *relay_chain - signer: *rc_signer - sudo: true - pallet: xcmPallet - call: send - args: [ - *ap_dest, # destination - { - v2: [ #message - { - Transact: { - originType: Superuser, - requireWeightAtMost: *weight_at_most, - call: $xcm_init_open_channel_with_cp - } - } - ] - } - ] - events: - - name: sudo.Sudid - attribute: - type: Result - value: Ok - - name: xcmPallet.Sent - - name: dmpQueue.ExecutedDownward - chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,021,258,000 - - name: polkadotXcm.Sent - chain: *assets_parachain - - name: ump.ExecutedUpward - timeout: 40000 - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,160,892,000 - - name: hrmp.OpenChannelRequested - timeout: 40000 - - queries: - requested_channels: - chain: *relay_chain - pallet: hrmp - call: hrmpOpenChannelRequestsList - args: [] - - asserts: - equal: - args: [ - $requested_channels, - [ - { - sender: *ap_id, - recipient: *pp_id - } - ] - ] - - - name: hrmp.hrmpAcceptOpenChannel (Penpal Parachain → Assets Parachain) - its: - - name: Penpal Parachain sends a response to the Relay Chain accepting the Assets Parachain's request for openning a HRMP channel - actions: - - extrinsics: - - chain: *penpal_parachain - signer: *pp_signer - sudo: true - pallet: polkadotXcm - call: send - args: [ - *rc_dest, # destination - { - v2: [ #message - { - WithdrawAsset: [*rc_ksm_fungible] - }, - { - BuyExecution: { - fees: *rc_ksm_fungible, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: Native, - requireWeightAtMost: *weight_at_most, - call: $accept_open_channel_with_ap - } - } - ] - } - ] - events: - - name: sudo.Sudid - attribute: - type: Result - value: Ok - - name: polkadotXcm.Sent - - name: ump.ExecutedUpward - chain: *relay_chain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,160,892,000 - - name: hrmp.OpenChannelAccepted - chain: *relay_chain diff --git a/parachains/integration-tests/statemine/xcm/4_hrmp.yml b/parachains/integration-tests/statemine/xcm/4_hrmp.yml deleted file mode 100644 index 28ef7bc803a..00000000000 --- a/parachains/integration-tests/statemine/xcm/4_hrmp.yml +++ /dev/null @@ -1,356 +0,0 @@ ---- -settings: - chains: - relay_chain: &relay_chain - wsPort: 9900 - assets_parachain: &assets_parachain - wsPort: 9910 - paraId: &ap_id 1000 - penpal_parachain: &penpal_parachain - wsPort: 9920 - paraId: &pp_id 2000 - variables: - common: - amount: &amount 1000000000000 - require_weight_at_most: &weight_at_most 1000000000 - amount_to_send: &amount_to_send 500000000000 - chains: - relay_chain: - signer: &rc_signer //Alice - assets_parachain_destination: &ap_dest { v1: { 0, interior: { x1: { parachain: *ap_id }}}} - assets_parachain_dest_routed: &ap_dest_routed { v1: { parents: 1, interior: { x1: { parachain: *ap_id } }}} - assets_parachain_account: - signer: &ap_signer //Alice - wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F - asset_id: &asset_id 2 - assets_pallet_id: &assets_pallet_id 50 - asset_min_balance: &asset_ed 1000 - penpal_parachain_destination: &pp_dest { v1: { parents: 1, interior: { x1: { parachain: *pp_id } }}} - ksm: &ap_ksm { concrete: { parents: 1, interior: { here: true }}} - ksm_fungible: &ap_ksm_fungible { id: *ap_ksm, fun: { fungible: *amount }} - suff_asset: &suff_asset { concrete: { parents: 0, interior: { x2: [ { PalletInstance: *assets_pallet_id }, { GeneralIndex: *asset_id } ] }}} - suff_asset_fail: &suff_asset_fail { concrete: { parents: 0, interior: { x2: [ { PalletInstance: *assets_pallet_id }, { GeneralIndex: 3 } ] }}} - suff_asset_fungible: &ap_suff_asset_fungible { id: *suff_asset, fun: { fungible: *weight_at_most }} - suff_asset_fungible_fail: &ap_suff_asset_fungible_fail { id: *suff_asset_fail, fun: { fungible: *weight_at_most }} - penpal_parachain: - sovereign_account: &pp_sovereign_sibl FBeL7EAeUroLWXW1yfKboiqTqVfbRBcsUKd6QqVf4kGBySS - signer: &pp_signer //Alice - penpal_parachain_account: &pp_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' - decodedCalls: - force_create_asset: - chain: *assets_parachain - pallet: assets - call: forceCreate - args: [ - *asset_id, - { Id: *ap_wallet }, # owner - true, # isSufficient - *asset_ed # minBalance - ] - system_remark_with_event: - chain: *assets_parachain - pallet: system - call: remarkWithEvent - args: [ 0x0011 ] - -tests: - - name: HRMP - describes: - - name: polkadotXcm.limitedReserveTransferAssets (Asset) | Assets Parachain -> Penpal Parachain - before: - - name: DEPENDANCY | A sufficient Asset should exist in the Assets Parachain - actions: - - extrinsics: - - chain: *relay_chain - signer: *rc_signer - sudo: true - pallet: xcmPallet - call: send - args: [ - *ap_dest, # destination - { - v2: [ #message - { - Transact: { - originType: Superuser, - requireWeightAtMost: *weight_at_most, - call: $force_create_asset - } - } - ] - } - ] - events: - - name: xcmPallet.Sent - - name: dmpQueue.ExecutedDownward - chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,021,258,000 - - queries: - forced_created_asset: - chain: *assets_parachain - pallet: assets - call: asset - args: [ *asset_id ] - - asserts: - isSome: - args: [ $forced_created_asset ] - - - name: DEPENDANCY | Some Assets should be minted for the sender - actions: - - extrinsics: - - chain: *assets_parachain - signer: *ap_signer - pallet: assets - call: mint - args: [ - *asset_id, - *ap_wallet, - *amount - ] - events: - - name: assets.Issued - - its: - - name: Assets Parachain should be able to reserve transfer an Asset to Penpal Parachain - actions: - - extrinsics: - - chain: *assets_parachain - signer: *ap_signer - pallet: polkadotXcm - call: limitedReserveTransferAssets - args: [ - *pp_dest, # destination - { # beneficiary - V1: { - parents: 0, - interior: { - X1: { - AccountId32: { - network: Any, - id: *pp_acc - } - } - } - } - }, - { # assets - V1: [ - { - id: { - Concrete: { - parents: 0, - interior: { - X2: [ - { - PalletInstance: 50 - }, - { - GeneralIndex: *asset_id - } - ] - } - } - }, - fun: { - Fungible: *amount_to_send - } - } - ] - }, - 0, # feeAssetItem - Unlimited # weightLimit - ] - events: - - name: polkadotXcm.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 654,608,000 - - name: assets.Transferred - attribute: - type: AccountId32 - value: *pp_sovereign_sibl - - name: assets.Transferred - attribute: - type: u128 - value: *amount_to_send - - - name: polkadotXcm.limitedReserveTransferAssets (KSM) | Assets Parachain -> Penpal Parachain - its: - - name: Assets Parachain should be able to reserve transfer KSM to Penpal Parachain - actions: - - extrinsics: - - chain: *assets_parachain - signer: *ap_signer - pallet: polkadotXcm - call: limitedReserveTransferAssets - args: [ - *pp_dest, # destination - { # beneficiary - V1: { - parents: 0, - interior: { - X1: { - AccountId32: { - network: Any, - id: *pp_acc - } - } - } - } - }, - { # assets - V1: [ - *ap_ksm_fungible - ] - }, - 0, # feeAssetItem - Unlimited # weightLimit - ] - events: - - name: polkadotXcm.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 654,608,000 - - name: balances.Endowed - attribute: - type: AccountId32 - value: *pp_sovereign_sibl - - name: balances.Endowed - attribute: - type: u128 - value: *amount - - - name: polkadotXcm.send( system.remarkWithEvent() ) | Penpal Parachain -> Assets Parachain - before: - - name: Get the asset balance of the Penpal Parachain Sovereign account in Assets Parachain - actions: - - queries: - assets_balance_pp_sovereign_before: - chain: *assets_parachain - pallet: assets - call: account - args: [ - *asset_id, - *pp_sovereign_sibl - ] - its: - - name: Penpal Parachain should be able to send XCM message paying its fee with sufficient asset in Assets Parachain - actions: - - extrinsics: - - chain: *penpal_parachain - signer: *pp_signer - sudo: true - pallet: polkadotXcm - call: send - args: [ - *ap_dest_routed, # destination - { - v2: [ #message - { - WithdrawAsset: [*ap_suff_asset_fungible] - }, - { - BuyExecution: { - fees: *ap_suff_asset_fungible, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: SovereignAccount, - requireWeightAtMost: *weight_at_most, - call: $system_remark_with_event - } - } - ] - } - ] - events: - - name: sudo.Sudid - attribute: - type: Result - value: Ok - - name: polkadotXcm.Sent - - name: assets.Burned - chain: *assets_parachain - attribute: - type: AccountId32 - value: *pp_sovereign_sibl - - name: assets.Issued - chain: *assets_parachain - attribute: - type: u32 - value: *asset_id - - name: system.Remarked - chain: *assets_parachain - attribute: - type: AccountId32 - value: *pp_sovereign_sibl - - queries: - assets_balance_pp_sovereign_after: - chain: *assets_parachain - pallet: assets - call: account - args: [ - *asset_id, - *pp_sovereign_sibl - ] - - - name: Should reduce the assets balance of the Penpal Parachain's SovereignAccount in the Assets Parachain - actions: - - asserts: - assetsDecreased: - args: [ - { - balances: { - before: $assets_balance_pp_sovereign_before, - after: $assets_balance_pp_sovereign_after, - }, - } - ] - - - name: Penpal Parachain SHOULD NOT be able to send XCM message paying its fee with sufficient assets if not enough balance - actions: - - extrinsics: - - chain: *penpal_parachain - signer: *pp_signer - sudo: true - pallet: polkadotXcm - call: send - args: [ - *ap_dest_routed, # destination - { - v2: [ #message - { - WithdrawAsset: [*ap_suff_asset_fungible_fail] - }, - { - BuyExecution: { - fees: *ap_suff_asset_fungible_fail, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: SovereignAccount, - requireWeightAtMost: *weight_at_most, - call: $system_remark_with_event - } - } - ] - } - ] - events: - - name: xcmpQueue.Fail - chain: *assets_parachain - attribute: - type: XcmV2TraitsError - value: FailedToTransactAsset diff --git a/parachains/integration-tests/statemint/config.toml b/parachains/integration-tests/statemint/config.toml deleted file mode 100644 index f989d366ef3..00000000000 --- a/parachains/integration-tests/statemint/config.toml +++ /dev/null @@ -1,49 +0,0 @@ -[relaychain] -default_command = "./bin/polkadot" -default_args = [ "-lparachain=debug" ] -chain = "polkadot-local" - - [[relaychain.nodes]] - name = "alice" - ws_port = 9900 - validator = true - - [[relaychain.nodes]] - name = "bob" - validator = true - - [[relaychain.nodes]] - name = "charlie" - validator = true - - [[relaychain.nodes]] - name = "dave" - validator = true - -[[parachains]] -id = 1000 -chain = "statemint-local" -cumulus_based = true - - [[parachains.collators]] - name = "collator1" - ws_port = 9910 - command = "./bin/polkadot-parachain" - - [[parachains.collators]] - name = "collator2" - command = "./bin/polkadot-parachain" - -[[parachains]] -id = 2000 -chain = "penpal-polkadot-2000" -cumulus_based = true - - [[parachains.collators]] - name = "collator3" - ws_port = 9920 - command = "./bin/polkadot-parachain" - - [[parachains.collators]] - name = "collator4" - command = "./bin/polkadot-parachain" diff --git a/parachains/integration-tests/statemint/xcm/3_hrmp-open-channels.yml b/parachains/integration-tests/statemint/xcm/3_hrmp-open-channels.yml deleted file mode 100644 index f83e778f1c0..00000000000 --- a/parachains/integration-tests/statemint/xcm/3_hrmp-open-channels.yml +++ /dev/null @@ -1,402 +0,0 @@ ---- -settings: - chains: - relay_chain: &relay_chain - wsPort: 9900 - assets_parachain: &assets_parachain - wsPort: 9910 - paraId: &ap_id 1000 - penpal_parachain: &penpal_parachain - wsPort: 9920 - paraId: &pp_id 2000 - variables: - common: - amount: &amount 2000000000000 - require_weight_at_most: &weight_at_most 1000000000 - hrmp_channels: - proposed_max_capacity: &max_capacity 8 - proposed_max_message_size: &max_message_size 8192 - channel: &channel { - maxCapacity: 8, - maxTotalSize: 8192, - maxMessageSize: 8192, - msgCount: 0, - totalSize: 0, - mqcHead: null, - senderDeposit: 0, - recipientDeposit: 0 - } - chains: - relay_chain: - signer: &rc_signer //Alice - assets_parachain_destination: &ap_dest { v1: { 0, interior: { x1: { parachain: *ap_id }}}} - ksm: &rc_ksm { concrete: { 0, interior: { here: true }}} - ksm_fungible: &rc_ksm_fungible { id: *rc_ksm, fun: { fungible: *amount }} - assets_parachain_account: - sovereign_account: &ap_sovereign F7fq1jSNVTPfJmaHaXCMtatT1EZefCUsa7rRiQVNR5efcah - relay_chain_destination: &rc_dest { v1: { parents: 1, interior: { here: true }}} - penpal_parachain: - sovereign_account: &pp_sovereign F7fq1jMZkfuCuoMTyiEVAP2DMpMt18WopgBqTJznLihLNbZ - signer: &pp_signer //Alice - decodedCalls: - init_open_channel_with_ap: - chain: *relay_chain - pallet: hrmp - call: hrmpInitOpenChannel - args: [ - *ap_id, # recipient - *max_capacity, # proposedMaxCapacity - *max_message_size # proposedMaxMessageSize - ] - init_open_channel_with_cp: - chain: *relay_chain - pallet: hrmp - call: hrmpInitOpenChannel - args: [ - *pp_id, # recipient - *max_capacity, # proposedMaxCapacity - *max_message_size # proposedMaxMessageSize - ] - accept_open_channel_with_ap: - chain: *relay_chain - pallet: hrmp - call: hrmpAcceptOpenChannel - args: [ - *ap_id, # recipient - ] - accept_init_open_request_from_cp: - chain: *relay_chain - pallet: hrmp - call: hrmpAcceptOpenChannel - args: [ - *pp_id, # sender - ] - xcm_accept_init_open_request_from_cp: - chain: *assets_parachain - pallet: polkadotXcm - call: send - args: [ - *rc_dest, # destination - { - v2: [ #message - { - WithdrawAsset: [*rc_ksm_fungible] - }, - { - BuyExecution: { - fees: *rc_ksm_fungible, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: Native, - requireWeightAtMost: *weight_at_most, - call: $accept_init_open_request_from_cp - } - } - ] - } - ] - xcm_init_open_channel_with_cp: - chain: *assets_parachain - pallet: polkadotXcm - call: send - args: [ - *rc_dest, # destination - { - v2: [ #message - { - WithdrawAsset: [*rc_ksm_fungible] - }, - { - BuyExecution: { - fees: *rc_ksm_fungible, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: Native, - requireWeightAtMost: *weight_at_most, - call: $init_open_channel_with_cp - } - } - ] - } - ] - -tests: - - name: HRMP - beforeEach: - - name: DEPENDANCY | Penpal Parachain Sovereign account in the Relay Chain needs to be funded - actions: - - extrinsics: - - chain: *relay_chain - signer: *rc_signer - pallet: balances - call: transfer - args: [ - *pp_sovereign, # destination - *amount, # value - ] - events: - - name: balances.Transfer - - - name: DEPENDANCY | Assets Parachain Sovereign account in the Relay Chain needs to be funded - actions: - - extrinsics: - - chain: *relay_chain - signer: *rc_signer - pallet: balances - call: transfer - args: [ - *ap_sovereign, # destination - *amount, # value - ] - events: - - name: balances.Transfer - describes: - - name: hrmp.hrmpInitOpenChannel (Penpal Parachain → Assets Parachain) - its: - - name: Penpal Parachain sends a request to the Relay Chain to open a channel with the Assets Parchain - actions: - - extrinsics: - - chain: *penpal_parachain - signer: *pp_signer - sudo: true - pallet: polkadotXcm - call: send - args: [ - *rc_dest, # destination - { - v2: [ #message - { - WithdrawAsset: [*rc_ksm_fungible] - }, - { - BuyExecution: { - fees: *rc_ksm_fungible, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: Native, - requireWeightAtMost: *weight_at_most, - call: $init_open_channel_with_ap - } - } - ] - } - ] - events: - - name: sudo.Sudid - attribute: - type: Result - value: Ok - - name: polkadotXcm.Sent - - name: ump.ExecutedUpward - chain: *relay_chain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - value: 4,000,000,000 - - name: hrmp.OpenChannelRequested - chain: *relay_chain - - queries: - requested_channels: - chain: *relay_chain - pallet: hrmp - call: hrmpOpenChannelRequestsList - args: [] - - asserts: - equal: - args: [ - $requested_channels, - [ - { - sender: *pp_id, - recipient: *ap_id - } - ] - ] - - - name: hrmp.hrmpAcceptOpenChannel (Assets Parachain → Penpal Parachain) - its: - - name: Assets Parachain sends a response to the Relay Chain accepting the Penpal Parachain's request for openning a HRMP channel - actions: - - extrinsics: - - chain: *relay_chain - signer: *rc_signer - sudo: true - pallet: xcmPallet - call: send - args: [ - *ap_dest, # destination - { - v2: [ #message - { - Transact: { - originType: Superuser, - requireWeightAtMost: *weight_at_most, - call: $xcm_accept_init_open_request_from_cp - } - } - ] - } - ] - events: - - name: sudo.Sudid - attribute: - type: Result - value: Ok - - name: xcmPallet.Sent - - name: dmpQueue.ExecutedDownward - chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,020,807,000 - - name: polkadotXcm.Sent - chain: *assets_parachain - - name: ump.ExecutedUpward - timeout: 40000 - attribute: - type: XcmV2TraitsOutcome - isComplete: true - value: 4,000,000,000 - - name: hrmp.OpenChannelAccepted - timeout: 40000 - - queries: - open_channels: - chain: *relay_chain - pallet: hrmp - call: hrmpChannels - delay: 80000 - args: [ - { - sender: *pp_id, - recipient: *ap_id - } - ] - - asserts: - equal: - args: [ - $open_channels, - *channel - ] - - - name: hrmp.hrmpInitOpenChannel (Assets Parachain → Penpal Parachain) - its: - - name: Assets Parchain sends a request to the Relay Chain to open a channel with a Penpal Parachain - actions: - - extrinsics: - - chain: *relay_chain - signer: *rc_signer - sudo: true - pallet: xcmPallet - call: send - args: [ - *ap_dest, # destination - { - v2: [ #message - { - Transact: { - originType: Superuser, - requireWeightAtMost: *weight_at_most, - call: $xcm_init_open_channel_with_cp - } - } - ] - } - ] - events: - - name: sudo.Sudid - attribute: - type: Result - value: Ok - - name: xcmPallet.Sent - - name: dmpQueue.ExecutedDownward - chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,020,807,000 - - name: polkadotXcm.Sent - chain: *assets_parachain - - name: ump.ExecutedUpward - timeout: 40000 - attribute: - type: XcmV2TraitsOutcome - isComplete: true - value: 4,000,000,000 - - name: hrmp.OpenChannelRequested - timeout: 40000 - - queries: - requested_channels: - chain: *relay_chain - pallet: hrmp - call: hrmpOpenChannelRequestsList - args: [] - - asserts: - equal: - args: [ - $requested_channels, - [ - { - sender: *ap_id, - recipient: *pp_id - } - ] - ] - - - name: hrmp.hrmpAcceptOpenChannel (Penpal Parachain → Assets Parachain) - its: - - name: Penpal Parachain sends a response to the Relay Chain accepting the Assets Parachain's request for openning a HRMP channel - actions: - - extrinsics: - - chain: *penpal_parachain - signer: *pp_signer - sudo: true - pallet: polkadotXcm - call: send - args: [ - *rc_dest, # destination - { - v2: [ #message - { - WithdrawAsset: [*rc_ksm_fungible] - }, - { - BuyExecution: { - fees: *rc_ksm_fungible, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: Native, - requireWeightAtMost: *weight_at_most, - call: $accept_open_channel_with_ap - } - } - ] - } - ] - events: - - name: sudo.Sudid - attribute: - type: Result - value: Ok - - name: polkadotXcm.Sent - - name: ump.ExecutedUpward - chain: *relay_chain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - value: 4,000,000,000 - - name: hrmp.OpenChannelAccepted - chain: *relay_chain diff --git a/parachains/integration-tests/statemint/xcm/4_hrmp.yml b/parachains/integration-tests/statemint/xcm/4_hrmp.yml deleted file mode 100644 index 00a3ff467bc..00000000000 --- a/parachains/integration-tests/statemint/xcm/4_hrmp.yml +++ /dev/null @@ -1,356 +0,0 @@ ---- -settings: - chains: - relay_chain: &relay_chain - wsPort: 9900 - assets_parachain: &assets_parachain - wsPort: 9910 - paraId: &ap_id 1000 - penpal_parachain: &penpal_parachain - wsPort: 9920 - paraId: &pp_id 2000 - variables: - common: - amount: &amount 1000000000000 - require_weight_at_most: &weight_at_most 1000000000 - amount_to_send: &amount_to_send 500000000000 - chains: - relay_chain: - signer: &rc_signer //Alice - assets_parachain_destination: &ap_dest { v1: { 0, interior: { x1: { parachain: *ap_id }}}} - assets_parachain_dest_routed: &ap_dest_routed { v1: { parents: 1, interior: { x1: { parachain: *ap_id } }}} - assets_parachain_account: - signer: &ap_signer //Alice - wallet: &ap_wallet HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F - asset_id: &asset_id 2 - assets_pallet_id: &assets_pallet_id 50 - asset_min_balance: &asset_ed 1000 - penpal_parachain_destination: &pp_dest { v1: { parents: 1, interior: { x1: { parachain: *pp_id } }}} - ksm: &ap_ksm { concrete: { parents: 1, interior: { here: true }}} - ksm_fungible: &ap_ksm_fungible { id: *ap_ksm, fun: { fungible: *amount }} - suff_asset: &suff_asset { concrete: { parents: 0, interior: { x2: [ { PalletInstance: *assets_pallet_id }, { GeneralIndex: *asset_id } ] }}} - suff_asset_fail: &suff_asset_fail { concrete: { parents: 0, interior: { x2: [ { PalletInstance: *assets_pallet_id }, { GeneralIndex: 3 } ] }}} - suff_asset_fungible: &ap_suff_asset_fungible { id: *suff_asset, fun: { fungible: *weight_at_most }} - suff_asset_fungible_fail: &ap_suff_asset_fungible_fail { id: *suff_asset_fail, fun: { fungible: *weight_at_most }} - penpal_parachain: - sovereign_account: &pp_sovereign_sibl 13cKp89Msu7M2PiaCuuGr1BzAsD5V3vaVbDMs3YtjMZHdGwR - signer: &pp_signer //Alice - penpal_parachain_account: &pp_acc '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d' - decodedCalls: - force_create_asset: - chain: *assets_parachain - pallet: assets - call: forceCreate - args: [ - *asset_id, - { Id: *ap_wallet }, # owner - true, # isSufficient - *asset_ed # minBalance - ] - system_remark_with_event: - chain: *assets_parachain - pallet: system - call: remarkWithEvent - args: [ 0x0011 ] - -tests: - - name: HRMP - describes: - - name: polkadotXcm.limitedReserveTransferAssets (Asset) | Assets Parachain -> Penpal Parachain - before: - - name: DEPENDANCY | A sufficient Asset should exist in the Assets Parachain - actions: - - extrinsics: - - chain: *relay_chain - signer: *rc_signer - sudo: true - pallet: xcmPallet - call: send - args: [ - *ap_dest, # destination - { - v2: [ #message - { - Transact: { - originType: Superuser, - requireWeightAtMost: *weight_at_most, - call: $force_create_asset - } - } - ] - } - ] - events: - - name: xcmPallet.Sent - - name: dmpQueue.ExecutedDownward - chain: *assets_parachain - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 1,020,807,000 - - queries: - forced_created_asset: - chain: *assets_parachain - pallet: assets - call: asset - args: [ *asset_id ] - - asserts: - isSome: - args: [ $forced_created_asset ] - - - name: DEPENDANCY | Some Assets should be minted for the sender - actions: - - extrinsics: - - chain: *assets_parachain - signer: *ap_signer - pallet: assets - call: mint - args: [ - *asset_id, - *ap_wallet, - *amount - ] - events: - - name: assets.Issued - - its: - - name: Assets Parachain should be able to reserve transfer an Asset to Penpal Parachain - actions: - - extrinsics: - - chain: *assets_parachain - signer: *ap_signer - pallet: polkadotXcm - call: limitedReserveTransferAssets - args: [ - *pp_dest, # destination - { # beneficiary - V1: { - parents: 0, - interior: { - X1: { - AccountId32: { - network: Any, - id: *pp_acc - } - } - } - } - }, - { # assets - V1: [ - { - id: { - Concrete: { - parents: 0, - interior: { - X2: [ - { - PalletInstance: 50 - }, - { - GeneralIndex: *asset_id - } - ] - } - } - }, - fun: { - Fungible: *amount_to_send - } - } - ] - }, - 0, # feeAssetItem - Unlimited # weightLimit - ] - events: - - name: polkadotXcm.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 654,404,000 - - name: assets.Transferred - attribute: - type: AccountId32 - value: *pp_sovereign_sibl - - name: assets.Transferred - attribute: - type: u128 - value: *amount_to_send - - - name: polkadotXcm.limitedReserveTransferAssets (KSM) | Assets Parachain -> Penpal Parachain - its: - - name: Assets Parachain should be able to reserve transfer KSM to Penpal Parachain - actions: - - extrinsics: - - chain: *assets_parachain - signer: *ap_signer - pallet: polkadotXcm - call: limitedReserveTransferAssets - args: [ - *pp_dest, # destination - { # beneficiary - V1: { - parents: 0, - interior: { - X1: { - AccountId32: { - network: Any, - id: *pp_acc - } - } - } - } - }, - { # assets - V1: [ - *ap_ksm_fungible - ] - }, - 0, # feeAssetItem - Unlimited # weightLimit - ] - events: - - name: polkadotXcm.Attempted - attribute: - type: XcmV2TraitsOutcome - isComplete: true - threshold: [10, 10] - value: 654,404,000 - - name: balances.Endowed - attribute: - type: AccountId32 - value: *pp_sovereign_sibl - - name: balances.Endowed - attribute: - type: u128 - value: *amount - - - name: polkadotXcm.send( system.remarkWithEvent() ) | Penpal Parachain -> Assets Parachain - before: - - name: Get the asset balance of the Penpal Parachain Sovereign account in Assets Parachain - actions: - - queries: - assets_balance_pp_sovereign_before: - chain: *assets_parachain - pallet: assets - call: account - args: [ - *asset_id, - *pp_sovereign_sibl - ] - its: - - name: Penpal Parachain should be able to send XCM message paying its fee with sufficient asset in Assets Parachain - actions: - - extrinsics: - - chain: *penpal_parachain - signer: *pp_signer - sudo: true - pallet: polkadotXcm - call: send - args: [ - *ap_dest_routed, # destination - { - v2: [ #message - { - WithdrawAsset: [*ap_suff_asset_fungible] - }, - { - BuyExecution: { - fees: *ap_suff_asset_fungible, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: SovereignAccount, - requireWeightAtMost: *weight_at_most, - call: $system_remark_with_event - } - } - ] - } - ] - events: - - name: sudo.Sudid - attribute: - type: Result - value: Ok - - name: polkadotXcm.Sent - - name: assets.Burned - chain: *assets_parachain - attribute: - type: AccountId32 - value: *pp_sovereign_sibl - - name: assets.Issued - chain: *assets_parachain - attribute: - type: u32 - value: *asset_id - - name: system.Remarked - chain: *assets_parachain - attribute: - type: AccountId32 - value: *pp_sovereign_sibl - - queries: - assets_balance_pp_sovereign_after: - chain: *assets_parachain - pallet: assets - call: account - args: [ - *asset_id, - *pp_sovereign_sibl - ] - - - name: Should reduce the assets balance of the Penpal Parachain's SovereignAccount in the Assets Parachain - actions: - - asserts: - assetsDecreased: - args: [ - { - balances: { - before: $assets_balance_pp_sovereign_before, - after: $assets_balance_pp_sovereign_after, - }, - } - ] - - - name: Penpal Parachain SHOULD NOT be able to send XCM message paying its fee with sufficient assets if not enough balance - actions: - - extrinsics: - - chain: *penpal_parachain - signer: *pp_signer - sudo: true - pallet: polkadotXcm - call: send - args: [ - *ap_dest_routed, # destination - { - v2: [ #message - { - WithdrawAsset: [*ap_suff_asset_fungible_fail] - }, - { - BuyExecution: { - fees: *ap_suff_asset_fungible_fail, - weightLimit: Unlimited - } - }, - { - Transact: { - originType: SovereignAccount, - requireWeightAtMost: *weight_at_most, - call: $system_remark_with_event - } - } - ] - } - ] - events: - - name: xcmpQueue.Fail - chain: *assets_parachain - attribute: - type: XcmV2TraitsError - value: FailedToTransactAsset diff --git a/parachains/pallets/parachain-info/Cargo.toml b/parachains/pallets/parachain-info/Cargo.toml index 3d706e35e8e..3fbccc215e0 100644 --- a/parachains/pallets/parachain-info/Cargo.toml +++ b/parachains/pallets/parachain-info/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/parachains/pallets/parachain-info/src/lib.rs b/parachains/pallets/parachain-info/src/lib.rs index d61387aaeb6..1910d6cf241 100644 --- a/parachains/pallets/parachain-info/src/lib.rs +++ b/parachains/pallets/parachain-info/src/lib.rs @@ -43,7 +43,6 @@ pub mod pallet { pub parachain_id: ParaId, } - #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { Self { parachain_id: 100.into() } @@ -53,7 +52,7 @@ pub mod pallet { #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { fn build(&self) { - >::put(&self.parachain_id); + >::put(self.parachain_id); } } diff --git a/parachains/pallets/ping/Cargo.toml b/parachains/pallets/ping/Cargo.toml index 1dd218ccc79..2af482598c2 100644 --- a/parachains/pallets/ping/Cargo.toml +++ b/parachains/pallets/ping/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/parachains/runtimes/assets/README.md b/parachains/runtimes/assets/README.md index 7f995d043c4..78145395cbf 100644 --- a/parachains/runtimes/assets/README.md +++ b/parachains/runtimes/assets/README.md @@ -1,9 +1,9 @@ # Assets Parachain -Implementation of _Statemint_, a blockchain to support generic assets in the Polkadot and Kusama -networks. +Implementation of Asset Hub, a blockchain to support generic assets in the Polkadot and Kusama +networks. Asset Hub was formerly known as "Statemint". -Statemint allows users to: +Asset Hub allows users to: - Deploy promise-backed assets, both fungible and non-fungible, with a DOT/KSM deposit. - Set admin roles to manage assets and asset classes. @@ -13,11 +13,11 @@ Statemint allows users to: - Transfer (and approve transfer) assets. - Interact with the chain via its transactional API or XCM. -Statemint must stay fully aligned with the Relay Chain it is connected to. As such, it will accept +Asset Hub must stay fully aligned with the Relay Chain it is connected to. As such, it will accept the Relay Chain's governance origins as its own. See -[the article on Statemint as common good parachain](https://www.parity.io/blog/statemint-generic-assets-chain-proposing-a-common-good-parachain-to-polkadot-governance/) +[the article on Asset Hub as common good parachain](https://www.parity.io/blog/statemint-generic-assets-chain-proposing-a-common-good-parachain-to-polkadot-governance/) for a higher level description. Wallets, custodians, etc. should see diff --git a/parachains/runtimes/assets/statemine/Cargo.toml b/parachains/runtimes/assets/asset-hub-kusama/Cargo.toml similarity index 97% rename from parachains/runtimes/assets/statemine/Cargo.toml rename to parachains/runtimes/assets/asset-hub-kusama/Cargo.toml index 2e47d80b5d0..8364ea1255c 100644 --- a/parachains/runtimes/assets/statemine/Cargo.toml +++ b/parachains/runtimes/assets/asset-hub-kusama/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "statemine-runtime" -version = "2.0.0" +name = "asset-hub-kusama-runtime" +version = "0.9.420" authors = ["Parity Technologies "] edition = "2021" -description = "Kusama variant of Statemint parachain runtime" +description = "Kusama variant of Asset Hub parachain runtime" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } hex-literal = { version = "0.4.1" } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } smallvec = "1.10.0" # Substrate diff --git a/parachains/runtimes/assets/statemine/build.rs b/parachains/runtimes/assets/asset-hub-kusama/build.rs similarity index 100% rename from parachains/runtimes/assets/statemine/build.rs rename to parachains/runtimes/assets/asset-hub-kusama/build.rs diff --git a/parachains/runtimes/assets/statemine/src/constants.rs b/parachains/runtimes/assets/asset-hub-kusama/src/constants.rs similarity index 98% rename from parachains/runtimes/assets/statemine/src/constants.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/constants.rs index 95e8c166a96..7822698be6c 100644 --- a/parachains/runtimes/assets/statemine/src/constants.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/constants.rs @@ -73,7 +73,7 @@ pub mod fee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { // in Kusama, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: - // in Statemine, we map to 1/10 of that, or 1/100 CENT + // in Asset Hub, we map to 1/10 of that, or 1/100 CENT let p = super::currency::CENTS; let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); diff --git a/parachains/runtimes/assets/statemine/src/lib.rs b/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs similarity index 97% rename from parachains/runtimes/assets/statemine/src/lib.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/lib.rs index c051ae43e14..733cc9cc4ca 100644 --- a/parachains/runtimes/assets/statemine/src/lib.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/lib.rs @@ -13,9 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! # Statemine Runtime +//! # Asset Hub Kusama Runtime //! -//! Statemine is the canary network for its Polkadot cousin, Statemint. +//! Asset Hub Kusama, formerly known as "Statemine", is the canary network for its Polkadot cousin. #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "256"] @@ -100,10 +100,13 @@ impl_opaque_keys! { #[cfg(feature = "state-trie-version-1")] #[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { + // Note: "statemine" is the legacy name for this chain. It has been renamed to + // "asset-hub-kusama". Many wallets/tools depend on the `spec_name`, so it remains "statemine" + // for the time being. Wallets/tools should update to treat "asset-hub-kusama" equally. spec_name: create_runtime_str!("statemine"), impl_name: create_runtime_str!("statemine"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 13, @@ -113,10 +116,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { #[cfg(not(feature = "state-trie-version-1"))] #[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { + // Note: "statemine" is the legacy name for this change. It has been renamed to + // "asset-hub-kusama". Many wallets/tools depend on the `spec_name`, so it remains "statemine" + // for the time being. Wallets/tools should update to treat "asset-hub-kusama" equally. spec_name: create_runtime_str!("statemine"), impl_name: create_runtime_str!("statemine"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 13, @@ -211,7 +217,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = weights::pallet_balances::WeightInfo; type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -219,7 +225,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -546,7 +552,7 @@ impl pallet_message_queue::Config for Runtime { >; #[cfg(not(feature = "runtime-benchmarks"))] type MessageProcessor = parachains_common::process_xcm_message::SplitMessages< - ProcessXcmMessage< + xcm_builder::ProcessXcmMessage< AggregateMessageOrigin, xcm_executor::XcmExecutor, RuntimeCall, @@ -577,7 +583,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type XcmpProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor; #[cfg(not(feature = "runtime-benchmarks"))] type XcmpProcessor = ProcessFromSibling< - ProcessXcmMessage< + xcm_builder::ProcessXcmMessage< AggregateMessageOrigin, xcm_executor::XcmExecutor, RuntimeCall, @@ -808,7 +814,7 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Migrations to apply on runtime upgrade. -pub type Migrations = (); +pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1,); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -1064,7 +1070,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -1100,7 +1106,6 @@ impl_runtime_apis! { id: Concrete(GeneralIndex(i as u128).into()), fun: Fungible(fungibles_amount * i as u128), } - .into() }) .chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) .chain((0..holding_non_fungibles).map(|i| MultiAsset { @@ -1120,7 +1125,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( KsmLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(KsmLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; @@ -1135,7 +1140,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(KsmLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } @@ -1239,7 +1244,7 @@ cumulus_pallet_parachain_system::register_validate_block! { #[cfg(feature = "state-trie-version-1")] parameter_types! { // The deposit configuration for the singed migration. Specially if you want to allow any signed account to do the migration (see `SignedFilter`, these deposits should be high) - pub const MigrationSignedDepositPerItem: Balance = 1 * CENTS; + pub const MigrationSignedDepositPerItem: Balance = CENTS; pub const MigrationSignedDepositBase: Balance = 2_000 * CENTS; pub const MigrationMaxKeyLen: u32 = 512; } diff --git a/parachains/runtimes/assets/statemine/src/weights/block_weights.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/block_weights.rs similarity index 100% rename from parachains/runtimes/assets/statemine/src/weights/block_weights.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/block_weights.rs diff --git a/parachains/runtimes/assets/statemint/src/weights/cumulus_pallet_parachain_system.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/cumulus_pallet_parachain_system.rs similarity index 100% rename from parachains/runtimes/assets/statemint/src/weights/cumulus_pallet_parachain_system.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/cumulus_pallet_parachain_system.rs diff --git a/parachains/runtimes/assets/statemint/src/weights/cumulus_pallet_xcmp_queue.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/cumulus_pallet_xcmp_queue.rs similarity index 82% rename from parachains/runtimes/assets/statemint/src/weights/cumulus_pallet_xcmp_queue.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/cumulus_pallet_xcmp_queue.rs index 542aced29e5..fb2f1d534c3 100644 --- a/parachains/runtimes/assets/statemint/src/weights/cumulus_pallet_xcmp_queue.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/cumulus_pallet_xcmp_queue.rs @@ -19,34 +19,31 @@ //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-03-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `i9`, CPU: `13th Gen Intel(R) Core(TM) i9-13900K` -//! EXECUTION: Some(Native), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./target/release/polkadot-parachain // benchmark // pallet -// --chain -// statemint-dev -// --pallet -// cumulus_pallet_xcmp_queue -// --extrinsic -// -// --execution -// native -// --output -// parachains/runtimes/assets/statemint/src/weights -// --steps -// 50 -// --repeat -// 20 +// --chain=asset-hub-kusama-dev +// --execution=wasm +// --wasm-execution=compiled +// --pallet=cumulus_pallet_xcmp_queue +// --extrinsic=* +// --steps=50 +// --repeat=20 +// --json +// --header=./file_header.txt +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/cumulus_pallet_xcmp_queue.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_xcmp_queue`. pub struct WeightInfo(PhantomData); @@ -57,8 +54,8 @@ impl cumulus_pallet_xcmp_queue::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `76` // Estimated: `1561` - // Minimum execution time: 1_846_000 picoseconds. - Weight::from_parts(1_991_000, 0) + // Minimum execution time: 5_800_000 picoseconds. + Weight::from_parts(5_998_000, 0) .saturating_add(Weight::from_parts(0, 1561)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -90,8 +87,8 @@ impl cumulus_pallet_xcmp_queue::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `76` // Estimated: `1561` - // Minimum execution time: 1_246_000 picoseconds. - Weight::from_parts(1_300_000, 0) + // Minimum execution time: 5_975_000 picoseconds. + Weight::from_parts(6_136_000, 0) .saturating_add(Weight::from_parts(0, 1561)) .saturating_add(T::DbWeight::get().reads(1)) } diff --git a/parachains/runtimes/assets/statemine/src/weights/extrinsic_weights.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/extrinsic_weights.rs similarity index 100% rename from parachains/runtimes/assets/statemine/src/weights/extrinsic_weights.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/extrinsic_weights.rs diff --git a/parachains/runtimes/assets/westmint/src/weights/frame_system.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/frame_system.rs similarity index 74% rename from parachains/runtimes/assets/westmint/src/weights/frame_system.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/frame_system.rs index 9f0e1e43f56..09c24b48259 100644 --- a/parachains/runtimes/assets/westmint/src/weights/frame_system.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/frame_system.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `frame_system` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=frame_system @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/frame_system.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/frame_system.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `frame_system`. pub struct WeightInfo(PhantomData); @@ -52,22 +53,25 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_150_000 picoseconds. - Weight::from_parts(2_242_000, 0) + // Minimum execution time: 2_296_000 picoseconds. + Weight::from_parts(2_354_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(368, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(365, 0).saturating_mul(b.into())) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_810_000 picoseconds. - Weight::from_parts(7_949_000, 0) + // Minimum execution time: 7_949_000 picoseconds. + Weight::from_parts(8_091_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_408, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(1_397, 0).saturating_mul(b.into())) + } + fn set_code() -> Weight { + Weight::from_parts(1_000_000, 0) } /// Storage: System Digest (r:1 w:1) /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) @@ -77,8 +81,8 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 4_446_000 picoseconds. - Weight::from_parts(4_769_000, 0) + // Minimum execution time: 4_344_000 picoseconds. + Weight::from_parts(4_499_000, 0) .saturating_add(Weight::from_parts(0, 1485)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -90,11 +94,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_378_000 picoseconds. - Weight::from_parts(2_458_000, 0) + // Minimum execution time: 2_562_000 picoseconds. + Weight::from_parts(2_599_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_873 - .saturating_add(Weight::from_parts(680_971, 0).saturating_mul(i.into())) + // Standard Error: 1_882 + .saturating_add(Weight::from_parts(660_746, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -104,11 +108,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_389_000 picoseconds. - Weight::from_parts(2_433_000, 0) + // Minimum execution time: 2_423_000 picoseconds. + Weight::from_parts(2_466_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 765 - .saturating_add(Weight::from_parts(502_307, 0).saturating_mul(i.into())) + // Standard Error: 775 + .saturating_add(Weight::from_parts(486_467, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -117,12 +121,12 @@ impl frame_system::WeightInfo for WeightInfo { fn kill_prefix(p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `84 + p * (69 ±0)` - // Estimated: `75 + p * (70 ±0)` - // Minimum execution time: 4_077_000 picoseconds. - Weight::from_parts(4_196_000, 0) - .saturating_add(Weight::from_parts(0, 75)) - // Standard Error: 920 - .saturating_add(Weight::from_parts(1_004_901, 0).saturating_mul(p.into())) + // Estimated: `77 + p * (70 ±0)` + // Minimum execution time: 4_216_000 picoseconds. + Weight::from_parts(4_281_000, 0) + .saturating_add(Weight::from_parts(0, 77)) + // Standard Error: 953 + .saturating_add(Weight::from_parts(1_023_931, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) diff --git a/parachains/runtimes/assets/statemine/src/weights/mod.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/mod.rs similarity index 100% rename from parachains/runtimes/assets/statemine/src/weights/mod.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/mod.rs diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_assets.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_assets.rs similarity index 85% rename from parachains/runtimes/assets/statemine/src/weights/pallet_assets.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_assets.rs index 94957ff84fa..410043bc4fe 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_assets.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_assets.rs @@ -20,13 +20,13 @@ //! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_assets @@ -35,7 +35,7 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_assets.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_assets.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -441,4 +441,73 @@ impl pallet_assets::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn touch() -> Weight { + // Proof Size summary in bytes: + // Measured: `453` + // Estimated: `3675` + // Minimum execution time: 37_468_000 picoseconds. + Weight::from_parts(37_957_000, 3675) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn touch_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `3675` + // Minimum execution time: 383_408_000 picoseconds. + Weight::from_parts(392_036_000, 3675) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn refund() -> Weight { + // Proof Size summary in bytes: + // Measured: `579` + // Estimated: `3675` + // Minimum execution time: 34_066_000 picoseconds. + Weight::from_parts(34_347_000, 3675) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn refund_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `510` + // Estimated: `3675` + // Minimum execution time: 32_060_000 picoseconds. + Weight::from_parts(32_519_000, 3675) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + fn block() -> Weight { + // Proof Size summary in bytes: + // Measured: `459` + // Estimated: `3675` + // Minimum execution time: 115_000_000 picoseconds. + Weight::from_parts(163_000_000, 3675) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } } diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_balances.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_balances.rs similarity index 71% rename from parachains/runtimes/assets/statemint/src/weights/pallet_balances.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_balances.rs index e81c1925649..563df00f845 100644 --- a/parachains/runtimes/assets/statemint/src/weights/pallet_balances.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_balances.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemint-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_balances @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/pallet_balances.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_balances.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_balances`. pub struct WeightInfo(PhantomData); @@ -53,8 +54,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 35_757_000 picoseconds. - Weight::from_parts(36_417_000, 0) + // Minimum execution time: 54_579_000 picoseconds. + Weight::from_parts(55_271_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -65,8 +66,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 27_074_000 picoseconds. - Weight::from_parts(27_335_000, 0) + // Minimum execution time: 41_342_000 picoseconds. + Weight::from_parts(41_759_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -77,8 +78,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 16_753_000 picoseconds. - Weight::from_parts(17_141_000, 0) + // Minimum execution time: 16_403_000 picoseconds. + Weight::from_parts(16_651_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -89,8 +90,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 20_459_000 picoseconds. - Weight::from_parts(20_848_000, 0) + // Minimum execution time: 23_225_000 picoseconds. + Weight::from_parts(23_577_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -101,8 +102,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `6196` - // Minimum execution time: 41_036_000 picoseconds. - Weight::from_parts(41_265_000, 0) + // Minimum execution time: 56_084_000 picoseconds. + Weight::from_parts(56_374_000, 0) .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -113,25 +114,38 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 35_925_000 picoseconds. - Weight::from_parts(36_511_000, 0) + // Minimum execution time: 50_374_000 picoseconds. + Weight::from_parts(52_040_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn upgrade_accounts(_: u32) -> Weight { - Weight::from_parts(0, 0) - } fn force_unreserve() -> Weight { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 16_377_000 picoseconds. - Weight::from_parts(16_722_000, 0) + // Minimum execution time: 18_975_000 picoseconds. + Weight::from_parts(19_317_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + u * (136 ±0)` + // Estimated: `990 + u * (2603 ±0)` + // Minimum execution time: 18_579_000 picoseconds. + Weight::from_parts(18_668_000, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 9_111 + .saturating_add(Weight::from_parts(14_381_916, 0).saturating_mul(u.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + } } diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_collator_selection.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_collator_selection.rs similarity index 68% rename from parachains/runtimes/assets/statemint/src/weights/pallet_collator_selection.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_collator_selection.rs index e86fa5544d0..ece29bc35c4 100644 --- a/parachains/runtimes/assets/statemint/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_collator_selection.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_collator_selection` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemint-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_collator_selection @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/pallet_collator_selection.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_collator_selection.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_collator_selection`. pub struct WeightInfo(PhantomData); @@ -56,11 +57,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `178 + b * (78 ±0)` // Estimated: `1168 + b * (2554 ±0)` - // Minimum execution time: 15_372_000 picoseconds. - Weight::from_parts(16_916_596, 0) + // Minimum execution time: 15_571_000 picoseconds. + Weight::from_parts(15_554_982, 0) .saturating_add(Weight::from_parts(0, 1168)) - // Standard Error: 3_537 - .saturating_add(Weight::from_parts(2_583_561, 0).saturating_mul(b.into())) + // Standard Error: 2_818 + .saturating_add(Weight::from_parts(2_610_335, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(Weight::from_parts(0, 2554).saturating_mul(b.into())) @@ -71,8 +72,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_637_000 picoseconds. - Weight::from_parts(7_821_000, 0) + // Minimum execution time: 7_816_000 picoseconds. + Weight::from_parts(8_030_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -82,8 +83,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_838_000 picoseconds. - Weight::from_parts(8_092_000, 0) + // Minimum execution time: 8_077_000 picoseconds. + Weight::from_parts(8_293_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,12 +104,12 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn register_as_candidate(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1108 + c * (48 ±0)` - // Estimated: `61671 + c * (49 ±0)` - // Minimum execution time: 37_630_000 picoseconds. - Weight::from_parts(30_551_625, 0) - .saturating_add(Weight::from_parts(0, 61671)) - // Standard Error: 1_282 - .saturating_add(Weight::from_parts(112_510, 0).saturating_mul(c.into())) + // Estimated: `49487 + c * (49 ±0)` + // Minimum execution time: 43_072_000 picoseconds. + Weight::from_parts(35_712_990, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 1_261 + .saturating_add(Weight::from_parts(112_854, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 49).saturating_mul(c.into())) @@ -122,11 +123,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `452 + c * (48 ±0)` // Estimated: `49487` - // Minimum execution time: 29_525_000 picoseconds. - Weight::from_parts(19_433_082, 0) + // Minimum execution time: 35_372_000 picoseconds. + Weight::from_parts(26_886_289, 0) .saturating_add(Weight::from_parts(0, 49487)) - // Standard Error: 1_290 - .saturating_add(Weight::from_parts(108_444, 0).saturating_mul(c.into())) + // Standard Error: 1_388 + .saturating_add(Weight::from_parts(106_632, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -139,13 +140,46 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn note_author() -> Weight { // Proof Size summary in bytes: // Measured: `103` - // Estimated: `7729` - // Minimum execution time: 29_428_000 picoseconds. - Weight::from_parts(29_752_000, 0) - .saturating_add(Weight::from_parts(0, 7729)) + // Estimated: `6196` + // Minimum execution time: 44_209_000 picoseconds. + Weight::from_parts(44_590_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) @@ -160,18 +194,18 @@ impl pallet_collator_selection::WeightInfo for WeightIn /// The range of component `c` is `[1, 1000]`. fn new_session(r: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `22721 + r * (116 ±0) + c * (97 ±0)` - // Estimated: `56697 + r * (2602 ±0) + c * (2520 ±0)` - // Minimum execution time: 17_105_000 picoseconds. - Weight::from_parts(17_304_000, 0) - .saturating_add(Weight::from_parts(0, 56697)) - // Standard Error: 839_957 - .saturating_add(Weight::from_parts(30_183_103, 0).saturating_mul(c.into())) + // Measured: `22721 + c * (97 ±0) + r * (116 ±0)` + // Estimated: `49487 + c * (2519 ±0) + r * (2602 ±0)` + // Minimum execution time: 17_397_000 picoseconds. + Weight::from_parts(17_600_000, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 897_810 + .saturating_add(Weight::from_parts(31_873_549, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2519).saturating_mul(c.into())) .saturating_add(Weight::from_parts(0, 2602).saturating_mul(r.into())) - .saturating_add(Weight::from_parts(0, 2520).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_message_queue.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_message_queue.rs similarity index 100% rename from parachains/runtimes/assets/statemint/src/weights/pallet_message_queue.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_message_queue.rs diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_multisig.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_multisig.rs similarity index 73% rename from parachains/runtimes/assets/westmint/src/weights/pallet_multisig.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_multisig.rs index b01f73c3007..04e704cc402 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_multisig.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_multisig.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_multisig` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_multisig @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_multisig.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_multisig.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_multisig`. pub struct WeightInfo(PhantomData); @@ -52,11 +53,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_071_000 picoseconds. - Weight::from_parts(12_418_308, 0) + // Minimum execution time: 12_303_000 picoseconds. + Weight::from_parts(12_695_362, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 1 - .saturating_add(Weight::from_parts(495, 0).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(557, 0).saturating_mul(z.into())) } /// Storage: Multisig Multisigs (r:1 w:1) /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) @@ -66,13 +67,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `262 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 37_454_000 picoseconds. - Weight::from_parts(31_908_123, 0) + // Minimum execution time: 42_467_000 picoseconds. + Weight::from_parts(36_773_932, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 637 - .saturating_add(Weight::from_parts(62_530, 0).saturating_mul(s.into())) - // Standard Error: 6 - .saturating_add(Weight::from_parts(1_217, 0).saturating_mul(z.into())) + // Standard Error: 459 + .saturating_add(Weight::from_parts(63_612, 0).saturating_mul(s.into())) + // Standard Error: 4 + .saturating_add(Weight::from_parts(1_269, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -84,13 +85,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 27_665_000 picoseconds. - Weight::from_parts(21_985_439, 0) + // Minimum execution time: 28_843_000 picoseconds. + Weight::from_parts(23_142_157, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 509 - .saturating_add(Weight::from_parts(63_318, 0).saturating_mul(s.into())) - // Standard Error: 4 - .saturating_add(Weight::from_parts(1_187, 0).saturating_mul(z.into())) + // Standard Error: 229 + .saturating_add(Weight::from_parts(63_362, 0).saturating_mul(s.into())) + // Standard Error: 2 + .saturating_add(Weight::from_parts(1_241, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,14 +104,14 @@ impl pallet_multisig::WeightInfo for WeightInfo { fn as_multi_complete(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `385 + s * (33 ±0)` - // Estimated: `10404` - // Minimum execution time: 42_985_000 picoseconds. - Weight::from_parts(35_504_175, 0) - .saturating_add(Weight::from_parts(0, 10404)) - // Standard Error: 530 - .saturating_add(Weight::from_parts(80_153, 0).saturating_mul(s.into())) + // Estimated: `6811` + // Minimum execution time: 48_265_000 picoseconds. + Weight::from_parts(40_503_415, 0) + .saturating_add(Weight::from_parts(0, 6811)) + // Standard Error: 528 + .saturating_add(Weight::from_parts(85_941, 0).saturating_mul(s.into())) // Standard Error: 5 - .saturating_add(Weight::from_parts(1_215, 0).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(1_281, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -121,11 +122,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `263 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 28_498_000 picoseconds. - Weight::from_parts(30_376_601, 0) + // Minimum execution time: 32_680_000 picoseconds. + Weight::from_parts(34_368_418, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 785 - .saturating_add(Weight::from_parts(65_913, 0).saturating_mul(s.into())) + // Standard Error: 558 + .saturating_add(Weight::from_parts(72_172, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -136,11 +137,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 19_047_000 picoseconds. - Weight::from_parts(20_338_502, 0) + // Minimum execution time: 19_571_000 picoseconds. + Weight::from_parts(20_887_762, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 544 - .saturating_add(Weight::from_parts(66_876, 0).saturating_mul(s.into())) + // Standard Error: 858 + .saturating_add(Weight::from_parts(64_869, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -151,11 +152,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `454 + s * (1 ±0)` // Estimated: `6811` - // Minimum execution time: 29_085_000 picoseconds. - Weight::from_parts(31_283_618, 0) + // Minimum execution time: 32_681_000 picoseconds. + Weight::from_parts(34_919_059, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 985 - .saturating_add(Weight::from_parts(67_469, 0).saturating_mul(s.into())) + // Standard Error: 613 + .saturating_add(Weight::from_parts(72_149, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_nfts.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_nfts.rs similarity index 82% rename from parachains/runtimes/assets/westmint/src/weights/pallet_nfts.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_nfts.rs index 904f7823041..689b1b750b9 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_nfts.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_nfts.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_nfts` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_nfts @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_nfts.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_nfts.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_nfts`. pub struct WeightInfo(PhantomData); @@ -60,10 +61,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn create() -> Weight { // Proof Size summary in bytes: // Measured: `145` - // Estimated: `5038` - // Minimum execution time: 34_344_000 picoseconds. - Weight::from_parts(35_251_000, 0) - .saturating_add(Weight::from_parts(0, 5038)) + // Estimated: `3549` + // Minimum execution time: 39_589_000 picoseconds. + Weight::from_parts(40_305_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -80,10 +81,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn force_create() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `5038` - // Minimum execution time: 22_704_000 picoseconds. - Weight::from_parts(23_146_000, 0) - .saturating_add(Weight::from_parts(0, 5038)) + // Estimated: `3549` + // Minimum execution time: 23_945_000 picoseconds. + Weight::from_parts(24_351_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -109,12 +110,12 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn destroy(_m: u32, _c: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `32170 + a * (366 ±0)` - // Estimated: `2538829 + a * (2954 ±0)` - // Minimum execution time: 976_206_000 picoseconds. - Weight::from_parts(924_770_064, 0) - .saturating_add(Weight::from_parts(0, 2538829)) - // Standard Error: 3_946 - .saturating_add(Weight::from_parts(5_708_229, 0).saturating_mul(a.into())) + // Estimated: `2523990 + a * (2954 ±0)` + // Minimum execution time: 992_533_000 picoseconds. + Weight::from_parts(941_813_359, 0) + .saturating_add(Weight::from_parts(0, 2523990)) + // Standard Error: 3_954 + .saturating_add(Weight::from_parts(5_784_754, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(1004)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1005)) @@ -136,10 +137,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn mint() -> Weight { // Proof Size summary in bytes: // Measured: `421` - // Estimated: `18460` - // Minimum execution time: 44_592_000 picoseconds. - Weight::from_parts(45_181_000, 0) - .saturating_add(Weight::from_parts(0, 18460)) + // Estimated: `4326` + // Minimum execution time: 49_305_000 picoseconds. + Weight::from_parts(50_143_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -158,10 +159,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn force_mint() -> Weight { // Proof Size summary in bytes: // Measured: `421` - // Estimated: `18460` - // Minimum execution time: 43_304_000 picoseconds. - Weight::from_parts(43_977_000, 0) - .saturating_add(Weight::from_parts(0, 18460)) + // Estimated: `4326` + // Minimum execution time: 48_627_000 picoseconds. + Weight::from_parts(48_954_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -184,10 +185,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn burn() -> Weight { // Proof Size summary in bytes: // Measured: `530` - // Estimated: `15200` - // Minimum execution time: 45_744_000 picoseconds. - Weight::from_parts(46_056_000, 0) - .saturating_add(Weight::from_parts(0, 15200)) + // Estimated: `4326` + // Minimum execution time: 49_958_000 picoseconds. + Weight::from_parts(50_387_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -208,10 +209,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn transfer() -> Weight { // Proof Size summary in bytes: // Measured: `559` - // Estimated: `14926` - // Minimum execution time: 35_663_000 picoseconds. - Weight::from_parts(36_865_000, 0) - .saturating_add(Weight::from_parts(0, 14926)) + // Estimated: `4326` + // Minimum execution time: 36_267_000 picoseconds. + Weight::from_parts(36_712_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -225,12 +226,12 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `729 + i * (108 ±0)` - // Estimated: `8077 + i * (3336 ±0)` - // Minimum execution time: 16_987_000 picoseconds. - Weight::from_parts(17_194_000, 0) - .saturating_add(Weight::from_parts(0, 8077)) - // Standard Error: 13_044 - .saturating_add(Weight::from_parts(13_324_147, 0).saturating_mul(i.into())) + // Estimated: `3549 + i * (3336 ±0)` + // Minimum execution time: 17_738_000 picoseconds. + Weight::from_parts(17_801_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) + // Standard Error: 13_596 + .saturating_add(Weight::from_parts(15_695_790, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -243,10 +244,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn lock_item_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `401` - // Estimated: `7047` - // Minimum execution time: 20_345_000 picoseconds. - Weight::from_parts(20_739_000, 0) - .saturating_add(Weight::from_parts(0, 7047)) + // Estimated: `3534` + // Minimum execution time: 20_845_000 picoseconds. + Weight::from_parts(21_133_000, 0) + .saturating_add(Weight::from_parts(0, 3534)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -257,10 +258,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn unlock_item_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `401` - // Estimated: `7047` - // Minimum execution time: 20_167_000 picoseconds. - Weight::from_parts(20_580_000, 0) - .saturating_add(Weight::from_parts(0, 7047)) + // Estimated: `3534` + // Minimum execution time: 20_862_000 picoseconds. + Weight::from_parts(21_105_000, 0) + .saturating_add(Weight::from_parts(0, 3534)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -271,10 +272,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn lock_collection() -> Weight { // Proof Size summary in bytes: // Measured: `306` - // Estimated: `7087` - // Minimum execution time: 17_831_000 picoseconds. - Weight::from_parts(18_174_000, 0) - .saturating_add(Weight::from_parts(0, 7087)) + // Estimated: `3549` + // Minimum execution time: 18_196_000 picoseconds. + Weight::from_parts(18_333_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -287,10 +288,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn transfer_ownership() -> Weight { // Proof Size summary in bytes: // Measured: `354` - // Estimated: `7066` - // Minimum execution time: 23_763_000 picoseconds. - Weight::from_parts(24_226_000, 0) - .saturating_add(Weight::from_parts(0, 7066)) + // Estimated: `3549` + // Minimum execution time: 24_025_000 picoseconds. + Weight::from_parts(24_277_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -301,10 +302,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_team() -> Weight { // Proof Size summary in bytes: // Measured: `335` - // Estimated: `9627` - // Minimum execution time: 40_034_000 picoseconds. - Weight::from_parts(40_402_000, 0) - .saturating_add(Weight::from_parts(0, 9627)) + // Estimated: `6078` + // Minimum execution time: 40_974_000 picoseconds. + Weight::from_parts(41_706_000, 0) + .saturating_add(Weight::from_parts(0, 6078)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -316,8 +317,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `277` // Estimated: `3549` - // Minimum execution time: 18_648_000 picoseconds. - Weight::from_parts(18_968_000, 0) + // Minimum execution time: 19_044_000 picoseconds. + Weight::from_parts(19_465_000, 0) .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(3)) @@ -330,8 +331,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `3549` - // Minimum execution time: 15_282_000 picoseconds. - Weight::from_parts(15_923_000, 0) + // Minimum execution time: 15_591_000 picoseconds. + Weight::from_parts(15_858_000, 0) .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -343,10 +344,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn lock_item_properties() -> Weight { // Proof Size summary in bytes: // Measured: `401` - // Estimated: `7047` - // Minimum execution time: 20_060_000 picoseconds. - Weight::from_parts(20_326_000, 0) - .saturating_add(Weight::from_parts(0, 7047)) + // Estimated: `3534` + // Minimum execution time: 20_831_000 picoseconds. + Weight::from_parts(21_121_000, 0) + .saturating_add(Weight::from_parts(0, 3534)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -363,10 +364,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `505` - // Estimated: `18078` - // Minimum execution time: 48_324_000 picoseconds. - Weight::from_parts(48_745_000, 0) - .saturating_add(Weight::from_parts(0, 18078)) + // Estimated: `3944` + // Minimum execution time: 50_650_000 picoseconds. + Weight::from_parts(51_315_000, 0) + .saturating_add(Weight::from_parts(0, 3944)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -377,10 +378,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn force_set_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `310` - // Estimated: `7493` - // Minimum execution time: 27_935_000 picoseconds. - Weight::from_parts(28_241_000, 0) - .saturating_add(Weight::from_parts(0, 7493)) + // Estimated: `3944` + // Minimum execution time: 28_244_000 picoseconds. + Weight::from_parts(28_627_000, 0) + .saturating_add(Weight::from_parts(0, 3944)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -395,10 +396,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn clear_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `949` - // Estimated: `14540` - // Minimum execution time: 44_972_000 picoseconds. - Weight::from_parts(45_618_000, 0) - .saturating_add(Weight::from_parts(0, 14540)) + // Estimated: `3944` + // Minimum execution time: 47_299_000 picoseconds. + Weight::from_parts(47_921_000, 0) + .saturating_add(Weight::from_parts(0, 3944)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -409,10 +410,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn approve_item_attributes() -> Weight { // Proof Size summary in bytes: // Measured: `347` - // Estimated: `8792` - // Minimum execution time: 19_246_000 picoseconds. - Weight::from_parts(19_715_000, 0) - .saturating_add(Weight::from_parts(0, 8792)) + // Estimated: `4466` + // Minimum execution time: 19_400_000 picoseconds. + Weight::from_parts(19_601_000, 0) + .saturating_add(Weight::from_parts(0, 4466)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -428,12 +429,12 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn cancel_item_attributes_approval(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `726 + n * (398 ±0)` - // Estimated: `16329 + n * (2954 ±0)` - // Minimum execution time: 28_372_000 picoseconds. - Weight::from_parts(28_671_000, 0) - .saturating_add(Weight::from_parts(0, 16329)) - // Standard Error: 3_479 - .saturating_add(Weight::from_parts(5_527_336, 0).saturating_mul(n.into())) + // Estimated: `4466 + n * (2954 ±0)` + // Minimum execution time: 28_552_000 picoseconds. + Weight::from_parts(28_822_000, 0) + .saturating_add(Weight::from_parts(0, 4466)) + // Standard Error: 3_265 + .saturating_add(Weight::from_parts(5_570_824, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2)) @@ -453,10 +454,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `505` - // Estimated: `17946` - // Minimum execution time: 39_852_000 picoseconds. - Weight::from_parts(40_280_000, 0) - .saturating_add(Weight::from_parts(0, 17946)) + // Estimated: `3812` + // Minimum execution time: 42_425_000 picoseconds. + Weight::from_parts(42_883_000, 0) + .saturating_add(Weight::from_parts(0, 3812)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -471,10 +472,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn clear_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `815` - // Estimated: `14408` - // Minimum execution time: 36_829_000 picoseconds. - Weight::from_parts(37_513_000, 0) - .saturating_add(Weight::from_parts(0, 14408)) + // Estimated: `3812` + // Minimum execution time: 40_219_000 picoseconds. + Weight::from_parts(41_709_000, 0) + .saturating_add(Weight::from_parts(0, 3812)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -489,10 +490,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `364` - // Estimated: `14380` - // Minimum execution time: 35_398_000 picoseconds. - Weight::from_parts(35_809_000, 0) - .saturating_add(Weight::from_parts(0, 14380)) + // Estimated: `3759` + // Minimum execution time: 39_376_000 picoseconds. + Weight::from_parts(39_895_000, 0) + .saturating_add(Weight::from_parts(0, 3759)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -507,10 +508,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `682` - // Estimated: `14380` - // Minimum execution time: 33_699_000 picoseconds. - Weight::from_parts(34_170_000, 0) - .saturating_add(Weight::from_parts(0, 14380)) + // Estimated: `3759` + // Minimum execution time: 38_414_000 picoseconds. + Weight::from_parts(38_627_000, 0) + .saturating_add(Weight::from_parts(0, 3759)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -521,10 +522,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn approve_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `376` - // Estimated: `7864` - // Minimum execution time: 21_789_000 picoseconds. - Weight::from_parts(22_454_000, 0) - .saturating_add(Weight::from_parts(0, 7864)) + // Estimated: `4326` + // Minimum execution time: 22_896_000 picoseconds. + Weight::from_parts(23_137_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -534,8 +535,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `384` // Estimated: `4326` - // Minimum execution time: 19_532_000 picoseconds. - Weight::from_parts(19_761_000, 0) + // Minimum execution time: 20_602_000 picoseconds. + Weight::from_parts(20_869_000, 0) .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -546,8 +547,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `384` // Estimated: `4326` - // Minimum execution time: 18_620_000 picoseconds. - Weight::from_parts(19_014_000, 0) + // Minimum execution time: 19_415_000 picoseconds. + Weight::from_parts(19_594_000, 0) .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -558,8 +559,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3517` - // Minimum execution time: 16_491_000 picoseconds. - Weight::from_parts(16_888_000, 0) + // Minimum execution time: 16_784_000 picoseconds. + Weight::from_parts(17_133_000, 0) .saturating_add(Weight::from_parts(0, 3517)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -571,10 +572,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: // Measured: `306` - // Estimated: `7087` - // Minimum execution time: 19_929_000 picoseconds. - Weight::from_parts(20_170_000, 0) - .saturating_add(Weight::from_parts(0, 7087)) + // Estimated: `3549` + // Minimum execution time: 20_391_000 picoseconds. + Weight::from_parts(20_710_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -585,10 +586,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn update_mint_settings() -> Weight { // Proof Size summary in bytes: // Measured: `289` - // Estimated: `7072` - // Minimum execution time: 19_500_000 picoseconds. - Weight::from_parts(19_839_000, 0) - .saturating_add(Weight::from_parts(0, 7072)) + // Estimated: `3538` + // Minimum execution time: 19_989_000 picoseconds. + Weight::from_parts(20_179_000, 0) + .saturating_add(Weight::from_parts(0, 3538)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -603,10 +604,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_price() -> Weight { // Proof Size summary in bytes: // Measured: `484` - // Estimated: `11377` - // Minimum execution time: 24_542_000 picoseconds. - Weight::from_parts(24_916_000, 0) - .saturating_add(Weight::from_parts(0, 11377)) + // Estimated: `4326` + // Minimum execution time: 24_308_000 picoseconds. + Weight::from_parts(24_721_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -627,10 +628,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn buy_item() -> Weight { // Proof Size summary in bytes: // Measured: `671` - // Estimated: `18480` - // Minimum execution time: 44_311_000 picoseconds. - Weight::from_parts(45_789_000, 0) - .saturating_add(Weight::from_parts(0, 18480)) + // Estimated: `4326` + // Minimum execution time: 45_626_000 picoseconds. + Weight::from_parts(46_030_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -639,11 +640,11 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_523_000 picoseconds. - Weight::from_parts(4_349_031, 0) + // Minimum execution time: 2_654_000 picoseconds. + Weight::from_parts(4_301_940, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 10_427 - .saturating_add(Weight::from_parts(3_718_129, 0).saturating_mul(n.into())) + // Standard Error: 9_223 + .saturating_add(Weight::from_parts(3_945_966, 0).saturating_mul(n.into())) } /// Storage: Nfts Item (r:2 w:0) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) @@ -653,8 +654,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `460` // Estimated: `7662` - // Minimum execution time: 23_007_000 picoseconds. - Weight::from_parts(23_305_000, 0) + // Minimum execution time: 23_071_000 picoseconds. + Weight::from_parts(23_535_000, 0) .saturating_add(Weight::from_parts(0, 7662)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -666,10 +667,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn cancel_swap() -> Weight { // Proof Size summary in bytes: // Measured: `479` - // Estimated: `7862` - // Minimum execution time: 21_173_000 picoseconds. - Weight::from_parts(21_451_000, 0) - .saturating_add(Weight::from_parts(0, 7862)) + // Estimated: `4326` + // Minimum execution time: 21_554_000 picoseconds. + Weight::from_parts(21_941_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -690,10 +691,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn claim_swap() -> Weight { // Proof Size summary in bytes: // Measured: `800` - // Estimated: `24321` - // Minimum execution time: 72_213_000 picoseconds. - Weight::from_parts(73_029_000, 0) - .saturating_add(Weight::from_parts(0, 24321)) + // Estimated: `7662` + // Minimum execution time: 74_272_000 picoseconds. + Weight::from_parts(75_374_000, 0) + .saturating_add(Weight::from_parts(0, 7662)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(10)) } @@ -719,12 +720,12 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn mint_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `524` - // Estimated: `29399 + n * (2954 ±0)` - // Minimum execution time: 125_518_000 picoseconds. - Weight::from_parts(129_781_908, 0) - .saturating_add(Weight::from_parts(0, 29399)) - // Standard Error: 21_840 - .saturating_add(Weight::from_parts(26_756_136, 0).saturating_mul(n.into())) + // Estimated: `6078 + n * (2954 ±0)` + // Minimum execution time: 133_545_000 picoseconds. + Weight::from_parts(137_797_962, 0) + .saturating_add(Weight::from_parts(0, 6078)) + // Standard Error: 33_124 + .saturating_add(Weight::from_parts(29_785_862, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6)) @@ -747,12 +748,12 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_attributes_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `554` - // Estimated: `20462 + n * (2954 ±0)` - // Minimum execution time: 76_133_000 picoseconds. - Weight::from_parts(85_559_988, 0) - .saturating_add(Weight::from_parts(0, 20462)) - // Standard Error: 49_851 - .saturating_add(Weight::from_parts(26_551_215, 0).saturating_mul(n.into())) + // Estimated: `4466 + n * (2954 ±0)` + // Minimum execution time: 77_475_000 picoseconds. + Weight::from_parts(88_353_947, 0) + .saturating_add(Weight::from_parts(0, 4466)) + // Standard Error: 60_491 + .saturating_add(Weight::from_parts(29_507_037, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2)) diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_proxy.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_proxy.rs similarity index 72% rename from parachains/runtimes/assets/westmint/src/weights/pallet_proxy.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_proxy.rs index fa22bf7bf68..27680ed3ea0 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_proxy.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_proxy.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_proxy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_proxy @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_proxy.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_proxy.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_proxy`. pub struct WeightInfo(PhantomData); @@ -54,11 +55,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 16_562_000 picoseconds. - Weight::from_parts(17_305_360, 0) + // Minimum execution time: 17_994_000 picoseconds. + Weight::from_parts(18_404_764, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_081 - .saturating_add(Weight::from_parts(37_267, 0).saturating_mul(p.into())) + // Standard Error: 931 + .saturating_add(Weight::from_parts(29_489, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) } /// Storage: Proxy Proxies (r:1 w:0) @@ -72,14 +73,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn proxy_announced(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `454 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `13997` - // Minimum execution time: 35_181_000 picoseconds. - Weight::from_parts(34_864_956, 0) - .saturating_add(Weight::from_parts(0, 13997)) - // Standard Error: 5_023 - .saturating_add(Weight::from_parts(158_916, 0).saturating_mul(a.into())) - // Standard Error: 5_189 - .saturating_add(Weight::from_parts(60_136, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 39_788_000 picoseconds. + Weight::from_parts(39_231_218, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_373 + .saturating_add(Weight::from_parts(144_577, 0).saturating_mul(a.into())) + // Standard Error: 1_418 + .saturating_add(Weight::from_parts(39_464, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -92,14 +93,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn remove_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `369 + a * (68 ±0)` - // Estimated: `9291` - // Minimum execution time: 21_758_000 picoseconds. - Weight::from_parts(23_149_882, 0) - .saturating_add(Weight::from_parts(0, 9291)) - // Standard Error: 1_877 - .saturating_add(Weight::from_parts(145_269, 0).saturating_mul(a.into())) - // Standard Error: 1_940 - .saturating_add(Weight::from_parts(5_129, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 25_778_000 picoseconds. + Weight::from_parts(26_117_943, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_161 + .saturating_add(Weight::from_parts(143_478, 0).saturating_mul(a.into())) + // Standard Error: 1_200 + .saturating_add(Weight::from_parts(8_492, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -112,14 +113,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn reject_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `369 + a * (68 ±0)` - // Estimated: `9291` - // Minimum execution time: 22_076_000 picoseconds. - Weight::from_parts(22_959_374, 0) - .saturating_add(Weight::from_parts(0, 9291)) - // Standard Error: 1_377 - .saturating_add(Weight::from_parts(146_462, 0).saturating_mul(a.into())) - // Standard Error: 1_423 - .saturating_add(Weight::from_parts(11_551, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 25_448_000 picoseconds. + Weight::from_parts(26_025_080, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_079 + .saturating_add(Weight::from_parts(146_383, 0).saturating_mul(a.into())) + // Standard Error: 1_115 + .saturating_add(Weight::from_parts(7_614, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -134,14 +135,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn announce(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `386 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `13997` - // Minimum execution time: 30_751_000 picoseconds. - Weight::from_parts(31_929_484, 0) - .saturating_add(Weight::from_parts(0, 13997)) - // Standard Error: 2_087 - .saturating_add(Weight::from_parts(147_703, 0).saturating_mul(a.into())) - // Standard Error: 2_156 - .saturating_add(Weight::from_parts(27_798, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 35_200_000 picoseconds. + Weight::from_parts(34_858_670, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_692 + .saturating_add(Weight::from_parts(148_578, 0).saturating_mul(a.into())) + // Standard Error: 1_748 + .saturating_add(Weight::from_parts(38_530, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -152,11 +153,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 23_700_000 picoseconds. - Weight::from_parts(24_509_575, 0) + // Minimum execution time: 26_373_000 picoseconds. + Weight::from_parts(27_005_379, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_699 - .saturating_add(Weight::from_parts(51_275, 0).saturating_mul(p.into())) + // Standard Error: 844 + .saturating_add(Weight::from_parts(58_125, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -167,11 +168,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 23_289_000 picoseconds. - Weight::from_parts(24_453_360, 0) + // Minimum execution time: 26_455_000 picoseconds. + Weight::from_parts(27_435_800, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_690 - .saturating_add(Weight::from_parts(62_718, 0).saturating_mul(p.into())) + // Standard Error: 1_489 + .saturating_add(Weight::from_parts(57_697, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -182,11 +183,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 18_877_000 picoseconds. - Weight::from_parts(19_780_042, 0) + // Minimum execution time: 23_169_000 picoseconds. + Weight::from_parts(23_866_116, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_171 - .saturating_add(Weight::from_parts(20_282, 0).saturating_mul(p.into())) + // Standard Error: 788 + .saturating_add(Weight::from_parts(25_795, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -197,11 +198,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `139` // Estimated: `4706` - // Minimum execution time: 25_354_000 picoseconds. - Weight::from_parts(26_362_285, 0) + // Minimum execution time: 28_172_000 picoseconds. + Weight::from_parts(28_972_303, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_459 - .saturating_add(Weight::from_parts(1_330, 0).saturating_mul(p.into())) + // Standard Error: 934 + .saturating_add(Weight::from_parts(10_208, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -212,11 +213,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `164 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 20_057_000 picoseconds. - Weight::from_parts(20_844_608, 0) + // Minimum execution time: 24_193_000 picoseconds. + Weight::from_parts(25_184_514, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_336 - .saturating_add(Weight::from_parts(27_855, 0).saturating_mul(p.into())) + // Standard Error: 3_667 + .saturating_add(Weight::from_parts(17_503, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_session.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_session.rs similarity index 80% rename from parachains/runtimes/assets/westmint/src/weights/pallet_session.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_session.rs index bb4705ace09..359ea9da901 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_session.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_session.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_session` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_session @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_session.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_session.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_session`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn set_keys() -> Weight { // Proof Size summary in bytes: // Measured: `270` - // Estimated: `7470` - // Minimum execution time: 17_394_000 picoseconds. - Weight::from_parts(17_828_000, 0) - .saturating_add(Weight::from_parts(0, 7470)) + // Estimated: `3735` + // Minimum execution time: 17_623_000 picoseconds. + Weight::from_parts(17_946_000, 0) + .saturating_add(Weight::from_parts(0, 3735)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -68,10 +69,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn purge_keys() -> Weight { // Proof Size summary in bytes: // Measured: `242` - // Estimated: `3949` - // Minimum execution time: 13_334_000 picoseconds. - Weight::from_parts(13_634_000, 0) - .saturating_add(Weight::from_parts(0, 3949)) + // Estimated: `3707` + // Minimum execution time: 13_059_000 picoseconds. + Weight::from_parts(13_341_000, 0) + .saturating_add(Weight::from_parts(0, 3707)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_timestamp.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_timestamp.rs similarity index 80% rename from parachains/runtimes/assets/statemint/src/weights/pallet_timestamp.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_timestamp.rs index 75d47ae1fd6..ef8da150383 100644 --- a/parachains/runtimes/assets/statemint/src/weights/pallet_timestamp.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_timestamp.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemint-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_timestamp @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/pallet_timestamp.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_timestamp.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_timestamp`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_timestamp::WeightInfo for WeightInfo { fn set() -> Weight { // Proof Size summary in bytes: // Measured: `86` - // Estimated: `2986` - // Minimum execution time: 9_174_000 picoseconds. - Weight::from_parts(9_644_000, 0) - .saturating_add(Weight::from_parts(0, 2986)) + // Estimated: `1493` + // Minimum execution time: 9_168_000 picoseconds. + Weight::from_parts(9_563_000, 0) + .saturating_add(Weight::from_parts(0, 1493)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +66,8 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `57` // Estimated: `0` - // Minimum execution time: 3_121_000 picoseconds. - Weight::from_parts(3_205_000, 0) + // Minimum execution time: 3_146_000 picoseconds. + Weight::from_parts(3_238_000, 0) .saturating_add(Weight::from_parts(0, 0)) } } diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_uniques.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_uniques.rs similarity index 80% rename from parachains/runtimes/assets/westmint/src/weights/pallet_uniques.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_uniques.rs index c32eebdc908..3c9372e2e5f 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_uniques.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_uniques.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_uniques` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_uniques @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_uniques.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_uniques.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_uniques`. pub struct WeightInfo(PhantomData); @@ -55,8 +56,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3643` - // Minimum execution time: 26_855_000 picoseconds. - Weight::from_parts(27_393_000, 0) + // Minimum execution time: 31_630_000 picoseconds. + Weight::from_parts(32_135_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -69,8 +70,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3643` - // Minimum execution time: 15_006_000 picoseconds. - Weight::from_parts(15_389_000, 0) + // Minimum execution time: 15_573_000 picoseconds. + Weight::from_parts(15_971_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -96,17 +97,17 @@ impl pallet_uniques::WeightInfo for WeightInfo { /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `257 + n * (76 ±0) + m * (56 ±0) + a * (107 ±0)` - // Estimated: `9210 + a * (2647 ±0) + n * (2597 ±0) + m * (2662 ±0)` - // Minimum execution time: 2_360_211_000 picoseconds. - Weight::from_parts(2_383_759_000, 0) - .saturating_add(Weight::from_parts(0, 9210)) - // Standard Error: 24_849 - .saturating_add(Weight::from_parts(6_304_424, 0).saturating_mul(n.into())) - // Standard Error: 24_849 - .saturating_add(Weight::from_parts(253_862, 0).saturating_mul(m.into())) - // Standard Error: 24_849 - .saturating_add(Weight::from_parts(324_295, 0).saturating_mul(a.into())) + // Measured: `257 + a * (107 ±0) + m * (56 ±0) + n * (76 ±0)` + // Estimated: `3643 + a * (2647 ±0) + m * (2662 ±0) + n * (2597 ±0)` + // Minimum execution time: 2_397_568_000 picoseconds. + Weight::from_parts(2_408_280_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) + // Standard Error: 24_497 + .saturating_add(Weight::from_parts(6_425_310, 0).saturating_mul(n.into())) + // Standard Error: 24_497 + .saturating_add(Weight::from_parts(252_611, 0).saturating_mul(m.into())) + // Standard Error: 24_497 + .saturating_add(Weight::from_parts(313_131, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) @@ -116,8 +117,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(m.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) .saturating_add(Weight::from_parts(0, 2647).saturating_mul(a.into())) - .saturating_add(Weight::from_parts(0, 2597).saturating_mul(n.into())) .saturating_add(Weight::from_parts(0, 2662).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 2597).saturating_mul(n.into())) } /// Storage: Uniques Asset (r:1 w:1) /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) @@ -130,10 +131,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn mint() -> Weight { // Proof Size summary in bytes: // Measured: `282` - // Estimated: `10719` - // Minimum execution time: 33_245_000 picoseconds. - Weight::from_parts(33_516_000, 0) - .saturating_add(Weight::from_parts(0, 10719)) + // Estimated: `3643` + // Minimum execution time: 37_233_000 picoseconds. + Weight::from_parts(37_731_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -148,10 +149,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn burn() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 34_237_000 picoseconds. - Weight::from_parts(34_725_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 38_493_000 picoseconds. + Weight::from_parts(38_939_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -166,10 +167,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn transfer() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 27_588_000 picoseconds. - Weight::from_parts(27_994_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 28_125_000 picoseconds. + Weight::from_parts(28_354_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -181,12 +182,12 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `738 + i * (76 ±0)` - // Estimated: `4633 + i * (2597 ±0)` - // Minimum execution time: 15_958_000 picoseconds. - Weight::from_parts(16_175_000, 0) - .saturating_add(Weight::from_parts(0, 4633)) - // Standard Error: 12_904 - .saturating_add(Weight::from_parts(13_261_405, 0).saturating_mul(i.into())) + // Estimated: `3643 + i * (2597 ±0)` + // Minimum execution time: 16_016_000 picoseconds. + Weight::from_parts(16_298_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) + // Standard Error: 12_979 + .saturating_add(Weight::from_parts(15_665_767, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -200,10 +201,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn freeze() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 19_124_000 picoseconds. - Weight::from_parts(19_432_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 19_730_000 picoseconds. + Weight::from_parts(20_008_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -214,10 +215,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn thaw() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 19_725_000 picoseconds. - Weight::from_parts(19_903_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 19_683_000 picoseconds. + Weight::from_parts(20_096_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -227,8 +228,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 15_091_000 picoseconds. - Weight::from_parts(15_405_000, 0) + // Minimum execution time: 14_854_000 picoseconds. + Weight::from_parts(15_217_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -239,8 +240,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 14_440_000 picoseconds. - Weight::from_parts(14_836_000, 0) + // Minimum execution time: 14_659_000 picoseconds. + Weight::from_parts(15_072_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -254,10 +255,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn transfer_ownership() -> Weight { // Proof Size summary in bytes: // Measured: `356` - // Estimated: `7160` - // Minimum execution time: 22_729_000 picoseconds. - Weight::from_parts(23_039_000, 0) - .saturating_add(Weight::from_parts(0, 7160)) + // Estimated: `3643` + // Minimum execution time: 23_412_000 picoseconds. + Weight::from_parts(23_634_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -267,8 +268,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 15_506_000 picoseconds. - Weight::from_parts(15_864_000, 0) + // Minimum execution time: 15_816_000 picoseconds. + Weight::from_parts(16_303_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -281,8 +282,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 18_244_000 picoseconds. - Weight::from_parts(18_591_000, 0) + // Minimum execution time: 18_056_000 picoseconds. + Weight::from_parts(18_315_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -296,10 +297,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `559` - // Estimated: `10932` - // Minimum execution time: 37_528_000 picoseconds. - Weight::from_parts(38_282_000, 0) - .saturating_add(Weight::from_parts(0, 10932)) + // Estimated: `3652` + // Minimum execution time: 41_560_000 picoseconds. + Weight::from_parts(41_962_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -312,10 +313,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn clear_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `756` - // Estimated: `10932` - // Minimum execution time: 36_654_000 picoseconds. - Weight::from_parts(36_947_000, 0) - .saturating_add(Weight::from_parts(0, 10932)) + // Estimated: `3652` + // Minimum execution time: 40_334_000 picoseconds. + Weight::from_parts(40_590_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -326,10 +327,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `348` - // Estimated: `7295` - // Minimum execution time: 29_703_000 picoseconds. - Weight::from_parts(30_032_000, 0) - .saturating_add(Weight::from_parts(0, 7295)) + // Estimated: `3652` + // Minimum execution time: 33_142_000 picoseconds. + Weight::from_parts(33_683_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -340,10 +341,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn clear_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `559` - // Estimated: `7295` - // Minimum execution time: 29_941_000 picoseconds. - Weight::from_parts(30_222_000, 0) - .saturating_add(Weight::from_parts(0, 7295)) + // Estimated: `3652` + // Minimum execution time: 32_918_000 picoseconds. + Weight::from_parts(33_270_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -354,10 +355,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `282` - // Estimated: `7275` - // Minimum execution time: 28_466_000 picoseconds. - Weight::from_parts(29_037_000, 0) - .saturating_add(Weight::from_parts(0, 7275)) + // Estimated: `3643` + // Minimum execution time: 33_736_000 picoseconds. + Weight::from_parts(34_148_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -368,10 +369,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `473` - // Estimated: `7275` - // Minimum execution time: 27_072_000 picoseconds. - Weight::from_parts(27_514_000, 0) - .saturating_add(Weight::from_parts(0, 7275)) + // Estimated: `3643` + // Minimum execution time: 31_648_000 picoseconds. + Weight::from_parts(32_074_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -382,10 +383,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn approve_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 20_791_000 picoseconds. - Weight::from_parts(21_072_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 21_429_000 picoseconds. + Weight::from_parts(21_830_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -396,10 +397,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn cancel_approval() -> Weight { // Proof Size summary in bytes: // Measured: `461` - // Estimated: `7230` - // Minimum execution time: 20_467_000 picoseconds. - Weight::from_parts(20_842_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 21_317_000 picoseconds. + Weight::from_parts(21_565_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -409,8 +410,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3517` - // Minimum execution time: 16_836_000 picoseconds. - Weight::from_parts(17_418_000, 0) + // Minimum execution time: 17_070_000 picoseconds. + Weight::from_parts(17_433_000, 0) .saturating_add(Weight::from_parts(0, 3517)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -422,10 +423,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: // Measured: `282` - // Estimated: `7132` - // Minimum execution time: 17_721_000 picoseconds. - Weight::from_parts(18_109_000, 0) - .saturating_add(Weight::from_parts(0, 7132)) + // Estimated: `3643` + // Minimum execution time: 17_943_000 picoseconds. + Weight::from_parts(18_307_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -437,8 +438,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `259` // Estimated: `3587` - // Minimum execution time: 17_599_000 picoseconds. - Weight::from_parts(17_802_000, 0) + // Minimum execution time: 17_872_000 picoseconds. + Weight::from_parts(18_029_000, 0) .saturating_add(Weight::from_parts(0, 3587)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -454,10 +455,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn buy_item() -> Weight { // Proof Size summary in bytes: // Measured: `540` - // Estimated: `10784` - // Minimum execution time: 38_642_000 picoseconds. - Weight::from_parts(39_168_000, 0) - .saturating_add(Weight::from_parts(0, 10784)) + // Estimated: `3643` + // Minimum execution time: 39_380_000 picoseconds. + Weight::from_parts(40_347_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_utility.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_utility.rs similarity index 71% rename from parachains/runtimes/assets/statemine/src/weights/pallet_utility.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_utility.rs index 25a8f1375d0..225e5cf0872 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_utility.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_utility.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_utility @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_utility.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_utility.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_utility`. pub struct WeightInfo(PhantomData); @@ -52,18 +53,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_113_000 picoseconds. - Weight::from_parts(38_041_346, 0) + // Minimum execution time: 7_460_000 picoseconds. + Weight::from_parts(8_335_963, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 4_785 - .saturating_add(Weight::from_parts(4_680_352, 0).saturating_mul(c.into())) + // Standard Error: 3_566 + .saturating_add(Weight::from_parts(6_080_076, 0).saturating_mul(c.into())) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_441_000 picoseconds. - Weight::from_parts(5_594_000, 0) + // Minimum execution time: 6_272_000 picoseconds. + Weight::from_parts(6_403_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -71,18 +72,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_203_000 picoseconds. - Weight::from_parts(18_311_542, 0) + // Minimum execution time: 7_570_000 picoseconds. + Weight::from_parts(18_080_572, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_281 - .saturating_add(Weight::from_parts(4_950_166, 0).saturating_mul(c.into())) + // Standard Error: 5_851 + .saturating_add(Weight::from_parts(6_351_469, 0).saturating_mul(c.into())) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_631_000 picoseconds. - Weight::from_parts(9_881_000, 0) + // Minimum execution time: 10_413_000 picoseconds. + Weight::from_parts(10_584_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -90,10 +91,10 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_146_000 picoseconds. - Weight::from_parts(22_172_240, 0) + // Minimum execution time: 7_470_000 picoseconds. + Weight::from_parts(4_574_861, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_023 - .saturating_add(Weight::from_parts(4_688_391, 0).saturating_mul(c.into())) + // Standard Error: 3_330 + .saturating_add(Weight::from_parts(6_093_390, 0).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_xcm.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_xcm.rs similarity index 84% rename from parachains/runtimes/assets/statemine/src/weights/pallet_xcm.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_xcm.rs index e2ff9a974b5..4f4bb37d748 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_xcm.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_xcm.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_xcm @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_xcm.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_xcm.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); @@ -60,10 +61,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn send() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `9780` - // Minimum execution time: 28_004_000 picoseconds. - Weight::from_parts(28_341_000, 0) - .saturating_add(Weight::from_parts(0, 9780)) + // Estimated: `3540` + // Minimum execution time: 29_342_000 picoseconds. + Weight::from_parts(29_952_000, 0) + .saturating_add(Weight::from_parts(0, 3540)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +74,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1489` - // Minimum execution time: 23_734_000 picoseconds. - Weight::from_parts(24_091_000, 0) + // Minimum execution time: 28_744_000 picoseconds. + Weight::from_parts(29_193_000, 0) .saturating_add(Weight::from_parts(0, 1489)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -84,8 +85,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1489` - // Minimum execution time: 19_172_000 picoseconds. - Weight::from_parts(19_439_000, 0) + // Minimum execution time: 21_757_000 picoseconds. + Weight::from_parts(22_088_000, 0) .saturating_add(Weight::from_parts(0, 1489)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -105,8 +106,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 10_181_000 picoseconds. - Weight::from_parts(10_441_000, 0) + // Minimum execution time: 10_671_000 picoseconds. + Weight::from_parts(10_948_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -116,8 +117,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_092_000 picoseconds. - Weight::from_parts(3_217_000, 0) + // Minimum execution time: 3_132_000 picoseconds. + Weight::from_parts(3_374_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -140,10 +141,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `14955` - // Minimum execution time: 36_167_000 picoseconds. - Weight::from_parts(37_036_000, 0) - .saturating_add(Weight::from_parts(0, 14955)) + // Estimated: `3540` + // Minimum execution time: 33_780_000 picoseconds. + Weight::from_parts(34_531_000, 0) + .saturating_add(Weight::from_parts(0, 3540)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -164,19 +165,21 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `257` - // Estimated: `14669` - // Minimum execution time: 39_341_000 picoseconds. - Weight::from_parts(40_254_000, 0) - .saturating_add(Weight::from_parts(0, 14669)) + // Estimated: `3722` + // Minimum execution time: 35_215_000 picoseconds. + Weight::from_parts(35_685_000, 0) + .saturating_add(Weight::from_parts(0, 3722)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: PolkadotXcm XcmExecutionSuspended (r:0 w:1) + /// Proof Skipped: PolkadotXcm XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured) fn force_suspension() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_092_000 picoseconds. - Weight::from_parts(3_217_000, 0) + // Minimum execution time: 3_252_000 picoseconds. + Weight::from_parts(3_392_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -186,8 +189,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `129` // Estimated: `11019` - // Minimum execution time: 20_159_000 picoseconds. - Weight::from_parts(20_621_000, 0) + // Minimum execution time: 17_330_000 picoseconds. + Weight::from_parts(17_730_000, 0) .saturating_add(Weight::from_parts(0, 11019)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -198,8 +201,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `133` // Estimated: `11023` - // Minimum execution time: 20_095_000 picoseconds. - Weight::from_parts(20_335_000, 0) + // Minimum execution time: 17_129_000 picoseconds. + Weight::from_parts(17_665_000, 0) .saturating_add(Weight::from_parts(0, 11023)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -210,8 +213,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `140` // Estimated: `13505` - // Minimum execution time: 20_826_000 picoseconds. - Weight::from_parts(21_160_000, 0) + // Minimum execution time: 18_220_000 picoseconds. + Weight::from_parts(18_764_000, 0) .saturating_add(Weight::from_parts(0, 13505)) .saturating_add(T::DbWeight::get().reads(5)) } @@ -230,10 +233,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn notify_current_targets() -> Weight { // Proof Size summary in bytes: // Measured: `142` - // Estimated: `16197` - // Minimum execution time: 38_595_000 picoseconds. - Weight::from_parts(39_178_000, 0) - .saturating_add(Weight::from_parts(0, 16197)) + // Estimated: `6082` + // Minimum execution time: 31_356_000 picoseconds. + Weight::from_parts(31_850_000, 0) + .saturating_add(Weight::from_parts(0, 6082)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -243,8 +246,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `172` // Estimated: `8587` - // Minimum execution time: 11_391_000 picoseconds. - Weight::from_parts(11_704_000, 0) + // Minimum execution time: 9_299_000 picoseconds. + Weight::from_parts(9_515_000, 0) .saturating_add(Weight::from_parts(0, 8587)) .saturating_add(T::DbWeight::get().reads(3)) } @@ -254,8 +257,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `140` // Estimated: `11030` - // Minimum execution time: 22_506_000 picoseconds. - Weight::from_parts(23_076_000, 0) + // Minimum execution time: 17_472_000 picoseconds. + Weight::from_parts(18_170_000, 0) .saturating_add(Weight::from_parts(0, 11030)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -275,10 +278,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: // Measured: `146` - // Estimated: `21171` - // Minimum execution time: 47_662_000 picoseconds. - Weight::from_parts(48_167_000, 0) - .saturating_add(Weight::from_parts(0, 21171)) + // Estimated: `11036` + // Minimum execution time: 39_134_000 picoseconds. + Weight::from_parts(39_847_000, 0) + .saturating_add(Weight::from_parts(0, 11036)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } diff --git a/parachains/runtimes/assets/statemine/src/weights/paritydb_weights.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/paritydb_weights.rs similarity index 100% rename from parachains/runtimes/assets/statemine/src/weights/paritydb_weights.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/paritydb_weights.rs diff --git a/parachains/runtimes/assets/statemine/src/weights/rocksdb_weights.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/rocksdb_weights.rs similarity index 100% rename from parachains/runtimes/assets/statemine/src/weights/rocksdb_weights.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/rocksdb_weights.rs diff --git a/parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/mod.rs similarity index 95% rename from parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/mod.rs index 5daa3acbcce..4bdda361a2b 100644 --- a/parachains/runtimes/assets/westmint/src/weights/xcm/mod.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/mod.rs @@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -53,19 +52,19 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } -pub struct WestmintXcmWeight(core::marker::PhantomData); -impl XcmWeightInfo for WestmintXcmWeight { +pub struct AssetHubKusamaXcmWeight(core::marker::PhantomData); +impl XcmWeightInfo for AssetHubKusamaXcmWeight { fn withdraw_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset()) } // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -123,7 +122,7 @@ impl XcmWeightInfo for WestmintXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } diff --git a/parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs similarity index 87% rename from parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 66f6bd713d5..d5dae072099 100644 --- a/parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -17,17 +17,17 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::fungible` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet // --template=./templates/xcm-bench-template.hbs -// --chain=westmint-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_xcm_benchmarks::fungible @@ -36,7 +36,7 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -54,8 +54,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `101` // Estimated: `3593` - // Minimum execution time: 22_591_000 picoseconds. - Weight::from_parts(23_052_000, 3593) + // Minimum execution time: 27_006_000 picoseconds. + Weight::from_parts(27_426_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +65,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `101` // Estimated: `6196` - // Minimum execution time: 32_036_000 picoseconds. - Weight::from_parts(32_396_000, 6196) + // Minimum execution time: 51_640_000 picoseconds. + Weight::from_parts(52_045_000, 6196) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -87,9 +87,9 @@ impl WeightInfo { pub fn transfer_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `176` - // Estimated: `17970` - // Minimum execution time: 58_331_000 picoseconds. - Weight::from_parts(59_048_000, 17970) + // Estimated: `6196` + // Minimum execution time: 75_401_000 picoseconds. + Weight::from_parts(75_956_000, 6196) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -97,8 +97,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_474_000 picoseconds. - Weight::from_parts(4_577_000, 0) + // Minimum execution time: 4_767_000 picoseconds. + Weight::from_parts(4_848_000, 0) } // Storage: System Account (r:1 w:1) // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) @@ -106,8 +106,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 28_611_000 picoseconds. - Weight::from_parts(28_992_000, 3593) + // Minimum execution time: 29_115_000 picoseconds. + Weight::from_parts(29_369_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -128,9 +128,9 @@ impl WeightInfo { pub fn deposit_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `14862` - // Minimum execution time: 57_179_000 picoseconds. - Weight::from_parts(58_149_000, 14862) + // Estimated: `3593` + // Minimum execution time: 54_197_000 picoseconds. + Weight::from_parts(54_906_000, 3593) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -149,9 +149,9 @@ impl WeightInfo { pub fn initiate_teleport() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 30_477_000 picoseconds. - Weight::from_parts(30_841_000, 11269) + // Estimated: `3540` + // Minimum execution time: 33_366_000 picoseconds. + Weight::from_parts(33_874_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs similarity index 80% rename from parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_generic.rs rename to parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 058f23631dd..d2b1221476a 100644 --- a/parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,17 +17,17 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet // --template=./templates/xcm-bench-template.hbs -// --chain=statemine-dev +// --chain=asset-hub-kusama-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_xcm_benchmarks::generic @@ -36,7 +36,7 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -63,9 +63,9 @@ impl WeightInfo { pub fn report_holding() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 367_337_000 picoseconds. - Weight::from_parts(368_530_000, 11269) + // Estimated: `3540` + // Minimum execution time: 473_259_000 picoseconds. + Weight::from_parts(474_680_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +73,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_121_000 picoseconds. - Weight::from_parts(4_318_000, 0) + // Minimum execution time: 4_502_000 picoseconds. + Weight::from_parts(4_557_000, 0) } // Storage: PolkadotXcm Queries (r:1 w:0) // Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) @@ -82,58 +82,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `69` // Estimated: `3534` - // Minimum execution time: 11_951_000 picoseconds. - Weight::from_parts(12_171_000, 3534) + // Minimum execution time: 11_743_000 picoseconds. + Weight::from_parts(12_010_000, 3534) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_626_000 picoseconds. - Weight::from_parts(13_891_000, 0) + // Minimum execution time: 15_514_000 picoseconds. + Weight::from_parts(15_798_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_276_000 picoseconds. - Weight::from_parts(4_444_000, 0) + // Minimum execution time: 4_760_000 picoseconds. + Weight::from_parts(4_935_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_969_000 picoseconds. - Weight::from_parts(3_090_000, 0) + // Minimum execution time: 3_093_000 picoseconds. + Weight::from_parts(3_170_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_148_000 picoseconds. - Weight::from_parts(3_252_000, 0) + // Minimum execution time: 3_160_000 picoseconds. + Weight::from_parts(3_324_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_027_000 picoseconds. - Weight::from_parts(3_081_000, 0) + // Minimum execution time: 3_076_000 picoseconds. + Weight::from_parts(3_135_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_863_000 picoseconds. - Weight::from_parts(3_934_000, 0) + // Minimum execution time: 4_245_000 picoseconds. + Weight::from_parts(4_344_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_013_000 picoseconds. - Weight::from_parts(3_115_000, 0) + // Minimum execution time: 3_093_000 picoseconds. + Weight::from_parts(3_170_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -150,9 +150,9 @@ impl WeightInfo { pub fn report_error() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 25_963_000 picoseconds. - Weight::from_parts(26_428_000, 11269) + // Estimated: `3540` + // Minimum execution time: 27_368_000 picoseconds. + Weight::from_parts(27_731_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -162,8 +162,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `126` // Estimated: `3591` - // Minimum execution time: 16_492_000 picoseconds. - Weight::from_parts(16_930_000, 3591) + // Minimum execution time: 17_634_000 picoseconds. + Weight::from_parts(18_068_000, 3591) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -171,8 +171,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_004_000 picoseconds. - Weight::from_parts(3_070_000, 0) + // Minimum execution time: 3_142_000 picoseconds. + Weight::from_parts(3_195_000, 0) } // Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1) // Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) @@ -189,9 +189,9 @@ impl WeightInfo { pub fn subscribe_version() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `13320` - // Minimum execution time: 28_804_000 picoseconds. - Weight::from_parts(29_543_000, 13320) + // Estimated: `3540` + // Minimum execution time: 28_784_000 picoseconds. + Weight::from_parts(29_246_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -201,8 +201,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_140_000 picoseconds. - Weight::from_parts(5_343_000, 0) + // Minimum execution time: 5_260_000 picoseconds. + Weight::from_parts(5_398_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainInfo ParachainId (r:1 w:0) @@ -220,9 +220,9 @@ impl WeightInfo { pub fn initiate_reserve_withdraw() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 410_533_000 picoseconds. - Weight::from_parts(412_507_000, 11269) + // Estimated: `3540` + // Minimum execution time: 528_849_000 picoseconds. + Weight::from_parts(530_923_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -230,36 +230,36 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 126_970_000 picoseconds. - Weight::from_parts(129_854_000, 0) + // Minimum execution time: 151_252_000 picoseconds. + Weight::from_parts(153_485_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_585_000 picoseconds. - Weight::from_parts(13_852_000, 0) + // Minimum execution time: 14_939_000 picoseconds. + Weight::from_parts(15_154_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_091_000 picoseconds. - Weight::from_parts(3_180_000, 0) + // Minimum execution time: 3_231_000 picoseconds. + Weight::from_parts(3_308_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_982_000 picoseconds. - Weight::from_parts(3_060_000, 0) + // Minimum execution time: 3_130_000 picoseconds. + Weight::from_parts(3_220_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_246_000 picoseconds. - Weight::from_parts(3_332_000, 0) + // Minimum execution time: 3_366_000 picoseconds. + Weight::from_parts(3_458_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -276,9 +276,9 @@ impl WeightInfo { pub fn query_pallet() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 29_939_000 picoseconds. - Weight::from_parts(30_426_000, 11269) + // Estimated: `3540` + // Minimum execution time: 31_212_000 picoseconds. + Weight::from_parts(31_656_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -286,8 +286,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_477_000 picoseconds. - Weight::from_parts(5_585_000, 0) + // Minimum execution time: 5_766_000 picoseconds. + Weight::from_parts(5_968_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -304,9 +304,9 @@ impl WeightInfo { pub fn report_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 26_349_000 picoseconds. - Weight::from_parts(26_957_000, 11269) + // Estimated: `3540` + // Minimum execution time: 27_754_000 picoseconds. + Weight::from_parts(28_064_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -314,35 +314,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_087_000 picoseconds. - Weight::from_parts(3_137_000, 0) + // Minimum execution time: 3_169_000 picoseconds. + Weight::from_parts(3_269_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_047_000 picoseconds. - Weight::from_parts(3_111_000, 0) + // Minimum execution time: 3_106_000 picoseconds. + Weight::from_parts(3_184_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_018_000 picoseconds. - Weight::from_parts(3_082_000, 0) + // Minimum execution time: 3_105_000 picoseconds. + Weight::from_parts(3_160_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_051_000 picoseconds. - Weight::from_parts(3_090_000, 0) + // Minimum execution time: 3_105_000 picoseconds. + Weight::from_parts(3_194_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_140_000 picoseconds. - Weight::from_parts(3_274_000, 0) + // Minimum execution time: 3_321_000 picoseconds. + Weight::from_parts(3_412_000, 0) } } diff --git a/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs new file mode 100644 index 00000000000..41f2424af4b --- /dev/null +++ b/parachains/runtimes/assets/asset-hub-kusama/src/xcm_config.rs @@ -0,0 +1,497 @@ +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::{ + AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, ForeignAssets, + ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, + TrustBackedAssetsInstance, WeightToFee, XcmpQueue, +}; +use assets_common::matching::{ + FromSiblingParachain, IsForeignConcreteAsset, StartsWith, StartsWithExplicitGlobalConsensus, +}; +use frame_support::{ + match_types, parameter_types, + traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, +}; +use frame_system::EnsureRoot; +use pallet_xcm::XcmPassthrough; +use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; +use polkadot_parachain::primitives::Sibling; +use sp_runtime::traits::ConvertInto; +use xcm::latest::prelude::*; +use xcm_builder::{ + AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, + DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FungiblesAdapter, IsConcrete, + LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, + UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, +}; +use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; + +parameter_types! { + pub const KsmLocation: MultiLocation = MultiLocation::parent(); + pub const RelayNetwork: Option = Some(NetworkId::Kusama); + pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); + pub UniversalLocation: InteriorMultiLocation = + X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); + pub UniversalLocationNetworkId: NetworkId = UniversalLocation::get().global_consensus().unwrap(); + pub TrustBackedAssetsPalletLocation: MultiLocation = + PalletInstance(::index() as u8).into(); + pub CheckingAccount: AccountId = PolkadotXcm::check_account(); + pub const GovernanceLocation: MultiLocation = MultiLocation::parent(); + pub const FellowshipLocation: MultiLocation = MultiLocation::parent(); +} + +/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used +/// when determining ownership of accounts for asset transacting and when attempting to use XCM +/// `Transact` in order to determine the dispatch Origin. +pub type LocationToAccountId = ( + // The parent (Relay-chain) origin converts to the parent `AccountId`. + ParentIsPreset, + // Sibling parachain origins convert to AccountId via the `ParaId::into`. + SiblingParachainConvertsVia, + // Straight up local `AccountId32` origins just alias directly to `AccountId`. + AccountId32Aliases, +); + +/// Means for transacting the native currency on this chain. +pub type CurrencyTransactor = CurrencyAdapter< + // Use this currency: + Balances, + // Use this currency when it is a fungible asset matching the given location or name: + IsConcrete, + // Convert an XCM MultiLocation into a local account id: + LocationToAccountId, + // Our chain's account ID type (we can't get away without mentioning it explicitly): + AccountId, + // We don't track any teleports of `Balances`. + (), +>; + +/// `AssetId/Balance` converter for `TrustBackedAssets` +pub type TrustBackedAssetsConvertedConcreteId = + assets_common::TrustBackedAssetsConvertedConcreteId; + +/// Means for transacting assets besides the native currency on this chain. +pub type FungiblesTransactor = FungiblesAdapter< + // Use this fungibles implementation: + Assets, + // Use this currency when it is a fungible asset matching the given location or name: + TrustBackedAssetsConvertedConcreteId, + // Convert an XCM MultiLocation into a local account id: + LocationToAccountId, + // Our chain's account ID type (we can't get away without mentioning it explicitly): + AccountId, + // We only want to allow teleports of known assets. We use non-zero issuance as an indication + // that this asset is known. + LocalMint>, + // The account to use for tracking teleports. + CheckingAccount, +>; + +/// `AssetId/Balance` converter for `TrustBackedAssets` +pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConvertedConcreteId< + ( + // Ignore `TrustBackedAssets` explicitly + StartsWith, + // Ignore assets that start explicitly with our `GlobalConsensus(NetworkId)`, means: + // - foreign assets from our consensus should be: `MultiLocation {parents: 1, X*(Parachain(xyz), ..)}` + // - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` won't be accepted here + StartsWithExplicitGlobalConsensus, + ), + Balance, +>; + +/// Means for transacting foreign assets from different global consensus. +pub type ForeignFungiblesTransactor = FungiblesAdapter< + // Use this fungibles implementation: + ForeignAssets, + // Use this currency when it is a fungible asset matching the given location or name: + ForeignAssetsConvertedConcreteId, + // Convert an XCM MultiLocation into a local account id: + LocationToAccountId, + // Our chain's account ID type (we can't get away without mentioning it explicitly): + AccountId, + // We dont need to check teleports here. + NoChecking, + // The account to use for tracking teleports. + CheckingAccount, +>; + +/// Means for transacting assets on this chain. +pub type AssetTransactors = (CurrencyTransactor, FungiblesTransactor, ForeignFungiblesTransactor); + +/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, +/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can +/// biases the kind of local `Origin` it will become. +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 + // foreign chains who want to have a local sovereign account on this chain which they control. + SovereignSignedViaLocation, + // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when + // recognised. + RelayChainAsNative, + // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when + // recognised. + SiblingParachainAsNative, + // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a + // transaction from the Root origin. + ParentAsSuperuser, + // Native signed account converter; this just converts an `AccountId32` origin into a normal + // `RuntimeOrigin::Signed` origin of the same 32-byte value. + SignedAccountId32AsNative, + // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. + XcmPassthrough, +); + +parameter_types! { + pub const MaxInstructions: u32 = 100; + pub const MaxAssetsIntoHolding: u32 = 64; + pub XcmAssetFeesReceiver: Option = Authorship::author(); +} + +match_types! { + pub type ParentOrParentsPlurality: impl Contains = { + MultiLocation { parents: 1, interior: Here } | + MultiLocation { parents: 1, interior: X1(Plurality { .. }) } + }; + pub type ParentOrSiblings: impl Contains = { + MultiLocation { parents: 1, interior: Here } | + MultiLocation { parents: 1, interior: X1(_) } + }; +} + +/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly +/// account for proof size weights. +/// +/// Calls that are allowed through this filter must: +/// 1. Have a fixed weight; +/// 2. Cannot lead to another call being made; +/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. +pub struct SafeCallFilter; +impl Contains for SafeCallFilter { + fn contains(call: &RuntimeCall) -> bool { + #[cfg(feature = "runtime-benchmarks")] + { + if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) { + return true + } + } + + matches!( + call, + RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. } | + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Assets( + pallet_assets::Call::create { .. } | + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::ForeignAssets( + pallet_assets::Call::create { .. } | + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::set_metadata { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::Nfts( + pallet_nfts::Call::create { .. } | + pallet_nfts::Call::force_create { .. } | + pallet_nfts::Call::destroy { .. } | + pallet_nfts::Call::mint { .. } | + pallet_nfts::Call::force_mint { .. } | + pallet_nfts::Call::burn { .. } | + pallet_nfts::Call::transfer { .. } | + pallet_nfts::Call::lock_item_transfer { .. } | + pallet_nfts::Call::unlock_item_transfer { .. } | + pallet_nfts::Call::lock_collection { .. } | + pallet_nfts::Call::transfer_ownership { .. } | + pallet_nfts::Call::set_team { .. } | + pallet_nfts::Call::force_collection_owner { .. } | + pallet_nfts::Call::force_collection_config { .. } | + pallet_nfts::Call::approve_transfer { .. } | + pallet_nfts::Call::cancel_approval { .. } | + pallet_nfts::Call::clear_all_transfer_approvals { .. } | + pallet_nfts::Call::lock_item_properties { .. } | + pallet_nfts::Call::set_attribute { .. } | + pallet_nfts::Call::force_set_attribute { .. } | + pallet_nfts::Call::clear_attribute { .. } | + pallet_nfts::Call::approve_item_attributes { .. } | + pallet_nfts::Call::cancel_item_attributes_approval { .. } | + pallet_nfts::Call::set_metadata { .. } | + pallet_nfts::Call::clear_metadata { .. } | + pallet_nfts::Call::set_collection_metadata { .. } | + pallet_nfts::Call::clear_collection_metadata { .. } | + pallet_nfts::Call::set_accept_ownership { .. } | + pallet_nfts::Call::set_collection_max_supply { .. } | + pallet_nfts::Call::update_mint_settings { .. } | + pallet_nfts::Call::set_price { .. } | + pallet_nfts::Call::buy_item { .. } | + pallet_nfts::Call::pay_tips { .. } | + pallet_nfts::Call::create_swap { .. } | + pallet_nfts::Call::cancel_swap { .. } | + pallet_nfts::Call::claim_swap { .. }, + ) | RuntimeCall::Uniques( + pallet_uniques::Call::create { .. } | + pallet_uniques::Call::force_create { .. } | + pallet_uniques::Call::destroy { .. } | + pallet_uniques::Call::mint { .. } | + pallet_uniques::Call::burn { .. } | + pallet_uniques::Call::transfer { .. } | + pallet_uniques::Call::freeze { .. } | + pallet_uniques::Call::thaw { .. } | + pallet_uniques::Call::freeze_collection { .. } | + pallet_uniques::Call::thaw_collection { .. } | + pallet_uniques::Call::transfer_ownership { .. } | + pallet_uniques::Call::set_team { .. } | + pallet_uniques::Call::approve_transfer { .. } | + pallet_uniques::Call::cancel_approval { .. } | + pallet_uniques::Call::force_item_status { .. } | + pallet_uniques::Call::set_attribute { .. } | + pallet_uniques::Call::clear_attribute { .. } | + pallet_uniques::Call::set_metadata { .. } | + pallet_uniques::Call::clear_metadata { .. } | + pallet_uniques::Call::set_collection_metadata { .. } | + pallet_uniques::Call::clear_collection_metadata { .. } | + pallet_uniques::Call::set_accept_ownership { .. } | + pallet_uniques::Call::set_collection_max_supply { .. } | + pallet_uniques::Call::set_price { .. } | + pallet_uniques::Call::buy_item { .. } + ) + ) + } +} + +pub type Barrier = TrailingSetTopicAsId< + DenyThenTry< + DenyReserveTransferToRelayChain, + ( + TakeWeightCredit, + // Expected responses are OK. + AllowKnownQueryResponses, + // Allow XCMs with some computed origins to pass through. + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Parent and its pluralities (i.e. governance bodies) get free execution. + AllowExplicitUnpaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, + ), + >, +>; + +pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentialDepositMultiplier< + Runtime, + WeightToFee, + pallet_assets::BalanceToAssetBalance, + TrustBackedAssetsInstance, +>; + +pub struct XcmConfig; +impl xcm_executor::Config for XcmConfig { + type RuntimeCall = RuntimeCall; + type XcmSender = XcmRouter; + type AssetTransactor = AssetTransactors; + type OriginConverter = XcmOriginToTransactDispatchOrigin; + // Asset Hub Kusama does not recognize a reserve location for any asset. This does not prevent + // Asset Hub acting _as_ a reserve location for KSM and assets created under `pallet-assets`. + // For KSM, users must use teleport where allowed (e.g. with the Relay Chain). + type IsReserve = (); + // We allow: + // - teleportation of KSM + // - teleportation of sibling parachain's assets (as ForeignCreators) + type IsTeleporter = ( + NativeAsset, + IsForeignConcreteAsset>>, + ); + type UniversalLocation = UniversalLocation; + type Barrier = Barrier; + type Weigher = WeightInfoBounds< + crate::weights::xcm::AssetHubKusamaXcmWeight, + RuntimeCall, + MaxInstructions, + >; + type Trader = ( + UsingComponents>, + cumulus_primitives_utility::TakeFirstAssetTrader< + AccountId, + AssetFeeAsExistentialDepositMultiplierFeeCharger, + TrustBackedAssetsConvertedConcreteId, + Assets, + cumulus_primitives_utility::XcmFeesTo32ByteAccount< + FungiblesTransactor, + AccountId, + XcmAssetFeesReceiver, + >, + >, + ); + type ResponseHandler = PolkadotXcm; + type AssetTrap = PolkadotXcm; + type AssetClaims = PolkadotXcm; + type SubscriptionService = PolkadotXcm; + type PalletInstancesInfo = AllPalletsWithSystem; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type AssetLocker = (); + type AssetExchanger = (); + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = WithOriginFilter; + type SafeCallFilter = SafeCallFilter; +} + +/// Converts a local signed origin into an XCM multilocation. +/// Forms the basis for local origins sending/executing XCMs. +pub type LocalOriginToLocation = SignedToAccountId32; + +/// The means for routing XCM messages which are not for local execution into the right message +/// queues. +pub type XcmRouter = WithUniqueTopic<( + // Two routers - use UMP to communicate with the relay chain: + cumulus_primitives_utility::ParentAsUmp, + // ..and XCMP to communicate with the sibling chains. + XcmpQueue, +)>; + +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parent.into()); +} + +impl pallet_xcm::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + // We want to disallow users sending (arbitrary) XCMs from this chain. + type SendXcmOrigin = EnsureXcmOrigin; + type XcmRouter = XcmRouter; + // We support local origins dispatching XCM executions in principle... + type ExecuteXcmOrigin = EnsureXcmOrigin; + // ... but disallow generic XCM execution. As a result only teleports and reserve transfers are allowed. + type XcmExecuteFilter = Nothing; + type XcmExecutor = XcmExecutor; + type XcmTeleportFilter = Everything; + type XcmReserveTransferFilter = Everything; + type Weigher = WeightInfoBounds< + crate::weights::xcm::AssetHubKusamaXcmWeight, + RuntimeCall, + MaxInstructions, + >; + + type UniversalLocation = UniversalLocation; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; + type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = LocationToAccountId; + type MaxLockers = ConstU32<8>; + type WeightInfo = crate::weights::pallet_xcm::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); +} + +impl cumulus_pallet_xcm::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = XcmExecutor; +} + +pub type ForeignCreatorsSovereignAccountOf = ( + SiblingParachainConvertsVia, + AccountId32Aliases, + ParentIsPreset, +); + +/// Simple conversion of `u32` into an `AssetId` for use in benchmarking. +pub struct XcmBenchmarkHelper; +#[cfg(feature = "runtime-benchmarks")] +impl pallet_assets::BenchmarkHelper for XcmBenchmarkHelper { + fn create_asset_id_parameter(id: u32) -> MultiLocation { + MultiLocation { parents: 1, interior: X1(Parachain(id)) } + } +} diff --git a/parachains/runtimes/assets/statemine/tests/tests.rs b/parachains/runtimes/assets/asset-hub-kusama/tests/tests.rs similarity index 90% rename from parachains/runtimes/assets/statemine/tests/tests.rs rename to parachains/runtimes/assets/asset-hub-kusama/tests/tests.rs index b9001a35a99..22d277c5d8c 100644 --- a/parachains/runtimes/assets/statemine/tests/tests.rs +++ b/parachains/runtimes/assets/asset-hub-kusama/tests/tests.rs @@ -1,22 +1,22 @@ -use asset_test_utils::{ExtBuilder, RuntimeHelper}; -use codec::{Decode, Encode}; -use cumulus_primitives_utility::ChargeWeightInFungibles; -use frame_support::{ - assert_noop, assert_ok, - traits::fungibles::InspectEnumerable, - weights::{Weight, WeightToFee as WeightToFeeT}, -}; -use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance}; -use statemine_runtime::xcm_config::{ +use asset_hub_kusama_runtime::xcm_config::{ AssetFeeAsExistentialDepositMultiplierFeeCharger, KsmLocation, TrustBackedAssetsPalletLocation, }; -pub use statemine_runtime::{ +pub use asset_hub_kusama_runtime::{ constants::fee::WeightToFee, xcm_config::{CheckingAccount, ForeignCreatorsSovereignAccountOf, XcmConfig}, AssetDeposit, Assets, Balances, ExistentialDeposit, ForeignAssets, ForeignAssetsInstance, MetadataDepositBase, MetadataDepositPerByte, ParachainSystem, Runtime, RuntimeCall, RuntimeEvent, SessionKeys, System, TrustBackedAssetsInstance, }; +use asset_test_utils::{CollatorSessionKeys, ExtBuilder, RuntimeHelper}; +use codec::{Decode, Encode}; +use cumulus_primitives_utility::ChargeWeightInFungibles; +use frame_support::{ + assert_noop, assert_ok, + traits::fungibles::InspectEnumerable, + weights::{Weight, WeightToFee as WeightToFeeT}, +}; +use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance}; use xcm::latest::prelude::*; use xcm_executor::traits::{Convert, Identity, JustTry, WeightTrader}; @@ -26,6 +26,14 @@ const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32]; type AssetIdForTrustBackedAssetsConvert = assets_common::AssetIdForTrustBackedAssetsConvert; +fn collator_session_keys() -> CollatorSessionKeys { + CollatorSessionKeys::new( + AccountId::from(ALICE), + AccountId::from(ALICE), + SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }, + ) +} + #[test] fn test_asset_xcm_trader() { ExtBuilder::::default() @@ -77,19 +85,16 @@ fn test_asset_xcm_trader() { // Lets pay with: asset_amount_needed + asset_amount_extra let asset_amount_extra = 100_u128; let asset: MultiAsset = - (asset_multilocation.clone(), asset_amount_needed + asset_amount_extra).into(); + (asset_multilocation, asset_amount_needed + asset_amount_extra).into(); let mut trader = ::Trader::new(); // Lets buy_weight and make sure buy_weight does not return an error - match trader.buy_weight(bought, asset.into()) { - Ok(unused_assets) => { - // Check whether a correct amount of unused assets is returned - assert_ok!(unused_assets - .ensure_contains(&(asset_multilocation, asset_amount_extra).into())); - }, - Err(e) => assert!(false, "Expected Ok(_). Got {:#?}", e), - } + let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok"); + // Check whether a correct amount of unused assets is returned + assert_ok!( + unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into()) + ); // Drop trader drop(trader); @@ -150,7 +155,7 @@ fn test_asset_xcm_trader_with_refund() { // lets calculate amount needed let amount_bought = WeightToFee::weight_to_fee(&bought); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Make sure buy_weight does not return an error assert_ok!(trader.buy_weight(bought, asset.clone().into())); @@ -224,7 +229,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() { "we are testing what happens when the amount does not exceed ED" ); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Buy weight should return an error assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); @@ -277,11 +282,11 @@ fn test_that_buying_ed_refund_does_not_refund() { // We know we will have to buy at least ED, so lets make sure first it will // fail with a payment of less than ED - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); // Now lets buy ED at least - let asset: MultiAsset = (asset_multilocation.clone(), ExistentialDeposit::get()).into(); + let asset: MultiAsset = (asset_multilocation, ExistentialDeposit::get()).into(); // Buy weight should work assert_ok!(trader.buy_weight(bought, asset.into())); @@ -416,7 +421,7 @@ fn test_assets_balances_api_works() { let foreign_asset_minimum_asset_balance = 3333333_u128; assert_ok!(ForeignAssets::force_create( RuntimeHelper::::root_origin(), - foreign_asset_id_multilocation.clone().into(), + foreign_asset_id_multilocation, AccountId::from(SOME_ASSET_ADMIN).into(), false, foreign_asset_minimum_asset_balance @@ -425,7 +430,7 @@ fn test_assets_balances_api_works() { // We first mint enough asset for the account to exist for assets assert_ok!(ForeignAssets::mint( RuntimeHelper::::origin_of(AccountId::from(SOME_ASSET_ADMIN)), - foreign_asset_id_multilocation.clone().into(), + foreign_asset_id_multilocation, AccountId::from(ALICE).into(), 6 * foreign_asset_minimum_asset_balance )); @@ -475,11 +480,7 @@ asset_test_utils::include_teleports_for_native_asset_works!( CheckingAccount, WeightToFee, ParachainSystem, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), Box::new(|runtime_event_encoded: Vec| { match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { @@ -504,11 +505,7 @@ asset_test_utils::include_teleports_for_foreign_assets_works!( ParachainSystem, ForeignCreatorsSovereignAccountOf, ForeignAssetsInstance, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), Box::new(|runtime_event_encoded: Vec| { match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { @@ -527,11 +524,7 @@ asset_test_utils::include_teleports_for_foreign_assets_works!( asset_test_utils::include_asset_transactor_transfer_with_local_consensus_currency_works!( Runtime, XcmConfig, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), Box::new(|| { assert!(Assets::asset_ids().collect::>().is_empty()); @@ -550,11 +543,7 @@ asset_test_utils::include_asset_transactor_transfer_with_pallet_assets_instance_ TrustBackedAssetsInstance, AssetIdForTrustBackedAssets, AssetIdForTrustBackedAssetsConvert, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), 12345, Box::new(|| { @@ -572,11 +561,7 @@ asset_test_utils::include_asset_transactor_transfer_with_pallet_assets_instance_ ForeignAssetsInstance, MultiLocation, JustTry, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), MultiLocation { parents: 1, interior: X2(Parachain(1313), GeneralIndex(12345)) }, Box::new(|| { @@ -595,11 +580,7 @@ asset_test_utils::include_create_and_manage_foreign_assets_for_local_consensus_p ForeignAssetsInstance, MultiLocation, JustTry, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), AssetDeposit::get(), MetadataDepositBase::get(), diff --git a/parachains/runtimes/assets/statemint/Cargo.toml b/parachains/runtimes/assets/asset-hub-polkadot/Cargo.toml similarity index 94% rename from parachains/runtimes/assets/statemint/Cargo.toml rename to parachains/runtimes/assets/asset-hub-polkadot/Cargo.toml index 75ae7bbf685..46a56d0af64 100644 --- a/parachains/runtimes/assets/statemint/Cargo.toml +++ b/parachains/runtimes/assets/asset-hub-polkadot/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "statemint-runtime" -version = "1.0.0" +name = "asset-hub-polkadot-runtime" +version = "0.9.420" authors = ["Parity Technologies "] edition = "2021" -description = "Statemint parachain runtime" +description = "Asset Hub Polkadot parachain runtime" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } hex-literal = { version = "0.4.1", optional = true } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } smallvec = "1.10.0" # Substrate @@ -26,6 +26,8 @@ pallet-aura = { git = "https://github.com/paritytech/substrate", default-feature pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-nfts = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-nfts-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } @@ -91,6 +93,7 @@ runtime-benchmarks = [ "pallet-assets/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", + "pallet-nfts/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-uniques/runtime-benchmarks", @@ -122,6 +125,7 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-collator-selection/try-runtime", "pallet-multisig/try-runtime", + "pallet-nfts/try-runtime", "pallet-proxy/try-runtime", "pallet-session/try-runtime", "pallet-timestamp/try-runtime", @@ -145,6 +149,8 @@ std = [ "pallet-authorship/std", "pallet-balances/std", "pallet-multisig/std", + "pallet-nfts/std", + "pallet-nfts-runtime-api/std", "pallet-proxy/std", "pallet-session/std", "pallet-timestamp/std", diff --git a/parachains/runtimes/assets/statemint/build.rs b/parachains/runtimes/assets/asset-hub-polkadot/build.rs similarity index 100% rename from parachains/runtimes/assets/statemint/build.rs rename to parachains/runtimes/assets/asset-hub-polkadot/build.rs diff --git a/parachains/runtimes/assets/statemint/src/constants.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/constants.rs similarity index 98% rename from parachains/runtimes/assets/statemint/src/constants.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/constants.rs index 35e7f03695b..dea920979f6 100644 --- a/parachains/runtimes/assets/statemint/src/constants.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/constants.rs @@ -74,7 +74,7 @@ pub mod fee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { // in Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: - // in Statemint, we map to 1/10 of that, or 1/100 CENT + // in Asset Hub, we map to 1/10 of that, or 1/100 CENT let p = super::currency::CENTS; let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); diff --git a/parachains/runtimes/assets/statemint/src/lib.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs similarity index 83% rename from parachains/runtimes/assets/statemint/src/lib.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs index d8390db9f4c..96033382cef 100644 --- a/parachains/runtimes/assets/statemint/src/lib.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/lib.rs @@ -13,10 +13,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! # Statemint Runtime +//! # Asset Hub Polkadot Runtime //! -//! Statemint is a parachain that provides an interface to create, manage, and use assets. Assets -//! may be fungible or non-fungible. +//! Asset Hub Polkadot is a parachain that provides an interface to create, manage, and use assets. +//! Assets may be fungible or non-fungible. +//! +//! ## Renaming +//! +//! This chain was originally known as "Statemint". You may see references to Statemint, Statemine, +//! and Westmint throughout the codebase. These are synonymous with "Asset Hub Polkadot, Kusama, and +//! Westend", respectively. //! //! ## Assets //! @@ -27,22 +33,22 @@ //! //! ### Native Balances //! -//! Statemint uses its parent DOT token as its native asset. +//! Asset Hub Polkadot uses its parent DOT token as its native asset. //! //! ### Governance //! -//! As a common good parachain, Statemint defers its governance (namely, its `Root` origin), to its +//! As a system parachain, Asset Hub defers its governance (namely, its `Root` origin), to its //! Relay Chain parent, Polkadot. //! //! ### Collator Selection //! -//! Statemint uses `pallet-collator-selection`, a simple first-come-first-served registration +//! Asset Hub uses `pallet-collator-selection`, a simple first-come-first-served registration //! system where collators can reserve a small bond to join the block producer set. There is no //! slashing. //! //! ### XCM //! -//! Because Statemint is fully under the control of the Relay Chain, it is meant to be a +//! Because Asset Hub is fully under the control of the Relay Chain, it is meant to be a //! `TrustedTeleporter`. It can also serve as a reserve location to other parachains for DOT as well //! as other local assets. @@ -57,12 +63,15 @@ pub mod constants; mod weights; pub mod xcm_config; +use assets_common::{ + foreign_creators::ForeignCreators, matching::FromSiblingParachain, MultiLocationForAssetId, +}; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto}, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Verify}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, Perbill, }; @@ -90,18 +99,19 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, }; +use pallet_nfts::PalletFeatures; pub use parachains_common as common; use parachains_common::{ impls::{AssetsToBlockAuthor, DealWithFees}, opaque, process_xcm_message::*, - AccountId, AssetIdForTrustBackedAssets, Balance, BlockNumber, Hash, Header, Index, Signature, - StatemintAuraId as AuraId, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, + AccountId, AssetHubPolkadotAuraId as AuraId, AssetIdForTrustBackedAssets, Balance, BlockNumber, + Hash, Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; use xcm_config::{ - DotLocation, FellowshipLocation, GovernanceLocation, TrustBackedAssetsConvertedConcreteId, - XcmOriginToTransactDispatchOrigin, + DotLocation, FellowshipLocation, ForeignAssetsConvertedConcreteId, GovernanceLocation, + TrustBackedAssetsConvertedConcreteId, XcmOriginToTransactDispatchOrigin, }; #[cfg(any(feature = "std", test))] @@ -112,6 +122,7 @@ use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use xcm::latest::BodyId; +use crate::xcm_config::ForeignCreatorsSovereignAccountOf; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; impl_opaque_keys! { @@ -122,10 +133,13 @@ impl_opaque_keys! { #[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { + // Note: "statemint" is the legacy name for this chain. It has been renamed to + // "asset-hub-polkadot". Many wallets/tools depend on the `spec_name`, so it remains "statemint" + // for the time being. Wallets/tools should update to treat "asset-hub-polkadot" equally. spec_name: create_runtime_str!("statemint"), impl_name: create_runtime_str!("statemint"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 13, @@ -220,7 +234,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = weights::pallet_balances::WeightInfo; type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -228,7 +242,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -283,6 +297,48 @@ impl pallet_assets::Config for Runtime { type BenchmarkHelper = (); } +parameter_types! { + // we just reuse the same deposits + pub const ForeignAssetsAssetDeposit: Balance = AssetDeposit::get(); + pub const ForeignAssetsAssetAccountDeposit: Balance = AssetAccountDeposit::get(); + pub const ForeignAssetsApprovalDeposit: Balance = ApprovalDeposit::get(); + pub const ForeignAssetsAssetsStringLimit: u32 = AssetsStringLimit::get(); + pub const ForeignAssetsMetadataDepositBase: Balance = MetadataDepositBase::get(); + pub const ForeignAssetsMetadataDepositPerByte: Balance = MetadataDepositPerByte::get(); +} + +/// Assets managed by some foreign location. Note: we do not declare a `ForeignAssetsCall` type, as +/// this type is used in proxy definitions. We assume that a foreign location would not want to set +/// an individual, local account as a proxy for the issuance of their assets. This issuance should +/// be managed by the foreign location's governance. +pub type ForeignAssetsInstance = pallet_assets::Instance2; +impl pallet_assets::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type AssetId = MultiLocationForAssetId; + type AssetIdParameter = MultiLocationForAssetId; + type Currency = Balances; + type CreateOrigin = ForeignCreators< + (FromSiblingParachain>,), + ForeignCreatorsSovereignAccountOf, + AccountId, + >; + type ForceOrigin = AssetsForceOrigin; + type AssetDeposit = ForeignAssetsAssetDeposit; + type MetadataDepositBase = ForeignAssetsMetadataDepositBase; + type MetadataDepositPerByte = ForeignAssetsMetadataDepositPerByte; + type ApprovalDeposit = ForeignAssetsApprovalDeposit; + type StringLimit = ForeignAssetsAssetsStringLimit; + type Freezer = (); + type Extra = (); + type WeightInfo = weights::pallet_assets::WeightInfo; + type CallbackHandle = (); + type AssetAccountDeposit = ForeignAssetsAssetAccountDeposit; + type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = xcm_config::XcmBenchmarkHelper; +} + parameter_types! { // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. pub const DepositBase: Balance = deposit(1, 88); @@ -363,6 +419,7 @@ impl InstanceFilter for ProxyType { c, RuntimeCall::Balances { .. } | RuntimeCall::Assets { .. } | + RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } ), ProxyType::CancelProxy => matches!( @@ -377,7 +434,7 @@ impl InstanceFilter for ProxyType { RuntimeCall::Assets { .. } | RuntimeCall::Utility { .. } | RuntimeCall::Multisig { .. } | - RuntimeCall::Uniques { .. } + RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } ) }, ProxyType::AssetOwner => matches!( @@ -391,6 +448,13 @@ impl InstanceFilter for ProxyType { RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) | RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) | RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | @@ -413,6 +477,17 @@ impl InstanceFilter for ProxyType { RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) | RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) | RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) | + RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | @@ -491,7 +566,7 @@ impl pallet_message_queue::Config for Runtime { >; #[cfg(not(feature = "runtime-benchmarks"))] type MessageProcessor = parachains_common::process_xcm_message::SplitMessages< - ProcessXcmMessage< + xcm_builder::ProcessXcmMessage< AggregateMessageOrigin, xcm_executor::XcmExecutor, RuntimeCall, @@ -526,7 +601,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type XcmpProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor; #[cfg(not(feature = "runtime-benchmarks"))] type XcmpProcessor = ProcessFromSibling< - ProcessXcmMessage< + xcm_builder::ProcessXcmMessage< AggregateMessageOrigin, xcm_executor::XcmExecutor, RuntimeCall, @@ -613,14 +688,11 @@ impl pallet_asset_tx_payment::Config for Runtime { } parameter_types! { - pub const CollectionDeposit: Balance = 10 * UNITS; // 10 UNIT deposit to create uniques class - pub const ItemDeposit: Balance = UNITS / 100; // 1 / 100 UNIT deposit to create uniques instance - pub const KeyLimit: u32 = 32; // Max 32 bytes per key - pub const ValueLimit: u32 = 64; // Max 64 bytes per value + pub const UniquesCollectionDeposit: Balance = 10 * UNITS; // 10 UNIT deposit to create uniques class + pub const UniquesItemDeposit: Balance = UNITS / 100; // 1 / 100 UNIT deposit to create uniques instance pub const UniquesMetadataDepositBase: Balance = deposit(1, 129); - pub const AttributeDepositBase: Balance = deposit(1, 0); - pub const DepositPerByte: Balance = deposit(0, 1); - pub const UniquesStringLimit: u32 = 128; + pub const UniquesAttributeDepositBase: Balance = deposit(1, 0); + pub const UniquesDepositPerByte: Balance = deposit(0, 1); } impl pallet_uniques::Config for Runtime { @@ -629,14 +701,14 @@ impl pallet_uniques::Config for Runtime { type ItemId = u32; type Currency = Balances; type ForceOrigin = AssetsForceOrigin; - type CollectionDeposit = CollectionDeposit; - type ItemDeposit = ItemDeposit; + type CollectionDeposit = UniquesCollectionDeposit; + type ItemDeposit = UniquesItemDeposit; type MetadataDepositBase = UniquesMetadataDepositBase; - type AttributeDepositBase = AttributeDepositBase; - type DepositPerByte = DepositPerByte; - type StringLimit = UniquesStringLimit; - type KeyLimit = KeyLimit; - type ValueLimit = ValueLimit; + type AttributeDepositBase = UniquesAttributeDepositBase; + type DepositPerByte = UniquesDepositPerByte; + type StringLimit = ConstU32<128>; + type KeyLimit = ConstU32<32>; // Max 32 bytes per key + type ValueLimit = ConstU32<64>; // Max 64 bytes per value type WeightInfo = weights::pallet_uniques::WeightInfo; #[cfg(feature = "runtime-benchmarks")] type Helper = (); @@ -644,6 +716,46 @@ impl pallet_uniques::Config for Runtime { type Locker = (); } +parameter_types! { + pub NftsPalletFeatures: PalletFeatures = PalletFeatures::all_enabled(); + pub const NftsMaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS; + // re-use the Uniques deposits + pub const NftsCollectionDeposit: Balance = UniquesCollectionDeposit::get(); + pub const NftsItemDeposit: Balance = UniquesItemDeposit::get(); + pub const NftsMetadataDepositBase: Balance = UniquesMetadataDepositBase::get(); + pub const NftsAttributeDepositBase: Balance = UniquesAttributeDepositBase::get(); + pub const NftsDepositPerByte: Balance = UniquesDepositPerByte::get(); +} + +impl pallet_nfts::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type CollectionId = u32; + type ItemId = u32; + type Currency = Balances; + type CreateOrigin = AsEnsureOriginWithArg>; + type ForceOrigin = AssetsForceOrigin; + type Locker = (); + type CollectionDeposit = NftsCollectionDeposit; + type ItemDeposit = NftsItemDeposit; + type MetadataDepositBase = NftsMetadataDepositBase; + type AttributeDepositBase = NftsAttributeDepositBase; + type DepositPerByte = NftsDepositPerByte; + type StringLimit = ConstU32<256>; + type KeyLimit = ConstU32<64>; + type ValueLimit = ConstU32<256>; + type ApprovalsLimit = ConstU32<20>; + type ItemAttributesApprovalsLimit = ConstU32<30>; + type MaxTips = ConstU32<10>; + type MaxDeadlineDuration = NftsMaxDeadlineDuration; + type MaxAttributesPerCall = ConstU32<10>; + type Features = NftsPalletFeatures; + type OffchainSignature = Signature; + type OffchainPublic = ::Signer; + type WeightInfo = weights::pallet_nfts::WeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type Helper = (); +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -686,6 +798,8 @@ construct_runtime!( // The main stage. Assets: pallet_assets::::{Pallet, Call, Storage, Event} = 50, Uniques: pallet_uniques::{Pallet, Call, Storage, Event} = 51, + Nfts: pallet_nfts::{Pallet, Call, Storage, Event} = 52, + ForeignAssets: pallet_assets::::{Pallet, Call, Storage, Event} = 53, } ); @@ -714,7 +828,7 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Migrations to apply on runtime upgrade. -pub type Migrations = (); +pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1,); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -731,9 +845,11 @@ mod benches { frame_benchmarking::define_benchmarks!( [frame_system, SystemBench::] [pallet_assets, Assets] + [pallet_assets, ForeignAssets] [pallet_balances, Balances] [pallet_message_queue, MessageQueue] [pallet_multisig, Multisig] + [pallet_nfts, Nfts] [pallet_proxy, Proxy] [pallet_session, SessionBench::] [pallet_uniques, Uniques] @@ -907,11 +1023,17 @@ impl_runtime_apis! { }, // collect pallet_assets (TrustBackedAssets) convert::<_, _, _, _, TrustBackedAssetsConvertedConcreteId>( - Assets::account_balances(account) + Assets::account_balances(account.clone()) + .iter() + .filter(|(_, balance)| balance > &0) + )?, + // collect pallet_assets (ForeignAssets) + convert::<_, _, _, _, ForeignAssetsConvertedConcreteId>( + ForeignAssets::account_balances(account) .iter() .filter(|(_, balance)| balance > &0) )?, - // collect ... e.g. pallet_assets ForeignAssets + // collect ... e.g. other tokens ].concat().into()) } } @@ -963,7 +1085,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -998,7 +1120,6 @@ impl_runtime_apis! { id: Concrete(GeneralIndex(i as u128).into()), fun: Fungible(fungibles_amount * i as u128), } - .into() }) .chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) .chain((0..holding_non_fungibles).map(|i| MultiAsset { @@ -1018,7 +1139,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( DotLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(DotLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(DotLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; } @@ -1032,7 +1153,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(DotLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } diff --git a/parachains/runtimes/assets/statemint/src/weights/block_weights.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/block_weights.rs similarity index 100% rename from parachains/runtimes/assets/statemint/src/weights/block_weights.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/block_weights.rs diff --git a/parachains/runtimes/assets/westmint/src/weights/cumulus_pallet_parachain_system.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/cumulus_pallet_parachain_system.rs similarity index 100% rename from parachains/runtimes/assets/westmint/src/weights/cumulus_pallet_parachain_system.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/cumulus_pallet_parachain_system.rs diff --git a/parachains/runtimes/assets/westmint/src/weights/cumulus_pallet_xcmp_queue.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs similarity index 82% rename from parachains/runtimes/assets/westmint/src/weights/cumulus_pallet_xcmp_queue.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs index 7e108255d0b..8df9ca57e71 100644 --- a/parachains/runtimes/assets/westmint/src/weights/cumulus_pallet_xcmp_queue.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs @@ -19,34 +19,31 @@ //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-03-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `i9`, CPU: `13th Gen Intel(R) Core(TM) i9-13900K` -//! EXECUTION: Some(Native), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./target/release/polkadot-parachain // benchmark // pallet -// --chain -// westmint-dev -// --pallet -// cumulus_pallet_xcmp_queue -// --extrinsic -// -// --execution -// native -// --output -// parachains/runtimes/assets/westmint/src/weights -// --steps -// 50 -// --repeat -// 20 +// --chain=asset-hub-polkadot-dev +// --execution=wasm +// --wasm-execution=compiled +// --pallet=cumulus_pallet_xcmp_queue +// --extrinsic=* +// --steps=50 +// --repeat=20 +// --json +// --header=./file_header.txt +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_xcmp_queue`. pub struct WeightInfo(PhantomData); @@ -57,8 +54,8 @@ impl cumulus_pallet_xcmp_queue::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `76` // Estimated: `1561` - // Minimum execution time: 1_822_000 picoseconds. - Weight::from_parts(2_025_000, 0) + // Minimum execution time: 5_499_000 picoseconds. + Weight::from_parts(5_677_000, 0) .saturating_add(Weight::from_parts(0, 1561)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -90,8 +87,8 @@ impl cumulus_pallet_xcmp_queue::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `76` // Estimated: `1561` - // Minimum execution time: 1_197_000 picoseconds. - Weight::from_parts(1_259_000, 0) + // Minimum execution time: 5_747_000 picoseconds. + Weight::from_parts(5_911_000, 0) .saturating_add(Weight::from_parts(0, 1561)) .saturating_add(T::DbWeight::get().reads(1)) } diff --git a/parachains/runtimes/assets/statemint/src/weights/extrinsic_weights.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/extrinsic_weights.rs similarity index 100% rename from parachains/runtimes/assets/statemint/src/weights/extrinsic_weights.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/extrinsic_weights.rs diff --git a/parachains/runtimes/assets/statemint/src/weights/frame_system.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/frame_system.rs similarity index 75% rename from parachains/runtimes/assets/statemint/src/weights/frame_system.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/frame_system.rs index 23a5e25cddb..763a58394ff 100644 --- a/parachains/runtimes/assets/statemint/src/weights/frame_system.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/frame_system.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `frame_system` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemint-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=frame_system @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/frame_system.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/frame_system.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `frame_system`. pub struct WeightInfo(PhantomData); @@ -52,22 +53,25 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_346_000 picoseconds. - Weight::from_parts(2_416_000, 0) + // Minimum execution time: 2_236_000 picoseconds. + Weight::from_parts(2_297_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(412, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(365, 0).saturating_mul(b.into())) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_010_000 picoseconds. - Weight::from_parts(8_171_000, 0) + // Minimum execution time: 7_839_000 picoseconds. + Weight::from_parts(7_977_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 0 - .saturating_add(Weight::from_parts(1_448, 0).saturating_mul(b.into())) + // Standard Error: 1 + .saturating_add(Weight::from_parts(1_406, 0).saturating_mul(b.into())) + } + fn set_code() -> Weight { + Weight::from_parts(1_000_000, 0) } /// Storage: System Digest (r:1 w:1) /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) @@ -77,8 +81,8 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 4_684_000 picoseconds. - Weight::from_parts(4_872_000, 0) + // Minimum execution time: 4_494_000 picoseconds. + Weight::from_parts(4_824_000, 0) .saturating_add(Weight::from_parts(0, 1485)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -90,11 +94,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_361_000 picoseconds. - Weight::from_parts(2_402_000, 0) + // Minimum execution time: 2_343_000 picoseconds. + Weight::from_parts(2_396_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_747 - .saturating_add(Weight::from_parts(682_536, 0).saturating_mul(i.into())) + // Standard Error: 2_074 + .saturating_add(Weight::from_parts(676_456, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -104,11 +108,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_515_000 picoseconds. - Weight::from_parts(2_565_000, 0) + // Minimum execution time: 2_345_000 picoseconds. + Weight::from_parts(2_374_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 859 - .saturating_add(Weight::from_parts(501_791, 0).saturating_mul(i.into())) + // Standard Error: 758 + .saturating_add(Weight::from_parts(491_397, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -118,11 +122,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `81 + p * (69 ±0)` // Estimated: `72 + p * (70 ±0)` - // Minimum execution time: 4_524_000 picoseconds. - Weight::from_parts(4_626_000, 0) + // Minimum execution time: 4_203_000 picoseconds. + Weight::from_parts(4_292_000, 0) .saturating_add(Weight::from_parts(0, 72)) - // Standard Error: 1_004 - .saturating_add(Weight::from_parts(1_011_603, 0).saturating_mul(p.into())) + // Standard Error: 1_026 + .saturating_add(Weight::from_parts(1_011_943, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) diff --git a/parachains/runtimes/assets/westmint/src/weights/mod.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/mod.rs similarity index 100% rename from parachains/runtimes/assets/westmint/src/weights/mod.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/mod.rs diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_assets.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_assets.rs similarity index 65% rename from parachains/runtimes/assets/statemint/src/weights/pallet_assets.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_assets.rs index 933dcb4d3af..20ac7e5e208 100644 --- a/parachains/runtimes/assets/statemint/src/weights/pallet_assets.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_assets.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_assets` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemint-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_assets @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/pallet_assets.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_assets.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_assets`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn create() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `7268` - // Minimum execution time: 24_714_000 picoseconds. - Weight::from_parts(25_310_000, 0) - .saturating_add(Weight::from_parts(0, 7268)) + // Estimated: `3675` + // Minimum execution time: 28_211_000 picoseconds. + Weight::from_parts(28_668_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -67,8 +68,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `6` // Estimated: `3675` - // Minimum execution time: 12_820_000 picoseconds. - Weight::from_parts(13_118_000, 0) + // Minimum execution time: 11_781_000 picoseconds. + Weight::from_parts(12_065_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -79,8 +80,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `277` // Estimated: `3675` - // Minimum execution time: 15_292_000 picoseconds. - Weight::from_parts(15_715_000, 0) + // Minimum execution time: 14_330_000 picoseconds. + Weight::from_parts(14_502_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -95,17 +96,17 @@ impl pallet_assets::WeightInfo for WeightInfo { fn destroy_accounts(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + c * (208 ±0)` - // Estimated: `8232 + c * (5180 ±0)` - // Minimum execution time: 17_955_000 picoseconds. - Weight::from_parts(18_157_000, 0) - .saturating_add(Weight::from_parts(0, 8232)) - // Standard Error: 7_214 - .saturating_add(Weight::from_parts(12_316_605, 0).saturating_mul(c.into())) + // Estimated: `3675 + c * (2603 ±0)` + // Minimum execution time: 17_319_000 picoseconds. + Weight::from_parts(17_663_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + // Standard Error: 7_032 + .saturating_add(Weight::from_parts(11_982_921, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(c.into()))) - .saturating_add(Weight::from_parts(0, 5180).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(c.into())) } /// Storage: Assets Asset (r:1 w:1) /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) @@ -115,12 +116,12 @@ impl pallet_assets::WeightInfo for WeightInfo { fn destroy_approvals(a: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `414 + a * (86 ±0)` - // Estimated: `7288 + a * (2623 ±0)` - // Minimum execution time: 18_626_000 picoseconds. - Weight::from_parts(18_760_000, 0) - .saturating_add(Weight::from_parts(0, 7288)) - // Standard Error: 4_382 - .saturating_add(Weight::from_parts(12_278_198, 0).saturating_mul(a.into())) + // Estimated: `3675 + a * (2623 ±0)` + // Minimum execution time: 18_296_000 picoseconds. + Weight::from_parts(18_465_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) + // Standard Error: 4_256 + .saturating_add(Weight::from_parts(14_090_852, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -134,10 +135,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn finish_destroy() -> Weight { // Proof Size summary in bytes: // Measured: `243` - // Estimated: `7280` - // Minimum execution time: 14_576_000 picoseconds. - Weight::from_parts(14_816_000, 0) - .saturating_add(Weight::from_parts(0, 7280)) + // Estimated: `3675` + // Minimum execution time: 14_265_000 picoseconds. + Weight::from_parts(14_527_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -148,10 +149,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn mint() -> Weight { // Proof Size summary in bytes: // Measured: `243` - // Estimated: `7242` - // Minimum execution time: 26_215_000 picoseconds. - Weight::from_parts(26_571_000, 0) - .saturating_add(Weight::from_parts(0, 7242)) + // Estimated: `3675` + // Minimum execution time: 25_227_000 picoseconds. + Weight::from_parts(25_846_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -162,10 +163,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn burn() -> Weight { // Proof Size summary in bytes: // Measured: `351` - // Estimated: `7242` - // Minimum execution time: 31_944_000 picoseconds. - Weight::from_parts(32_675_000, 0) - .saturating_add(Weight::from_parts(0, 7242)) + // Estimated: `3675` + // Minimum execution time: 31_131_000 picoseconds. + Weight::from_parts(31_792_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -178,10 +179,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn transfer() -> Weight { // Proof Size summary in bytes: // Measured: `351` - // Estimated: `13412` - // Minimum execution time: 44_126_000 picoseconds. - Weight::from_parts(44_567_000, 0) - .saturating_add(Weight::from_parts(0, 13412)) + // Estimated: `6144` + // Minimum execution time: 43_177_000 picoseconds. + Weight::from_parts(43_498_000, 0) + .saturating_add(Weight::from_parts(0, 6144)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -194,10 +195,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn transfer_keep_alive() -> Weight { // Proof Size summary in bytes: // Measured: `351` - // Estimated: `13412` - // Minimum execution time: 39_414_000 picoseconds. - Weight::from_parts(39_891_000, 0) - .saturating_add(Weight::from_parts(0, 13412)) + // Estimated: `6144` + // Minimum execution time: 37_702_000 picoseconds. + Weight::from_parts(38_413_000, 0) + .saturating_add(Weight::from_parts(0, 6144)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -210,10 +211,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn force_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `351` - // Estimated: `13412` - // Minimum execution time: 44_875_000 picoseconds. - Weight::from_parts(45_961_000, 0) - .saturating_add(Weight::from_parts(0, 13412)) + // Estimated: `6144` + // Minimum execution time: 43_061_000 picoseconds. + Weight::from_parts(43_657_000, 0) + .saturating_add(Weight::from_parts(0, 6144)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -224,10 +225,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn freeze() -> Weight { // Proof Size summary in bytes: // Measured: `351` - // Estimated: `7242` - // Minimum execution time: 18_388_000 picoseconds. - Weight::from_parts(18_718_000, 0) - .saturating_add(Weight::from_parts(0, 7242)) + // Estimated: `3675` + // Minimum execution time: 17_386_000 picoseconds. + Weight::from_parts(17_618_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -238,10 +239,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn thaw() -> Weight { // Proof Size summary in bytes: // Measured: `351` - // Estimated: `7242` - // Minimum execution time: 18_292_000 picoseconds. - Weight::from_parts(18_633_000, 0) - .saturating_add(Weight::from_parts(0, 7242)) + // Estimated: `3675` + // Minimum execution time: 17_180_000 picoseconds. + Weight::from_parts(17_458_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -251,8 +252,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `277` // Estimated: `3675` - // Minimum execution time: 14_604_000 picoseconds. - Weight::from_parts(14_980_000, 0) + // Minimum execution time: 13_802_000 picoseconds. + Weight::from_parts(14_110_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -263,8 +264,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `277` // Estimated: `3675` - // Minimum execution time: 14_008_000 picoseconds. - Weight::from_parts(14_428_000, 0) + // Minimum execution time: 13_903_000 picoseconds. + Weight::from_parts(14_158_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -276,10 +277,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn transfer_ownership() -> Weight { // Proof Size summary in bytes: // Measured: `243` - // Estimated: `7280` - // Minimum execution time: 15_453_000 picoseconds. - Weight::from_parts(15_963_000, 0) - .saturating_add(Weight::from_parts(0, 7280)) + // Estimated: `3675` + // Minimum execution time: 15_371_000 picoseconds. + Weight::from_parts(15_651_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -289,8 +290,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `243` // Estimated: `3675` - // Minimum execution time: 14_515_000 picoseconds. - Weight::from_parts(14_835_000, 0) + // Minimum execution time: 14_229_000 picoseconds. + Weight::from_parts(14_440_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -301,17 +302,15 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. - fn set_metadata(n: u32, s: u32, ) -> Weight { + fn set_metadata(_n: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `243` - // Estimated: `7280` - // Minimum execution time: 25_865_000 picoseconds. - Weight::from_parts(26_845_899, 0) - .saturating_add(Weight::from_parts(0, 7280)) - // Standard Error: 1_061 - .saturating_add(Weight::from_parts(4_438, 0).saturating_mul(n.into())) - // Standard Error: 1_061 - .saturating_add(Weight::from_parts(5_130, 0).saturating_mul(s.into())) + // Estimated: `3675` + // Minimum execution time: 29_075_000 picoseconds. + Weight::from_parts(29_848_037, 0) + .saturating_add(Weight::from_parts(0, 3675)) + // Standard Error: 404 + .saturating_add(Weight::from_parts(2_259, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -322,10 +321,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn clear_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `407` - // Estimated: `7280` - // Minimum execution time: 25_970_000 picoseconds. - Weight::from_parts(26_439_000, 0) - .saturating_add(Weight::from_parts(0, 7280)) + // Estimated: `3675` + // Minimum execution time: 29_204_000 picoseconds. + Weight::from_parts(29_542_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -335,17 +334,15 @@ impl pallet_assets::WeightInfo for WeightInfo { /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. - fn force_set_metadata(n: u32, s: u32, ) -> Weight { + fn force_set_metadata(_n: u32, s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `82` - // Estimated: `7280` - // Minimum execution time: 14_101_000 picoseconds. - Weight::from_parts(14_786_155, 0) - .saturating_add(Weight::from_parts(0, 7280)) - // Standard Error: 383 - .saturating_add(Weight::from_parts(581, 0).saturating_mul(n.into())) - // Standard Error: 383 - .saturating_add(Weight::from_parts(4_514, 0).saturating_mul(s.into())) + // Estimated: `3675` + // Minimum execution time: 13_144_000 picoseconds. + Weight::from_parts(13_741_573, 0) + .saturating_add(Weight::from_parts(0, 3675)) + // Standard Error: 314 + .saturating_add(Weight::from_parts(2_146, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -356,10 +353,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn force_clear_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `407` - // Estimated: `7280` - // Minimum execution time: 26_563_000 picoseconds. - Weight::from_parts(26_733_000, 0) - .saturating_add(Weight::from_parts(0, 7280)) + // Estimated: `3675` + // Minimum execution time: 28_718_000 picoseconds. + Weight::from_parts(29_090_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -369,8 +366,8 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `243` // Estimated: `3675` - // Minimum execution time: 13_948_000 picoseconds. - Weight::from_parts(14_330_000, 0) + // Minimum execution time: 13_183_000 picoseconds. + Weight::from_parts(13_442_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -382,10 +379,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn approve_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `277` - // Estimated: `7288` - // Minimum execution time: 30_307_000 picoseconds. - Weight::from_parts(30_677_000, 0) - .saturating_add(Weight::from_parts(0, 7288)) + // Estimated: `3675` + // Minimum execution time: 32_260_000 picoseconds. + Weight::from_parts(32_739_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -400,10 +397,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn transfer_approved() -> Weight { // Proof Size summary in bytes: // Measured: `521` - // Estimated: `17025` - // Minimum execution time: 59_228_000 picoseconds. - Weight::from_parts(59_702_000, 0) - .saturating_add(Weight::from_parts(0, 17025)) + // Estimated: `6144` + // Minimum execution time: 61_085_000 picoseconds. + Weight::from_parts(61_779_000, 0) + .saturating_add(Weight::from_parts(0, 6144)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -414,10 +411,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn cancel_approval() -> Weight { // Proof Size summary in bytes: // Measured: `447` - // Estimated: `7288` - // Minimum execution time: 31_228_000 picoseconds. - Weight::from_parts(31_564_000, 0) - .saturating_add(Weight::from_parts(0, 7288)) + // Estimated: `3675` + // Minimum execution time: 34_236_000 picoseconds. + Weight::from_parts(34_692_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -428,10 +425,10 @@ impl pallet_assets::WeightInfo for WeightInfo { fn force_cancel_approval() -> Weight { // Proof Size summary in bytes: // Measured: `447` - // Estimated: `7288` - // Minimum execution time: 32_931_000 picoseconds. - Weight::from_parts(33_406_000, 0) - .saturating_add(Weight::from_parts(0, 7288)) + // Estimated: `3675` + // Minimum execution time: 34_765_000 picoseconds. + Weight::from_parts(35_364_000, 0) + .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -441,10 +438,79 @@ impl pallet_assets::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `243` // Estimated: `3675` - // Minimum execution time: 15_084_000 picoseconds. - Weight::from_parts(15_358_000, 0) + // Minimum execution time: 14_550_000 picoseconds. + Weight::from_parts(14_799_000, 0) .saturating_add(Weight::from_parts(0, 3675)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn touch() -> Weight { + // Proof Size summary in bytes: + // Measured: `453` + // Estimated: `3675` + // Minimum execution time: 37_468_000 picoseconds. + Weight::from_parts(37_957_000, 3675) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn touch_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `3675` + // Minimum execution time: 383_408_000 picoseconds. + Weight::from_parts(392_036_000, 3675) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn refund() -> Weight { + // Proof Size summary in bytes: + // Measured: `579` + // Estimated: `3675` + // Minimum execution time: 34_066_000 picoseconds. + Weight::from_parts(34_347_000, 3675) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn refund_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `510` + // Estimated: `3675` + // Minimum execution time: 32_060_000 picoseconds. + Weight::from_parts(32_519_000, 3675) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + fn block() -> Weight { + // Proof Size summary in bytes: + // Measured: `459` + // Estimated: `3675` + // Minimum execution time: 115_000_000 picoseconds. + Weight::from_parts(163_000_000, 3675) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } } diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_balances.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_balances.rs similarity index 71% rename from parachains/runtimes/assets/westmint/src/weights/pallet_balances.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_balances.rs index acae356b1cb..a2623edff67 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_balances.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_balances.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_balances @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_balances.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_balances.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_balances`. pub struct WeightInfo(PhantomData); @@ -53,8 +54,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 35_470_000 picoseconds. - Weight::from_parts(36_170_000, 0) + // Minimum execution time: 52_756_000 picoseconds. + Weight::from_parts(53_298_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -65,8 +66,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 26_173_000 picoseconds. - Weight::from_parts(26_636_000, 0) + // Minimum execution time: 40_071_000 picoseconds. + Weight::from_parts(40_563_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -77,8 +78,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 15_875_000 picoseconds. - Weight::from_parts(16_109_000, 0) + // Minimum execution time: 15_936_000 picoseconds. + Weight::from_parts(16_317_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -89,8 +90,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 18_726_000 picoseconds. - Weight::from_parts(19_101_000, 0) + // Minimum execution time: 22_750_000 picoseconds. + Weight::from_parts(23_053_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -101,8 +102,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `6196` - // Minimum execution time: 37_080_000 picoseconds. - Weight::from_parts(37_562_000, 0) + // Minimum execution time: 54_270_000 picoseconds. + Weight::from_parts(54_857_000, 0) .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -113,25 +114,38 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 32_468_000 picoseconds. - Weight::from_parts(32_858_000, 0) + // Minimum execution time: 49_155_000 picoseconds. + Weight::from_parts(49_567_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn upgrade_accounts(_: u32) -> Weight { - Weight::from_parts(0, 0) - } fn force_unreserve() -> Weight { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 14_725_000 picoseconds. - Weight::from_parts(14_926_000, 0) + // Minimum execution time: 18_651_000 picoseconds. + Weight::from_parts(19_007_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + u * (136 ±0)` + // Estimated: `990 + u * (2603 ±0)` + // Minimum execution time: 18_523_000 picoseconds. + Weight::from_parts(18_943_000, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 11_771 + .saturating_add(Weight::from_parts(14_176_687, 0).saturating_mul(u.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + } } diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_collator_selection.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_collator_selection.rs similarity index 68% rename from parachains/runtimes/assets/statemine/src/weights/pallet_collator_selection.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_collator_selection.rs index 6165f030031..9ac1b4a4444 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_collator_selection.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_collator_selection` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_collator_selection @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_collator_selection.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_collator_selection.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_collator_selection`. pub struct WeightInfo(PhantomData); @@ -56,11 +57,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `178 + b * (78 ±0)` // Estimated: `1168 + b * (2554 ±0)` - // Minimum execution time: 15_415_000 picoseconds. - Weight::from_parts(15_521_960, 0) + // Minimum execution time: 15_000_000 picoseconds. + Weight::from_parts(14_942_281, 0) .saturating_add(Weight::from_parts(0, 1168)) - // Standard Error: 3_294 - .saturating_add(Weight::from_parts(2_582_035, 0).saturating_mul(b.into())) + // Standard Error: 3_013 + .saturating_add(Weight::from_parts(2_673_944, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(Weight::from_parts(0, 2554).saturating_mul(b.into())) @@ -71,8 +72,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_363_000 picoseconds. - Weight::from_parts(7_715_000, 0) + // Minimum execution time: 7_341_000 picoseconds. + Weight::from_parts(7_608_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -82,8 +83,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_516_000 picoseconds. - Weight::from_parts(7_860_000, 0) + // Minimum execution time: 7_710_000 picoseconds. + Weight::from_parts(7_973_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,12 +104,12 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn register_as_candidate(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1108 + c * (48 ±0)` - // Estimated: `61671 + c * (49 ±0)` - // Minimum execution time: 38_063_000 picoseconds. - Weight::from_parts(30_924_306, 0) - .saturating_add(Weight::from_parts(0, 61671)) - // Standard Error: 1_232 - .saturating_add(Weight::from_parts(106_039, 0).saturating_mul(c.into())) + // Estimated: `49487 + c * (49 ±0)` + // Minimum execution time: 42_547_000 picoseconds. + Weight::from_parts(35_070_051, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 1_231 + .saturating_add(Weight::from_parts(105_769, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 49).saturating_mul(c.into())) @@ -122,11 +123,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `452 + c * (48 ±0)` // Estimated: `49487` - // Minimum execution time: 29_598_000 picoseconds. - Weight::from_parts(19_372_924, 0) + // Minimum execution time: 33_828_000 picoseconds. + Weight::from_parts(23_360_256, 0) .saturating_add(Weight::from_parts(0, 49487)) - // Standard Error: 1_253 - .saturating_add(Weight::from_parts(106_394, 0).saturating_mul(c.into())) + // Standard Error: 1_294 + .saturating_add(Weight::from_parts(106_027, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -139,13 +140,46 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn note_author() -> Weight { // Proof Size summary in bytes: // Measured: `103` - // Estimated: `7729` - // Minimum execution time: 28_647_000 picoseconds. - Weight::from_parts(28_951_000, 0) - .saturating_add(Weight::from_parts(0, 7729)) + // Estimated: `6196` + // Minimum execution time: 43_367_000 picoseconds. + Weight::from_parts(44_039_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) @@ -160,18 +194,18 @@ impl pallet_collator_selection::WeightInfo for WeightIn /// The range of component `c` is `[1, 1000]`. fn new_session(r: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `22721 + r * (116 ±0) + c * (97 ±0)` - // Estimated: `56697 + c * (2520 ±0) + r * (2602 ±0)` - // Minimum execution time: 17_043_000 picoseconds. - Weight::from_parts(17_352_000, 0) - .saturating_add(Weight::from_parts(0, 56697)) - // Standard Error: 798_735 - .saturating_add(Weight::from_parts(28_961_284, 0).saturating_mul(c.into())) + // Measured: `22721 + c * (97 ±0) + r * (116 ±0)` + // Estimated: `49487 + c * (2519 ±0) + r * (2602 ±0)` + // Minimum execution time: 17_277_000 picoseconds. + Weight::from_parts(17_657_000, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 855_404 + .saturating_add(Weight::from_parts(30_433_186, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) - .saturating_add(Weight::from_parts(0, 2520).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 2519).saturating_mul(c.into())) .saturating_add(Weight::from_parts(0, 2602).saturating_mul(r.into())) } } diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_message_queue.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_message_queue.rs similarity index 100% rename from parachains/runtimes/assets/westmint/src/weights/pallet_message_queue.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_message_queue.rs diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_multisig.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_multisig.rs similarity index 73% rename from parachains/runtimes/assets/statemint/src/weights/pallet_multisig.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_multisig.rs index 2a93d9e41c2..39367ac6b88 100644 --- a/parachains/runtimes/assets/statemint/src/weights/pallet_multisig.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_multisig.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_multisig` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemint-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_multisig @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/pallet_multisig.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_multisig.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_multisig`. pub struct WeightInfo(PhantomData); @@ -52,11 +53,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_445_000 picoseconds. - Weight::from_parts(12_887_726, 0) + // Minimum execution time: 11_556_000 picoseconds. + Weight::from_parts(11_977_075, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 1 - .saturating_add(Weight::from_parts(608, 0).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(493, 0).saturating_mul(z.into())) } /// Storage: Multisig Multisigs (r:1 w:1) /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) @@ -66,13 +67,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `262 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 38_178_000 picoseconds. - Weight::from_parts(31_903_342, 0) + // Minimum execution time: 41_285_000 picoseconds. + Weight::from_parts(35_323_592, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 743 - .saturating_add(Weight::from_parts(67_484, 0).saturating_mul(s.into())) - // Standard Error: 7 - .saturating_add(Weight::from_parts(1_353, 0).saturating_mul(z.into())) + // Standard Error: 454 + .saturating_add(Weight::from_parts(64_841, 0).saturating_mul(s.into())) + // Standard Error: 4 + .saturating_add(Weight::from_parts(1_195, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -84,13 +85,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 28_095_000 picoseconds. - Weight::from_parts(22_610_540, 0) + // Minimum execution time: 27_217_000 picoseconds. + Weight::from_parts(21_829_864, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 571 - .saturating_add(Weight::from_parts(59_325, 0).saturating_mul(s.into())) - // Standard Error: 5 - .saturating_add(Weight::from_parts(1_310, 0).saturating_mul(z.into())) + // Standard Error: 473 + .saturating_add(Weight::from_parts(59_818, 0).saturating_mul(s.into())) + // Standard Error: 4 + .saturating_add(Weight::from_parts(1_179, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,14 +104,14 @@ impl pallet_multisig::WeightInfo for WeightInfo { fn as_multi_complete(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `385 + s * (33 ±0)` - // Estimated: `10404` - // Minimum execution time: 43_571_000 picoseconds. - Weight::from_parts(35_747_616, 0) - .saturating_add(Weight::from_parts(0, 10404)) - // Standard Error: 555 - .saturating_add(Weight::from_parts(86_297, 0).saturating_mul(s.into())) - // Standard Error: 5 - .saturating_add(Weight::from_parts(1_333, 0).saturating_mul(z.into())) + // Estimated: `6811` + // Minimum execution time: 46_235_000 picoseconds. + Weight::from_parts(38_643_321, 0) + .saturating_add(Weight::from_parts(0, 6811)) + // Standard Error: 484 + .saturating_add(Weight::from_parts(82_619, 0).saturating_mul(s.into())) + // Standard Error: 4 + .saturating_add(Weight::from_parts(1_223, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -121,11 +122,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `263 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 29_122_000 picoseconds. - Weight::from_parts(30_681_183, 0) + // Minimum execution time: 31_827_000 picoseconds. + Weight::from_parts(33_743_065, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 787 - .saturating_add(Weight::from_parts(69_464, 0).saturating_mul(s.into())) + // Standard Error: 669 + .saturating_add(Weight::from_parts(68_793, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -136,11 +137,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 19_219_000 picoseconds. - Weight::from_parts(20_598_069, 0) + // Minimum execution time: 19_148_000 picoseconds. + Weight::from_parts(20_211_716, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 572 - .saturating_add(Weight::from_parts(66_940, 0).saturating_mul(s.into())) + // Standard Error: 376 + .saturating_add(Weight::from_parts(62_199, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -151,11 +152,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `454 + s * (1 ±0)` // Estimated: `6811` - // Minimum execution time: 29_859_000 picoseconds. - Weight::from_parts(31_610_947, 0) + // Minimum execution time: 32_770_000 picoseconds. + Weight::from_parts(34_731_111, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 739 - .saturating_add(Weight::from_parts(70_349, 0).saturating_mul(s.into())) + // Standard Error: 761 + .saturating_add(Weight::from_parts(70_575, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_nfts.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_nfts.rs new file mode 100644 index 00000000000..d2ca392417e --- /dev/null +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_nfts.rs @@ -0,0 +1,763 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Autogenerated weights for `pallet_nfts` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// ./artifacts/polkadot-parachain +// benchmark +// pallet +// --chain=asset-hub-polkadot-dev +// --execution=wasm +// --wasm-execution=compiled +// --pallet=pallet_nfts +// --extrinsic=* +// --steps=50 +// --repeat=20 +// --json +// --header=./file_header.txt +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_nfts.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_nfts`. +pub struct WeightInfo(PhantomData); +impl pallet_nfts::WeightInfo for WeightInfo { + /// Storage: Nfts NextCollectionId (r:1 w:1) + /// Proof: Nfts NextCollectionId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:0 w:1) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:1) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn create() -> Weight { + // Proof Size summary in bytes: + // Measured: `145` + // Estimated: `3549` + // Minimum execution time: 39_589_000 picoseconds. + Weight::from_parts(40_305_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Nfts NextCollectionId (r:1 w:1) + /// Proof: Nfts NextCollectionId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:0 w:1) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:1) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn force_create() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `3549` + // Minimum execution time: 23_945_000 picoseconds. + Weight::from_parts(24_351_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:0) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(347), added: 2822, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:1) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1001 w:1000) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(479), added: 2954, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1000 w:1000) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts CollectionMetadataOf (r:0 w:1) + /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(294), added: 2769, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:1) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// The range of component `m` is `[0, 1000]`. + /// The range of component `c` is `[0, 1000]`. + /// The range of component `a` is `[0, 1000]`. + fn destroy(_m: u32, _c: u32, a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `32170 + a * (366 ±0)` + // Estimated: `2523990 + a * (2954 ±0)` + // Minimum execution time: 992_533_000 picoseconds. + Weight::from_parts(941_813_359, 0) + .saturating_add(Weight::from_parts(0, 2523990)) + // Standard Error: 3_954 + .saturating_add(Weight::from_parts(5_784_754, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(1004)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(1005)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 2954).saturating_mul(a.into())) + } + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + fn mint() -> Weight { + // Proof Size summary in bytes: + // Measured: `421` + // Estimated: `4326` + // Minimum execution time: 49_305_000 picoseconds. + Weight::from_parts(50_143_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + fn force_mint() -> Weight { + // Proof Size summary in bytes: + // Measured: `421` + // Estimated: `4326` + // Minimum execution time: 48_627_000 picoseconds. + Weight::from_parts(48_954_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:0) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(347), added: 2822, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:0 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(1001), added: 3476, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) + fn burn() -> Weight { + // Proof Size summary in bytes: + // Measured: `530` + // Estimated: `4326` + // Minimum execution time: 49_958_000 picoseconds. + Weight::from_parts(50_387_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(7)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:2) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) + fn transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `4326` + // Minimum execution time: 36_267_000 picoseconds. + Weight::from_parts(36_712_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:5000 w:5000) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// The range of component `i` is `[0, 5000]`. + fn redeposit(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `729 + i * (108 ±0)` + // Estimated: `3549 + i * (3336 ±0)` + // Minimum execution time: 17_738_000 picoseconds. + Weight::from_parts(17_801_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) + // Standard Error: 13_596 + .saturating_add(Weight::from_parts(15_695_790, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_parts(0, 3336).saturating_mul(i.into())) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + fn lock_item_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `401` + // Estimated: `3534` + // Minimum execution time: 20_845_000 picoseconds. + Weight::from_parts(21_133_000, 0) + .saturating_add(Weight::from_parts(0, 3534)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + fn unlock_item_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `401` + // Estimated: `3534` + // Minimum execution time: 20_862_000 picoseconds. + Weight::from_parts(21_105_000, 0) + .saturating_add(Weight::from_parts(0, 3534)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + fn lock_collection() -> Weight { + // Proof Size summary in bytes: + // Measured: `306` + // Estimated: `3549` + // Minimum execution time: 18_196_000 picoseconds. + Weight::from_parts(18_333_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts OwnershipAcceptance (r:1 w:1) + /// Proof: Nfts OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:2) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn transfer_ownership() -> Weight { + // Proof Size summary in bytes: + // Measured: `354` + // Estimated: `3549` + // Minimum execution time: 24_025_000 picoseconds. + Weight::from_parts(24_277_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:2 w:4) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + fn set_team() -> Weight { + // Proof Size summary in bytes: + // Measured: `335` + // Estimated: `6078` + // Minimum execution time: 40_974_000 picoseconds. + Weight::from_parts(41_706_000, 0) + .saturating_add(Weight::from_parts(0, 6078)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:2) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn force_collection_owner() -> Weight { + // Proof Size summary in bytes: + // Measured: `277` + // Estimated: `3549` + // Minimum execution time: 19_044_000 picoseconds. + Weight::from_parts(19_465_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + fn force_collection_config() -> Weight { + // Proof Size summary in bytes: + // Measured: `242` + // Estimated: `3549` + // Minimum execution time: 15_591_000 picoseconds. + Weight::from_parts(15_858_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + fn lock_item_properties() -> Weight { + // Proof Size summary in bytes: + // Measured: `401` + // Estimated: `3534` + // Minimum execution time: 20_831_000 picoseconds. + Weight::from_parts(21_121_000, 0) + .saturating_add(Weight::from_parts(0, 3534)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1 w:1) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(479), added: 2954, mode: MaxEncodedLen) + fn set_attribute() -> Weight { + // Proof Size summary in bytes: + // Measured: `505` + // Estimated: `3944` + // Minimum execution time: 50_650_000 picoseconds. + Weight::from_parts(51_315_000, 0) + .saturating_add(Weight::from_parts(0, 3944)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1 w:1) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(479), added: 2954, mode: MaxEncodedLen) + fn force_set_attribute() -> Weight { + // Proof Size summary in bytes: + // Measured: `310` + // Estimated: `3944` + // Minimum execution time: 28_244_000 picoseconds. + Weight::from_parts(28_627_000, 0) + .saturating_add(Weight::from_parts(0, 3944)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Nfts Attribute (r:1 w:1) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(479), added: 2954, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + fn clear_attribute() -> Weight { + // Proof Size summary in bytes: + // Measured: `949` + // Estimated: `3944` + // Minimum execution time: 47_299_000 picoseconds. + Weight::from_parts(47_921_000, 0) + .saturating_add(Weight::from_parts(0, 3944)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(1001), added: 3476, mode: MaxEncodedLen) + fn approve_item_attributes() -> Weight { + // Proof Size summary in bytes: + // Measured: `347` + // Estimated: `4466` + // Minimum execution time: 19_400_000 picoseconds. + Weight::from_parts(19_601_000, 0) + .saturating_add(Weight::from_parts(0, 4466)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(1001), added: 3476, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1001 w:1000) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(479), added: 2954, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 1000]`. + fn cancel_item_attributes_approval(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `726 + n * (398 ±0)` + // Estimated: `4466 + n * (2954 ±0)` + // Minimum execution time: 28_552_000 picoseconds. + Weight::from_parts(28_822_000, 0) + .saturating_add(Weight::from_parts(0, 4466)) + // Standard Error: 3_265 + .saturating_add(Weight::from_parts(5_570_824, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2954).saturating_mul(n.into())) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:1) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(347), added: 2822, mode: MaxEncodedLen) + fn set_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `505` + // Estimated: `3812` + // Minimum execution time: 42_425_000 picoseconds. + Weight::from_parts(42_883_000, 0) + .saturating_add(Weight::from_parts(0, 3812)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:1) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(347), added: 2822, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + fn clear_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `815` + // Estimated: `3812` + // Minimum execution time: 40_219_000 picoseconds. + Weight::from_parts(41_709_000, 0) + .saturating_add(Weight::from_parts(0, 3812)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionMetadataOf (r:1 w:1) + /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(294), added: 2769, mode: MaxEncodedLen) + fn set_collection_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `364` + // Estimated: `3759` + // Minimum execution time: 39_376_000 picoseconds. + Weight::from_parts(39_895_000, 0) + .saturating_add(Weight::from_parts(0, 3759)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionMetadataOf (r:1 w:1) + /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(294), added: 2769, mode: MaxEncodedLen) + fn clear_collection_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `682` + // Estimated: `3759` + // Minimum execution time: 38_414_000 picoseconds. + Weight::from_parts(38_627_000, 0) + .saturating_add(Weight::from_parts(0, 3759)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + fn approve_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `376` + // Estimated: `4326` + // Minimum execution time: 22_896_000 picoseconds. + Weight::from_parts(23_137_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + fn cancel_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `384` + // Estimated: `4326` + // Minimum execution time: 20_602_000 picoseconds. + Weight::from_parts(20_869_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + fn clear_all_transfer_approvals() -> Weight { + // Proof Size summary in bytes: + // Measured: `384` + // Estimated: `4326` + // Minimum execution time: 19_415_000 picoseconds. + Weight::from_parts(19_594_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts OwnershipAcceptance (r:1 w:1) + /// Proof: Nfts OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + fn set_accept_ownership() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `3517` + // Minimum execution time: 16_784_000 picoseconds. + Weight::from_parts(17_133_000, 0) + .saturating_add(Weight::from_parts(0, 3517)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts CollectionConfigOf (r:1 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + fn set_collection_max_supply() -> Weight { + // Proof Size summary in bytes: + // Measured: `306` + // Estimated: `3549` + // Minimum execution time: 20_391_000 picoseconds. + Weight::from_parts(20_710_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + fn update_mint_settings() -> Weight { + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `3538` + // Minimum execution time: 19_989_000 picoseconds. + Weight::from_parts(20_179_000, 0) + .saturating_add(Weight::from_parts(0, 3538)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + fn set_price() -> Weight { + // Proof Size summary in bytes: + // Measured: `484` + // Estimated: `4326` + // Minimum execution time: 24_308_000 picoseconds. + Weight::from_parts(24_721_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:1 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:2) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) + fn buy_item() -> Weight { + // Proof Size summary in bytes: + // Measured: `671` + // Estimated: `4326` + // Minimum execution time: 45_626_000 picoseconds. + Weight::from_parts(46_030_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// The range of component `n` is `[0, 10]`. + fn pay_tips(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_654_000 picoseconds. + Weight::from_parts(4_301_940, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 9_223 + .saturating_add(Weight::from_parts(3_945_966, 0).saturating_mul(n.into())) + } + /// Storage: Nfts Item (r:2 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) + fn create_swap() -> Weight { + // Proof Size summary in bytes: + // Measured: `460` + // Estimated: `7662` + // Minimum execution time: 23_071_000 picoseconds. + Weight::from_parts(23_535_000, 0) + .saturating_add(Weight::from_parts(0, 7662)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts PendingSwapOf (r:1 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + fn cancel_swap() -> Weight { + // Proof Size summary in bytes: + // Measured: `479` + // Estimated: `4326` + // Minimum execution time: 21_554_000 picoseconds. + Weight::from_parts(21_941_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Nfts Item (r:2 w:2) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:1 w:2) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:2 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:4) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:2) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + fn claim_swap() -> Weight { + // Proof Size summary in bytes: + // Measured: `800` + // Estimated: `7662` + // Minimum execution time: 74_272_000 picoseconds. + Weight::from_parts(75_374_000, 0) + .saturating_add(Weight::from_parts(0, 7662)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(10)) + } + /// Storage: Nfts CollectionRoleOf (r:2 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:10 w:10) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(479), added: 2954, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:1) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(347), added: 2822, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 10]`. + fn mint_pre_signed(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `524` + // Estimated: `6078 + n * (2954 ±0)` + // Minimum execution time: 133_545_000 picoseconds. + Weight::from_parts(137_797_962, 0) + .saturating_add(Weight::from_parts(0, 6078)) + // Standard Error: 33_124 + .saturating_add(Weight::from_parts(29_785_862, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(6)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2954).saturating_mul(n.into())) + } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(1001), added: 3476, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:10 w:10) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(479), added: 2954, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 10]`. + fn set_attributes_pre_signed(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `554` + // Estimated: `4466 + n * (2954 ±0)` + // Minimum execution time: 77_475_000 picoseconds. + Weight::from_parts(88_353_947, 0) + .saturating_add(Weight::from_parts(0, 4466)) + // Standard Error: 60_491 + .saturating_add(Weight::from_parts(29_507_037, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2954).saturating_mul(n.into())) + } +} diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_proxy.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_proxy.rs similarity index 71% rename from parachains/runtimes/assets/statemine/src/weights/pallet_proxy.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_proxy.rs index 9e97e9e982d..5ffc4b30df3 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_proxy.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_proxy.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_proxy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_proxy @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_proxy.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_proxy.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_proxy`. pub struct WeightInfo(PhantomData); @@ -54,11 +55,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 16_846_000 picoseconds. - Weight::from_parts(17_545_125, 0) + // Minimum execution time: 16_736_000 picoseconds. + Weight::from_parts(17_180_115, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_168 - .saturating_add(Weight::from_parts(38_590, 0).saturating_mul(p.into())) + // Standard Error: 616 + .saturating_add(Weight::from_parts(29_847, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) } /// Storage: Proxy Proxies (r:1 w:0) @@ -72,14 +73,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn proxy_announced(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `454 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `13997` - // Minimum execution time: 35_646_000 picoseconds. - Weight::from_parts(35_944_816, 0) - .saturating_add(Weight::from_parts(0, 13997)) - // Standard Error: 1_868 - .saturating_add(Weight::from_parts(137_815, 0).saturating_mul(a.into())) - // Standard Error: 1_930 - .saturating_add(Weight::from_parts(38_331, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 38_677_000 picoseconds. + Weight::from_parts(38_332_966, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_354 + .saturating_add(Weight::from_parts(134_195, 0).saturating_mul(a.into())) + // Standard Error: 1_399 + .saturating_add(Weight::from_parts(37_946, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -92,14 +93,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn remove_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `369 + a * (68 ±0)` - // Estimated: `9291` - // Minimum execution time: 22_142_000 picoseconds. - Weight::from_parts(23_269_000, 0) - .saturating_add(Weight::from_parts(0, 9291)) - // Standard Error: 1_365 - .saturating_add(Weight::from_parts(140_747, 0).saturating_mul(a.into())) - // Standard Error: 1_411 - .saturating_add(Weight::from_parts(14_983, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 25_593_000 picoseconds. + Weight::from_parts(26_236_639, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_160 + .saturating_add(Weight::from_parts(129_362, 0).saturating_mul(a.into())) + // Standard Error: 1_199 + .saturating_add(Weight::from_parts(8_687, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -112,14 +113,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn reject_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `369 + a * (68 ±0)` - // Estimated: `9291` - // Minimum execution time: 22_465_000 picoseconds. - Weight::from_parts(23_366_335, 0) - .saturating_add(Weight::from_parts(0, 9291)) - // Standard Error: 4_348 - .saturating_add(Weight::from_parts(149_266, 0).saturating_mul(a.into())) - // Standard Error: 4_492 - .saturating_add(Weight::from_parts(10_411, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 25_596_000 picoseconds. + Weight::from_parts(25_854_867, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_372 + .saturating_add(Weight::from_parts(137_697, 0).saturating_mul(a.into())) + // Standard Error: 1_417 + .saturating_add(Weight::from_parts(14_082, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -134,14 +135,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn announce(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `386 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `13997` - // Minimum execution time: 31_086_000 picoseconds. - Weight::from_parts(32_252_234, 0) - .saturating_add(Weight::from_parts(0, 13997)) - // Standard Error: 2_039 - .saturating_add(Weight::from_parts(131_541, 0).saturating_mul(a.into())) - // Standard Error: 2_107 - .saturating_add(Weight::from_parts(41_085, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 35_255_000 picoseconds. + Weight::from_parts(34_659_291, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_072 + .saturating_add(Weight::from_parts(126_577, 0).saturating_mul(a.into())) + // Standard Error: 1_107 + .saturating_add(Weight::from_parts(41_124, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -152,11 +153,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 24_040_000 picoseconds. - Weight::from_parts(24_914_869, 0) + // Minimum execution time: 26_245_000 picoseconds. + Weight::from_parts(26_910_616, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 2_025 - .saturating_add(Weight::from_parts(47_844, 0).saturating_mul(p.into())) + // Standard Error: 1_107 + .saturating_add(Weight::from_parts(54_705, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -167,11 +168,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 23_495_000 picoseconds. - Weight::from_parts(24_788_899, 0) + // Minimum execution time: 26_080_000 picoseconds. + Weight::from_parts(27_081_618, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_911 - .saturating_add(Weight::from_parts(68_917, 0).saturating_mul(p.into())) + // Standard Error: 1_644 + .saturating_add(Weight::from_parts(53_919, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -182,24 +183,26 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 19_269_000 picoseconds. - Weight::from_parts(20_040_655, 0) + // Minimum execution time: 23_191_000 picoseconds. + Weight::from_parts(23_827_934, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_327 - .saturating_add(Weight::from_parts(24_180, 0).saturating_mul(p.into())) + // Standard Error: 1_078 + .saturating_add(Weight::from_parts(28_417, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: Proxy Proxies (r:1 w:1) /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. - fn create_pure(_p: u32, ) -> Weight { + fn create_pure(p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `139` // Estimated: `4706` - // Minimum execution time: 25_926_000 picoseconds. - Weight::from_parts(26_963_808, 0) + // Minimum execution time: 27_895_000 picoseconds. + Weight::from_parts(28_599_042, 0) .saturating_add(Weight::from_parts(0, 4706)) + // Standard Error: 953 + .saturating_add(Weight::from_parts(12_641, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -210,11 +213,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `164 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 19_961_000 picoseconds. - Weight::from_parts(20_928_300, 0) + // Minimum execution time: 24_395_000 picoseconds. + Weight::from_parts(24_924_060, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_576 - .saturating_add(Weight::from_parts(28_604, 0).saturating_mul(p.into())) + // Standard Error: 720 + .saturating_add(Weight::from_parts(27_470, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_session.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_session.rs similarity index 80% rename from parachains/runtimes/assets/statemine/src/weights/pallet_session.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_session.rs index 06d41c6383a..9d7ea753c7c 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_session.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_session.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_session` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_session @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_session.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_session.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_session`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn set_keys() -> Weight { // Proof Size summary in bytes: // Measured: `270` - // Estimated: `7470` - // Minimum execution time: 17_273_000 picoseconds. - Weight::from_parts(17_562_000, 0) - .saturating_add(Weight::from_parts(0, 7470)) + // Estimated: `3735` + // Minimum execution time: 17_271_000 picoseconds. + Weight::from_parts(17_533_000, 0) + .saturating_add(Weight::from_parts(0, 3735)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -68,10 +69,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn purge_keys() -> Weight { // Proof Size summary in bytes: // Measured: `242` - // Estimated: `3949` - // Minimum execution time: 13_268_000 picoseconds. - Weight::from_parts(13_646_000, 0) - .saturating_add(Weight::from_parts(0, 3949)) + // Estimated: `3707` + // Minimum execution time: 13_077_000 picoseconds. + Weight::from_parts(13_283_000, 0) + .saturating_add(Weight::from_parts(0, 3707)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_timestamp.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_timestamp.rs similarity index 80% rename from parachains/runtimes/assets/statemine/src/weights/pallet_timestamp.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_timestamp.rs index af27f018b00..e6d26cbfaa4 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_timestamp.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_timestamp.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_timestamp @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_timestamp.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_timestamp.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_timestamp`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_timestamp::WeightInfo for WeightInfo { fn set() -> Weight { // Proof Size summary in bytes: // Measured: `86` - // Estimated: `2986` - // Minimum execution time: 9_234_000 picoseconds. - Weight::from_parts(9_578_000, 0) - .saturating_add(Weight::from_parts(0, 2986)) + // Estimated: `1493` + // Minimum execution time: 9_418_000 picoseconds. + Weight::from_parts(9_665_000, 0) + .saturating_add(Weight::from_parts(0, 1493)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +66,8 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `57` // Estimated: `0` - // Minimum execution time: 3_193_000 picoseconds. - Weight::from_parts(3_306_000, 0) + // Minimum execution time: 3_266_000 picoseconds. + Weight::from_parts(3_386_000, 0) .saturating_add(Weight::from_parts(0, 0)) } } diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_uniques.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_uniques.rs similarity index 80% rename from parachains/runtimes/assets/statemine/src/weights/pallet_uniques.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_uniques.rs index 44846163ff0..583e54840b8 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_uniques.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_uniques.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_uniques` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_uniques @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_uniques.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_uniques.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_uniques`. pub struct WeightInfo(PhantomData); @@ -55,8 +56,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3643` - // Minimum execution time: 25_977_000 picoseconds. - Weight::from_parts(27_109_000, 0) + // Minimum execution time: 30_269_000 picoseconds. + Weight::from_parts(30_661_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -69,8 +70,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3643` - // Minimum execution time: 14_712_000 picoseconds. - Weight::from_parts(15_150_000, 0) + // Minimum execution time: 14_801_000 picoseconds. + Weight::from_parts(15_041_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -96,17 +97,17 @@ impl pallet_uniques::WeightInfo for WeightInfo { /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `257 + n * (76 ±0) + m * (56 ±0) + a * (107 ±0)` - // Estimated: `9210 + n * (2597 ±0) + a * (2647 ±0) + m * (2662 ±0)` - // Minimum execution time: 2_367_187_000 picoseconds. - Weight::from_parts(2_382_789_000, 0) - .saturating_add(Weight::from_parts(0, 9210)) - // Standard Error: 24_652 - .saturating_add(Weight::from_parts(6_204_090, 0).saturating_mul(n.into())) - // Standard Error: 24_652 - .saturating_add(Weight::from_parts(246_468, 0).saturating_mul(m.into())) - // Standard Error: 24_652 - .saturating_add(Weight::from_parts(346_915, 0).saturating_mul(a.into())) + // Measured: `257 + a * (107 ±0) + m * (56 ±0) + n * (76 ±0)` + // Estimated: `3643 + a * (2647 ±0) + m * (2662 ±0) + n * (2597 ±0)` + // Minimum execution time: 2_439_268_000 picoseconds. + Weight::from_parts(2_450_670_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) + // Standard Error: 24_972 + .saturating_add(Weight::from_parts(6_281_799, 0).saturating_mul(n.into())) + // Standard Error: 24_972 + .saturating_add(Weight::from_parts(245_622, 0).saturating_mul(m.into())) + // Standard Error: 24_972 + .saturating_add(Weight::from_parts(345_135, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) @@ -115,9 +116,9 @@ impl pallet_uniques::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(m.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) - .saturating_add(Weight::from_parts(0, 2597).saturating_mul(n.into())) .saturating_add(Weight::from_parts(0, 2647).saturating_mul(a.into())) .saturating_add(Weight::from_parts(0, 2662).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 2597).saturating_mul(n.into())) } /// Storage: Uniques Asset (r:1 w:1) /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) @@ -130,10 +131,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn mint() -> Weight { // Proof Size summary in bytes: // Measured: `282` - // Estimated: `10719` - // Minimum execution time: 31_948_000 picoseconds. - Weight::from_parts(32_314_000, 0) - .saturating_add(Weight::from_parts(0, 10719)) + // Estimated: `3643` + // Minimum execution time: 36_449_000 picoseconds. + Weight::from_parts(36_816_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -148,10 +149,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn burn() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 33_711_000 picoseconds. - Weight::from_parts(34_742_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 37_704_000 picoseconds. + Weight::from_parts(38_102_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -166,10 +167,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn transfer() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 26_609_000 picoseconds. - Weight::from_parts(27_130_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 26_986_000 picoseconds. + Weight::from_parts(27_427_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -181,12 +182,12 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `738 + i * (76 ±0)` - // Estimated: `4633 + i * (2597 ±0)` - // Minimum execution time: 15_463_000 picoseconds. - Weight::from_parts(15_625_000, 0) - .saturating_add(Weight::from_parts(0, 4633)) - // Standard Error: 12_996 - .saturating_add(Weight::from_parts(13_104_503, 0).saturating_mul(i.into())) + // Estimated: `3643 + i * (2597 ±0)` + // Minimum execution time: 15_664_000 picoseconds. + Weight::from_parts(15_788_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) + // Standard Error: 12_408 + .saturating_add(Weight::from_parts(15_388_354, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -200,10 +201,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn freeze() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 18_897_000 picoseconds. - Weight::from_parts(19_276_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 19_399_000 picoseconds. + Weight::from_parts(19_658_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -214,10 +215,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn thaw() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 18_883_000 picoseconds. - Weight::from_parts(19_526_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 19_300_000 picoseconds. + Weight::from_parts(19_511_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -227,8 +228,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 14_519_000 picoseconds. - Weight::from_parts(14_887_000, 0) + // Minimum execution time: 14_407_000 picoseconds. + Weight::from_parts(14_748_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -239,8 +240,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 14_172_000 picoseconds. - Weight::from_parts(14_395_000, 0) + // Minimum execution time: 14_376_000 picoseconds. + Weight::from_parts(14_785_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -254,10 +255,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn transfer_ownership() -> Weight { // Proof Size summary in bytes: // Measured: `356` - // Estimated: `7160` - // Minimum execution time: 22_131_000 picoseconds. - Weight::from_parts(22_540_000, 0) - .saturating_add(Weight::from_parts(0, 7160)) + // Estimated: `3643` + // Minimum execution time: 22_832_000 picoseconds. + Weight::from_parts(23_065_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -267,8 +268,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 15_582_000 picoseconds. - Weight::from_parts(15_907_000, 0) + // Minimum execution time: 15_379_000 picoseconds. + Weight::from_parts(15_798_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -281,8 +282,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 17_915_000 picoseconds. - Weight::from_parts(18_190_000, 0) + // Minimum execution time: 17_345_000 picoseconds. + Weight::from_parts(17_747_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -296,10 +297,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `559` - // Estimated: `10932` - // Minimum execution time: 37_851_000 picoseconds. - Weight::from_parts(38_554_000, 0) - .saturating_add(Weight::from_parts(0, 10932)) + // Estimated: `3652` + // Minimum execution time: 40_047_000 picoseconds. + Weight::from_parts(40_494_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -312,10 +313,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn clear_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `756` - // Estimated: `10932` - // Minimum execution time: 37_289_000 picoseconds. - Weight::from_parts(37_807_000, 0) - .saturating_add(Weight::from_parts(0, 10932)) + // Estimated: `3652` + // Minimum execution time: 39_254_000 picoseconds. + Weight::from_parts(39_689_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -326,10 +327,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `348` - // Estimated: `7295` - // Minimum execution time: 28_825_000 picoseconds. - Weight::from_parts(29_277_000, 0) - .saturating_add(Weight::from_parts(0, 7295)) + // Estimated: `3652` + // Minimum execution time: 31_189_000 picoseconds. + Weight::from_parts(31_431_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -340,10 +341,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn clear_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `559` - // Estimated: `7295` - // Minimum execution time: 29_274_000 picoseconds. - Weight::from_parts(29_941_000, 0) - .saturating_add(Weight::from_parts(0, 7295)) + // Estimated: `3652` + // Minimum execution time: 31_868_000 picoseconds. + Weight::from_parts(32_476_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -354,10 +355,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `282` - // Estimated: `7275` - // Minimum execution time: 28_196_000 picoseconds. - Weight::from_parts(28_563_000, 0) - .saturating_add(Weight::from_parts(0, 7275)) + // Estimated: `3643` + // Minimum execution time: 32_587_000 picoseconds. + Weight::from_parts(32_913_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -368,10 +369,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `473` - // Estimated: `7275` - // Minimum execution time: 26_657_000 picoseconds. - Weight::from_parts(27_189_000, 0) - .saturating_add(Weight::from_parts(0, 7275)) + // Estimated: `3643` + // Minimum execution time: 30_951_000 picoseconds. + Weight::from_parts(31_269_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -382,10 +383,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn approve_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 21_135_000 picoseconds. - Weight::from_parts(21_445_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 20_550_000 picoseconds. + Weight::from_parts(20_880_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -396,10 +397,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn cancel_approval() -> Weight { // Proof Size summary in bytes: // Measured: `461` - // Estimated: `7230` - // Minimum execution time: 20_803_000 picoseconds. - Weight::from_parts(21_249_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 20_593_000 picoseconds. + Weight::from_parts(20_816_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -409,8 +410,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3517` - // Minimum execution time: 16_421_000 picoseconds. - Weight::from_parts(16_940_000, 0) + // Minimum execution time: 16_290_000 picoseconds. + Weight::from_parts(16_841_000, 0) .saturating_add(Weight::from_parts(0, 3517)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -422,10 +423,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: // Measured: `282` - // Estimated: `7132` - // Minimum execution time: 17_792_000 picoseconds. - Weight::from_parts(18_087_000, 0) - .saturating_add(Weight::from_parts(0, 7132)) + // Estimated: `3643` + // Minimum execution time: 17_538_000 picoseconds. + Weight::from_parts(17_775_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -437,8 +438,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `259` // Estimated: `3587` - // Minimum execution time: 17_036_000 picoseconds. - Weight::from_parts(17_365_000, 0) + // Minimum execution time: 17_311_000 picoseconds. + Weight::from_parts(17_495_000, 0) .saturating_add(Weight::from_parts(0, 3587)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -454,10 +455,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn buy_item() -> Weight { // Proof Size summary in bytes: // Measured: `540` - // Estimated: `10784` - // Minimum execution time: 37_920_000 picoseconds. - Weight::from_parts(38_587_000, 0) - .saturating_add(Weight::from_parts(0, 10784)) + // Estimated: `3643` + // Minimum execution time: 37_556_000 picoseconds. + Weight::from_parts(38_050_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_utility.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_utility.rs similarity index 71% rename from parachains/runtimes/assets/statemint/src/weights/pallet_utility.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_utility.rs index d14fdba6fad..fecc38e475a 100644 --- a/parachains/runtimes/assets/statemint/src/weights/pallet_utility.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_utility.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemint-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_utility @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/pallet_utility.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_utility.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_utility`. pub struct WeightInfo(PhantomData); @@ -52,18 +53,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_357_000 picoseconds. - Weight::from_parts(16_071_177, 0) + // Minimum execution time: 7_223_000 picoseconds. + Weight::from_parts(9_533_894, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_492 - .saturating_add(Weight::from_parts(5_041_311, 0).saturating_mul(c.into())) + // Standard Error: 1_912 + .saturating_add(Weight::from_parts(4_539_292, 0).saturating_mul(c.into())) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_903_000 picoseconds. - Weight::from_parts(6_075_000, 0) + // Minimum execution time: 5_345_000 picoseconds. + Weight::from_parts(5_436_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -71,18 +72,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_616_000 picoseconds. - Weight::from_parts(17_676_240, 0) + // Minimum execution time: 7_096_000 picoseconds. + Weight::from_parts(10_872_600, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_274 - .saturating_add(Weight::from_parts(5_358_895, 0).saturating_mul(c.into())) + // Standard Error: 2_654 + .saturating_add(Weight::from_parts(4_834_319, 0).saturating_mul(c.into())) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 10_072_000 picoseconds. - Weight::from_parts(10_405_000, 0) + // Minimum execution time: 9_519_000 picoseconds. + Weight::from_parts(9_776_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -90,10 +91,10 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_207_000 picoseconds. - Weight::from_parts(18_974_639, 0) + // Minimum execution time: 7_149_000 picoseconds. + Weight::from_parts(17_125_597, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_301 - .saturating_add(Weight::from_parts(5_025_161, 0).saturating_mul(c.into())) + // Standard Error: 3_120 + .saturating_add(Weight::from_parts(4_553_744, 0).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_xcm.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_xcm.rs similarity index 84% rename from parachains/runtimes/assets/statemint/src/weights/pallet_xcm.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_xcm.rs index 32f1d1cd687..d31ebcfe719 100644 --- a/parachains/runtimes/assets/statemint/src/weights/pallet_xcm.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_xcm.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemint-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_xcm @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/pallet_xcm.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/pallet_xcm.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); @@ -60,10 +61,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn send() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `9595` - // Minimum execution time: 27_505_000 picoseconds. - Weight::from_parts(27_841_000, 0) - .saturating_add(Weight::from_parts(0, 9595)) + // Estimated: `3503` + // Minimum execution time: 26_503_000 picoseconds. + Weight::from_parts(26_786_000, 0) + .saturating_add(Weight::from_parts(0, 3503)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +74,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1489` - // Minimum execution time: 27_156_000 picoseconds. - Weight::from_parts(27_641_000, 0) + // Minimum execution time: 25_005_000 picoseconds. + Weight::from_parts(25_355_000, 0) .saturating_add(Weight::from_parts(0, 1489)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -84,8 +85,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1489` - // Minimum execution time: 20_954_000 picoseconds. - Weight::from_parts(21_381_000, 0) + // Minimum execution time: 19_585_000 picoseconds. + Weight::from_parts(19_921_000, 0) .saturating_add(Weight::from_parts(0, 1489)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -105,8 +106,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 10_560_000 picoseconds. - Weight::from_parts(10_752_000, 0) + // Minimum execution time: 9_923_000 picoseconds. + Weight::from_parts(10_123_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -116,8 +117,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_451_000 picoseconds. - Weight::from_parts(3_580_000, 0) + // Minimum execution time: 3_048_000 picoseconds. + Weight::from_parts(3_226_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -140,10 +141,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `14659` - // Minimum execution time: 33_607_000 picoseconds. - Weight::from_parts(33_917_000, 0) - .saturating_add(Weight::from_parts(0, 14659)) + // Estimated: `3503` + // Minimum execution time: 30_761_000 picoseconds. + Weight::from_parts(31_177_000, 0) + .saturating_add(Weight::from_parts(0, 3503)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -164,19 +165,21 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `220` - // Estimated: `14410` - // Minimum execution time: 35_300_000 picoseconds. - Weight::from_parts(35_783_000, 0) - .saturating_add(Weight::from_parts(0, 14410)) + // Estimated: `3685` + // Minimum execution time: 33_124_000 picoseconds. + Weight::from_parts(33_531_000, 0) + .saturating_add(Weight::from_parts(0, 3685)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: PolkadotXcm XcmExecutionSuspended (r:0 w:1) + /// Proof Skipped: PolkadotXcm XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured) fn force_suspension() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_451_000 picoseconds. - Weight::from_parts(3_580_000, 0) + // Minimum execution time: 3_119_000 picoseconds. + Weight::from_parts(3_353_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -186,8 +189,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `95` // Estimated: `10985` - // Minimum execution time: 15_664_000 picoseconds. - Weight::from_parts(15_908_000, 0) + // Minimum execution time: 14_497_000 picoseconds. + Weight::from_parts(14_785_000, 0) .saturating_add(Weight::from_parts(0, 10985)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -198,8 +201,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `99` // Estimated: `10989` - // Minimum execution time: 15_376_000 picoseconds. - Weight::from_parts(15_780_000, 0) + // Minimum execution time: 14_846_000 picoseconds. + Weight::from_parts(15_064_000, 0) .saturating_add(Weight::from_parts(0, 10989)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -210,8 +213,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `13471` - // Minimum execution time: 15_898_000 picoseconds. - Weight::from_parts(16_159_000, 0) + // Minimum execution time: 15_346_000 picoseconds. + Weight::from_parts(15_580_000, 0) .saturating_add(Weight::from_parts(0, 13471)) .saturating_add(T::DbWeight::get().reads(5)) } @@ -230,10 +233,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn notify_current_targets() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `15981` - // Minimum execution time: 31_267_000 picoseconds. - Weight::from_parts(31_635_000, 0) - .saturating_add(Weight::from_parts(0, 15981)) + // Estimated: `6046` + // Minimum execution time: 29_631_000 picoseconds. + Weight::from_parts(30_224_000, 0) + .saturating_add(Weight::from_parts(0, 6046)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -243,8 +246,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `136` // Estimated: `8551` - // Minimum execution time: 8_659_000 picoseconds. - Weight::from_parts(8_983_000, 0) + // Minimum execution time: 8_203_000 picoseconds. + Weight::from_parts(8_380_000, 0) .saturating_add(Weight::from_parts(0, 8551)) .saturating_add(T::DbWeight::get().reads(3)) } @@ -254,8 +257,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `10996` - // Minimum execution time: 16_025_000 picoseconds. - Weight::from_parts(16_296_000, 0) + // Minimum execution time: 15_138_000 picoseconds. + Weight::from_parts(15_396_000, 0) .saturating_add(Weight::from_parts(0, 10996)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -275,10 +278,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: // Measured: `112` - // Estimated: `20967` - // Minimum execution time: 37_654_000 picoseconds. - Weight::from_parts(38_144_000, 0) - .saturating_add(Weight::from_parts(0, 20967)) + // Estimated: `11002` + // Minimum execution time: 34_941_000 picoseconds. + Weight::from_parts(35_810_000, 0) + .saturating_add(Weight::from_parts(0, 11002)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } diff --git a/parachains/runtimes/assets/statemint/src/weights/paritydb_weights.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/paritydb_weights.rs similarity index 100% rename from parachains/runtimes/assets/statemint/src/weights/paritydb_weights.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/paritydb_weights.rs diff --git a/parachains/runtimes/assets/statemint/src/weights/rocksdb_weights.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/rocksdb_weights.rs similarity index 100% rename from parachains/runtimes/assets/statemint/src/weights/rocksdb_weights.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/rocksdb_weights.rs diff --git a/parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/mod.rs similarity index 95% rename from parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/mod.rs index 877a54ba848..234ab204fbc 100644 --- a/parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/mod.rs @@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -53,19 +52,19 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } -pub struct StatemineXcmWeight(core::marker::PhantomData); -impl XcmWeightInfo for StatemineXcmWeight { +pub struct AssetHubPolkadotXcmWeight(core::marker::PhantomData); +impl XcmWeightInfo for AssetHubPolkadotXcmWeight { fn withdraw_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset()) } // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -123,7 +122,7 @@ impl XcmWeightInfo for StatemineXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } diff --git a/parachains/runtimes/assets/statemint/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs similarity index 87% rename from parachains/runtimes/assets/statemint/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 147a348b19d..474a93465a9 100644 --- a/parachains/runtimes/assets/statemint/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -17,17 +17,17 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::fungible` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet // --template=./templates/xcm-bench-template.hbs -// --chain=statemint-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_xcm_benchmarks::fungible @@ -36,7 +36,7 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -54,8 +54,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `101` // Estimated: `3593` - // Minimum execution time: 23_489_000 picoseconds. - Weight::from_parts(23_993_000, 3593) + // Minimum execution time: 25_798_000 picoseconds. + Weight::from_parts(26_063_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +65,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `101` // Estimated: `6196` - // Minimum execution time: 32_933_000 picoseconds. - Weight::from_parts(33_445_000, 6196) + // Minimum execution time: 48_637_000 picoseconds. + Weight::from_parts(49_176_000, 6196) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -87,9 +87,9 @@ impl WeightInfo { pub fn transfer_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `139` - // Estimated: `17785` - // Minimum execution time: 56_285_000 picoseconds. - Weight::from_parts(56_858_000, 17785) + // Estimated: `6196` + // Minimum execution time: 69_969_000 picoseconds. + Weight::from_parts(70_663_000, 6196) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -97,8 +97,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_900_000 picoseconds. - Weight::from_parts(4_996_000, 0) + // Minimum execution time: 3_909_000 picoseconds. + Weight::from_parts(4_060_000, 0) } // Storage: System Account (r:1 w:1) // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) @@ -106,8 +106,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 26_047_000 picoseconds. - Weight::from_parts(26_408_000, 3593) + // Minimum execution time: 26_306_000 picoseconds. + Weight::from_parts(26_822_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -128,9 +128,9 @@ impl WeightInfo { pub fn deposit_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `14677` - // Minimum execution time: 48_997_000 picoseconds. - Weight::from_parts(49_605_000, 14677) + // Estimated: `3593` + // Minimum execution time: 48_829_000 picoseconds. + Weight::from_parts(49_277_000, 3593) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -149,9 +149,9 @@ impl WeightInfo { pub fn initiate_teleport() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `11084` - // Minimum execution time: 31_114_000 picoseconds. - Weight::from_parts(31_825_000, 11084) + // Estimated: `3503` + // Minimum execution time: 28_753_000 picoseconds. + Weight::from_parts(29_256_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/assets/statemint/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs similarity index 80% rename from parachains/runtimes/assets/statemint/src/weights/xcm/pallet_xcm_benchmarks_generic.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index ca264e8fa17..6f65e27184a 100644 --- a/parachains/runtimes/assets/statemint/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,17 +17,17 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet // --template=./templates/xcm-bench-template.hbs -// --chain=statemint-dev +// --chain=asset-hub-polkadot-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_xcm_benchmarks::generic @@ -36,7 +36,7 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +// --output=./parachains/runtimes/assets/asset-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -63,9 +63,9 @@ impl WeightInfo { pub fn report_holding() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `11084` - // Minimum execution time: 452_120_000 picoseconds. - Weight::from_parts(453_246_000, 11084) + // Estimated: `3503` + // Minimum execution time: 360_004_000 picoseconds. + Weight::from_parts(361_533_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +73,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_323_000 picoseconds. - Weight::from_parts(4_409_000, 0) + // Minimum execution time: 4_029_000 picoseconds. + Weight::from_parts(4_132_000, 0) } // Storage: PolkadotXcm Queries (r:1 w:0) // Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) @@ -82,58 +82,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 12_046_000 picoseconds. - Weight::from_parts(12_316_000, 3497) + // Minimum execution time: 10_802_000 picoseconds. + Weight::from_parts(10_932_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 14_603_000 picoseconds. - Weight::from_parts(14_929_000, 0) + // Minimum execution time: 13_281_000 picoseconds. + Weight::from_parts(13_574_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_461_000 picoseconds. - Weight::from_parts(4_655_000, 0) + // Minimum execution time: 4_257_000 picoseconds. + Weight::from_parts(4_394_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_400_000 picoseconds. - Weight::from_parts(3_487_000, 0) + // Minimum execution time: 2_829_000 picoseconds. + Weight::from_parts(2_911_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_337_000 picoseconds. - Weight::from_parts(3_403_000, 0) + // Minimum execution time: 2_881_000 picoseconds. + Weight::from_parts(2_964_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_259_000 picoseconds. - Weight::from_parts(3_350_000, 0) + // Minimum execution time: 2_850_000 picoseconds. + Weight::from_parts(2_915_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_292_000 picoseconds. - Weight::from_parts(4_471_000, 0) + // Minimum execution time: 3_663_000 picoseconds. + Weight::from_parts(3_745_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_281_000 picoseconds. - Weight::from_parts(3_329_000, 0) + // Minimum execution time: 2_804_000 picoseconds. + Weight::from_parts(2_895_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -150,9 +150,9 @@ impl WeightInfo { pub fn report_error() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `11084` - // Minimum execution time: 26_054_000 picoseconds. - Weight::from_parts(26_386_000, 11084) + // Estimated: `3503` + // Minimum execution time: 24_558_000 picoseconds. + Weight::from_parts(24_983_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -162,8 +162,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 16_413_000 picoseconds. - Weight::from_parts(16_590_000, 3555) + // Minimum execution time: 15_020_000 picoseconds. + Weight::from_parts(15_368_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -171,8 +171,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_314_000 picoseconds. - Weight::from_parts(3_410_000, 0) + // Minimum execution time: 2_954_000 picoseconds. + Weight::from_parts(3_028_000, 0) } // Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1) // Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) @@ -189,9 +189,9 @@ impl WeightInfo { pub fn subscribe_version() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `13098` - // Minimum execution time: 28_232_000 picoseconds. - Weight::from_parts(28_661_000, 13098) + // Estimated: `3503` + // Minimum execution time: 26_773_000 picoseconds. + Weight::from_parts(27_256_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -201,8 +201,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_517_000 picoseconds. - Weight::from_parts(5_596_000, 0) + // Minimum execution time: 4_896_000 picoseconds. + Weight::from_parts(5_044_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainInfo ParachainId (r:1 w:0) @@ -220,9 +220,9 @@ impl WeightInfo { pub fn initiate_reserve_withdraw() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `11084` - // Minimum execution time: 502_759_000 picoseconds. - Weight::from_parts(504_262_000, 11084) + // Estimated: `3503` + // Minimum execution time: 399_114_000 picoseconds. + Weight::from_parts(400_268_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -230,36 +230,36 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 157_990_000 picoseconds. - Weight::from_parts(158_216_000, 0) + // Minimum execution time: 122_318_000 picoseconds. + Weight::from_parts(122_649_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 15_005_000 picoseconds. - Weight::from_parts(15_203_000, 0) + // Minimum execution time: 12_851_000 picoseconds. + Weight::from_parts(13_267_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_475_000 picoseconds. - Weight::from_parts(3_522_000, 0) + // Minimum execution time: 2_886_000 picoseconds. + Weight::from_parts(2_954_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_343_000 picoseconds. - Weight::from_parts(3_417_000, 0) + // Minimum execution time: 2_920_000 picoseconds. + Weight::from_parts(3_021_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_519_000 picoseconds. - Weight::from_parts(3_625_000, 0) + // Minimum execution time: 3_184_000 picoseconds. + Weight::from_parts(3_236_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -276,9 +276,9 @@ impl WeightInfo { pub fn query_pallet() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `11084` - // Minimum execution time: 29_760_000 picoseconds. - Weight::from_parts(30_340_000, 11084) + // Estimated: `3503` + // Minimum execution time: 27_230_000 picoseconds. + Weight::from_parts(27_825_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -286,8 +286,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_732_000 picoseconds. - Weight::from_parts(5_858_000, 0) + // Minimum execution time: 5_273_000 picoseconds. + Weight::from_parts(5_359_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -304,9 +304,9 @@ impl WeightInfo { pub fn report_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `11084` - // Minimum execution time: 26_440_000 picoseconds. - Weight::from_parts(26_870_000, 11084) + // Estimated: `3503` + // Minimum execution time: 24_714_000 picoseconds. + Weight::from_parts(25_082_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -314,35 +314,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_334_000 picoseconds. - Weight::from_parts(3_408_000, 0) + // Minimum execution time: 2_817_000 picoseconds. + Weight::from_parts(2_880_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_263_000 picoseconds. - Weight::from_parts(3_380_000, 0) + // Minimum execution time: 2_775_000 picoseconds. + Weight::from_parts(2_847_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_338_000 picoseconds. - Weight::from_parts(3_388_000, 0) + // Minimum execution time: 2_806_000 picoseconds. + Weight::from_parts(2_869_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_286_000 picoseconds. - Weight::from_parts(3_384_000, 0) + // Minimum execution time: 2_881_000 picoseconds. + Weight::from_parts(2_964_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_494_000 picoseconds. - Weight::from_parts(3_563_000, 0) + // Minimum execution time: 2_985_000 picoseconds. + Weight::from_parts(3_087_000, 0) } } diff --git a/parachains/runtimes/assets/statemine/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs similarity index 60% rename from parachains/runtimes/assets/statemine/src/xcm_config.rs rename to parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs index dc08ea60f46..9e39a062328 100644 --- a/parachains/runtimes/assets/statemine/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/src/xcm_config.rs @@ -27,28 +27,24 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ - AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry, - }, -}; +use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, - ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, WithComputedOrigin, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, + DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FungiblesAdapter, IsConcrete, + LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + WeightInfoBounds, WithComputedOrigin, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; parameter_types! { - pub const KsmLocation: MultiLocation = MultiLocation::parent(); - pub const RelayNetwork: Option = Some(NetworkId::Kusama); + pub const DotLocation: MultiLocation = MultiLocation::parent(); + pub const RelayNetwork: Option = Some(NetworkId::Polkadot); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); @@ -56,8 +52,8 @@ parameter_types! { pub TrustBackedAssetsPalletLocation: MultiLocation = PalletInstance(::index() as u8).into(); pub CheckingAccount: AccountId = PolkadotXcm::check_account(); + pub FellowshipLocation: MultiLocation = MultiLocation::new(1, Parachain(1001)); pub const GovernanceLocation: MultiLocation = MultiLocation::parent(); - pub const FellowshipLocation: MultiLocation = MultiLocation::parent(); } /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used @@ -77,7 +73,7 @@ pub type CurrencyTransactor = CurrencyAdapter< // Use this currency: Balances, // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, + IsConcrete, // Convert an XCM MultiLocation into a local account id: LocationToAccountId, // Our chain's account ID type (we can't get away without mentioning it explicitly): @@ -86,7 +82,7 @@ pub type CurrencyTransactor = CurrencyAdapter< (), >; -/// `AssetId/Balance` converter for `TrustBackedAssets` +/// `AssetId/Balance` converter for `TrustBackedAssets`` pub type TrustBackedAssetsConvertedConcreteId = assets_common::TrustBackedAssetsConvertedConcreteId; @@ -112,9 +108,9 @@ pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConverte ( // Ignore `TrustBackedAssets` explicitly StartsWith, - // Ignore asset which starts explicitly with our `GlobalConsensus(NetworkId)`, means: - // - foreign assets from our consensus should be: `MultiLocation {parent: 1, X*(Parachain(xyz))} - // - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` wont be accepted here + // Ignore assets that start explicitly with our `GlobalConsensus(NetworkId)`, means: + // - foreign assets from our consensus should be: `MultiLocation {parents: 1, X*(Parachain(xyz), ..)}` + // - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` won't be accepted here StartsWithExplicitGlobalConsensus, ), Balance, @@ -178,6 +174,9 @@ match_types! { MultiLocation { parents: 1, interior: Here } | MultiLocation { parents: 1, interior: X1(_) } }; + pub type FellowsPlurality: impl Contains = { + MultiLocation { parents: 1, interior: X2(Parachain(1001), Plurality { id: BodyId::Technical, ..}) } + }; } /// A call filter for the XCM Transact instruction. This is a temporary measure until we properly @@ -197,150 +196,149 @@ impl Contains for SafeCallFilter { } } - match call { + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Assets( - pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::ForeignAssets( + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. } | + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Assets( + pallet_assets::Call::create { .. } | + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::set_metadata { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::ForeignAssets( pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::set_metadata { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::Nfts( + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::set_metadata { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::Nfts( pallet_nfts::Call::create { .. } | - pallet_nfts::Call::force_create { .. } | - pallet_nfts::Call::destroy { .. } | - pallet_nfts::Call::mint { .. } | - pallet_nfts::Call::force_mint { .. } | - pallet_nfts::Call::burn { .. } | - pallet_nfts::Call::transfer { .. } | - pallet_nfts::Call::lock_item_transfer { .. } | - pallet_nfts::Call::unlock_item_transfer { .. } | - pallet_nfts::Call::lock_collection { .. } | - pallet_nfts::Call::transfer_ownership { .. } | - pallet_nfts::Call::set_team { .. } | - pallet_nfts::Call::force_collection_owner { .. } | - pallet_nfts::Call::force_collection_config { .. } | - pallet_nfts::Call::approve_transfer { .. } | - pallet_nfts::Call::cancel_approval { .. } | - pallet_nfts::Call::clear_all_transfer_approvals { .. } | - pallet_nfts::Call::lock_item_properties { .. } | - pallet_nfts::Call::set_attribute { .. } | - pallet_nfts::Call::force_set_attribute { .. } | - pallet_nfts::Call::clear_attribute { .. } | - pallet_nfts::Call::approve_item_attributes { .. } | - pallet_nfts::Call::cancel_item_attributes_approval { .. } | - pallet_nfts::Call::set_metadata { .. } | - pallet_nfts::Call::clear_metadata { .. } | - pallet_nfts::Call::set_collection_metadata { .. } | - pallet_nfts::Call::clear_collection_metadata { .. } | - pallet_nfts::Call::set_accept_ownership { .. } | - pallet_nfts::Call::set_collection_max_supply { .. } | - pallet_nfts::Call::update_mint_settings { .. } | - pallet_nfts::Call::set_price { .. } | - pallet_nfts::Call::buy_item { .. } | - pallet_nfts::Call::pay_tips { .. } | - pallet_nfts::Call::create_swap { .. } | - pallet_nfts::Call::cancel_swap { .. } | - pallet_nfts::Call::claim_swap { .. }, - ) | - RuntimeCall::Uniques( + pallet_nfts::Call::force_create { .. } | + pallet_nfts::Call::destroy { .. } | + pallet_nfts::Call::mint { .. } | + pallet_nfts::Call::force_mint { .. } | + pallet_nfts::Call::burn { .. } | + pallet_nfts::Call::transfer { .. } | + pallet_nfts::Call::lock_item_transfer { .. } | + pallet_nfts::Call::unlock_item_transfer { .. } | + pallet_nfts::Call::lock_collection { .. } | + pallet_nfts::Call::transfer_ownership { .. } | + pallet_nfts::Call::set_team { .. } | + pallet_nfts::Call::force_collection_owner { .. } | + pallet_nfts::Call::force_collection_config { .. } | + pallet_nfts::Call::approve_transfer { .. } | + pallet_nfts::Call::cancel_approval { .. } | + pallet_nfts::Call::clear_all_transfer_approvals { .. } | + pallet_nfts::Call::lock_item_properties { .. } | + pallet_nfts::Call::set_attribute { .. } | + pallet_nfts::Call::force_set_attribute { .. } | + pallet_nfts::Call::clear_attribute { .. } | + pallet_nfts::Call::approve_item_attributes { .. } | + pallet_nfts::Call::cancel_item_attributes_approval { .. } | + pallet_nfts::Call::set_metadata { .. } | + pallet_nfts::Call::clear_metadata { .. } | + pallet_nfts::Call::set_collection_metadata { .. } | + pallet_nfts::Call::clear_collection_metadata { .. } | + pallet_nfts::Call::set_accept_ownership { .. } | + pallet_nfts::Call::set_collection_max_supply { .. } | + pallet_nfts::Call::update_mint_settings { .. } | + pallet_nfts::Call::set_price { .. } | + pallet_nfts::Call::buy_item { .. } | + pallet_nfts::Call::pay_tips { .. } | + pallet_nfts::Call::create_swap { .. } | + pallet_nfts::Call::cancel_swap { .. } | + pallet_nfts::Call::claim_swap { .. }, + ) | RuntimeCall::Uniques( pallet_uniques::Call::create { .. } | - pallet_uniques::Call::force_create { .. } | - pallet_uniques::Call::destroy { .. } | - pallet_uniques::Call::mint { .. } | - pallet_uniques::Call::burn { .. } | - pallet_uniques::Call::transfer { .. } | - pallet_uniques::Call::freeze { .. } | - pallet_uniques::Call::thaw { .. } | - pallet_uniques::Call::freeze_collection { .. } | - pallet_uniques::Call::thaw_collection { .. } | - pallet_uniques::Call::transfer_ownership { .. } | - pallet_uniques::Call::set_team { .. } | - pallet_uniques::Call::approve_transfer { .. } | - pallet_uniques::Call::cancel_approval { .. } | - pallet_uniques::Call::force_item_status { .. } | - pallet_uniques::Call::set_attribute { .. } | - pallet_uniques::Call::clear_attribute { .. } | - pallet_uniques::Call::set_metadata { .. } | - pallet_uniques::Call::clear_metadata { .. } | - pallet_uniques::Call::set_collection_metadata { .. } | - pallet_uniques::Call::clear_collection_metadata { .. } | - pallet_uniques::Call::set_accept_ownership { .. } | - pallet_uniques::Call::set_collection_max_supply { .. } | - pallet_uniques::Call::set_price { .. } | - pallet_uniques::Call::buy_item { .. }, - ) => true, - _ => false, - } + pallet_uniques::Call::force_create { .. } | + pallet_uniques::Call::destroy { .. } | + pallet_uniques::Call::mint { .. } | + pallet_uniques::Call::burn { .. } | + pallet_uniques::Call::transfer { .. } | + pallet_uniques::Call::freeze { .. } | + pallet_uniques::Call::thaw { .. } | + pallet_uniques::Call::freeze_collection { .. } | + pallet_uniques::Call::thaw_collection { .. } | + pallet_uniques::Call::transfer_ownership { .. } | + pallet_uniques::Call::set_team { .. } | + pallet_uniques::Call::approve_transfer { .. } | + pallet_uniques::Call::cancel_approval { .. } | + pallet_uniques::Call::force_item_status { .. } | + pallet_uniques::Call::set_attribute { .. } | + pallet_uniques::Call::clear_attribute { .. } | + pallet_uniques::Call::set_metadata { .. } | + pallet_uniques::Call::clear_metadata { .. } | + pallet_uniques::Call::set_collection_metadata { .. } | + pallet_uniques::Call::clear_collection_metadata { .. } | + pallet_uniques::Call::set_accept_ownership { .. } | + pallet_uniques::Call::set_collection_max_supply { .. } | + pallet_uniques::Call::set_price { .. } | + pallet_uniques::Call::buy_item { .. }, + ) + ) } } @@ -355,8 +353,8 @@ pub type Barrier = DenyThenTry< ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Parent and its pluralities (i.e. governance bodies) get free execution. - AllowExplicitUnpaidExecutionFrom, + // Parent, its pluralities (i.e. governance bodies), and the Fellows plurality get free execution. + AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, ), @@ -379,12 +377,12 @@ impl xcm_executor::Config for XcmConfig { type XcmSender = XcmRouter; type AssetTransactor = AssetTransactors; type OriginConverter = XcmOriginToTransactDispatchOrigin; - // Statemine does not recognize a reserve location for any asset. This does not prevent - // Statemine acting _as_ a reserve location for KSM and assets created under `pallet-assets`. - // For KSM, users must use teleport where allowed (e.g. with the Relay Chain). + // Asset Hub Polkadot does not recognize a reserve location for any asset. This does not prevent + // Asset Hub acting _as_ a reserve location for DOT and assets created under `pallet-assets`. + // For DOT, users must use teleport where allowed (e.g. with the Relay Chain). type IsReserve = (); // We allow: - // - teleportation of KSM + // - teleportation of DOT // - teleportation of sibling parachain's assets (as ForeignCreators) type IsTeleporter = ( NativeAsset, @@ -393,12 +391,12 @@ impl xcm_executor::Config for XcmConfig { type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds< - crate::weights::xcm::StatemineXcmWeight, + crate::weights::xcm::AssetHubPolkadotXcmWeight, RuntimeCall, MaxInstructions, >; type Trader = ( - UsingComponents>, + UsingComponents>, cumulus_primitives_utility::TakeFirstAssetTrader< AccountId, AssetFeeAsExistentialDepositMultiplierFeeCharger, @@ -457,11 +455,10 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = WeightInfoBounds< - crate::weights::xcm::StatemineXcmWeight, + crate::weights::xcm::AssetHubPolkadotXcmWeight, RuntimeCall, MaxInstructions, >; - type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; @@ -476,6 +473,8 @@ impl pallet_xcm::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { @@ -492,9 +491,7 @@ pub type ForeignCreatorsSovereignAccountOf = ( /// Simple conversion of `u32` into an `AssetId` for use in benchmarking. pub struct XcmBenchmarkHelper; #[cfg(feature = "runtime-benchmarks")] -use pallet_assets::BenchmarkHelper; -#[cfg(feature = "runtime-benchmarks")] -impl BenchmarkHelper for XcmBenchmarkHelper { +impl pallet_assets::BenchmarkHelper for XcmBenchmarkHelper { fn create_asset_id_parameter(id: u32) -> MultiLocation { MultiLocation { parents: 1, interior: X1(Parachain(id)) } } diff --git a/parachains/runtimes/assets/statemint/tests/tests.rs b/parachains/runtimes/assets/asset-hub-polkadot/tests/tests.rs similarity index 72% rename from parachains/runtimes/assets/statemint/tests/tests.rs rename to parachains/runtimes/assets/asset-hub-polkadot/tests/tests.rs index 7bbed6bb54a..f78f53c5e6b 100644 --- a/parachains/runtimes/assets/statemint/tests/tests.rs +++ b/parachains/runtimes/assets/asset-hub-polkadot/tests/tests.rs @@ -1,5 +1,14 @@ -use asset_test_utils::{ExtBuilder, RuntimeHelper}; -use codec::Decode; +use asset_hub_polkadot_runtime::xcm_config::{ + AssetFeeAsExistentialDepositMultiplierFeeCharger, CheckingAccount, DotLocation, + ForeignCreatorsSovereignAccountOf, TrustBackedAssetsPalletLocation, XcmConfig, +}; +pub use asset_hub_polkadot_runtime::{ + constants::fee::WeightToFee, AssetDeposit, Assets, Balances, ExistentialDeposit, ForeignAssets, + ForeignAssetsInstance, MetadataDepositBase, MetadataDepositPerByte, ParachainSystem, Runtime, + RuntimeCall, RuntimeEvent, SessionKeys, System, TrustBackedAssetsInstance, +}; +use asset_test_utils::{CollatorSessionKeys, ExtBuilder, RuntimeHelper}; +use codec::{Decode, Encode}; use cumulus_primitives_utility::ChargeWeightInFungibles; use frame_support::{ assert_noop, assert_ok, @@ -7,25 +16,25 @@ use frame_support::{ weights::{Weight, WeightToFee as WeightToFeeT}, }; use parachains_common::{ - AccountId, AssetIdForTrustBackedAssets, Balance, StatemintAuraId as AuraId, -}; -use statemint_runtime::xcm_config::{ - AssetFeeAsExistentialDepositMultiplierFeeCharger, CheckingAccount, DotLocation, - TrustBackedAssetsPalletLocation, -}; -pub use statemint_runtime::{ - constants::fee::WeightToFee, xcm_config::XcmConfig, AssetDeposit, Assets, Balances, - ExistentialDeposit, ParachainSystem, Runtime, RuntimeEvent, SessionKeys, System, - TrustBackedAssetsInstance, + AccountId, AssetHubPolkadotAuraId as AuraId, AssetIdForTrustBackedAssets, Balance, }; use xcm::latest::prelude::*; -use xcm_executor::traits::{Convert, WeightTrader}; +use xcm_executor::traits::{Convert, Identity, JustTry, WeightTrader}; const ALICE: [u8; 32] = [1u8; 32]; +const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32]; type AssetIdForTrustBackedAssetsConvert = assets_common::AssetIdForTrustBackedAssetsConvert; +fn collator_session_keys() -> CollatorSessionKeys { + CollatorSessionKeys::new( + AccountId::from(ALICE), + AccountId::from(ALICE), + SessionKeys { aura: AuraId::from(sp_core::ed25519::Public::from_raw(ALICE)) }, + ) +} + #[test] fn test_asset_xcm_trader() { ExtBuilder::::default() @@ -64,7 +73,7 @@ fn test_asset_xcm_trader() { RuntimeHelper::::run_to_block(2, Some(AccountId::from(ALICE))); // We are going to buy 400e9 weight - // Because of the ED being higher in statemine + // Because of the ED being higher in kusama's asset hub // and not to complicate things, we use a little // bit more of weight let bought = Weight::from_parts(400_000_000_000u64, 0); @@ -80,19 +89,16 @@ fn test_asset_xcm_trader() { // Lets pay with: asset_amount_needed + asset_amount_extra let asset_amount_extra = 100_u128; let asset: MultiAsset = - (asset_multilocation.clone(), asset_amount_needed + asset_amount_extra).into(); + (asset_multilocation, asset_amount_needed + asset_amount_extra).into(); let mut trader = ::Trader::new(); // Lets buy_weight and make sure buy_weight does not return an error - match trader.buy_weight(bought, asset.into()) { - Ok(unused_assets) => { - // Check whether a correct amount of unused assets is returned - assert_ok!(unused_assets - .ensure_contains(&(asset_multilocation, asset_amount_extra).into())); - }, - Err(e) => assert!(false, "Expected Ok(_). Got {:#?}", e), - } + let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok"); + // Check whether a correct amount of unused assets is returned + assert_ok!( + unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into()) + ); // Drop trader drop(trader); @@ -146,7 +152,7 @@ fn test_asset_xcm_trader_with_refund() { RuntimeHelper::::run_to_block(2, Some(AccountId::from(ALICE))); // We are going to buy 400e9 weight - // Because of the ED being higher in statemine + // Because of the ED being higher in kusama's asset hub // and not to complicate things, we use a little // bit more of weight let bought = Weight::from_parts(400_000_000_000u64, 0); @@ -156,7 +162,7 @@ fn test_asset_xcm_trader_with_refund() { // lets calculate amount needed let amount_bought = WeightToFee::weight_to_fee(&bought); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Make sure buy_weight does not return an error assert_ok!(trader.buy_weight(bought, asset.clone().into())); @@ -219,7 +225,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() { RuntimeHelper::::run_to_block(2, Some(AccountId::from(ALICE))); // We are going to buy 50e9 weight - // Because of the ED being higher in statemine + // Because of the ED being higher in kusama's asset hub // and not to complicate things, we use a little // bit more of weight let bought = Weight::from_parts(50_000_000_000u64, 0); @@ -233,7 +239,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() { "we are testing what happens when the amount does not exceed ED" ); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Buy weight should return an error assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); @@ -286,11 +292,11 @@ fn test_that_buying_ed_refund_does_not_refund() { // We know we will have to buy at least ED, so lets make sure first it will // fail with a payment of less than ED - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); // Now lets buy ED at least - let asset: MultiAsset = (asset_multilocation.clone(), ExistentialDeposit::get()).into(); + let asset: MultiAsset = (asset_multilocation, ExistentialDeposit::get()).into(); // Buy weight should work assert_ok!(trader.buy_weight(bought, asset.into())); @@ -345,7 +351,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() { RuntimeHelper::::run_to_block(2, Some(AccountId::from(ALICE))); // We are going to buy 400e9 weight - // Because of the ED being higher in statemine + // Because of the ED being higher in kusama's asset hub // and not to complicate things, we use a little // bit more of weight let bought = Weight::from_parts(400_000_000_000u64, 0); @@ -385,9 +391,15 @@ fn test_assets_balances_api_works() { .build() .execute_with(|| { let local_asset_id = 1; + let foreign_asset_id_multilocation = + MultiLocation { parents: 1, interior: X2(Parachain(1234), GeneralIndex(12345)) }; // check before assert_eq!(Assets::balance(local_asset_id, AccountId::from(ALICE)), 0); + assert_eq!( + ForeignAssets::balance(foreign_asset_id_multilocation, AccountId::from(ALICE)), + 0 + ); assert_eq!(Balances::free_balance(AccountId::from(ALICE)), 0); assert!(Runtime::query_account_balances(AccountId::from(ALICE)) .unwrap() @@ -418,18 +430,40 @@ fn test_assets_balances_api_works() { minimum_asset_balance )); + // create foreign asset + let foreign_asset_minimum_asset_balance = 3333333_u128; + assert_ok!(ForeignAssets::force_create( + RuntimeHelper::::root_origin(), + foreign_asset_id_multilocation, + AccountId::from(SOME_ASSET_ADMIN).into(), + false, + foreign_asset_minimum_asset_balance + )); + + // We first mint enough asset for the account to exist for assets + assert_ok!(ForeignAssets::mint( + RuntimeHelper::::origin_of(AccountId::from(SOME_ASSET_ADMIN)), + foreign_asset_id_multilocation, + AccountId::from(ALICE).into(), + 6 * foreign_asset_minimum_asset_balance + )); + // check after assert_eq!( Assets::balance(local_asset_id, AccountId::from(ALICE)), minimum_asset_balance ); + assert_eq!( + ForeignAssets::balance(foreign_asset_id_multilocation, AccountId::from(ALICE)), + 6 * minimum_asset_balance + ); assert_eq!(Balances::free_balance(AccountId::from(ALICE)), some_currency); let result: MultiAssets = Runtime::query_account_balances(AccountId::from(ALICE)) .unwrap() .try_into() .unwrap(); - assert_eq!(result.len(), 2); + assert_eq!(result.len(), 3); // check currency assert!(result.inner().iter().any(|asset| asset.eq( @@ -444,6 +478,12 @@ fn test_assets_balances_api_works() { minimum_asset_balance ) .into()))); + // check foreign asset + assert!(result.inner().iter().any(|asset| asset.eq(&( + Identity::reverse_ref(foreign_asset_id_multilocation).unwrap(), + 6 * foreign_asset_minimum_asset_balance + ) + .into()))); }); } @@ -453,11 +493,7 @@ asset_test_utils::include_teleports_for_native_asset_works!( CheckingAccount, WeightToFee, ParachainSystem, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::ed25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), Box::new(|runtime_event_encoded: Vec| { match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { @@ -474,37 +510,119 @@ asset_test_utils::include_teleports_for_native_asset_works!( 1000 ); -asset_test_utils::include_asset_transactor_transfer_with_local_consensus_currency_works!( +asset_test_utils::include_teleports_for_foreign_assets_works!( Runtime, XcmConfig, + CheckingAccount, + WeightToFee, + ParachainSystem, + ForeignCreatorsSovereignAccountOf, + ForeignAssetsInstance, asset_test_utils::CollatorSessionKeys::new( AccountId::from(ALICE), AccountId::from(ALICE), SessionKeys { aura: AuraId::from(sp_core::ed25519::Public::from_raw(ALICE)) } ), ExistentialDeposit::get(), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event), + _ => None, + } + }), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), + _ => None, + } + }) +); + +asset_test_utils::include_asset_transactor_transfer_with_local_consensus_currency_works!( + Runtime, + XcmConfig, + collator_session_keys(), + ExistentialDeposit::get(), Box::new(|| { assert!(Assets::asset_ids().collect::>().is_empty()); + assert!(ForeignAssets::asset_ids().collect::>().is_empty()); }), Box::new(|| { assert!(Assets::asset_ids().collect::>().is_empty()); + assert!(ForeignAssets::asset_ids().collect::>().is_empty()); }) ); asset_test_utils::include_asset_transactor_transfer_with_pallet_assets_instance_works!( - asset_transactor_transfer_with_pallet_assets_instance_works, + asset_transactor_transfer_with_trust_backed_assets_works, Runtime, XcmConfig, TrustBackedAssetsInstance, AssetIdForTrustBackedAssets, AssetIdForTrustBackedAssetsConvert, + collator_session_keys(), + ExistentialDeposit::get(), + 12345, + Box::new(|| { + assert!(ForeignAssets::asset_ids().collect::>().is_empty()); + }), + Box::new(|| { + assert!(ForeignAssets::asset_ids().collect::>().is_empty()); + }) +); + +asset_test_utils::include_asset_transactor_transfer_with_pallet_assets_instance_works!( + asset_transactor_transfer_with_foreign_assets_works, + Runtime, + XcmConfig, + ForeignAssetsInstance, + MultiLocation, + JustTry, asset_test_utils::CollatorSessionKeys::new( AccountId::from(ALICE), AccountId::from(ALICE), SessionKeys { aura: AuraId::from(sp_core::ed25519::Public::from_raw(ALICE)) } ), ExistentialDeposit::get(), - 12345, - Box::new(|| {}), - Box::new(|| {}) + MultiLocation { parents: 1, interior: X2(Parachain(1313), GeneralIndex(12345)) }, + Box::new(|| { + assert!(Assets::asset_ids().collect::>().is_empty()); + }), + Box::new(|| { + assert!(Assets::asset_ids().collect::>().is_empty()); + }) +); + +asset_test_utils::include_create_and_manage_foreign_assets_for_local_consensus_parachain_assets_works!( + Runtime, + XcmConfig, + WeightToFee, + ForeignCreatorsSovereignAccountOf, + ForeignAssetsInstance, + MultiLocation, + JustTry, + asset_test_utils::CollatorSessionKeys::new( + AccountId::from(ALICE), + AccountId::from(ALICE), + SessionKeys { aura: AuraId::from(sp_core::ed25519::Public::from_raw(ALICE)) } + ), + ExistentialDeposit::get(), + AssetDeposit::get(), + MetadataDepositBase::get(), + MetadataDepositPerByte::get(), + Box::new(|pallet_asset_call| RuntimeCall::ForeignAssets(pallet_asset_call).encode()), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::ForeignAssets(pallet_asset_event)) => Some(pallet_asset_event), + _ => None, + } + }), + Box::new(|| { + assert!(Assets::asset_ids().collect::>().is_empty()); + assert!(ForeignAssets::asset_ids().collect::>().is_empty()); + }), + Box::new(|| { + assert!(Assets::asset_ids().collect::>().is_empty()); + assert_eq!(ForeignAssets::asset_ids().collect::>().len(), 1); + }) ); diff --git a/parachains/runtimes/assets/westmint/Cargo.toml b/parachains/runtimes/assets/asset-hub-westend/Cargo.toml similarity index 95% rename from parachains/runtimes/assets/westmint/Cargo.toml rename to parachains/runtimes/assets/asset-hub-westend/Cargo.toml index 508ddcfdd08..bd971ed6007 100644 --- a/parachains/runtimes/assets/westmint/Cargo.toml +++ b/parachains/runtimes/assets/asset-hub-westend/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "westmint-runtime" -version = "1.0.0" +name = "asset-hub-westend-runtime" +version = "0.9.420" authors = ["Parity Technologies "] edition = "2021" -description = "Westend variant of Statemint parachain runtime" +description = "Westend variant of Asset Hub parachain runtime" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } hex-literal = { version = "0.4.1", optional = true } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } smallvec = "1.10.0" # Substrate @@ -26,6 +26,7 @@ pallet-aura = { git = "https://github.com/paritytech/substrate", default-feature pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-nft-fractionalization = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-nfts = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-nfts-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } @@ -92,6 +93,7 @@ runtime-benchmarks = [ "pallet-assets/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", + "pallet-nft-fractionalization/runtime-benchmarks", "pallet-nfts/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", @@ -124,6 +126,7 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-collator-selection/try-runtime", "pallet-multisig/try-runtime", + "pallet-nft-fractionalization/try-runtime", "pallet-nfts/try-runtime", "pallet-proxy/try-runtime", "pallet-session/try-runtime", @@ -148,6 +151,7 @@ std = [ "pallet-authorship/std", "pallet-balances/std", "pallet-multisig/std", + "pallet-nft-fractionalization/std", "pallet-nfts/std", "pallet-nfts-runtime-api/std", "pallet-proxy/std", diff --git a/parachains/runtimes/assets/westmint/build.rs b/parachains/runtimes/assets/asset-hub-westend/build.rs similarity index 100% rename from parachains/runtimes/assets/westmint/build.rs rename to parachains/runtimes/assets/asset-hub-westend/build.rs diff --git a/parachains/runtimes/assets/westmint/src/constants.rs b/parachains/runtimes/assets/asset-hub-westend/src/constants.rs similarity index 98% rename from parachains/runtimes/assets/westmint/src/constants.rs rename to parachains/runtimes/assets/asset-hub-westend/src/constants.rs index 11e6d1bf35b..e3e2dff1db9 100644 --- a/parachains/runtimes/assets/westmint/src/constants.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/constants.rs @@ -76,7 +76,7 @@ pub mod fee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { // in Westend, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: - // in Westmint, we map to 1/10 of that, or 1/100 CENT + // in Asset Hub, we map to 1/10 of that, or 1/100 CENT let p = super::currency::CENTS; let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); diff --git a/parachains/runtimes/assets/westmint/src/lib.rs b/parachains/runtimes/assets/asset-hub-westend/src/lib.rs similarity index 95% rename from parachains/runtimes/assets/westmint/src/lib.rs rename to parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 1f4af983916..00aa0015b51 100644 --- a/parachains/runtimes/assets/westmint/src/lib.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -13,9 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! # Westmint Runtime +//! # Asset Hub Westend Runtime //! -//! Westmint is the testnet for Statemint. +//! Testnet for Asset Hub Polkadot. #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "256"] @@ -55,7 +55,7 @@ use frame_support::{ InstanceFilter, TransformOrigin, }, weights::{ConstantMultiplier, Weight}, - PalletId, RuntimeDebug, + BoundedVec, PalletId, RuntimeDebug, }; use frame_system::{ limits::{BlockLength, BlockWeights}, @@ -66,11 +66,12 @@ pub use parachains_common as common; use parachains_common::{ impls::{AssetsToBlockAuthor, DealWithFees}, opaque, - process_xcm_message::{ParaIdToSibling, ProcessFromSibling, ProcessXcmMessage}, + process_xcm_message::{ParaIdToSibling, ProcessFromSibling}, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, BlockNumber, Hash, Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; +use xcm_builder::ProcessXcmMessage; use xcm_config::{ ForeignAssetsConvertedConcreteId, TrustBackedAssetsConvertedConcreteId, WestendLocation, XcmOriginToTransactDispatchOrigin, @@ -95,10 +96,13 @@ impl_opaque_keys! { #[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { + // Note: "westmint" is the legacy name for this chain. It has been renamed to + // "asset-hub-westend". Many wallets/tools depend on the `spec_name`, so it remains "westmint" + // for the time being. Wallets/tools should update to treat "asset-hub-westend" equally. spec_name: create_runtime_str!("westmint"), impl_name: create_runtime_str!("westmint"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 13, @@ -193,15 +197,15 @@ impl pallet_balances::Config for Runtime { type WeightInfo = weights::pallet_balances::WeightInfo; type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); - type MaxHolds = ConstU32<0>; + type MaxHolds = ConstU32<1>; type MaxFreezes = ConstU32<0>; } parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -378,6 +382,7 @@ impl InstanceFilter for ProxyType { c, RuntimeCall::Balances { .. } | RuntimeCall::Assets { .. } | + RuntimeCall::NftFractionalization { .. } | RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } ), @@ -393,6 +398,7 @@ impl InstanceFilter for ProxyType { RuntimeCall::Assets { .. } | RuntimeCall::Utility { .. } | RuntimeCall::Multisig { .. } | + RuntimeCall::NftFractionalization { .. } | RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } ) }, @@ -661,6 +667,32 @@ impl pallet_uniques::Config for Runtime { type Locker = (); } +parameter_types! { + pub const NftFractionalizationPalletId: PalletId = PalletId(*b"fraction"); + pub NewAssetSymbol: BoundedVec = (*b"FRAC").to_vec().try_into().unwrap(); + pub NewAssetName: BoundedVec = (*b"Frac").to_vec().try_into().unwrap(); +} + +impl pallet_nft_fractionalization::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Deposit = AssetDeposit; + type Currency = Balances; + type NewAssetSymbol = NewAssetSymbol; + type NewAssetName = NewAssetName; + type StringLimit = AssetsStringLimit; + type NftCollectionId = ::CollectionId; + type NftId = ::ItemId; + type AssetBalance = ::Balance; + type AssetId = >::AssetId; + type Assets = Assets; + type Nfts = Nfts; + type PalletId = NftFractionalizationPalletId; + type WeightInfo = pallet_nft_fractionalization::weights::SubstrateWeight; + type RuntimeHoldReason = RuntimeHoldReason; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); +} + parameter_types! { pub NftsPalletFeatures: PalletFeatures = PalletFeatures::all_enabled(); pub const NftsMaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS; @@ -745,6 +777,7 @@ construct_runtime!( Uniques: pallet_uniques::{Pallet, Call, Storage, Event} = 51, Nfts: pallet_nfts::{Pallet, Call, Storage, Event} = 52, ForeignAssets: pallet_assets::::{Pallet, Call, Storage, Event} = 53, + NftFractionalization: pallet_nft_fractionalization::{Pallet, Call, Storage, Event, HoldReason} = 54, } ); @@ -770,10 +803,14 @@ pub type SignedExtra = ( /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; + /// Migrations to apply on runtime upgrade. -pub type Migrations = (pallet_nfts::migration::v1::MigrateToV1,); +pub type Migrations = ( + // v9420 + pallet_nfts::migration::v1::MigrateToV1, + // unreleased + pallet_collator_selection::migration::v1::MigrateToV1, +); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -794,6 +831,7 @@ mod benches { [pallet_balances, Balances] [pallet_message_queue, MessageQueue] [pallet_multisig, Multisig] + [pallet_nft_fractionalization, NftFractionalization] [pallet_nfts, Nfts] [pallet_proxy, Proxy] [pallet_session, SessionBench::] @@ -1072,7 +1110,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -1107,7 +1145,6 @@ impl_runtime_apis! { id: Concrete(GeneralIndex(i as u128).into()), fun: Fungible(fungibles_amount * i as u128), } - .into() }) .chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) })) .chain((0..holding_non_fungibles).map(|i| MultiAsset { @@ -1127,7 +1164,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( WestendLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WestendLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(WestendLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; @@ -1142,7 +1179,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(WestendLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } diff --git a/parachains/runtimes/assets/westmint/src/weights/block_weights.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/block_weights.rs similarity index 100% rename from parachains/runtimes/assets/westmint/src/weights/block_weights.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/block_weights.rs diff --git a/parachains/runtimes/assets/statemine/src/weights/cumulus_pallet_parachain_system.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/cumulus_pallet_parachain_system.rs similarity index 100% rename from parachains/runtimes/assets/statemine/src/weights/cumulus_pallet_parachain_system.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/cumulus_pallet_parachain_system.rs diff --git a/parachains/runtimes/assets/statemine/src/weights/cumulus_pallet_xcmp_queue.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/cumulus_pallet_xcmp_queue.rs similarity index 78% rename from parachains/runtimes/assets/statemine/src/weights/cumulus_pallet_xcmp_queue.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/cumulus_pallet_xcmp_queue.rs index f33f20189f0..6a2b8a968eb 100644 --- a/parachains/runtimes/assets/statemine/src/weights/cumulus_pallet_xcmp_queue.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/cumulus_pallet_xcmp_queue.rs @@ -4,34 +4,31 @@ //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-03-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `i9`, CPU: `13th Gen Intel(R) Core(TM) i9-13900K` -//! EXECUTION: Some(Native), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./target/release/polkadot-parachain // benchmark // pallet -// --chain -// statemine-dev -// --pallet -// cumulus_pallet_xcmp_queue -// --extrinsic -// -// --execution -// native -// --output -// parachains/runtimes/assets/statemine/src/weights -// --steps -// 50 -// --repeat -// 20 +// --chain=asset-hub-westend-dev +// --execution=wasm +// --wasm-execution=compiled +// --pallet=cumulus_pallet_xcmp_queue +// --extrinsic=* +// --steps=50 +// --repeat=20 +// --json +// --header=./file_header.txt +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/cumulus_pallet_xcmp_queue.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_xcmp_queue`. pub struct WeightInfo(PhantomData); @@ -42,8 +39,8 @@ impl cumulus_pallet_xcmp_queue::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `76` // Estimated: `1561` - // Minimum execution time: 1_829_000 picoseconds. - Weight::from_parts(1_905_000, 0) + // Minimum execution time: 5_514_000 picoseconds. + Weight::from_parts(5_658_000, 0) .saturating_add(Weight::from_parts(0, 1561)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -75,8 +72,8 @@ impl cumulus_pallet_xcmp_queue::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `76` // Estimated: `1561` - // Minimum execution time: 1_216_000 picoseconds. - Weight::from_parts(1_278_000, 0) + // Minimum execution time: 5_517_000 picoseconds. + Weight::from_parts(5_773_000, 0) .saturating_add(Weight::from_parts(0, 1561)) .saturating_add(T::DbWeight::get().reads(1)) } diff --git a/parachains/runtimes/assets/westmint/src/weights/extrinsic_weights.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/extrinsic_weights.rs similarity index 100% rename from parachains/runtimes/assets/westmint/src/weights/extrinsic_weights.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/extrinsic_weights.rs diff --git a/parachains/runtimes/assets/statemine/src/weights/frame_system.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/frame_system.rs similarity index 74% rename from parachains/runtimes/assets/statemine/src/weights/frame_system.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/frame_system.rs index 4f0967e636d..90dced86bd0 100644 --- a/parachains/runtimes/assets/statemine/src/weights/frame_system.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/frame_system.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `frame_system` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=frame_system @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/frame_system.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/frame_system.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `frame_system`. pub struct WeightInfo(PhantomData); @@ -52,22 +53,22 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_146_000 picoseconds. - Weight::from_parts(2_194_000, 0) + // Minimum execution time: 2_250_000 picoseconds. + Weight::from_parts(2_324_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(368, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(367, 0).saturating_mul(b.into())) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_732_000 picoseconds. - Weight::from_parts(8_001_000, 0) + // Minimum execution time: 7_617_000 picoseconds. + Weight::from_parts(7_744_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_403, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(1_399, 0).saturating_mul(b.into())) } /// Storage: System Digest (r:1 w:1) /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) @@ -77,12 +78,15 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 4_287_000 picoseconds. - Weight::from_parts(4_602_000, 0) + // Minimum execution time: 4_491_000 picoseconds. + Weight::from_parts(4_652_000, 0) .saturating_add(Weight::from_parts(0, 1485)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } + fn set_code() -> Weight { + Weight::from_parts(1_000_000, 0) + } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `i` is `[0, 1000]`. @@ -90,11 +94,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_319_000 picoseconds. - Weight::from_parts(2_401_000, 0) + // Minimum execution time: 2_463_000 picoseconds. + Weight::from_parts(2_499_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_933 - .saturating_add(Weight::from_parts(669_111, 0).saturating_mul(i.into())) + // Standard Error: 1_952 + .saturating_add(Weight::from_parts(673_075, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -104,11 +108,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_381_000 picoseconds. - Weight::from_parts(2_405_000, 0) + // Minimum execution time: 2_336_000 picoseconds. + Weight::from_parts(2_403_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 779 - .saturating_add(Weight::from_parts(492_780, 0).saturating_mul(i.into())) + // Standard Error: 792 + .saturating_add(Weight::from_parts(491_501, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -117,12 +121,12 @@ impl frame_system::WeightInfo for WeightInfo { fn kill_prefix(p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `84 + p * (69 ±0)` - // Estimated: `75 + p * (70 ±0)` - // Minimum execution time: 4_204_000 picoseconds. - Weight::from_parts(4_269_000, 0) - .saturating_add(Weight::from_parts(0, 75)) - // Standard Error: 1_101 - .saturating_add(Weight::from_parts(1_014_807, 0).saturating_mul(p.into())) + // Estimated: `77 + p * (70 ±0)` + // Minimum execution time: 4_246_000 picoseconds. + Weight::from_parts(4_352_000, 0) + .saturating_add(Weight::from_parts(0, 77)) + // Standard Error: 1_010 + .saturating_add(Weight::from_parts(1_048_520, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) diff --git a/parachains/runtimes/assets/statemint/src/weights/mod.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/mod.rs similarity index 92% rename from parachains/runtimes/assets/statemint/src/weights/mod.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/mod.rs index 3d030daee47..9ab2cc3dc72 100644 --- a/parachains/runtimes/assets/statemint/src/weights/mod.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/mod.rs @@ -8,6 +8,8 @@ pub mod pallet_balances; pub mod pallet_collator_selection; pub mod pallet_message_queue; pub mod pallet_multisig; +pub mod pallet_nft_fractionalization; +pub mod pallet_nfts; pub mod pallet_proxy; pub mod pallet_session; pub mod pallet_timestamp; diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_assets.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets.rs similarity index 85% rename from parachains/runtimes/assets/westmint/src/weights/pallet_assets.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets.rs index f08633cd2ba..a3d1d19438b 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_assets.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets.rs @@ -20,13 +20,13 @@ //! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_assets @@ -35,7 +35,7 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_assets.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_assets.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -443,4 +443,73 @@ impl pallet_assets::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn touch() -> Weight { + // Proof Size summary in bytes: + // Measured: `453` + // Estimated: `3675` + // Minimum execution time: 37_468_000 picoseconds. + Weight::from_parts(37_957_000, 3675) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn touch_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `3675` + // Minimum execution time: 383_408_000 picoseconds. + Weight::from_parts(392_036_000, 3675) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn refund() -> Weight { + // Proof Size summary in bytes: + // Measured: `579` + // Estimated: `3675` + // Minimum execution time: 34_066_000 picoseconds. + Weight::from_parts(34_347_000, 3675) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + fn refund_other() -> Weight { + // Proof Size summary in bytes: + // Measured: `510` + // Estimated: `3675` + // Minimum execution time: 32_060_000 picoseconds. + Weight::from_parts(32_519_000, 3675) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + fn block() -> Weight { + // Proof Size summary in bytes: + // Measured: `459` + // Estimated: `3675` + // Minimum execution time: 115_000_000 picoseconds. + Weight::from_parts(163_000_000, 3675) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } } diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_balances.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_balances.rs similarity index 71% rename from parachains/runtimes/assets/statemine/src/weights/pallet_balances.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_balances.rs index 2d3be9da403..4ff5b5075b9 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_balances.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_balances.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_balances @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_balances.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_balances.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_balances`. pub struct WeightInfo(PhantomData); @@ -53,8 +54,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 34_132_000 picoseconds. - Weight::from_parts(34_669_000, 0) + // Minimum execution time: 52_618_000 picoseconds. + Weight::from_parts(53_260_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -65,8 +66,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 25_052_000 picoseconds. - Weight::from_parts(25_681_000, 0) + // Minimum execution time: 39_969_000 picoseconds. + Weight::from_parts(40_584_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -77,8 +78,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 15_072_000 picoseconds. - Weight::from_parts(15_451_000, 0) + // Minimum execution time: 15_907_000 picoseconds. + Weight::from_parts(16_236_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -89,8 +90,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 18_416_000 picoseconds. - Weight::from_parts(18_742_000, 0) + // Minimum execution time: 22_839_000 picoseconds. + Weight::from_parts(23_138_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -101,8 +102,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `6196` - // Minimum execution time: 36_626_000 picoseconds. - Weight::from_parts(37_176_000, 0) + // Minimum execution time: 53_986_000 picoseconds. + Weight::from_parts(54_583_000, 0) .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -113,25 +114,38 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 31_008_000 picoseconds. - Weight::from_parts(31_562_000, 0) + // Minimum execution time: 48_496_000 picoseconds. + Weight::from_parts(49_111_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn upgrade_accounts(_: u32) -> Weight { - Weight::from_parts(0, 0) - } fn force_unreserve() -> Weight { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 14_214_000 picoseconds. - Weight::from_parts(14_535_000, 0) + // Minimum execution time: 18_457_000 picoseconds. + Weight::from_parts(18_719_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + u * (136 ±0)` + // Estimated: `990 + u * (2603 ±0)` + // Minimum execution time: 18_243_000 picoseconds. + Weight::from_parts(18_314_000, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 10_135 + .saturating_add(Weight::from_parts(13_980_773, 0).saturating_mul(u.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + } } diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_collator_selection.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_collator_selection.rs similarity index 68% rename from parachains/runtimes/assets/westmint/src/weights/pallet_collator_selection.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_collator_selection.rs index eaabe14f8b1..962f1924179 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_collator_selection.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_collator_selection` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_collator_selection @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_collator_selection.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_collator_selection.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_collator_selection`. pub struct WeightInfo(PhantomData); @@ -56,11 +57,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `178 + b * (78 ±0)` // Estimated: `1168 + b * (2554 ±0)` - // Minimum execution time: 15_458_000 picoseconds. - Weight::from_parts(16_243_295, 0) + // Minimum execution time: 14_583_000 picoseconds. + Weight::from_parts(14_662_374, 0) .saturating_add(Weight::from_parts(0, 1168)) - // Standard Error: 3_682 - .saturating_add(Weight::from_parts(2_601_545, 0).saturating_mul(b.into())) + // Standard Error: 2_862 + .saturating_add(Weight::from_parts(2_576_034, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(Weight::from_parts(0, 2554).saturating_mul(b.into())) @@ -71,8 +72,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_542_000 picoseconds. - Weight::from_parts(7_735_000, 0) + // Minimum execution time: 7_240_000 picoseconds. + Weight::from_parts(7_430_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -82,8 +83,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_344_000 picoseconds. - Weight::from_parts(7_660_000, 0) + // Minimum execution time: 7_517_000 picoseconds. + Weight::from_parts(7_704_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,12 +104,12 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn register_as_candidate(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1108 + c * (48 ±0)` - // Estimated: `61671 + c * (49 ±0)` - // Minimum execution time: 38_651_000 picoseconds. - Weight::from_parts(31_016_267, 0) - .saturating_add(Weight::from_parts(0, 61671)) - // Standard Error: 1_279 - .saturating_add(Weight::from_parts(106_148, 0).saturating_mul(c.into())) + // Estimated: `49487 + c * (49 ±0)` + // Minimum execution time: 42_001_000 picoseconds. + Weight::from_parts(34_741_590, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 1_220 + .saturating_add(Weight::from_parts(104_452, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 49).saturating_mul(c.into())) @@ -122,11 +123,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `469 + c * (48 ±0)` // Estimated: `49487` - // Minimum execution time: 27_474_000 picoseconds. - Weight::from_parts(18_915_300, 0) + // Minimum execution time: 31_537_000 picoseconds. + Weight::from_parts(23_342_837, 0) .saturating_add(Weight::from_parts(0, 49487)) - // Standard Error: 1_242 - .saturating_add(Weight::from_parts(107_733, 0).saturating_mul(c.into())) + // Standard Error: 1_210 + .saturating_add(Weight::from_parts(104_584, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -139,13 +140,46 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn note_author() -> Weight { // Proof Size summary in bytes: // Measured: `103` - // Estimated: `7729` - // Minimum execution time: 29_327_000 picoseconds. - Weight::from_parts(29_858_000, 0) - .saturating_add(Weight::from_parts(0, 7729)) + // Estimated: `6196` + // Minimum execution time: 42_787_000 picoseconds. + Weight::from_parts(43_339_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) @@ -160,18 +194,18 @@ impl pallet_collator_selection::WeightInfo for WeightIn /// The range of component `c` is `[1, 1000]`. fn new_session(r: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `22693 + r * (116 ±0) + c * (97 ±0)` - // Estimated: `56697 + r * (2603 ±0) + c * (2520 ±0)` - // Minimum execution time: 17_185_000 picoseconds. - Weight::from_parts(17_436_000, 0) - .saturating_add(Weight::from_parts(0, 56697)) - // Standard Error: 795_522 - .saturating_add(Weight::from_parts(28_877_010, 0).saturating_mul(c.into())) + // Measured: `22693 + c * (97 ±0) + r * (116 ±0)` + // Estimated: `49487 + c * (2519 ±0) + r * (2603 ±0)` + // Minimum execution time: 17_395_000 picoseconds. + Weight::from_parts(17_530_000, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 848_373 + .saturating_add(Weight::from_parts(30_252_593, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2519).saturating_mul(c.into())) .saturating_add(Weight::from_parts(0, 2603).saturating_mul(r.into())) - .saturating_add(Weight::from_parts(0, 2520).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_message_queue.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_message_queue.rs similarity index 100% rename from parachains/runtimes/assets/statemine/src/weights/pallet_message_queue.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_message_queue.rs diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_multisig.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_multisig.rs similarity index 73% rename from parachains/runtimes/assets/statemine/src/weights/pallet_multisig.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_multisig.rs index 2e5f4b322f0..0216364554d 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_multisig.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_multisig.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_multisig` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_multisig @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_multisig.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_multisig.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_multisig`. pub struct WeightInfo(PhantomData); @@ -52,11 +53,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_992_000 picoseconds. - Weight::from_parts(12_412_280, 0) + // Minimum execution time: 11_856_000 picoseconds. + Weight::from_parts(12_334_994, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3 - .saturating_add(Weight::from_parts(503, 0).saturating_mul(z.into())) + // Standard Error: 2 + .saturating_add(Weight::from_parts(506, 0).saturating_mul(z.into())) } /// Storage: Multisig Multisigs (r:1 w:1) /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) @@ -66,13 +67,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `262 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 37_343_000 picoseconds. - Weight::from_parts(31_041_082, 0) + // Minimum execution time: 41_975_000 picoseconds. + Weight::from_parts(35_772_064, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 579 - .saturating_add(Weight::from_parts(68_564, 0).saturating_mul(s.into())) - // Standard Error: 5 - .saturating_add(Weight::from_parts(1_253, 0).saturating_mul(z.into())) + // Standard Error: 481 + .saturating_add(Weight::from_parts(67_985, 0).saturating_mul(s.into())) + // Standard Error: 4 + .saturating_add(Weight::from_parts(1_213, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -84,13 +85,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 27_702_000 picoseconds. - Weight::from_parts(22_324_758, 0) + // Minimum execution time: 28_065_000 picoseconds. + Weight::from_parts(22_550_479, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 382 - .saturating_add(Weight::from_parts(59_647, 0).saturating_mul(s.into())) + // Standard Error: 333 + .saturating_add(Weight::from_parts(60_600, 0).saturating_mul(s.into())) // Standard Error: 3 - .saturating_add(Weight::from_parts(1_199, 0).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(1_194, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,14 +104,14 @@ impl pallet_multisig::WeightInfo for WeightInfo { fn as_multi_complete(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `385 + s * (33 ±0)` - // Estimated: `10404` - // Minimum execution time: 42_944_000 picoseconds. - Weight::from_parts(35_467_441, 0) - .saturating_add(Weight::from_parts(0, 10404)) - // Standard Error: 600 - .saturating_add(Weight::from_parts(80_406, 0).saturating_mul(s.into())) + // Estimated: `6811` + // Minimum execution time: 47_059_000 picoseconds. + Weight::from_parts(39_787_186, 0) + .saturating_add(Weight::from_parts(0, 6811)) + // Standard Error: 556 + .saturating_add(Weight::from_parts(82_920, 0).saturating_mul(s.into())) // Standard Error: 5 - .saturating_add(Weight::from_parts(1_220, 0).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(1_236, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -121,11 +122,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `263 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 27_997_000 picoseconds. - Weight::from_parts(30_250_714, 0) + // Minimum execution time: 31_979_000 picoseconds. + Weight::from_parts(33_915_067, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 709 - .saturating_add(Weight::from_parts(67_226, 0).saturating_mul(s.into())) + // Standard Error: 567 + .saturating_add(Weight::from_parts(72_232, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -136,11 +137,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 19_821_000 picoseconds. - Weight::from_parts(20_670_152, 0) + // Minimum execution time: 19_301_000 picoseconds. + Weight::from_parts(20_450_461, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 470 - .saturating_add(Weight::from_parts(65_289, 0).saturating_mul(s.into())) + // Standard Error: 407 + .saturating_add(Weight::from_parts(63_650, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -151,11 +152,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `454 + s * (1 ±0)` // Estimated: `6811` - // Minimum execution time: 28_820_000 picoseconds. - Weight::from_parts(31_182_331, 0) + // Minimum execution time: 32_846_000 picoseconds. + Weight::from_parts(34_842_187, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 874 - .saturating_add(Weight::from_parts(68_617, 0).saturating_mul(s.into())) + // Standard Error: 637 + .saturating_add(Weight::from_parts(71_046, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_nft_fractionalization.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_nft_fractionalization.rs new file mode 100644 index 00000000000..967bac75e96 --- /dev/null +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_nft_fractionalization.rs @@ -0,0 +1,63 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Autogenerated weights for `pallet_nfts` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 + +// Executed Command: +// ./artifacts/polkadot-parachain +// benchmark +// pallet +// --chain=asset-hub-westend-dev +// --execution=wasm +// --wasm-execution=compiled +// --pallet=pallet_nft_fractionalization +// --extrinsic=* +// --steps=50 +// --repeat=20 +// --json +// --header=./file_header.txt +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_nft_fractionalization.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_nfts`. +pub struct WeightInfo(PhantomData); +impl pallet_nft_fractionalization::WeightInfo for WeightInfo { + fn fractionalize() -> Weight { + // Minimum execution time: 44_312 nanoseconds. + Weight::from_parts(25_147_000, 3549) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + fn unify() -> Weight { + // Minimum execution time: 31_654 nanoseconds. + Weight::from_parts(25_147_000, 3549) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } +} diff --git a/parachains/runtimes/assets/statemine/src/weights/pallet_nfts.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_nfts.rs similarity index 82% rename from parachains/runtimes/assets/statemine/src/weights/pallet_nfts.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_nfts.rs index 8c4425114b1..a540881b8ca 100644 --- a/parachains/runtimes/assets/statemine/src/weights/pallet_nfts.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_nfts.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_nfts` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemine-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_nfts @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_nfts.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_nfts.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_nfts`. pub struct WeightInfo(PhantomData); @@ -60,10 +61,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn create() -> Weight { // Proof Size summary in bytes: // Measured: `145` - // Estimated: `5038` - // Minimum execution time: 34_100_000 picoseconds. - Weight::from_parts(34_649_000, 0) - .saturating_add(Weight::from_parts(0, 5038)) + // Estimated: `3549` + // Minimum execution time: 38_536_000 picoseconds. + Weight::from_parts(39_046_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -80,10 +81,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn force_create() -> Weight { // Proof Size summary in bytes: // Measured: `42` - // Estimated: `5038` - // Minimum execution time: 22_415_000 picoseconds. - Weight::from_parts(22_808_000, 0) - .saturating_add(Weight::from_parts(0, 5038)) + // Estimated: `3549` + // Minimum execution time: 22_776_000 picoseconds. + Weight::from_parts(23_177_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -106,17 +107,15 @@ impl pallet_nfts::WeightInfo for WeightInfo { /// The range of component `m` is `[0, 1000]`. /// The range of component `c` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. - fn destroy(m: u32, _c: u32, a: u32, ) -> Weight { + fn destroy(_m: u32, _c: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `32170 + a * (366 ±0)` - // Estimated: `2538829 + a * (2954 ±0)` - // Minimum execution time: 978_514_000 picoseconds. - Weight::from_parts(915_478_956, 0) - .saturating_add(Weight::from_parts(0, 2538829)) - // Standard Error: 4_368 - .saturating_add(Weight::from_parts(3_621, 0).saturating_mul(m.into())) - // Standard Error: 4_368 - .saturating_add(Weight::from_parts(5_742_436, 0).saturating_mul(a.into())) + // Estimated: `2523990 + a * (2954 ±0)` + // Minimum execution time: 989_671_000 picoseconds. + Weight::from_parts(935_494_331, 0) + .saturating_add(Weight::from_parts(0, 2523990)) + // Standard Error: 3_986 + .saturating_add(Weight::from_parts(5_721_724, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(1004)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1005)) @@ -138,10 +137,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn mint() -> Weight { // Proof Size summary in bytes: // Measured: `421` - // Estimated: `18460` - // Minimum execution time: 44_509_000 picoseconds. - Weight::from_parts(45_090_000, 0) - .saturating_add(Weight::from_parts(0, 18460)) + // Estimated: `4326` + // Minimum execution time: 48_990_000 picoseconds. + Weight::from_parts(49_439_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -160,10 +159,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn force_mint() -> Weight { // Proof Size summary in bytes: // Measured: `421` - // Estimated: `18460` - // Minimum execution time: 43_761_000 picoseconds. - Weight::from_parts(44_304_000, 0) - .saturating_add(Weight::from_parts(0, 18460)) + // Estimated: `4326` + // Minimum execution time: 48_068_000 picoseconds. + Weight::from_parts(48_446_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -186,10 +185,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn burn() -> Weight { // Proof Size summary in bytes: // Measured: `530` - // Estimated: `15200` - // Minimum execution time: 45_215_000 picoseconds. - Weight::from_parts(46_367_000, 0) - .saturating_add(Weight::from_parts(0, 15200)) + // Estimated: `4326` + // Minimum execution time: 48_943_000 picoseconds. + Weight::from_parts(49_568_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -210,10 +209,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn transfer() -> Weight { // Proof Size summary in bytes: // Measured: `559` - // Estimated: `14926` - // Minimum execution time: 35_381_000 picoseconds. - Weight::from_parts(35_896_000, 0) - .saturating_add(Weight::from_parts(0, 14926)) + // Estimated: `4326` + // Minimum execution time: 35_764_000 picoseconds. + Weight::from_parts(36_232_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -227,12 +226,12 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `729 + i * (108 ±0)` - // Estimated: `8077 + i * (3336 ±0)` - // Minimum execution time: 16_621_000 picoseconds. - Weight::from_parts(16_839_000, 0) - .saturating_add(Weight::from_parts(0, 8077)) - // Standard Error: 13_184 - .saturating_add(Weight::from_parts(13_274_447, 0).saturating_mul(i.into())) + // Estimated: `3549 + i * (3336 ±0)` + // Minimum execution time: 17_108_000 picoseconds. + Weight::from_parts(17_220_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) + // Standard Error: 14_557 + .saturating_add(Weight::from_parts(15_545_711, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -245,10 +244,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn lock_item_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `401` - // Estimated: `7047` - // Minimum execution time: 20_314_000 picoseconds. - Weight::from_parts(20_726_000, 0) - .saturating_add(Weight::from_parts(0, 7047)) + // Estimated: `3534` + // Minimum execution time: 20_958_000 picoseconds. + Weight::from_parts(21_129_000, 0) + .saturating_add(Weight::from_parts(0, 3534)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -259,10 +258,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn unlock_item_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `401` - // Estimated: `7047` - // Minimum execution time: 20_178_000 picoseconds. - Weight::from_parts(20_565_000, 0) - .saturating_add(Weight::from_parts(0, 7047)) + // Estimated: `3534` + // Minimum execution time: 20_864_000 picoseconds. + Weight::from_parts(21_016_000, 0) + .saturating_add(Weight::from_parts(0, 3534)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -273,10 +272,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn lock_collection() -> Weight { // Proof Size summary in bytes: // Measured: `306` - // Estimated: `7087` - // Minimum execution time: 17_142_000 picoseconds. - Weight::from_parts(18_191_000, 0) - .saturating_add(Weight::from_parts(0, 7087)) + // Estimated: `3549` + // Minimum execution time: 17_934_000 picoseconds. + Weight::from_parts(18_152_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -289,10 +288,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn transfer_ownership() -> Weight { // Proof Size summary in bytes: // Measured: `354` - // Estimated: `7066` - // Minimum execution time: 22_902_000 picoseconds. - Weight::from_parts(23_495_000, 0) - .saturating_add(Weight::from_parts(0, 7066)) + // Estimated: `3549` + // Minimum execution time: 23_477_000 picoseconds. + Weight::from_parts(23_830_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -303,10 +302,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_team() -> Weight { // Proof Size summary in bytes: // Measured: `335` - // Estimated: `9627` - // Minimum execution time: 41_436_000 picoseconds. - Weight::from_parts(41_922_000, 0) - .saturating_add(Weight::from_parts(0, 9627)) + // Estimated: `6078` + // Minimum execution time: 40_775_000 picoseconds. + Weight::from_parts(41_159_000, 0) + .saturating_add(Weight::from_parts(0, 6078)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -318,8 +317,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `277` // Estimated: `3549` - // Minimum execution time: 19_015_000 picoseconds. - Weight::from_parts(19_490_000, 0) + // Minimum execution time: 18_569_000 picoseconds. + Weight::from_parts(18_844_000, 0) .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(3)) @@ -332,8 +331,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `242` // Estimated: `3549` - // Minimum execution time: 15_532_000 picoseconds. - Weight::from_parts(15_827_000, 0) + // Minimum execution time: 15_395_000 picoseconds. + Weight::from_parts(15_554_000, 0) .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -345,10 +344,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn lock_item_properties() -> Weight { // Proof Size summary in bytes: // Measured: `401` - // Estimated: `7047` - // Minimum execution time: 21_022_000 picoseconds. - Weight::from_parts(21_289_000, 0) - .saturating_add(Weight::from_parts(0, 7047)) + // Estimated: `3534` + // Minimum execution time: 20_497_000 picoseconds. + Weight::from_parts(20_872_000, 0) + .saturating_add(Weight::from_parts(0, 3534)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -365,10 +364,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `505` - // Estimated: `18078` - // Minimum execution time: 47_283_000 picoseconds. - Weight::from_parts(47_793_000, 0) - .saturating_add(Weight::from_parts(0, 18078)) + // Estimated: `3944` + // Minimum execution time: 49_930_000 picoseconds. + Weight::from_parts(50_200_000, 0) + .saturating_add(Weight::from_parts(0, 3944)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -379,10 +378,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn force_set_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `310` - // Estimated: `7493` - // Minimum execution time: 27_462_000 picoseconds. - Weight::from_parts(27_798_000, 0) - .saturating_add(Weight::from_parts(0, 7493)) + // Estimated: `3944` + // Minimum execution time: 27_930_000 picoseconds. + Weight::from_parts(28_319_000, 0) + .saturating_add(Weight::from_parts(0, 3944)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -397,10 +396,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn clear_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `949` - // Estimated: `14540` - // Minimum execution time: 44_392_000 picoseconds. - Weight::from_parts(44_956_000, 0) - .saturating_add(Weight::from_parts(0, 14540)) + // Estimated: `3944` + // Minimum execution time: 47_306_000 picoseconds. + Weight::from_parts(47_676_000, 0) + .saturating_add(Weight::from_parts(0, 3944)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -411,10 +410,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn approve_item_attributes() -> Weight { // Proof Size summary in bytes: // Measured: `347` - // Estimated: `8792` - // Minimum execution time: 18_619_000 picoseconds. - Weight::from_parts(18_970_000, 0) - .saturating_add(Weight::from_parts(0, 8792)) + // Estimated: `4466` + // Minimum execution time: 18_749_000 picoseconds. + Weight::from_parts(19_080_000, 0) + .saturating_add(Weight::from_parts(0, 4466)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -430,12 +429,12 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn cancel_item_attributes_approval(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `726 + n * (398 ±0)` - // Estimated: `16329 + n * (2954 ±0)` - // Minimum execution time: 28_293_000 picoseconds. - Weight::from_parts(28_502_000, 0) - .saturating_add(Weight::from_parts(0, 16329)) - // Standard Error: 4_215 - .saturating_add(Weight::from_parts(5_601_603, 0).saturating_mul(n.into())) + // Estimated: `4466 + n * (2954 ±0)` + // Minimum execution time: 28_200_000 picoseconds. + Weight::from_parts(28_552_000, 0) + .saturating_add(Weight::from_parts(0, 4466)) + // Standard Error: 3_352 + .saturating_add(Weight::from_parts(5_584_045, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2)) @@ -455,10 +454,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `505` - // Estimated: `17946` - // Minimum execution time: 39_371_000 picoseconds. - Weight::from_parts(39_852_000, 0) - .saturating_add(Weight::from_parts(0, 17946)) + // Estimated: `3812` + // Minimum execution time: 41_646_000 picoseconds. + Weight::from_parts(42_171_000, 0) + .saturating_add(Weight::from_parts(0, 3812)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -473,10 +472,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn clear_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `815` - // Estimated: `14408` - // Minimum execution time: 37_535_000 picoseconds. - Weight::from_parts(38_894_000, 0) - .saturating_add(Weight::from_parts(0, 14408)) + // Estimated: `3812` + // Minimum execution time: 40_022_000 picoseconds. + Weight::from_parts(40_363_000, 0) + .saturating_add(Weight::from_parts(0, 3812)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -491,10 +490,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `364` - // Estimated: `14380` - // Minimum execution time: 35_608_000 picoseconds. - Weight::from_parts(35_741_000, 0) - .saturating_add(Weight::from_parts(0, 14380)) + // Estimated: `3759` + // Minimum execution time: 38_872_000 picoseconds. + Weight::from_parts(39_223_000, 0) + .saturating_add(Weight::from_parts(0, 3759)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -509,10 +508,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `682` - // Estimated: `14380` - // Minimum execution time: 33_234_000 picoseconds. - Weight::from_parts(33_617_000, 0) - .saturating_add(Weight::from_parts(0, 14380)) + // Estimated: `3759` + // Minimum execution time: 37_582_000 picoseconds. + Weight::from_parts(38_305_000, 0) + .saturating_add(Weight::from_parts(0, 3759)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -523,10 +522,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn approve_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `376` - // Estimated: `7864` - // Minimum execution time: 22_900_000 picoseconds. - Weight::from_parts(23_351_000, 0) - .saturating_add(Weight::from_parts(0, 7864)) + // Estimated: `4326` + // Minimum execution time: 22_551_000 picoseconds. + Weight::from_parts(22_984_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -536,8 +535,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `384` // Estimated: `4326` - // Minimum execution time: 20_413_000 picoseconds. - Weight::from_parts(20_622_000, 0) + // Minimum execution time: 19_879_000 picoseconds. + Weight::from_parts(20_310_000, 0) .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -548,8 +547,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `384` // Estimated: `4326` - // Minimum execution time: 19_132_000 picoseconds. - Weight::from_parts(19_443_000, 0) + // Minimum execution time: 18_958_000 picoseconds. + Weight::from_parts(19_247_000, 0) .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -560,8 +559,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3517` - // Minimum execution time: 16_661_000 picoseconds. - Weight::from_parts(16_925_000, 0) + // Minimum execution time: 16_432_000 picoseconds. + Weight::from_parts(16_762_000, 0) .saturating_add(Weight::from_parts(0, 3517)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -573,10 +572,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: // Measured: `306` - // Estimated: `7087` - // Minimum execution time: 19_575_000 picoseconds. - Weight::from_parts(19_826_000, 0) - .saturating_add(Weight::from_parts(0, 7087)) + // Estimated: `3549` + // Minimum execution time: 19_950_000 picoseconds. + Weight::from_parts(20_169_000, 0) + .saturating_add(Weight::from_parts(0, 3549)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -587,10 +586,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn update_mint_settings() -> Weight { // Proof Size summary in bytes: // Measured: `289` - // Estimated: `7072` - // Minimum execution time: 19_749_000 picoseconds. - Weight::from_parts(19_902_000, 0) - .saturating_add(Weight::from_parts(0, 7072)) + // Estimated: `3538` + // Minimum execution time: 19_727_000 picoseconds. + Weight::from_parts(19_977_000, 0) + .saturating_add(Weight::from_parts(0, 3538)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -605,10 +604,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_price() -> Weight { // Proof Size summary in bytes: // Measured: `484` - // Estimated: `11377` - // Minimum execution time: 23_970_000 picoseconds. - Weight::from_parts(24_589_000, 0) - .saturating_add(Weight::from_parts(0, 11377)) + // Estimated: `4326` + // Minimum execution time: 24_200_000 picoseconds. + Weight::from_parts(24_433_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -629,10 +628,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn buy_item() -> Weight { // Proof Size summary in bytes: // Measured: `671` - // Estimated: `18480` - // Minimum execution time: 43_929_000 picoseconds. - Weight::from_parts(44_364_000, 0) - .saturating_add(Weight::from_parts(0, 18480)) + // Estimated: `4326` + // Minimum execution time: 44_868_000 picoseconds. + Weight::from_parts(45_386_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -641,11 +640,11 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_611_000 picoseconds. - Weight::from_parts(4_292_527, 0) + // Minimum execution time: 2_573_000 picoseconds. + Weight::from_parts(4_309_077, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 9_304 - .saturating_add(Weight::from_parts(3_636_886, 0).saturating_mul(n.into())) + // Standard Error: 9_731 + .saturating_add(Weight::from_parts(3_668_159, 0).saturating_mul(n.into())) } /// Storage: Nfts Item (r:2 w:0) /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) @@ -655,8 +654,8 @@ impl pallet_nfts::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `460` // Estimated: `7662` - // Minimum execution time: 22_643_000 picoseconds. - Weight::from_parts(22_957_000, 0) + // Minimum execution time: 22_763_000 picoseconds. + Weight::from_parts(22_911_000, 0) .saturating_add(Weight::from_parts(0, 7662)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) @@ -668,10 +667,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn cancel_swap() -> Weight { // Proof Size summary in bytes: // Measured: `479` - // Estimated: `7862` - // Minimum execution time: 21_037_000 picoseconds. - Weight::from_parts(21_359_000, 0) - .saturating_add(Weight::from_parts(0, 7862)) + // Estimated: `4326` + // Minimum execution time: 21_393_000 picoseconds. + Weight::from_parts(21_656_000, 0) + .saturating_add(Weight::from_parts(0, 4326)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -692,10 +691,10 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn claim_swap() -> Weight { // Proof Size summary in bytes: // Measured: `800` - // Estimated: `24321` - // Minimum execution time: 72_434_000 picoseconds. - Weight::from_parts(73_184_000, 0) - .saturating_add(Weight::from_parts(0, 24321)) + // Estimated: `7662` + // Minimum execution time: 73_894_000 picoseconds. + Weight::from_parts(75_692_000, 0) + .saturating_add(Weight::from_parts(0, 7662)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(10)) } @@ -721,12 +720,12 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn mint_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `524` - // Estimated: `29399 + n * (2954 ±0)` - // Minimum execution time: 125_554_000 picoseconds. - Weight::from_parts(129_631_978, 0) - .saturating_add(Weight::from_parts(0, 29399)) - // Standard Error: 20_858 - .saturating_add(Weight::from_parts(26_871_088, 0).saturating_mul(n.into())) + // Estimated: `6078 + n * (2954 ±0)` + // Minimum execution time: 132_196_000 picoseconds. + Weight::from_parts(136_454_873, 0) + .saturating_add(Weight::from_parts(0, 6078)) + // Standard Error: 18_901 + .saturating_add(Weight::from_parts(29_375_812, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6)) @@ -749,12 +748,12 @@ impl pallet_nfts::WeightInfo for WeightInfo { fn set_attributes_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `554` - // Estimated: `20462 + n * (2954 ±0)` - // Minimum execution time: 76_170_000 picoseconds. - Weight::from_parts(85_697_599, 0) - .saturating_add(Weight::from_parts(0, 20462)) - // Standard Error: 51_480 - .saturating_add(Weight::from_parts(26_398_485, 0).saturating_mul(n.into())) + // Estimated: `4466 + n * (2954 ±0)` + // Minimum execution time: 76_734_000 picoseconds. + Weight::from_parts(87_761_745, 0) + .saturating_add(Weight::from_parts(0, 4466)) + // Standard Error: 59_520 + .saturating_add(Weight::from_parts(28_979_367, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2)) diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_proxy.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_proxy.rs similarity index 72% rename from parachains/runtimes/assets/statemint/src/weights/pallet_proxy.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_proxy.rs index 1471920ba2f..b92e3c4eede 100644 --- a/parachains/runtimes/assets/statemint/src/weights/pallet_proxy.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_proxy.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_proxy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemint-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_proxy @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/pallet_proxy.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_proxy.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_proxy`. pub struct WeightInfo(PhantomData); @@ -54,11 +55,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 17_484_000 picoseconds. - Weight::from_parts(17_998_669, 0) + // Minimum execution time: 16_863_000 picoseconds. + Weight::from_parts(17_287_999, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_091 - .saturating_add(Weight::from_parts(33_441, 0).saturating_mul(p.into())) + // Standard Error: 841 + .saturating_add(Weight::from_parts(25_908, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) } /// Storage: Proxy Proxies (r:1 w:0) @@ -72,14 +73,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn proxy_announced(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `454 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `13997` - // Minimum execution time: 35_828_000 picoseconds. - Weight::from_parts(36_241_110, 0) - .saturating_add(Weight::from_parts(0, 13997)) - // Standard Error: 2_219 - .saturating_add(Weight::from_parts(156_309, 0).saturating_mul(a.into())) - // Standard Error: 2_292 - .saturating_add(Weight::from_parts(32_167, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 38_170_000 picoseconds. + Weight::from_parts(37_695_584, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_836 + .saturating_add(Weight::from_parts(146_800, 0).saturating_mul(a.into())) + // Standard Error: 1_897 + .saturating_add(Weight::from_parts(38_057, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -92,14 +93,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn remove_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `369 + a * (68 ±0)` - // Estimated: `9291` - // Minimum execution time: 22_512_000 picoseconds. - Weight::from_parts(23_254_777, 0) - .saturating_add(Weight::from_parts(0, 9291)) - // Standard Error: 1_318 - .saturating_add(Weight::from_parts(148_302, 0).saturating_mul(a.into())) - // Standard Error: 1_362 - .saturating_add(Weight::from_parts(13_945, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 25_161_000 picoseconds. + Weight::from_parts(25_440_795, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_095 + .saturating_add(Weight::from_parts(135_319, 0).saturating_mul(a.into())) + // Standard Error: 1_131 + .saturating_add(Weight::from_parts(11_250, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -112,14 +113,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn reject_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `369 + a * (68 ±0)` - // Estimated: `9291` - // Minimum execution time: 22_528_000 picoseconds. - Weight::from_parts(23_510_728, 0) - .saturating_add(Weight::from_parts(0, 9291)) - // Standard Error: 1_393 - .saturating_add(Weight::from_parts(143_817, 0).saturating_mul(a.into())) - // Standard Error: 1_439 - .saturating_add(Weight::from_parts(9_334, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 25_441_000 picoseconds. + Weight::from_parts(25_850_657, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_148 + .saturating_add(Weight::from_parts(127_981, 0).saturating_mul(a.into())) + // Standard Error: 1_186 + .saturating_add(Weight::from_parts(6_961, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -134,14 +135,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn announce(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `386 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `13997` - // Minimum execution time: 31_233_000 picoseconds. - Weight::from_parts(32_142_917, 0) - .saturating_add(Weight::from_parts(0, 13997)) - // Standard Error: 1_888 - .saturating_add(Weight::from_parts(142_949, 0).saturating_mul(a.into())) - // Standard Error: 1_951 - .saturating_add(Weight::from_parts(46_737, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 34_657_000 picoseconds. + Weight::from_parts(33_913_455, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_087 + .saturating_add(Weight::from_parts(128_175, 0).saturating_mul(a.into())) + // Standard Error: 1_123 + .saturating_add(Weight::from_parts(40_321, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -152,11 +153,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 24_085_000 picoseconds. - Weight::from_parts(25_032_056, 0) + // Minimum execution time: 25_575_000 picoseconds. + Weight::from_parts(26_235_398, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_758 - .saturating_add(Weight::from_parts(52_203, 0).saturating_mul(p.into())) + // Standard Error: 924 + .saturating_add(Weight::from_parts(51_662, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -167,11 +168,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 23_678_000 picoseconds. - Weight::from_parts(24_981_101, 0) + // Minimum execution time: 25_416_000 picoseconds. + Weight::from_parts(26_557_151, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_874 - .saturating_add(Weight::from_parts(73_774, 0).saturating_mul(p.into())) + // Standard Error: 1_447 + .saturating_add(Weight::from_parts(50_558, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -182,11 +183,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 19_119_000 picoseconds. - Weight::from_parts(19_982_142, 0) + // Minimum execution time: 22_606_000 picoseconds. + Weight::from_parts(23_262_867, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_174 - .saturating_add(Weight::from_parts(26_182, 0).saturating_mul(p.into())) + // Standard Error: 1_186 + .saturating_add(Weight::from_parts(26_393, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -197,11 +198,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `139` // Estimated: `4706` - // Minimum execution time: 26_077_000 picoseconds. - Weight::from_parts(27_130_205, 0) + // Minimum execution time: 27_288_000 picoseconds. + Weight::from_parts(27_957_909, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_539 - .saturating_add(Weight::from_parts(1_625, 0).saturating_mul(p.into())) + // Standard Error: 706 + .saturating_add(Weight::from_parts(8_841, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -212,11 +213,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `164 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 20_178_000 picoseconds. - Weight::from_parts(21_090_914, 0) + // Minimum execution time: 23_640_000 picoseconds. + Weight::from_parts(24_327_982, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_488 - .saturating_add(Weight::from_parts(36_285, 0).saturating_mul(p.into())) + // Standard Error: 828 + .saturating_add(Weight::from_parts(28_240, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_session.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_session.rs similarity index 80% rename from parachains/runtimes/assets/statemint/src/weights/pallet_session.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_session.rs index 87458dcd84b..f768b5436a0 100644 --- a/parachains/runtimes/assets/statemint/src/weights/pallet_session.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_session.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_session` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemint-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_session @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/pallet_session.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_session.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_session`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn set_keys() -> Weight { // Proof Size summary in bytes: // Measured: `270` - // Estimated: `7470` - // Minimum execution time: 17_008_000 picoseconds. - Weight::from_parts(17_288_000, 0) - .saturating_add(Weight::from_parts(0, 7470)) + // Estimated: `3735` + // Minimum execution time: 17_308_000 picoseconds. + Weight::from_parts(17_624_000, 0) + .saturating_add(Weight::from_parts(0, 3735)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -68,10 +69,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn purge_keys() -> Weight { // Proof Size summary in bytes: // Measured: `242` - // Estimated: `3949` - // Minimum execution time: 13_427_000 picoseconds. - Weight::from_parts(13_609_000, 0) - .saturating_add(Weight::from_parts(0, 3949)) + // Estimated: `3707` + // Minimum execution time: 12_828_000 picoseconds. + Weight::from_parts(12_985_000, 0) + .saturating_add(Weight::from_parts(0, 3707)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_timestamp.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_timestamp.rs similarity index 80% rename from parachains/runtimes/assets/westmint/src/weights/pallet_timestamp.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_timestamp.rs index 7475e81c9ad..6380b2d4bdf 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_timestamp.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_timestamp.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_timestamp @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_timestamp.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_timestamp.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_timestamp`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_timestamp::WeightInfo for WeightInfo { fn set() -> Weight { // Proof Size summary in bytes: // Measured: `86` - // Estimated: `2986` - // Minimum execution time: 9_273_000 picoseconds. - Weight::from_parts(9_653_000, 0) - .saturating_add(Weight::from_parts(0, 2986)) + // Estimated: `1493` + // Minimum execution time: 9_150_000 picoseconds. + Weight::from_parts(9_474_000, 0) + .saturating_add(Weight::from_parts(0, 1493)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +66,8 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `57` // Estimated: `0` - // Minimum execution time: 3_289_000 picoseconds. - Weight::from_parts(3_379_000, 0) + // Minimum execution time: 3_210_000 picoseconds. + Weight::from_parts(3_330_000, 0) .saturating_add(Weight::from_parts(0, 0)) } } diff --git a/parachains/runtimes/assets/statemint/src/weights/pallet_uniques.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_uniques.rs similarity index 80% rename from parachains/runtimes/assets/statemint/src/weights/pallet_uniques.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_uniques.rs index 1c33a12ab3d..e2b3710f033 100644 --- a/parachains/runtimes/assets/statemint/src/weights/pallet_uniques.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_uniques.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_uniques` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=statemint-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_uniques @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemint/src/weights/pallet_uniques.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_uniques.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_uniques`. pub struct WeightInfo(PhantomData); @@ -55,8 +56,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `145` // Estimated: `3643` - // Minimum execution time: 26_653_000 picoseconds. - Weight::from_parts(27_024_000, 0) + // Minimum execution time: 29_873_000 picoseconds. + Weight::from_parts(30_382_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -69,8 +70,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3643` - // Minimum execution time: 15_168_000 picoseconds. - Weight::from_parts(15_535_000, 0) + // Minimum execution time: 14_338_000 picoseconds. + Weight::from_parts(14_710_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -96,17 +97,17 @@ impl pallet_uniques::WeightInfo for WeightInfo { /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `257 + n * (76 ±0) + m * (56 ±0) + a * (107 ±0)` - // Estimated: `9210 + n * (2597 ±0) + m * (2662 ±0) + a * (2647 ±0)` - // Minimum execution time: 2_365_108_000 picoseconds. - Weight::from_parts(2_380_000_000, 0) - .saturating_add(Weight::from_parts(0, 9210)) - // Standard Error: 24_588 - .saturating_add(Weight::from_parts(6_339_196, 0).saturating_mul(n.into())) - // Standard Error: 24_588 - .saturating_add(Weight::from_parts(265_876, 0).saturating_mul(m.into())) - // Standard Error: 24_588 - .saturating_add(Weight::from_parts(316_327, 0).saturating_mul(a.into())) + // Measured: `257 + a * (107 ±0) + m * (56 ±0) + n * (76 ±0)` + // Estimated: `3643 + a * (2647 ±0) + m * (2662 ±0) + n * (2597 ±0)` + // Minimum execution time: 2_398_014_000 picoseconds. + Weight::from_parts(2_410_569_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) + // Standard Error: 24_769 + .saturating_add(Weight::from_parts(6_309_077, 0).saturating_mul(n.into())) + // Standard Error: 24_769 + .saturating_add(Weight::from_parts(257_995, 0).saturating_mul(m.into())) + // Standard Error: 24_769 + .saturating_add(Weight::from_parts(317_885, 0).saturating_mul(a.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) @@ -115,9 +116,9 @@ impl pallet_uniques::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(m.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) - .saturating_add(Weight::from_parts(0, 2597).saturating_mul(n.into())) - .saturating_add(Weight::from_parts(0, 2662).saturating_mul(m.into())) .saturating_add(Weight::from_parts(0, 2647).saturating_mul(a.into())) + .saturating_add(Weight::from_parts(0, 2662).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 2597).saturating_mul(n.into())) } /// Storage: Uniques Asset (r:1 w:1) /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) @@ -130,10 +131,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn mint() -> Weight { // Proof Size summary in bytes: // Measured: `282` - // Estimated: `10719` - // Minimum execution time: 32_891_000 picoseconds. - Weight::from_parts(33_169_000, 0) - .saturating_add(Weight::from_parts(0, 10719)) + // Estimated: `3643` + // Minimum execution time: 36_084_000 picoseconds. + Weight::from_parts(36_377_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -148,10 +149,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn burn() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 33_895_000 picoseconds. - Weight::from_parts(34_205_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 37_397_000 picoseconds. + Weight::from_parts(37_763_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -166,10 +167,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn transfer() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 27_841_000 picoseconds. - Weight::from_parts(28_213_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 27_423_000 picoseconds. + Weight::from_parts(27_666_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -181,12 +182,12 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `738 + i * (76 ±0)` - // Estimated: `4633 + i * (2597 ±0)` - // Minimum execution time: 16_054_000 picoseconds. - Weight::from_parts(16_331_000, 0) - .saturating_add(Weight::from_parts(0, 4633)) - // Standard Error: 12_166 - .saturating_add(Weight::from_parts(13_413_428, 0).saturating_mul(i.into())) + // Estimated: `3643 + i * (2597 ±0)` + // Minimum execution time: 15_215_000 picoseconds. + Weight::from_parts(15_450_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) + // Standard Error: 12_841 + .saturating_add(Weight::from_parts(15_164_179, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -200,10 +201,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn freeze() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 19_419_000 picoseconds. - Weight::from_parts(19_724_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 19_169_000 picoseconds. + Weight::from_parts(19_541_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -214,10 +215,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn thaw() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 20_053_000 picoseconds. - Weight::from_parts(23_080_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 18_941_000 picoseconds. + Weight::from_parts(19_336_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -227,8 +228,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 15_569_000 picoseconds. - Weight::from_parts(16_658_000, 0) + // Minimum execution time: 14_356_000 picoseconds. + Weight::from_parts(14_650_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -239,8 +240,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 15_350_000 picoseconds. - Weight::from_parts(15_771_000, 0) + // Minimum execution time: 14_303_000 picoseconds. + Weight::from_parts(14_504_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -254,10 +255,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn transfer_ownership() -> Weight { // Proof Size summary in bytes: // Measured: `356` - // Estimated: `7160` - // Minimum execution time: 23_564_000 picoseconds. - Weight::from_parts(24_005_000, 0) - .saturating_add(Weight::from_parts(0, 7160)) + // Estimated: `3643` + // Minimum execution time: 22_663_000 picoseconds. + Weight::from_parts(23_053_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -267,8 +268,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 16_165_000 picoseconds. - Weight::from_parts(16_482_000, 0) + // Minimum execution time: 15_198_000 picoseconds. + Weight::from_parts(15_645_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -281,8 +282,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `3643` - // Minimum execution time: 18_377_000 picoseconds. - Weight::from_parts(19_060_000, 0) + // Minimum execution time: 17_381_000 picoseconds. + Weight::from_parts(17_588_000, 0) .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -296,10 +297,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `559` - // Estimated: `10932` - // Minimum execution time: 39_403_000 picoseconds. - Weight::from_parts(39_925_000, 0) - .saturating_add(Weight::from_parts(0, 10932)) + // Estimated: `3652` + // Minimum execution time: 39_838_000 picoseconds. + Weight::from_parts(40_387_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -312,10 +313,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn clear_attribute() -> Weight { // Proof Size summary in bytes: // Measured: `756` - // Estimated: `10932` - // Minimum execution time: 36_786_000 picoseconds. - Weight::from_parts(37_558_000, 0) - .saturating_add(Weight::from_parts(0, 10932)) + // Estimated: `3652` + // Minimum execution time: 38_600_000 picoseconds. + Weight::from_parts(39_215_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -326,10 +327,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `348` - // Estimated: `7295` - // Minimum execution time: 30_327_000 picoseconds. - Weight::from_parts(30_769_000, 0) - .saturating_add(Weight::from_parts(0, 7295)) + // Estimated: `3652` + // Minimum execution time: 31_563_000 picoseconds. + Weight::from_parts(32_111_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -340,10 +341,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn clear_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `559` - // Estimated: `7295` - // Minimum execution time: 29_756_000 picoseconds. - Weight::from_parts(31_077_000, 0) - .saturating_add(Weight::from_parts(0, 7295)) + // Estimated: `3652` + // Minimum execution time: 31_525_000 picoseconds. + Weight::from_parts(31_904_000, 0) + .saturating_add(Weight::from_parts(0, 3652)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -354,10 +355,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `282` - // Estimated: `7275` - // Minimum execution time: 29_811_000 picoseconds. - Weight::from_parts(30_220_000, 0) - .saturating_add(Weight::from_parts(0, 7275)) + // Estimated: `3643` + // Minimum execution time: 32_104_000 picoseconds. + Weight::from_parts(32_429_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -368,10 +369,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: // Measured: `473` - // Estimated: `7275` - // Minimum execution time: 27_708_000 picoseconds. - Weight::from_parts(28_309_000, 0) - .saturating_add(Weight::from_parts(0, 7275)) + // Estimated: `3643` + // Minimum execution time: 30_433_000 picoseconds. + Weight::from_parts(30_662_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -382,10 +383,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn approve_transfer() -> Weight { // Proof Size summary in bytes: // Measured: `428` - // Estimated: `7230` - // Minimum execution time: 21_525_000 picoseconds. - Weight::from_parts(21_784_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 20_463_000 picoseconds. + Weight::from_parts(20_879_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -396,10 +397,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn cancel_approval() -> Weight { // Proof Size summary in bytes: // Measured: `461` - // Estimated: `7230` - // Minimum execution time: 21_605_000 picoseconds. - Weight::from_parts(21_805_000, 0) - .saturating_add(Weight::from_parts(0, 7230)) + // Estimated: `3643` + // Minimum execution time: 20_158_000 picoseconds. + Weight::from_parts(20_465_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -409,8 +410,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3517` - // Minimum execution time: 17_046_000 picoseconds. - Weight::from_parts(17_387_000, 0) + // Minimum execution time: 16_009_000 picoseconds. + Weight::from_parts(16_396_000, 0) .saturating_add(Weight::from_parts(0, 3517)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -422,10 +423,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: // Measured: `282` - // Estimated: `7132` - // Minimum execution time: 18_453_000 picoseconds. - Weight::from_parts(18_716_000, 0) - .saturating_add(Weight::from_parts(0, 7132)) + // Estimated: `3643` + // Minimum execution time: 17_034_000 picoseconds. + Weight::from_parts(17_286_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -437,8 +438,8 @@ impl pallet_uniques::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `259` // Estimated: `3587` - // Minimum execution time: 17_965_000 picoseconds. - Weight::from_parts(18_347_000, 0) + // Minimum execution time: 17_020_000 picoseconds. + Weight::from_parts(17_318_000, 0) .saturating_add(Weight::from_parts(0, 3587)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -454,10 +455,10 @@ impl pallet_uniques::WeightInfo for WeightInfo { fn buy_item() -> Weight { // Proof Size summary in bytes: // Measured: `540` - // Estimated: `10784` - // Minimum execution time: 38_974_000 picoseconds. - Weight::from_parts(39_420_000, 0) - .saturating_add(Weight::from_parts(0, 10784)) + // Estimated: `3643` + // Minimum execution time: 37_771_000 picoseconds. + Weight::from_parts(38_708_000, 0) + .saturating_add(Weight::from_parts(0, 3643)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_utility.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_utility.rs similarity index 71% rename from parachains/runtimes/assets/westmint/src/weights/pallet_utility.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_utility.rs index 76db89d9078..9584d32ac10 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_utility.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_utility.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_utility @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_utility.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_utility.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_utility`. pub struct WeightInfo(PhantomData); @@ -52,18 +53,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_995_000 picoseconds. - Weight::from_parts(19_761_796, 0) + // Minimum execution time: 7_065_000 picoseconds. + Weight::from_parts(7_907_851, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_672 - .saturating_add(Weight::from_parts(4_682_116, 0).saturating_mul(c.into())) + // Standard Error: 2_515 + .saturating_add(Weight::from_parts(5_447_457, 0).saturating_mul(c.into())) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_549_000 picoseconds. - Weight::from_parts(5_723_000, 0) + // Minimum execution time: 5_845_000 picoseconds. + Weight::from_parts(6_053_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -71,18 +72,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_210_000 picoseconds. - Weight::from_parts(15_002_117, 0) + // Minimum execution time: 7_094_000 picoseconds. + Weight::from_parts(1_459_029, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_199 - .saturating_add(Weight::from_parts(4_917_852, 0).saturating_mul(c.into())) + // Standard Error: 4_016 + .saturating_add(Weight::from_parts(5_680_469, 0).saturating_mul(c.into())) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_596_000 picoseconds. - Weight::from_parts(9_875_000, 0) + // Minimum execution time: 9_972_000 picoseconds. + Weight::from_parts(10_167_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -90,10 +91,10 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_024_000 picoseconds. - Weight::from_parts(15_781_473, 0) + // Minimum execution time: 7_148_000 picoseconds. + Weight::from_parts(6_914_554, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2_344 - .saturating_add(Weight::from_parts(4_665_530, 0).saturating_mul(c.into())) + // Standard Error: 3_605 + .saturating_add(Weight::from_parts(5_440_589, 0).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/assets/westmint/src/weights/pallet_xcm.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs similarity index 83% rename from parachains/runtimes/assets/westmint/src/weights/pallet_xcm.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs index 0d650e50929..cffebc3ea84 100644 --- a/parachains/runtimes/assets/westmint/src/weights/pallet_xcm.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs @@ -17,16 +17,16 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet -// --chain=westmint-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_xcm @@ -35,14 +35,15 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_xcm.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/pallet_xcm.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); @@ -60,10 +61,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn send() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `9780` - // Minimum execution time: 28_019_000 picoseconds. - Weight::from_parts(29_053_000, 0) - .saturating_add(Weight::from_parts(0, 9780)) + // Estimated: `3540` + // Minimum execution time: 30_683_000 picoseconds. + Weight::from_parts(31_228_000, 0) + .saturating_add(Weight::from_parts(0, 3540)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +74,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1489` - // Minimum execution time: 24_127_000 picoseconds. - Weight::from_parts(24_609_000, 0) + // Minimum execution time: 29_299_000 picoseconds. + Weight::from_parts(29_857_000, 0) .saturating_add(Weight::from_parts(0, 1489)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -84,8 +85,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1489` - // Minimum execution time: 18_826_000 picoseconds. - Weight::from_parts(19_183_000, 0) + // Minimum execution time: 22_639_000 picoseconds. + Weight::from_parts(23_057_000, 0) .saturating_add(Weight::from_parts(0, 1489)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -93,8 +94,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_865_000 picoseconds. - Weight::from_parts(10_129_000, 0) + // Minimum execution time: 11_623_000 picoseconds. + Weight::from_parts(11_996_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// Storage: PolkadotXcm SupportedVersion (r:0 w:1) @@ -103,8 +104,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_995_000 picoseconds. - Weight::from_parts(10_290_000, 0) + // Minimum execution time: 11_678_000 picoseconds. + Weight::from_parts(12_002_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -114,8 +115,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_144_000 picoseconds. - Weight::from_parts(3_225_000, 0) + // Minimum execution time: 3_702_000 picoseconds. + Weight::from_parts(3_927_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -138,10 +139,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `14955` - // Minimum execution time: 33_946_000 picoseconds. - Weight::from_parts(34_595_000, 0) - .saturating_add(Weight::from_parts(0, 14955)) + // Estimated: `3540` + // Minimum execution time: 37_617_000 picoseconds. + Weight::from_parts(38_443_000, 0) + .saturating_add(Weight::from_parts(0, 3540)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -162,19 +163,21 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `257` - // Estimated: `14669` - // Minimum execution time: 34_408_000 picoseconds. - Weight::from_parts(34_845_000, 0) - .saturating_add(Weight::from_parts(0, 14669)) + // Estimated: `3722` + // Minimum execution time: 39_333_000 picoseconds. + Weight::from_parts(40_174_000, 0) + .saturating_add(Weight::from_parts(0, 3722)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: PolkadotXcm XcmExecutionSuspended (r:0 w:1) + /// Proof Skipped: PolkadotXcm XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured) fn force_suspension() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_144_000 picoseconds. - Weight::from_parts(3_225_000, 0) + // Minimum execution time: 3_857_000 picoseconds. + Weight::from_parts(4_158_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -184,8 +187,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `129` // Estimated: `11019` - // Minimum execution time: 17_219_000 picoseconds. - Weight::from_parts(17_552_000, 0) + // Minimum execution time: 17_929_000 picoseconds. + Weight::from_parts(18_175_000, 0) .saturating_add(Weight::from_parts(0, 11019)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -196,8 +199,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `133` // Estimated: `11023` - // Minimum execution time: 17_382_000 picoseconds. - Weight::from_parts(17_791_000, 0) + // Minimum execution time: 17_241_000 picoseconds. + Weight::from_parts(17_618_000, 0) .saturating_add(Weight::from_parts(0, 11023)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -208,8 +211,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `140` // Estimated: `13505` - // Minimum execution time: 18_051_000 picoseconds. - Weight::from_parts(18_643_000, 0) + // Minimum execution time: 18_013_000 picoseconds. + Weight::from_parts(18_485_000, 0) .saturating_add(Weight::from_parts(0, 13505)) .saturating_add(T::DbWeight::get().reads(5)) } @@ -228,10 +231,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn notify_current_targets() -> Weight { // Proof Size summary in bytes: // Measured: `142` - // Estimated: `16197` - // Minimum execution time: 33_113_000 picoseconds. - Weight::from_parts(34_048_000, 0) - .saturating_add(Weight::from_parts(0, 16197)) + // Estimated: `6082` + // Minimum execution time: 30_736_000 picoseconds. + Weight::from_parts(31_215_000, 0) + .saturating_add(Weight::from_parts(0, 6082)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -241,8 +244,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `172` // Estimated: `8587` - // Minimum execution time: 9_569_000 picoseconds. - Weight::from_parts(9_933_000, 0) + // Minimum execution time: 9_005_000 picoseconds. + Weight::from_parts(9_289_000, 0) .saturating_add(Weight::from_parts(0, 8587)) .saturating_add(T::DbWeight::get().reads(3)) } @@ -252,8 +255,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `140` // Estimated: `11030` - // Minimum execution time: 19_098_000 picoseconds. - Weight::from_parts(19_550_000, 0) + // Minimum execution time: 17_506_000 picoseconds. + Weight::from_parts(17_811_000, 0) .saturating_add(Weight::from_parts(0, 11030)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -273,10 +276,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: // Measured: `146` - // Estimated: `21171` - // Minimum execution time: 40_365_000 picoseconds. - Weight::from_parts(41_092_000, 0) - .saturating_add(Weight::from_parts(0, 21171)) + // Estimated: `11036` + // Minimum execution time: 37_343_000 picoseconds. + Weight::from_parts(37_774_000, 0) + .saturating_add(Weight::from_parts(0, 11036)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } diff --git a/parachains/runtimes/assets/westmint/src/weights/paritydb_weights.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/paritydb_weights.rs similarity index 100% rename from parachains/runtimes/assets/westmint/src/weights/paritydb_weights.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/paritydb_weights.rs diff --git a/parachains/runtimes/assets/westmint/src/weights/rocksdb_weights.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/rocksdb_weights.rs similarity index 100% rename from parachains/runtimes/assets/westmint/src/weights/rocksdb_weights.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/rocksdb_weights.rs diff --git a/parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs similarity index 95% rename from parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index 1b4a2bcfdd7..4cc46939843 100644 --- a/parachains/runtimes/assets/statemint/src/weights/xcm/mod.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -53,19 +52,19 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } -pub struct StatemintXcmWeight(core::marker::PhantomData); -impl XcmWeightInfo for StatemintXcmWeight { +pub struct AssetHubWestendXcmWeight(core::marker::PhantomData); +impl XcmWeightInfo for AssetHubWestendXcmWeight { fn withdraw_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset()) } // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -123,7 +122,7 @@ impl XcmWeightInfo for StatemintXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } diff --git a/parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs similarity index 87% rename from parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index d93dd65746b..429c43a343c 100644 --- a/parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -17,17 +17,17 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::fungible` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet // --template=./templates/xcm-bench-template.hbs -// --chain=statemine-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_xcm_benchmarks::fungible @@ -36,7 +36,7 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -54,8 +54,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `101` // Estimated: `3593` - // Minimum execution time: 23_021_000 picoseconds. - Weight::from_parts(23_385_000, 3593) + // Minimum execution time: 25_802_000 picoseconds. + Weight::from_parts(26_076_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +65,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `101` // Estimated: `6196` - // Minimum execution time: 33_451_000 picoseconds. - Weight::from_parts(33_779_000, 6196) + // Minimum execution time: 48_092_000 picoseconds. + Weight::from_parts(48_397_000, 6196) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -87,9 +87,9 @@ impl WeightInfo { pub fn transfer_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `176` - // Estimated: `17970` - // Minimum execution time: 56_145_000 picoseconds. - Weight::from_parts(56_830_000, 17970) + // Estimated: `6196` + // Minimum execution time: 70_237_000 picoseconds. + Weight::from_parts(70_692_000, 6196) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -97,8 +97,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_315_000 picoseconds. - Weight::from_parts(4_448_000, 0) + // Minimum execution time: 4_045_000 picoseconds. + Weight::from_parts(4_135_000, 0) } // Storage: System Account (r:1 w:1) // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) @@ -106,8 +106,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 25_505_000 picoseconds. - Weight::from_parts(25_697_000, 3593) + // Minimum execution time: 26_201_000 picoseconds. + Weight::from_parts(26_820_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -128,9 +128,9 @@ impl WeightInfo { pub fn deposit_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `14862` - // Minimum execution time: 50_620_000 picoseconds. - Weight::from_parts(50_926_000, 14862) + // Estimated: `3593` + // Minimum execution time: 50_526_000 picoseconds. + Weight::from_parts(51_121_000, 3593) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -149,9 +149,9 @@ impl WeightInfo { pub fn initiate_teleport() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 31_700_000 picoseconds. - Weight::from_parts(32_178_000, 11269) + // Estimated: `3540` + // Minimum execution time: 30_690_000 picoseconds. + Weight::from_parts(31_032_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs similarity index 80% rename from parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_generic.rs rename to parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 67c2b083f89..7676d7b3a38 100644 --- a/parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,17 +17,17 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-westend-dev"), DB CACHE: 1024 // Executed Command: // ./artifacts/polkadot-parachain // benchmark // pallet // --template=./templates/xcm-bench-template.hbs -// --chain=westmint-dev +// --chain=asset-hub-westend-dev // --execution=wasm // --wasm-execution=compiled // --pallet=pallet_xcm_benchmarks::generic @@ -36,7 +36,7 @@ // --repeat=20 // --json // --header=./file_header.txt -// --output=./parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +// --output=./parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -63,9 +63,9 @@ impl WeightInfo { pub fn report_holding() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 355_263_000 picoseconds. - Weight::from_parts(357_327_000, 11269) + // Estimated: `3540` + // Minimum execution time: 361_717_000 picoseconds. + Weight::from_parts(362_438_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +73,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_068_000 picoseconds. - Weight::from_parts(4_273_000, 0) + // Minimum execution time: 3_952_000 picoseconds. + Weight::from_parts(4_060_000, 0) } // Storage: PolkadotXcm Queries (r:1 w:0) // Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) @@ -82,58 +82,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `69` // Estimated: `3534` - // Minimum execution time: 11_279_000 picoseconds. - Weight::from_parts(11_626_000, 3534) + // Minimum execution time: 10_984_000 picoseconds. + Weight::from_parts(11_204_000, 3534) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_246_000 picoseconds. - Weight::from_parts(13_425_000, 0) + // Minimum execution time: 13_942_000 picoseconds. + Weight::from_parts(14_077_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_426_000 picoseconds. - Weight::from_parts(4_600_000, 0) + // Minimum execution time: 4_242_000 picoseconds. + Weight::from_parts(4_354_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_838_000 picoseconds. - Weight::from_parts(2_921_000, 0) + // Minimum execution time: 2_802_000 picoseconds. + Weight::from_parts(2_851_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_858_000 picoseconds. - Weight::from_parts(2_981_000, 0) + // Minimum execution time: 2_797_000 picoseconds. + Weight::from_parts(2_899_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_848_000 picoseconds. - Weight::from_parts(2_922_000, 0) + // Minimum execution time: 2_767_000 picoseconds. + Weight::from_parts(2_837_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_732_000 picoseconds. - Weight::from_parts(3_801_000, 0) + // Minimum execution time: 3_669_000 picoseconds. + Weight::from_parts(3_721_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_882_000 picoseconds. - Weight::from_parts(2_971_000, 0) + // Minimum execution time: 2_719_000 picoseconds. + Weight::from_parts(2_789_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -150,9 +150,9 @@ impl WeightInfo { pub fn report_error() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 25_538_000 picoseconds. - Weight::from_parts(25_964_000, 11269) + // Estimated: `3540` + // Minimum execution time: 25_261_000 picoseconds. + Weight::from_parts(25_779_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -162,8 +162,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `126` // Estimated: `3591` - // Minimum execution time: 16_187_000 picoseconds. - Weight::from_parts(16_478_000, 3591) + // Minimum execution time: 16_124_000 picoseconds. + Weight::from_parts(16_394_000, 3591) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -171,8 +171,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_804_000 picoseconds. - Weight::from_parts(2_874_000, 0) + // Minimum execution time: 2_757_000 picoseconds. + Weight::from_parts(2_847_000, 0) } // Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1) // Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) @@ -189,9 +189,9 @@ impl WeightInfo { pub fn subscribe_version() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `13320` - // Minimum execution time: 28_208_000 picoseconds. - Weight::from_parts(28_512_000, 13320) + // Estimated: `3540` + // Minimum execution time: 27_522_000 picoseconds. + Weight::from_parts(27_997_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -201,8 +201,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_021_000 picoseconds. - Weight::from_parts(5_128_000, 0) + // Minimum execution time: 4_975_000 picoseconds. + Weight::from_parts(5_129_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainInfo ParachainId (r:1 w:0) @@ -220,9 +220,9 @@ impl WeightInfo { pub fn initiate_reserve_withdraw() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 403_561_000 picoseconds. - Weight::from_parts(404_798_000, 11269) + // Estimated: `3540` + // Minimum execution time: 398_886_000 picoseconds. + Weight::from_parts(400_023_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -230,36 +230,36 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 122_646_000 picoseconds. - Weight::from_parts(123_057_000, 0) + // Minimum execution time: 120_499_000 picoseconds. + Weight::from_parts(120_883_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_916_000 picoseconds. - Weight::from_parts(14_178_000, 0) + // Minimum execution time: 13_140_000 picoseconds. + Weight::from_parts(13_404_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_025_000 picoseconds. - Weight::from_parts(3_083_000, 0) + // Minimum execution time: 2_861_000 picoseconds. + Weight::from_parts(2_920_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_879_000 picoseconds. - Weight::from_parts(2_947_000, 0) + // Minimum execution time: 2_791_000 picoseconds. + Weight::from_parts(2_843_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_067_000 picoseconds. - Weight::from_parts(3_129_000, 0) + // Minimum execution time: 2_992_000 picoseconds. + Weight::from_parts(3_057_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -276,9 +276,9 @@ impl WeightInfo { pub fn query_pallet() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 29_511_000 picoseconds. - Weight::from_parts(29_922_000, 11269) + // Estimated: `3540` + // Minimum execution time: 29_505_000 picoseconds. + Weight::from_parts(30_219_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -286,8 +286,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_410_000 picoseconds. - Weight::from_parts(5_531_000, 0) + // Minimum execution time: 5_344_000 picoseconds. + Weight::from_parts(5_490_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -304,9 +304,9 @@ impl WeightInfo { pub fn report_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `75` - // Estimated: `11269` - // Minimum execution time: 26_044_000 picoseconds. - Weight::from_parts(26_397_000, 11269) + // Estimated: `3540` + // Minimum execution time: 25_333_000 picoseconds. + Weight::from_parts(25_683_000, 3540) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -314,35 +314,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_950_000 picoseconds. - Weight::from_parts(2_989_000, 0) + // Minimum execution time: 2_734_000 picoseconds. + Weight::from_parts(2_813_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_877_000 picoseconds. - Weight::from_parts(2_928_000, 0) + // Minimum execution time: 2_766_000 picoseconds. + Weight::from_parts(2_824_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_884_000 picoseconds. - Weight::from_parts(2_959_000, 0) + // Minimum execution time: 2_763_000 picoseconds. + Weight::from_parts(2_839_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_733_000 picoseconds. - Weight::from_parts(2_862_000, 0) + // Minimum execution time: 2_753_000 picoseconds. + Weight::from_parts(2_837_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_917_000 picoseconds. - Weight::from_parts(2_990_000, 0) + // Minimum execution time: 3_001_000 picoseconds. + Weight::from_parts(3_064_000, 0) } } diff --git a/parachains/runtimes/assets/westmint/src/xcm_config.rs b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs similarity index 59% rename from parachains/runtimes/assets/westmint/src/xcm_config.rs rename to parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 13ffeb5cfc0..2904fb14746 100644 --- a/parachains/runtimes/assets/westmint/src/xcm_config.rs +++ b/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -28,22 +28,18 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ - AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry, - }, -}; +use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier}; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::ConvertInto; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, - ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, WithComputedOrigin, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, + DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FungiblesAdapter, IsConcrete, + LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, + UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -112,7 +108,7 @@ pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConverte // Ignore `TrustBackedAssets` explicitly StartsWith, // Ignore asset which starts explicitly with our `GlobalConsensus(NetworkId)`, means: - // - foreign assets from our consensus should be: `MultiLocation {parent: 1, X*(Parachain(xyz))} + // - foreign assets from our consensus should be: `MultiLocation {parents: 1, X*(Parachain(xyz), ..)} // - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` wont be accepted here StartsWithExplicitGlobalConsensus, ), @@ -174,6 +170,7 @@ match_types! { MultiLocation { parents: 1, interior: X1(Plurality { .. }) } }; } + /// A call filter for the XCM Transact instruction. This is a temporary measure until we properly /// account for proof size weights. /// @@ -191,177 +188,179 @@ impl Contains for SafeCallFilter { } } - match call { + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::Utility( - pallet_utility::Call::as_derivative { .. } | - pallet_utility::Call::batch { .. } | - pallet_utility::Call::batch_all { .. }, - ) | - RuntimeCall::Assets( + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. } | + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::Utility( + pallet_utility::Call::as_derivative { .. } | + pallet_utility::Call::batch { .. } | + pallet_utility::Call::batch_all { .. }, + ) | RuntimeCall::Assets( pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::ForeignAssets( + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::ForeignAssets( pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::set_metadata { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::Nfts( + pallet_assets::Call::force_create { .. } | + pallet_assets::Call::start_destroy { .. } | + pallet_assets::Call::destroy_accounts { .. } | + pallet_assets::Call::destroy_approvals { .. } | + pallet_assets::Call::finish_destroy { .. } | + pallet_assets::Call::mint { .. } | + pallet_assets::Call::burn { .. } | + pallet_assets::Call::transfer { .. } | + pallet_assets::Call::transfer_keep_alive { .. } | + pallet_assets::Call::force_transfer { .. } | + pallet_assets::Call::freeze { .. } | + pallet_assets::Call::thaw { .. } | + pallet_assets::Call::freeze_asset { .. } | + pallet_assets::Call::thaw_asset { .. } | + pallet_assets::Call::transfer_ownership { .. } | + pallet_assets::Call::set_team { .. } | + pallet_assets::Call::set_metadata { .. } | + pallet_assets::Call::clear_metadata { .. } | + pallet_assets::Call::force_clear_metadata { .. } | + pallet_assets::Call::force_asset_status { .. } | + pallet_assets::Call::approve_transfer { .. } | + pallet_assets::Call::cancel_approval { .. } | + pallet_assets::Call::force_cancel_approval { .. } | + pallet_assets::Call::transfer_approved { .. } | + pallet_assets::Call::touch { .. } | + pallet_assets::Call::refund { .. }, + ) | RuntimeCall::NftFractionalization( + pallet_nft_fractionalization::Call::fractionalize { .. } | + pallet_nft_fractionalization::Call::unify { .. }, + ) | RuntimeCall::Nfts( pallet_nfts::Call::create { .. } | - pallet_nfts::Call::force_create { .. } | - pallet_nfts::Call::destroy { .. } | - pallet_nfts::Call::mint { .. } | - pallet_nfts::Call::force_mint { .. } | - pallet_nfts::Call::burn { .. } | - pallet_nfts::Call::transfer { .. } | - pallet_nfts::Call::lock_item_transfer { .. } | - pallet_nfts::Call::unlock_item_transfer { .. } | - pallet_nfts::Call::lock_collection { .. } | - pallet_nfts::Call::transfer_ownership { .. } | - pallet_nfts::Call::set_team { .. } | - pallet_nfts::Call::force_collection_owner { .. } | - pallet_nfts::Call::force_collection_config { .. } | - pallet_nfts::Call::approve_transfer { .. } | - pallet_nfts::Call::cancel_approval { .. } | - pallet_nfts::Call::clear_all_transfer_approvals { .. } | - pallet_nfts::Call::lock_item_properties { .. } | - pallet_nfts::Call::set_attribute { .. } | - pallet_nfts::Call::force_set_attribute { .. } | - pallet_nfts::Call::clear_attribute { .. } | - pallet_nfts::Call::approve_item_attributes { .. } | - pallet_nfts::Call::cancel_item_attributes_approval { .. } | - pallet_nfts::Call::set_metadata { .. } | - pallet_nfts::Call::clear_metadata { .. } | - pallet_nfts::Call::set_collection_metadata { .. } | - pallet_nfts::Call::clear_collection_metadata { .. } | - pallet_nfts::Call::set_accept_ownership { .. } | - pallet_nfts::Call::set_collection_max_supply { .. } | - pallet_nfts::Call::update_mint_settings { .. } | - pallet_nfts::Call::set_price { .. } | - pallet_nfts::Call::buy_item { .. } | - pallet_nfts::Call::pay_tips { .. } | - pallet_nfts::Call::create_swap { .. } | - pallet_nfts::Call::cancel_swap { .. } | - pallet_nfts::Call::claim_swap { .. }, - ) | - RuntimeCall::Uniques( + pallet_nfts::Call::force_create { .. } | + pallet_nfts::Call::destroy { .. } | + pallet_nfts::Call::mint { .. } | + pallet_nfts::Call::force_mint { .. } | + pallet_nfts::Call::burn { .. } | + pallet_nfts::Call::transfer { .. } | + pallet_nfts::Call::lock_item_transfer { .. } | + pallet_nfts::Call::unlock_item_transfer { .. } | + pallet_nfts::Call::lock_collection { .. } | + pallet_nfts::Call::transfer_ownership { .. } | + pallet_nfts::Call::set_team { .. } | + pallet_nfts::Call::force_collection_owner { .. } | + pallet_nfts::Call::force_collection_config { .. } | + pallet_nfts::Call::approve_transfer { .. } | + pallet_nfts::Call::cancel_approval { .. } | + pallet_nfts::Call::clear_all_transfer_approvals { .. } | + pallet_nfts::Call::lock_item_properties { .. } | + pallet_nfts::Call::set_attribute { .. } | + pallet_nfts::Call::force_set_attribute { .. } | + pallet_nfts::Call::clear_attribute { .. } | + pallet_nfts::Call::approve_item_attributes { .. } | + pallet_nfts::Call::cancel_item_attributes_approval { .. } | + pallet_nfts::Call::set_metadata { .. } | + pallet_nfts::Call::clear_metadata { .. } | + pallet_nfts::Call::set_collection_metadata { .. } | + pallet_nfts::Call::clear_collection_metadata { .. } | + pallet_nfts::Call::set_accept_ownership { .. } | + pallet_nfts::Call::set_collection_max_supply { .. } | + pallet_nfts::Call::update_mint_settings { .. } | + pallet_nfts::Call::set_price { .. } | + pallet_nfts::Call::buy_item { .. } | + pallet_nfts::Call::pay_tips { .. } | + pallet_nfts::Call::create_swap { .. } | + pallet_nfts::Call::cancel_swap { .. } | + pallet_nfts::Call::claim_swap { .. }, + ) | RuntimeCall::Uniques( pallet_uniques::Call::create { .. } | - pallet_uniques::Call::force_create { .. } | - pallet_uniques::Call::destroy { .. } | - pallet_uniques::Call::mint { .. } | - pallet_uniques::Call::burn { .. } | - pallet_uniques::Call::transfer { .. } | - pallet_uniques::Call::freeze { .. } | - pallet_uniques::Call::thaw { .. } | - pallet_uniques::Call::freeze_collection { .. } | - pallet_uniques::Call::thaw_collection { .. } | - pallet_uniques::Call::transfer_ownership { .. } | - pallet_uniques::Call::set_team { .. } | - pallet_uniques::Call::approve_transfer { .. } | - pallet_uniques::Call::cancel_approval { .. } | - pallet_uniques::Call::force_item_status { .. } | - pallet_uniques::Call::set_attribute { .. } | - pallet_uniques::Call::clear_attribute { .. } | - pallet_uniques::Call::set_metadata { .. } | - pallet_uniques::Call::clear_metadata { .. } | - pallet_uniques::Call::set_collection_metadata { .. } | - pallet_uniques::Call::clear_collection_metadata { .. } | - pallet_uniques::Call::set_accept_ownership { .. } | - pallet_uniques::Call::set_collection_max_supply { .. } | - pallet_uniques::Call::set_price { .. } | - pallet_uniques::Call::buy_item { .. }, - ) => true, - _ => false, - } + pallet_uniques::Call::force_create { .. } | + pallet_uniques::Call::destroy { .. } | + pallet_uniques::Call::mint { .. } | + pallet_uniques::Call::burn { .. } | + pallet_uniques::Call::transfer { .. } | + pallet_uniques::Call::freeze { .. } | + pallet_uniques::Call::thaw { .. } | + pallet_uniques::Call::freeze_collection { .. } | + pallet_uniques::Call::thaw_collection { .. } | + pallet_uniques::Call::transfer_ownership { .. } | + pallet_uniques::Call::set_team { .. } | + pallet_uniques::Call::approve_transfer { .. } | + pallet_uniques::Call::cancel_approval { .. } | + pallet_uniques::Call::force_item_status { .. } | + pallet_uniques::Call::set_attribute { .. } | + pallet_uniques::Call::clear_attribute { .. } | + pallet_uniques::Call::set_metadata { .. } | + pallet_uniques::Call::clear_metadata { .. } | + pallet_uniques::Call::set_collection_metadata { .. } | + pallet_uniques::Call::clear_collection_metadata { .. } | + pallet_uniques::Call::set_accept_ownership { .. } | + pallet_uniques::Call::set_collection_max_supply { .. } | + pallet_uniques::Call::set_price { .. } | + pallet_uniques::Call::buy_item { .. }, + ) + ) } } -pub type Barrier = DenyThenTry< - DenyReserveTransferToRelayChain, - ( - TakeWeightCredit, - // Expected responses are OK. - AllowKnownQueryResponses, - // Allow XCMs with some computed origins to pass through. - WithComputedOrigin< - ( - // If the message is one that immediately attemps to pay for execution, then allow it. - AllowTopLevelPaidExecutionFrom, - // Parent and its pluralities (i.e. governance bodies) get free execution. - AllowExplicitUnpaidExecutionFrom, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, - ), - UniversalLocation, - ConstU32<8>, - >, - ), +pub type Barrier = TrailingSetTopicAsId< + DenyThenTry< + DenyReserveTransferToRelayChain, + ( + TakeWeightCredit, + // Expected responses are OK. + AllowKnownQueryResponses, + // Allow XCMs with some computed origins to pass through. + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Parent and its pluralities (i.e. governance bodies) get free execution. + AllowExplicitUnpaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, + ), + >, >; pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentialDepositMultiplier< @@ -377,8 +376,8 @@ impl xcm_executor::Config for XcmConfig { type XcmSender = XcmRouter; type AssetTransactor = AssetTransactors; type OriginConverter = XcmOriginToTransactDispatchOrigin; - // Westmint does not recognize a reserve location for any asset. This does not prevent - // Westmint acting _as_ a reserve location for WND and assets created under `pallet-assets`. + // Asset Hub Westend does not recognize a reserve location for any asset. This does not prevent + // Asset Hub acting _as_ a reserve location for WND and assets created under `pallet-assets`. // For WND, users must use teleport where allowed (e.g. with the Relay Chain). type IsReserve = (); // We allow: @@ -391,7 +390,7 @@ impl xcm_executor::Config for XcmConfig { type UniversalLocation = UniversalLocation; type Barrier = Barrier; type Weigher = WeightInfoBounds< - crate::weights::xcm::WestmintXcmWeight, + crate::weights::xcm::AssetHubWestendXcmWeight, RuntimeCall, MaxInstructions, >; @@ -429,12 +428,12 @@ pub type LocalOriginToLocation = SignedToAccountId32, // ..and XCMP to communicate with the sibling chains. XcmpQueue, -); +)>; #[cfg(feature = "runtime-benchmarks")] parameter_types! { @@ -451,7 +450,7 @@ impl pallet_xcm::Config for Runtime { type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; type Weigher = WeightInfoBounds< - crate::weights::xcm::WestmintXcmWeight, + crate::weights::xcm::AssetHubWestendXcmWeight, RuntimeCall, MaxInstructions, >; @@ -469,6 +468,8 @@ impl pallet_xcm::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { @@ -485,9 +486,7 @@ pub type ForeignCreatorsSovereignAccountOf = ( /// Simple conversion of `u32` into an `AssetId` for use in benchmarking. pub struct XcmBenchmarkHelper; #[cfg(feature = "runtime-benchmarks")] -use pallet_assets::BenchmarkHelper; -#[cfg(feature = "runtime-benchmarks")] -impl BenchmarkHelper for XcmBenchmarkHelper { +impl pallet_assets::BenchmarkHelper for XcmBenchmarkHelper { fn create_asset_id_parameter(id: u32) -> MultiLocation { MultiLocation { parents: 1, interior: X1(Parachain(id)) } } diff --git a/parachains/runtimes/assets/westmint/tests/tests.rs b/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs similarity index 90% rename from parachains/runtimes/assets/westmint/tests/tests.rs rename to parachains/runtimes/assets/asset-hub-westend/tests/tests.rs index 3ef09d14e52..87bfb4b699a 100644 --- a/parachains/runtimes/assets/westmint/tests/tests.rs +++ b/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs @@ -1,26 +1,26 @@ -use asset_test_utils::{ExtBuilder, RuntimeHelper, XcmReceivedFrom}; -use codec::{Decode, DecodeLimit, Encode}; -use cumulus_primitives_utility::ChargeWeightInFungibles; -use frame_support::{ - assert_noop, assert_ok, sp_io, - traits::fungibles::InspectEnumerable, - weights::{Weight, WeightToFee as WeightToFeeT}, -}; -use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance}; -use std::convert::Into; -pub use westmint_runtime::{ +pub use asset_hub_westend_runtime::{ constants::fee::WeightToFee, xcm_config::{CheckingAccount, TrustBackedAssetsPalletLocation, XcmConfig}, AssetDeposit, Assets, Balances, ExistentialDeposit, ForeignAssets, ForeignAssetsInstance, ParachainSystem, Runtime, SessionKeys, System, TrustBackedAssetsInstance, }; -use westmint_runtime::{ +use asset_hub_westend_runtime::{ xcm_config::{ AssetFeeAsExistentialDepositMultiplierFeeCharger, ForeignCreatorsSovereignAccountOf, WestendLocation, }, MetadataDepositBase, MetadataDepositPerByte, RuntimeCall, RuntimeEvent, }; +use asset_test_utils::{CollatorSessionKeys, ExtBuilder, RuntimeHelper, XcmReceivedFrom}; +use codec::{Decode, DecodeLimit, Encode}; +use cumulus_primitives_utility::ChargeWeightInFungibles; +use frame_support::{ + assert_noop, assert_ok, sp_io, + traits::fungibles::InspectEnumerable, + weights::{Weight, WeightToFee as WeightToFeeT}, +}; +use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance}; +use std::convert::Into; use xcm::{latest::prelude::*, VersionedXcm, MAX_XCM_DECODE_DEPTH}; use xcm_executor::{ traits::{Convert, Identity, JustTry, WeightTrader}, @@ -33,6 +33,14 @@ const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32]; type AssetIdForTrustBackedAssetsConvert = assets_common::AssetIdForTrustBackedAssetsConvert; +fn collator_session_keys() -> CollatorSessionKeys { + CollatorSessionKeys::new( + AccountId::from(ALICE), + AccountId::from(ALICE), + SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) }, + ) +} + #[test] fn test_asset_xcm_trader() { ExtBuilder::::default() @@ -84,19 +92,16 @@ fn test_asset_xcm_trader() { // Lets pay with: asset_amount_needed + asset_amount_extra let asset_amount_extra = 100_u128; let asset: MultiAsset = - (asset_multilocation.clone(), asset_amount_needed + asset_amount_extra).into(); + (asset_multilocation, asset_amount_needed + asset_amount_extra).into(); let mut trader = ::Trader::new(); // Lets buy_weight and make sure buy_weight does not return an error - match trader.buy_weight(bought, asset.into()) { - Ok(unused_assets) => { - // Check whether a correct amount of unused assets is returned - assert_ok!(unused_assets - .ensure_contains(&(asset_multilocation, asset_amount_extra).into())); - }, - Err(e) => assert!(false, "Expected Ok(_). Got {:#?}", e), - } + let unused_assets = trader.buy_weight(bought, asset.into()).expect("Expected Ok"); + // Check whether a correct amount of unused assets is returned + assert_ok!( + unused_assets.ensure_contains(&(asset_multilocation, asset_amount_extra).into()) + ); // Drop trader drop(trader); @@ -156,7 +161,7 @@ fn test_asset_xcm_trader_with_refund() { // lets calculate amount needed let amount_bought = WeightToFee::weight_to_fee(&bought); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Make sure buy_weight does not return an error assert_ok!(trader.buy_weight(bought, asset.clone().into())); @@ -230,7 +235,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() { "we are testing what happens when the amount does not exceed ED" ); - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); // Buy weight should return an error assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); @@ -282,11 +287,11 @@ fn test_that_buying_ed_refund_does_not_refund() { // We know we will have to buy at least ED, so lets make sure first it will // fail with a payment of less than ED - let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into(); + let asset: MultiAsset = (asset_multilocation, amount_bought).into(); assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive); // Now lets buy ED at least - let asset: MultiAsset = (asset_multilocation.clone(), ExistentialDeposit::get()).into(); + let asset: MultiAsset = (asset_multilocation, ExistentialDeposit::get()).into(); // Buy weight should work assert_ok!(trader.buy_weight(bought, asset.into())); @@ -421,7 +426,7 @@ fn test_assets_balances_api_works() { let foreign_asset_minimum_asset_balance = 3333333_u128; assert_ok!(ForeignAssets::force_create( RuntimeHelper::::root_origin(), - foreign_asset_id_multilocation.clone().into(), + foreign_asset_id_multilocation, AccountId::from(SOME_ASSET_ADMIN).into(), false, foreign_asset_minimum_asset_balance @@ -430,7 +435,7 @@ fn test_assets_balances_api_works() { // We first mint enough asset for the account to exist for assets assert_ok!(ForeignAssets::mint( RuntimeHelper::::origin_of(AccountId::from(SOME_ASSET_ADMIN)), - foreign_asset_id_multilocation.clone().into(), + foreign_asset_id_multilocation, AccountId::from(ALICE).into(), 6 * foreign_asset_minimum_asset_balance )); @@ -480,11 +485,7 @@ asset_test_utils::include_teleports_for_native_asset_works!( CheckingAccount, WeightToFee, ParachainSystem, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), Box::new(|runtime_event_encoded: Vec| { match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { @@ -509,11 +510,7 @@ asset_test_utils::include_teleports_for_foreign_assets_works!( ParachainSystem, ForeignCreatorsSovereignAccountOf, ForeignAssetsInstance, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), Box::new(|runtime_event_encoded: Vec| { match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { @@ -532,11 +529,7 @@ asset_test_utils::include_teleports_for_foreign_assets_works!( asset_test_utils::include_asset_transactor_transfer_with_local_consensus_currency_works!( Runtime, XcmConfig, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), Box::new(|| { assert!(Assets::asset_ids().collect::>().is_empty()); @@ -555,11 +548,7 @@ asset_test_utils::include_asset_transactor_transfer_with_pallet_assets_instance_ TrustBackedAssetsInstance, AssetIdForTrustBackedAssets, AssetIdForTrustBackedAssetsConvert, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), 12345, Box::new(|| { @@ -577,11 +566,7 @@ asset_test_utils::include_asset_transactor_transfer_with_pallet_assets_instance_ ForeignAssetsInstance, MultiLocation, JustTry, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), MultiLocation { parents: 1, interior: X2(Parachain(1313), GeneralIndex(12345)) }, Box::new(|| { @@ -600,11 +585,7 @@ asset_test_utils::include_create_and_manage_foreign_assets_for_local_consensus_p ForeignAssetsInstance, MultiLocation, JustTry, - asset_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), + collator_session_keys(), ExistentialDeposit::get(), AssetDeposit::get(), MetadataDepositBase::get(), diff --git a/parachains/runtimes/assets/common/Cargo.toml b/parachains/runtimes/assets/common/Cargo.toml index 69f56a2405e..f8c459a922d 100644 --- a/parachains/runtimes/assets/common/Cargo.toml +++ b/parachains/runtimes/assets/common/Cargo.toml @@ -7,8 +7,8 @@ description = "Assets common utilities" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } -log = { version = "0.4.17", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } +log = { version = "0.4.18", default-features = false } # Substrate frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/parachains/runtimes/assets/common/src/foreign_creators.rs b/parachains/runtimes/assets/common/src/foreign_creators.rs index 3d7567409f6..dbdf4301d66 100644 --- a/parachains/runtimes/assets/common/src/foreign_creators.rs +++ b/parachains/runtimes/assets/common/src/foreign_creators.rs @@ -43,7 +43,7 @@ where asset_location: &MultiLocation, ) -> sp_std::result::Result { let origin_location = EnsureXcm::::try_origin(origin.clone())?; - if !IsForeign::contains(&asset_location, &origin_location) { + if !IsForeign::contains(asset_location, &origin_location) { return Err(origin) } AccountOf::convert(origin_location).map_err(|_| origin) @@ -51,6 +51,6 @@ where #[cfg(feature = "runtime-benchmarks")] fn try_successful_origin(a: &MultiLocation) -> Result { - Ok(pallet_xcm::Origin::Xcm(a.clone()).into()) + Ok(pallet_xcm::Origin::Xcm(*a).into()) } } diff --git a/parachains/runtimes/assets/common/src/matching.rs b/parachains/runtimes/assets/common/src/matching.rs index a5e030412b9..964f25cda35 100644 --- a/parachains/runtimes/assets/common/src/matching.rs +++ b/parachains/runtimes/assets/common/src/matching.rs @@ -42,10 +42,7 @@ impl> Contains for StartsWithExplicitGlobalConsensus { fn contains(t: &MultiLocation) -> bool { - match t.interior.global_consensus() { - Ok(requested_network) if requested_network.eq(&Network::get()) => true, - _ => false, - } + matches!(t.interior.global_consensus(), Ok(requested_network) if requested_network.eq(&Network::get())) } } @@ -61,7 +58,7 @@ impl> ContainsPair bool { log::trace!(target: "xcm::contains", "IsForeignConcreteAsset asset: {:?}, origin: {:?}", asset, origin); - matches!(asset.id, Concrete(ref id) if IsForeign::contains(id, &origin)) + matches!(asset.id, Concrete(ref id) if IsForeign::contains(id, origin)) } } @@ -73,18 +70,14 @@ impl> ContainsPair { fn contains(&a: &MultiLocation, b: &MultiLocation) -> bool { // `a` needs to be from `b` at least - if !a.starts_with(&b) { + if !a.starts_with(b) { return false } // here we check if sibling match a { - MultiLocation { parents: 1, interior } => match interior.first() { - Some(Parachain(sibling_para_id)) - if sibling_para_id.ne(&u32::from(SelfParaId::get())) => - true, - _ => false, - }, + MultiLocation { parents: 1, interior } => + matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get()))), _ => false, } } diff --git a/parachains/runtimes/assets/statemint/src/xcm_config.rs b/parachains/runtimes/assets/statemint/src/xcm_config.rs deleted file mode 100644 index c0866f1f47a..00000000000 --- a/parachains/runtimes/assets/statemint/src/xcm_config.rs +++ /dev/null @@ -1,380 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use super::{ - AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, ParachainInfo, - ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, - TrustBackedAssetsInstance, WeightToFee, XcmpQueue, -}; -use frame_support::{ - match_types, parameter_types, - traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess}, -}; -use frame_system::EnsureRoot; -use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ - AssetFeeAsExistentialDepositMultiplier, DenyReserveTransferToRelayChain, DenyThenTry, - }, -}; -use polkadot_parachain::primitives::Sibling; -use sp_runtime::traits::ConvertInto; -use xcm::latest::prelude::*; -use xcm_builder::{ - AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, ParentAsSuperuser, ParentIsPreset, - RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, WithComputedOrigin, -}; -use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; - -parameter_types! { - pub const DotLocation: MultiLocation = MultiLocation::parent(); - pub const RelayNetwork: Option = Some(NetworkId::Polkadot); - pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub UniversalLocation: InteriorMultiLocation = - X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); - pub TrustBackedAssetsPalletLocation: MultiLocation = - PalletInstance(::index() as u8).into(); - pub CheckingAccount: AccountId = PolkadotXcm::check_account(); - pub FellowshipLocation: MultiLocation = MultiLocation::new(1, Parachain(1001)); - pub const GovernanceLocation: MultiLocation = MultiLocation::parent(); -} - -/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used -/// when determining ownership of accounts for asset transacting and when attempting to use XCM -/// `Transact` in order to determine the dispatch Origin. -pub type LocationToAccountId = ( - // The parent (Relay-chain) origin converts to the parent `AccountId`. - ParentIsPreset, - // Sibling parachain origins convert to AccountId via the `ParaId::into`. - SiblingParachainConvertsVia, - // Straight up local `AccountId32` origins just alias directly to `AccountId`. - AccountId32Aliases, -); - -/// Means for transacting the native currency on this chain. -pub type CurrencyTransactor = CurrencyAdapter< - // Use this currency: - Balances, - // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, - // Convert an XCM MultiLocation into a local account id: - LocationToAccountId, - // Our chain's account ID type (we can't get away without mentioning it explicitly): - AccountId, - // We don't track any teleports of `Balances`. - (), ->; - -/// `AssetId/Balance` converter for `TrustBackedAssets`` -pub type TrustBackedAssetsConvertedConcreteId = - assets_common::TrustBackedAssetsConvertedConcreteId; - -/// Means for transacting assets besides the native currency on this chain. -pub type FungiblesTransactor = FungiblesAdapter< - // Use this fungibles implementation: - Assets, - // Use this currency when it is a fungible asset matching the given location or name: - TrustBackedAssetsConvertedConcreteId, - // Convert an XCM MultiLocation into a local account id: - LocationToAccountId, - // Our chain's account ID type (we can't get away without mentioning it explicitly): - AccountId, - // We only want to allow teleports of known assets. We use non-zero issuance as an indication - // that this asset is known. - LocalMint>, - // The account to use for tracking teleports. - CheckingAccount, ->; -/// Means for transacting assets on this chain. -pub type AssetTransactors = (CurrencyTransactor, FungiblesTransactor); - -/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, -/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can -/// biases the kind of local `Origin` it will become. -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 - // foreign chains who want to have a local sovereign account on this chain which they control. - SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when - // recognised. - RelayChainAsNative, - // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognised. - SiblingParachainAsNative, - // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a - // transaction from the Root origin. - ParentAsSuperuser, - // Native signed account converter; this just converts an `AccountId32` origin into a normal - // `RuntimeOrigin::Signed` origin of the same 32-byte value. - SignedAccountId32AsNative, - // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. - XcmPassthrough, -); - -parameter_types! { - pub const MaxInstructions: u32 = 100; - pub const MaxAssetsIntoHolding: u32 = 64; - pub XcmAssetFeesReceiver: Option = Authorship::author(); -} - -match_types! { - pub type ParentOrParentsPlurality: impl Contains = { - MultiLocation { parents: 1, interior: Here } | - MultiLocation { parents: 1, interior: X1(Plurality { .. }) } - }; - pub type ParentOrSiblings: impl Contains = { - MultiLocation { parents: 1, interior: Here } | - MultiLocation { parents: 1, interior: X1(_) } - }; - pub type FellowsPlurality: impl Contains = { - MultiLocation { parents: 1, interior: X2(Parachain(1001), Plurality { id: BodyId::Technical, ..}) } - }; -} - -/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly -/// account for proof size weights. -/// -/// Calls that are allowed through this filter must: -/// 1. Have a fixed weight; -/// 2. Cannot lead to another call being made; -/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters. -pub struct SafeCallFilter; -impl Contains for SafeCallFilter { - fn contains(call: &RuntimeCall) -> bool { - #[cfg(feature = "runtime-benchmarks")] - { - if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) { - return true - } - } - - match call { - RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. } | - pallet_collator_selection::Call::set_invulnerables { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Assets( - pallet_assets::Call::create { .. } | - pallet_assets::Call::force_create { .. } | - pallet_assets::Call::start_destroy { .. } | - pallet_assets::Call::destroy_accounts { .. } | - pallet_assets::Call::destroy_approvals { .. } | - pallet_assets::Call::finish_destroy { .. } | - pallet_assets::Call::mint { .. } | - pallet_assets::Call::burn { .. } | - pallet_assets::Call::transfer { .. } | - pallet_assets::Call::transfer_keep_alive { .. } | - pallet_assets::Call::force_transfer { .. } | - pallet_assets::Call::freeze { .. } | - pallet_assets::Call::thaw { .. } | - pallet_assets::Call::freeze_asset { .. } | - pallet_assets::Call::thaw_asset { .. } | - pallet_assets::Call::transfer_ownership { .. } | - pallet_assets::Call::set_team { .. } | - pallet_assets::Call::clear_metadata { .. } | - pallet_assets::Call::force_clear_metadata { .. } | - pallet_assets::Call::force_asset_status { .. } | - pallet_assets::Call::approve_transfer { .. } | - pallet_assets::Call::cancel_approval { .. } | - pallet_assets::Call::force_cancel_approval { .. } | - pallet_assets::Call::transfer_approved { .. } | - pallet_assets::Call::touch { .. } | - pallet_assets::Call::refund { .. }, - ) | - RuntimeCall::Uniques( - pallet_uniques::Call::create { .. } | - pallet_uniques::Call::force_create { .. } | - pallet_uniques::Call::destroy { .. } | - pallet_uniques::Call::mint { .. } | - pallet_uniques::Call::burn { .. } | - pallet_uniques::Call::transfer { .. } | - pallet_uniques::Call::freeze { .. } | - pallet_uniques::Call::thaw { .. } | - pallet_uniques::Call::freeze_collection { .. } | - pallet_uniques::Call::thaw_collection { .. } | - pallet_uniques::Call::transfer_ownership { .. } | - pallet_uniques::Call::set_team { .. } | - pallet_uniques::Call::approve_transfer { .. } | - pallet_uniques::Call::cancel_approval { .. } | - pallet_uniques::Call::force_item_status { .. } | - pallet_uniques::Call::set_attribute { .. } | - pallet_uniques::Call::clear_attribute { .. } | - pallet_uniques::Call::set_metadata { .. } | - pallet_uniques::Call::clear_metadata { .. } | - pallet_uniques::Call::set_collection_metadata { .. } | - pallet_uniques::Call::clear_collection_metadata { .. } | - pallet_uniques::Call::set_accept_ownership { .. } | - pallet_uniques::Call::set_collection_max_supply { .. } | - pallet_uniques::Call::set_price { .. } | - pallet_uniques::Call::buy_item { .. }, - ) => true, - _ => false, - } - } -} - -pub type Barrier = DenyThenTry< - DenyReserveTransferToRelayChain, - ( - TakeWeightCredit, - // Expected responses are OK. - AllowKnownQueryResponses, - // Allow XCMs with some computed origins to pass through. - WithComputedOrigin< - ( - // If the message is one that immediately attemps to pay for execution, then allow it. - AllowTopLevelPaidExecutionFrom, - // Parent, its pluralities (i.e. governance bodies), and the Fellows plurality get free execution. - AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, FellowsPlurality)>, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, - ), - UniversalLocation, - ConstU32<8>, - >, - ), ->; - -pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentialDepositMultiplier< - Runtime, - WeightToFee, - pallet_assets::BalanceToAssetBalance, - TrustBackedAssetsInstance, ->; - -pub struct XcmConfig; -impl xcm_executor::Config for XcmConfig { - type RuntimeCall = RuntimeCall; - type XcmSender = XcmRouter; - type AssetTransactor = AssetTransactors; - type OriginConverter = XcmOriginToTransactDispatchOrigin; - // Statemint does not recognize a reserve location for any asset. This does not prevent - // Statemint acting _as_ a reserve location for DOT and assets created under `pallet-assets`. - // For DOT, users must use teleport where allowed (e.g. with the Relay Chain). - type IsReserve = (); - type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of DOT - type UniversalLocation = UniversalLocation; - type Barrier = Barrier; - type Weigher = WeightInfoBounds< - crate::weights::xcm::StatemintXcmWeight, - RuntimeCall, - MaxInstructions, - >; - type Trader = ( - UsingComponents>, - cumulus_primitives_utility::TakeFirstAssetTrader< - AccountId, - AssetFeeAsExistentialDepositMultiplierFeeCharger, - TrustBackedAssetsConvertedConcreteId, - Assets, - cumulus_primitives_utility::XcmFeesTo32ByteAccount< - FungiblesTransactor, - AccountId, - XcmAssetFeesReceiver, - >, - >, - ); - type ResponseHandler = PolkadotXcm; - type AssetTrap = PolkadotXcm; - type AssetClaims = PolkadotXcm; - type SubscriptionService = PolkadotXcm; - type PalletInstancesInfo = AllPalletsWithSystem; - type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type AssetLocker = (); - type AssetExchanger = (); - type FeeManager = (); - type MessageExporter = (); - type UniversalAliases = Nothing; - type CallDispatcher = WithOriginFilter; - type SafeCallFilter = SafeCallFilter; -} - -/// Converts a local signed origin into an XCM multilocation. -/// Forms the basis for local origins sending/executing XCMs. -pub type LocalOriginToLocation = SignedToAccountId32; - -/// The means for routing XCM messages which are not for local execution into the right message -/// queues. -pub type XcmRouter = ( - // Two routers - use UMP to communicate with the relay chain: - cumulus_primitives_utility::ParentAsUmp, - // ..and XCMP to communicate with the sibling chains. - XcmpQueue, -); - -#[cfg(feature = "runtime-benchmarks")] -parameter_types! { - pub ReachableDest: Option = Some(Parent.into()); -} - -impl pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - // We want to disallow users sending (arbitrary) XCMs from this chain. - type SendXcmOrigin = EnsureXcmOrigin; - type XcmRouter = XcmRouter; - // We support local origins dispatching XCM executions in principle... - type ExecuteXcmOrigin = EnsureXcmOrigin; - // ... but disallow generic XCM execution. As a result only teleports and reserve transfers are allowed. - type XcmExecuteFilter = Nothing; - type XcmExecutor = XcmExecutor; - type XcmTeleportFilter = Everything; - type XcmReserveTransferFilter = Everything; - type Weigher = WeightInfoBounds< - crate::weights::xcm::StatemintXcmWeight, - RuntimeCall, - MaxInstructions, - >; - type UniversalLocation = UniversalLocation; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; - type Currency = Balances; - type CurrencyMatcher = (); - type TrustedLockers = (); - type SovereignAccountOf = LocationToAccountId; - type MaxLockers = ConstU32<8>; - type WeightInfo = crate::weights::pallet_xcm::WeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = ReachableDest; - type AdminOrigin = EnsureRoot; -} - -impl cumulus_pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; -} diff --git a/parachains/runtimes/assets/test-utils/Cargo.toml b/parachains/runtimes/assets/test-utils/Cargo.toml index 2a9e70ce2dd..feeee7b23e0 100644 --- a/parachains/runtimes/assets/test-utils/Cargo.toml +++ b/parachains/runtimes/assets/test-utils/Cargo.toml @@ -3,7 +3,7 @@ name = "asset-test-utils" version = "1.0.0" authors = ["Parity Technologies "] edition = "2021" -description = "Statemint parachain runtime" +description = "Test utils for Asset Hub runtimes." [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } @@ -30,6 +30,7 @@ cumulus-primitives-core = { path = "../../../../primitives/core", default-featur cumulus-primitives-parachain-inherent = { path = "../../../../primitives/parachain-inherent", default-features = false } cumulus-test-relay-sproof-builder = { path = "../../../../test/relay-sproof-builder", default-features = false } parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } +parachains-runtimes-test-utils = { path = "../../test-utils", default-features = false } # Polkadot xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } @@ -60,6 +61,7 @@ std = [ "assets-common/std", "parachains-common/std", "parachain-info/std", + "parachains-runtimes-test-utils/std", "polkadot-parachain/std", "sp-consensus-aura/std", "sp-io/std", diff --git a/parachains/runtimes/assets/test-utils/src/lib.rs b/parachains/runtimes/assets/test-utils/src/lib.rs index 06d6282e008..9a24867592e 100644 --- a/parachains/runtimes/assets/test-utils/src/lib.rs +++ b/parachains/runtimes/assets/test-utils/src/lib.rs @@ -1,385 +1,20 @@ -use sp_std::marker::PhantomData; +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. -use cumulus_primitives_core::{AbridgedHrmpChannel, ParaId, PersistedValidationData}; -use cumulus_primitives_parachain_inherent::ParachainInherentData; -use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; -use frame_support::{ - dispatch::{DispatchResult, RawOrigin, UnfilteredDispatchable}, - inherent::{InherentData, ProvideInherent}, - traits::{GenesisBuild, OriginTrait}, - weights::Weight, -}; -use parachains_common::AccountId; -use polkadot_parachain::primitives::{HrmpChannelId, RelayChainBlockNumber}; -use sp_consensus_aura::AURA_ENGINE_ID; -use sp_core::Encode; -use sp_runtime::{Digest, DigestItem}; -use xcm::{ - latest::{MultiAsset, MultiLocation, XcmContext, XcmHash}, - prelude::{Concrete, Fungible, Outcome, XcmError, XcmVersion}, -}; -use xcm_executor::{traits::TransactAsset, Assets}; +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. -pub mod test_cases; -pub use test_cases::CollatorSessionKeys; - -pub type BalanceOf = ::Balance; -pub type AccountIdOf = ::AccountId; -pub type ValidatorIdOf = ::ValidatorId; -pub type SessionKeysOf = ::Keys; - -// Basic builder based on balances, collators and pallet_sessopm -pub struct ExtBuilder< - Runtime: frame_system::Config - + pallet_balances::Config - + pallet_session::Config - + pallet_xcm::Config - + parachain_info::Config, -> { - // endowed accounts with balances - balances: Vec<(AccountIdOf, BalanceOf)>, - // collators to test block prod - collators: Vec>, - // keys added to pallet session - keys: Vec<(AccountIdOf, ValidatorIdOf, SessionKeysOf)>, - // safe xcm version for pallet_xcm - safe_xcm_version: Option, - // para id - para_id: Option, - _runtime: PhantomData, -} - -impl< - Runtime: frame_system::Config - + pallet_balances::Config - + pallet_session::Config - + pallet_xcm::Config - + parachain_info::Config, - > Default for ExtBuilder -{ - fn default() -> ExtBuilder { - ExtBuilder { - balances: vec![], - collators: vec![], - keys: vec![], - safe_xcm_version: None, - para_id: None, - _runtime: PhantomData, - } - } -} - -impl< - Runtime: frame_system::Config - + pallet_balances::Config - + pallet_session::Config - + pallet_xcm::Config - + parachain_info::Config, - > ExtBuilder -{ - pub fn with_balances( - mut self, - balances: Vec<(AccountIdOf, BalanceOf)>, - ) -> Self { - self.balances = balances; - self - } - pub fn with_collators(mut self, collators: Vec>) -> Self { - self.collators = collators; - self - } - - pub fn with_session_keys( - mut self, - keys: Vec<(AccountIdOf, ValidatorIdOf, SessionKeysOf)>, - ) -> Self { - self.keys = keys; - self - } - - pub fn with_tracing(self) -> Self { - frame_support::sp_tracing::try_init_simple(); - self - } - - pub fn with_safe_xcm_version(mut self, safe_xcm_version: XcmVersion) -> Self { - self.safe_xcm_version = Some(safe_xcm_version); - self - } - - pub fn with_para_id(mut self, para_id: ParaId) -> Self { - self.para_id = Some(para_id); - self - } - - pub fn build(self) -> sp_io::TestExternalities - where - Runtime: - pallet_collator_selection::Config + pallet_balances::Config + pallet_session::Config, - ValidatorIdOf: From>, - { - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - - >::assimilate_storage( - &pallet_xcm::GenesisConfig { safe_xcm_version: self.safe_xcm_version }, - &mut t, - ) - .unwrap(); - - if let Some(para_id) = self.para_id { - >::assimilate_storage( - ¶chain_info::GenesisConfig { parachain_id: para_id }, - &mut t, - ) - .unwrap(); - } - - pallet_balances::GenesisConfig:: { balances: self.balances.into() } - .assimilate_storage(&mut t) - .unwrap(); - - pallet_collator_selection::GenesisConfig:: { - invulnerables: self.collators.clone().into(), - candidacy_bond: Default::default(), - desired_candidates: Default::default(), - } - .assimilate_storage(&mut t) - .unwrap(); - - pallet_session::GenesisConfig:: { keys: self.keys } - .assimilate_storage(&mut t) - .unwrap(); - - let mut ext = sp_io::TestExternalities::new(t); +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. - ext.execute_with(|| { - frame_system::Pallet::::set_block_number(1u32.into()); - }); +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . - ext - } -} +//! Module contains predefined test-case scenarios for `Runtime` with various assets. -pub struct RuntimeHelper(PhantomData); -/// Utility function that advances the chain to the desired block number. -/// If an author is provided, that author information is injected to all the blocks in the meantime. -impl RuntimeHelper -where - AccountIdOf: - Into<<::RuntimeOrigin as OriginTrait>::AccountId>, -{ - pub fn run_to_block(n: u32, author: Option) { - while frame_system::Pallet::::block_number() < n.into() { - // Set the new block number and author - match author { - Some(ref author) => { - let pre_digest = Digest { - logs: vec![DigestItem::PreRuntime(AURA_ENGINE_ID, author.encode())], - }; - frame_system::Pallet::::reset_events(); - frame_system::Pallet::::initialize( - &(frame_system::Pallet::::block_number() + 1u32.into()), - &frame_system::Pallet::::parent_hash(), - &pre_digest, - ); - }, - None => { - frame_system::Pallet::::set_block_number( - frame_system::Pallet::::block_number() + 1u32.into(), - ); - }, - } - } - } - - pub fn root_origin() -> ::RuntimeOrigin { - ::RuntimeOrigin::root() - } - - pub fn origin_of( - account_id: AccountIdOf, - ) -> ::RuntimeOrigin { - ::RuntimeOrigin::signed(account_id.into()) - } -} - -impl RuntimeHelper { - pub fn do_transfer( - from: MultiLocation, - to: MultiLocation, - (asset, amount): (MultiLocation, u128), - ) -> Result { - ::transfer_asset( - &MultiAsset { id: Concrete(asset), fun: Fungible(amount) }, - &from, - &to, - // We aren't able to track the XCM that initiated the fee deposit, so we create a - // fake message hash here - &XcmContext::with_message_hash([0; 32]), - ) - } -} - -impl RuntimeHelper { - pub fn do_teleport_assets( - origin: ::RuntimeOrigin, - dest: MultiLocation, - beneficiary: MultiLocation, - (asset, amount): (MultiLocation, u128), - open_hrmp_channel: Option<(u32, u32)>, - ) -> DispatchResult - where - HrmpChannelOpener: frame_support::inherent::ProvideInherent< - Call = cumulus_pallet_parachain_system::Call, - >, - { - // open hrmp (if needed) - if let Some((source_para_id, target_para_id)) = open_hrmp_channel { - mock_open_hrmp_channel::( - source_para_id.into(), - target_para_id.into(), - ); - } - - // do teleport - >::teleport_assets( - origin, - Box::new(dest.into()), - Box::new(beneficiary.into()), - Box::new((Concrete(asset), amount).into()), - 0, - ) - } -} - -pub enum XcmReceivedFrom { - Parent, - Sibling, -} - -impl RuntimeHelper { - pub fn xcm_max_weight(from: XcmReceivedFrom) -> Weight { - use frame_support::traits::Get; - match from { - XcmReceivedFrom::Parent => ParachainSystem::ReservedDmpWeight::get(), - XcmReceivedFrom::Sibling => ParachainSystem::ReservedXcmpWeight::get(), - } - } -} - -impl RuntimeHelper { - pub fn assert_pallet_xcm_event_outcome( - unwrap_pallet_xcm_event: &Box) -> Option>>, - assert_outcome: fn(Outcome), - ) { - let outcome = >::events() - .into_iter() - .filter_map(|e| unwrap_pallet_xcm_event(e.event.encode())) - .find_map(|e| match e { - pallet_xcm::Event::Attempted(outcome) => Some(outcome), - _ => None, - }); - match outcome { - Some(outcome) => assert_outcome(outcome), - None => assert!(false, "No `pallet_xcm::Event::Attempted(outcome)` event found!"), - } - } -} - -impl RuntimeHelper { - pub fn xcmp_queue_message_sent( - unwrap_xcmp_queue_event: Box< - dyn Fn(Vec) -> Option>, - >, - ) -> Option { - >::events() - .into_iter() - .filter_map(|e| unwrap_xcmp_queue_event(e.event.encode())) - .find_map(|e| match e { - cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { message_hash } => message_hash, - _ => None, - }) - } -} - -pub fn assert_metadata( - asset_id: impl Into + Copy, - expected_name: &str, - expected_symbol: &str, - expected_decimals: u8, -) where - Fungibles: frame_support::traits::tokens::fungibles::metadata::Inspect - + frame_support::traits::tokens::fungibles::Inspect, -{ - assert_eq!(Fungibles::name(asset_id.into()), Vec::from(expected_name),); - assert_eq!(Fungibles::symbol(asset_id.into()), Vec::from(expected_symbol),); - assert_eq!(Fungibles::decimals(asset_id.into()), expected_decimals); -} - -pub fn assert_total( - asset_id: impl Into + Copy, - expected_total_issuance: impl Into, - expected_active_issuance: impl Into, -) where - Fungibles: frame_support::traits::tokens::fungibles::metadata::Inspect - + frame_support::traits::tokens::fungibles::Inspect, -{ - assert_eq!(Fungibles::total_issuance(asset_id.into()), expected_total_issuance.into()); - assert_eq!(Fungibles::active_issuance(asset_id.into()), expected_active_issuance.into()); -} - -/// Helper function which emulates opening HRMP channel which is needed for `XcmpQueue` to pass -pub fn mock_open_hrmp_channel< - C: cumulus_pallet_parachain_system::Config, - T: ProvideInherent>, ->( - sender: ParaId, - recipient: ParaId, -) { - let n = 1_u32; - let mut sproof_builder = RelayStateSproofBuilder::default(); - sproof_builder.para_id = sender; - sproof_builder.hrmp_channels.insert( - HrmpChannelId { sender, recipient }, - AbridgedHrmpChannel { - max_capacity: 10, - max_total_size: 10_000_000_u32, - max_message_size: 10_000_000_u32, - msg_count: 0, - total_size: 0_u32, - mqc_head: None, - }, - ); - sproof_builder.hrmp_egress_channel_index = Some(vec![recipient]); - - let (relay_parent_storage_root, relay_chain_state) = sproof_builder.into_state_root_and_proof(); - let vfp = PersistedValidationData { - relay_parent_number: n as RelayChainBlockNumber, - relay_parent_storage_root, - ..Default::default() - }; - // It is insufficient to push the validation function params - // to storage; they must also be included in the inherent data. - let inherent_data = { - let mut inherent_data = InherentData::default(); - let system_inherent_data = ParachainInherentData { - validation_data: vfp.clone(), - relay_chain_state, - downward_messages: Default::default(), - horizontal_messages: Default::default(), - }; - inherent_data - .put_data( - cumulus_primitives_parachain_inherent::INHERENT_IDENTIFIER, - &system_inherent_data, - ) - .expect("failed to put VFP inherent"); - inherent_data - }; - - // execute the block - T::create_inherent(&inherent_data) - .expect("got an inherent") - .dispatch_bypass_filter(RawOrigin::None.into()) - .expect("dispatch succeeded"); -} +pub mod test_cases; +pub use parachains_runtimes_test_utils::*; diff --git a/parachains/runtimes/assets/test-utils/src/test_cases.rs b/parachains/runtimes/assets/test-utils/src/test_cases.rs index 3fd27940aea..366c1922cda 100644 --- a/parachains/runtimes/assets/test-utils/src/test_cases.rs +++ b/parachains/runtimes/assets/test-utils/src/test_cases.rs @@ -15,10 +15,6 @@ //! Module contains predefined test-case scenarios for `Runtime` with various assets. -use crate::{ - assert_metadata, assert_total, AccountIdOf, BalanceOf, ExtBuilder, RuntimeHelper, - SessionKeysOf, ValidatorIdOf, XcmReceivedFrom, -}; use codec::Encode; use frame_support::{ assert_noop, assert_ok, @@ -26,6 +22,10 @@ use frame_support::{ weights::Weight, }; use parachains_common::Balance; +use parachains_runtimes_test_utils::{ + assert_metadata, assert_total, AccountIdOf, BalanceOf, CollatorSessionKeys, ExtBuilder, + RuntimeHelper, ValidatorIdOf, XcmReceivedFrom, +}; use sp_runtime::{ traits::{StaticLookup, Zero}, DispatchError, Saturating, @@ -33,35 +33,6 @@ use sp_runtime::{ use xcm::latest::prelude::*; use xcm_executor::{traits::Convert, XcmExecutor}; -pub struct CollatorSessionKeys< - Runtime: frame_system::Config + pallet_balances::Config + pallet_session::Config, -> { - collator: AccountIdOf, - validator: ValidatorIdOf, - key: SessionKeysOf, -} - -impl - CollatorSessionKeys -{ - pub fn new( - collator: AccountIdOf, - validator: ValidatorIdOf, - key: SessionKeysOf, - ) -> Self { - Self { collator, validator, key } - } - pub fn collators(&self) -> Vec> { - vec![self.collator.clone()] - } - - pub fn session_keys( - &self, - ) -> Vec<(AccountIdOf, ValidatorIdOf, SessionKeysOf)> { - vec![(self.collator.clone(), self.validator.clone(), self.key.clone())] - } -} - /// Test-case makes sure that `Runtime` can receive native asset from relay chain /// and can teleport it back and to the other parachains pub fn teleports_for_native_asset_works< @@ -134,7 +105,7 @@ pub fn teleports_for_native_asset_works< BuyExecution { fees: MultiAsset { id: Concrete(native_asset_id), - fun: Fungible(buy_execution_fee_amount_eta.into()), + fun: Fungible(buy_execution_fee_amount_eta), }, weight_limit: Limited(Weight::from_parts(303531000, 65536)), }, @@ -190,7 +161,7 @@ pub fn teleports_for_native_asset_works< RuntimeHelper::::origin_of(target_account.clone()), dest, dest_beneficiary, - (native_asset_id, native_asset_to_teleport_away.clone().into()), + (native_asset_id, native_asset_to_teleport_away.into()), None, )); // check balances @@ -235,7 +206,7 @@ pub fn teleports_for_native_asset_works< RuntimeHelper::::origin_of(target_account.clone()), dest, dest_beneficiary, - (native_asset_id, native_asset_to_teleport_away.clone().into()), + (native_asset_id, native_asset_to_teleport_away.into()), Some((runtime_para_id, other_para_id)), )); @@ -366,7 +337,7 @@ pub fn teleports_for_foreign_assets_works< WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 0)); let buy_execution_fee = MultiAsset { id: Concrete(MultiLocation::parent()), - fun: Fungible(buy_execution_fee_amount.into()), + fun: Fungible(buy_execution_fee_amount), }; let teleported_foreign_asset_amount = 10000000000000; @@ -376,7 +347,7 @@ pub fn teleports_for_foreign_assets_works< .with_session_keys(collator_session_keys.session_keys()) .with_balances(vec![ ( - foreign_creator_as_account_id.clone(), + foreign_creator_as_account_id, existential_deposit + (buy_execution_fee_amount * 2).into(), ), (target_account.clone(), existential_deposit), @@ -441,7 +412,7 @@ pub fn teleports_for_foreign_assets_works< BuyExecution { fees: MultiAsset { id: Concrete(MultiLocation::parent()), - fun: Fungible(buy_execution_fee_amount.into()), + fun: Fungible(buy_execution_fee_amount), }, weight_limit: Limited(Weight::from_parts(403531000, 65536)), }, @@ -536,7 +507,7 @@ pub fn teleports_for_foreign_assets_works< RuntimeHelper::::origin_of(target_account.clone()), dest, dest_beneficiary, - (foreign_asset_id_multilocation, asset_to_teleport_away.clone().into()), + (foreign_asset_id_multilocation, asset_to_teleport_away), Some((runtime_para_id, foreign_para_id)), )); @@ -788,7 +759,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works< .execute_with(|| { // create some asset class let asset_minimum_asset_balance = 3333333_u128; - let asset_id_as_multilocation = AssetIdConverter::reverse_ref(&asset_id).unwrap(); + let asset_id_as_multilocation = AssetIdConverter::reverse_ref(asset_id).unwrap(); assert_ok!(>::force_create( RuntimeHelper::::root_origin(), asset_id.into(), @@ -869,7 +840,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works< id: charlie_account.clone().into() }), }, - (asset_id_as_multilocation, 1 * asset_minimum_asset_balance), + (asset_id_as_multilocation, asset_minimum_asset_balance), ), XcmError::FailedToTransactAsset(Into::<&str>::into( sp_runtime::TokenError::CannotCreate @@ -890,7 +861,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works< parents: 0, interior: X1(AccountId32 { network: None, id: bob_account.clone().into() }), }, - (asset_id_as_multilocation, 1 * asset_minimum_asset_balance), + (asset_id_as_multilocation, asset_minimum_asset_balance), ), Ok(_) )); @@ -908,7 +879,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works< asset_id.into(), &bob_account ), - (1 * asset_minimum_asset_balance).into() + asset_minimum_asset_balance.into() ); assert_eq!( >::balance( @@ -1096,7 +1067,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor additional_checks_before(); // execute XCM with Transacts to create/manage foreign assets by foreign governance - // prepapre data for xcm::Transact(create) + // prepare data for xcm::Transact(create) let foreign_asset_create = runtime_call_encode(pallet_assets::Call::< Runtime, ForeignAssetsPalletInstance, @@ -1106,7 +1077,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor admin: foreign_creator_as_account_id.clone().into(), min_balance: 1.into(), }); - // prepapre data for xcm::Transact(set_metadata) + // prepare data for xcm::Transact(set_metadata) let foreign_asset_set_metadata = runtime_call_encode(pallet_assets::Call::< Runtime, ForeignAssetsPalletInstance, @@ -1116,7 +1087,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor symbol: Vec::from(ASSET_SYMBOL), decimals: 12, }); - // prepapre data for xcm::Transact(set_team - change just freezer to Bob) + // prepare data for xcm::Transact(set_team - change just freezer to Bob) let foreign_asset_set_team = runtime_call_encode(pallet_assets::Call::< Runtime, ForeignAssetsPalletInstance, @@ -1130,7 +1101,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor // lets simulate this was triggered by relay chain from local consensus sibling parachain let xcm = Xcm(vec![ WithdrawAsset(buy_execution_fee.clone().into()), - BuyExecution { fees: buy_execution_fee.clone().into(), weight_limit: Unlimited }, + BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited }, Transact { origin_kind: OriginKind::Xcm, require_weight_at_most: Weight::from_parts(40_000_000_000, 8000), @@ -1247,7 +1218,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor }); let xcm = Xcm(vec![ WithdrawAsset(buy_execution_fee.clone().into()), - BuyExecution { fees: buy_execution_fee.clone().into(), weight_limit: Unlimited }, + BuyExecution { fees: buy_execution_fee.clone(), weight_limit: Unlimited }, Transact { origin_kind: OriginKind::Xcm, require_weight_at_most: Weight::from_parts(20_000_000_000, 8000), diff --git a/parachains/runtimes/bridge-hubs/README.md b/parachains/runtimes/bridge-hubs/README.md index 79e82f3497a..b187f1da2db 100644 --- a/parachains/runtimes/bridge-hubs/README.md +++ b/parachains/runtimes/bridge-hubs/README.md @@ -1,32 +1,247 @@ -# Bridge-hubs Parachain +- [Bridge-hub Parachains](#bridge-hub-parachains) + * [Requirements for local run/testing](#requirements-for-local-run-testing) + * [How to test locally Rococo <-> Wococo bridge](#how-to-test-locally-rococo-----wococo-bridge) + + [Run chains (Rococo + BridgeHub, Wococo + BridgeHub) with zombienet](#run-chains--rococo---bridgehub--wococo---bridgehub--with-zombienet) + + [Run relayer (BridgeHubRococo, BridgeHubWococo)](#run-relayer--bridgehubrococo--bridgehubwococo-) + - [Run with script (alternative 1)](#run-with-script--alternative-1-) + - [Run with binary (alternative 2)](#run-with-binary--alternative-2-) + + [Send messages](#send-messages) + - [Local zombienet run](#local-zombienet-run) + - [Live Rockmine2 to Wockmint](#live-rockmine2-to-wockmint) + * [How to test local BridgeHubKusama](#how-to-test-local-bridgehubkusama) + * [How to test local BridgeHubPolkadot](#how-to-test-local-bridgehubpolkadot) -Implementation of _BridgeHub_, a blockchain to support message passing between Substrate based chains like Polkadot and Kusama networks. +# Bridge-hub Parachains -_BridgeHub_ allows users to: - -- Passing arbitrary messages between different Substrate chains (Polkadot <-> Kusama). - -- Message passing is - -_BridgeHub_ is meant to be **_system parachain_** with main responsibilities: -- sync finality proofs between relay chains +_BridgeHub(s)_ are **_system parachains_** that will house trustless bridges from the local +ecosystem to others. +The current trustless bridges planned for the BridgeHub(s) are: +- `BridgeHubPolkadot` system parachain: + 1. Polkadot <-> Kusama bridge + 2. Polkadot <-> Ethereum bridge (Snowbridge) +- `BridgeHubKusama` system parachain: + 1. Kusama <-> Polkadot bridge + 2. Kusama <-> Ethereum bridge + The high-level responsibilities of each bridge living on BridgeHub: +- sync finality proofs between relay chains (or equivalent) - sync finality proofs between BridgeHub parachains - pass (XCM) messages between different BridgeHub parachains ![](./docs/bridge-hub-parachain-design.jpg "Basic deployment setup") -## How to try locally +## Requirements for local run/testing + +``` +# Prepare empty directory for testing +mkdir -p ~/local_bridge_testing/bin +mkdir -p ~/local_bridge_testing/logs + +--- +# 1. Install zombienet +Go to: https://github.com/paritytech/zombienet/releases +Copy the apropriate binary (zombienet-linux) from the latest release to ~/local_bridge_testing/bin + +--- +# 2. Build polkadot binary +git clone https://github.com/paritytech/polkadot.git +cd polkadot + +# if you want to test Kusama/Polkadot bridge, we need "sudo pallet + fast-runtime", +# so please, find the latest polkadot's repository branch `it/release-vX.Y.Z-fast-sudo` +# e.g: +# git checkout -b it/release-v0.9.42-fast-sudo --track origin/it/release-v0.9.42-fast-sudo + +cargo build --release --features fast-runtime +cp target/release/polkadot ~/local_bridge_testing/bin/polkadot + +--- +# 3. Build cumulus polkadot-parachain binary +cd + +# checkout desired branch or use master: +# git checkout -b master --track origin/master + +cargo build --release --locked -p polkadot-parachain-bin +cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain +cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain-mint + +--- +# 4. Build substrate-relay binary +git clone https://github.com/paritytech/parity-bridges-common.git +cd parity-bridges-common + +# checkout desired branch or use master: +# git checkout -b master --track origin/master +git checkout -b polkadot-staging --track origin/polkadot-staging + +cargo build --release -p substrate-relay +cp target/release/substrate-relay ~/local_bridge_testing/bin/substrate-relay + +--- +# 5. Build polkadot-parachain-mint binary with `asset-hub-kusama`/`asset-hub-westend` for moving assets +cd +# TODO:check-parameter - change this when merged to master +git checkout -b bko-transfer-asset-via-bridge --track origin/bko-transfer-asset-via-bridge +cargo build --release --locked -p polkadot-parachain-bin +cp target/release/polkadot-parachain ~/local_bridge_testing/bin/polkadot-parachain-mint +``` + +## How to test locally Rococo <-> Wococo bridge + +### Run chains (Rococo + BridgeHub, Wococo + BridgeHub) with zombienet + +``` +# Rococo + BridgeHubRococo + Rockmine (mirroring Kusama) +POLKADOT_BINARY_PATH=~/local_bridge_testing/bin/polkadot \ +POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain \ +POLKADOT_PARACHAIN_BINARY_PATH_FOR_ROCKMINE=~/local_bridge_testing/bin/polkadot-parachain-mint \ + ~/local_bridge_testing/bin/zombienet-linux --provider native spawn ./zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml +``` + +``` +# Wococo + BridgeHubWococo + Wockmint (mirroring Polkadot) +POLKADOT_BINARY_PATH=~/local_bridge_testing/bin/polkadot \ +POLKADOT_PARACHAIN_BINARY_PATH=~/local_bridge_testing/bin/polkadot-parachain \ +POLKADOT_PARACHAIN_BINARY_PATH_FOR_WOCKMINT=~/local_bridge_testing/bin/polkadot-parachain-mint \ + ~/local_bridge_testing/bin/zombienet-linux --provider native spawn ./zombienet/bridge-hubs/bridge_hub_wococo_local_network.toml +``` + +### Run relayer (BridgeHubRococo, BridgeHubWococo) + +**Accounts of BridgeHub parachains:** +- `Bob` is pallet owner of all bridge pallets + +#### Run with script (alternative 1) +``` +cd +./scripts/bridges_rococo_wococo.sh run-relay +``` + +#### Run with binary (alternative 2) +Need to wait for parachain activation (start producing blocks), then run: + +``` +# 1. Init bridges: + +# Rococo -> Wococo +RUST_LOG=runtime=trace,rpc=trace,bridge=trace \ + ~/local_bridge_testing/bin/substrate-relay init-bridge rococo-to-bridge-hub-wococo \ + --source-host localhost \ + --source-port 9942 \ + --source-version-mode Auto \ + --target-host localhost \ + --target-port 8945 \ + --target-version-mode Auto \ + --target-signer //Bob + +# Wococo -> Rococo +RUST_LOG=runtime=trace,rpc=trace,bridge=trace \ + ~/local_bridge_testing/bin/substrate-relay init-bridge wococo-to-bridge-hub-rococo \ + --source-host localhost \ + --source-port 9945 \ + --source-version-mode Auto \ + --target-host localhost \ + --target-port 8943 \ + --target-version-mode Auto \ + --target-signer //Bob + +# 2. Relay relay-chain headers, parachain headers and messages** +RUST_LOG=runtime=trace,rpc=trace,bridge=trace \ + ~/local_bridge_testing/bin/substrate-relay relay-headers-and-messages bridge-hub-rococo-bridge-hub-wococo \ + --rococo-host localhost \ + --rococo-port 9942 \ + --rococo-version-mode Auto \ + --bridge-hub-rococo-host localhost \ + --bridge-hub-rococo-port 8943 \ + --bridge-hub-rococo-version-mode Auto \ + --bridge-hub-rococo-signer //Charlie \ + --wococo-headers-to-bridge-hub-rococo-signer //Bob \ + --wococo-parachains-to-bridge-hub-rococo-signer //Bob \ + --bridge-hub-rococo-transactions-mortality 4 \ + --wococo-host localhost \ + --wococo-port 9945 \ + --wococo-version-mode Auto \ + --bridge-hub-wococo-host localhost \ + --bridge-hub-wococo-port 8945 \ + --bridge-hub-wococo-version-mode Auto \ + --bridge-hub-wococo-signer //Charlie \ + --rococo-headers-to-bridge-hub-wococo-signer //Bob \ + --rococo-parachains-to-bridge-hub-wococo-signer //Bob \ + --bridge-hub-wococo-transactions-mortality 4 \ + --lane 00000001 +``` + +**Check relay-chain headers relaying:** +- Rococo parachain: + - https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A8943#/chainstate + - Pallet: **bridgeWococoGrandpa** + - Keys: **bestFinalized()** +- Wococo parachain: + - https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A8945#/chainstate + - Pallet: **bridgeRococoGrandpa** + - Keys: **bestFinalized()** + +**Check parachain headers relaying:** +- Rococo parachain: + - https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A8943#/chainstate + - Pallet: **bridgeWococoParachain** + - Keys: **bestParaHeads()** +- Wococo parachain: + - https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A8945#/chainstate + - Pallet: **bridgeRococoParachain** + - Keys: **bestParaHeads()** + +### Send messages + +#### Local zombienet run + +1. allow bridge transfer on kusama/westend asset hubs (governance-like): + ``` + ./scripts/bridges_rococo_wococo.sh allow-transfers-local + ``` + +2. do (asset) transfer from kusama's asset hub to westend's asset hub: + ``` + ./scripts/bridges_rococo_wococo.sh transfer-asset-from-asset-hub-kusama-local + ``` + +3. do (ping) transfer from kusama's asset hub to westend's asset hub + ``` + ./scripts/bridges_rococo_wococo.sh ping-via-bridge-from-asset-hub-kusama-local + ``` + +- open explorers: (see zombienets) + - Kusama Asset Hub (see events `xcmpQueue.XcmpMessageSent`, `bridgeTransfer.ReserveAssetsDeposited`, `bridgeTransfer.TransferInitiated`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9910#/explorer + - BridgeHubRococo (see `bridgeWococoMessages.MessageAccepted`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8943#/explorer + - BridgeHubWococo (see `bridgeRococoMessages.MessagesReceived`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8945#/explorer + - Westend Asset Hub (see `xcmpQueue.Success` for `transfer-asset` and `xcmpQueue.Fail` for `ping-via-bridge`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9010#/explorer + - BridgeHubRococo (see `bridgeWococoMessages.MessagesDelivered`) https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:8943#/explorer + +#### Live Rockmine2 to Wockmint +- uses account seed on Live Rococo:Rockmine2 + ``` + cd + + ./scripts/bridges_rococo_wococo.sh transfer-asset-from-asset-hub-rococo + or + ./scripts/bridges_rococo_wococo.sh ping-via-bridge-from-asset-hub-rococo + ``` + +- open explorers: + - Rockmine2 (see events `xcmpQueue.XcmpMessageSent`, `bridgeTransfer.ReserveAssetsDeposited`, `bridgeTransfer.TransferInitiated`) https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fws-rococo-rockmine2-collator-node-0.parity-testnet.parity.io#/explorer + - BridgeHubRococo (see `bridgeWococoMessages.MessageAccepted`) https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-bridge-hub-rpc.polkadot.io#/explorer + - BridgeHubWococo (see `bridgeRococoMessages.MessagesReceived`) https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fwococo-bridge-hub-rpc.polkadot.io#/explorer + - Wockmint (see `xcmpQueue.Success` for `transfer-asset` and `xcmpQueue.Fail` for `ping-via-bridge`) https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fws-wococo-wockmint-collator-node-0.parity-testnet.parity.io#/explorer + - BridgeHubRococo (see `bridgeWococoMessages.MessagesDelivered`) + +## How to test local BridgeHubKusama ``` cd -cargo build --release -p polkadot-parachain@0.9.320 +cargo build --release -p polkadot-parachain-bin # script expect to have pre-built polkadot binary on the path: ../polkadot/target/release/polkadot # if using `kusama-local` / `polkadot-local`, build polkadot with `--features fast-runtime` -# BridgeHubRococo -zombienet-linux --provider native spawn ./zombienet/examples/bridge_hub_rococo_local_network.toml - -# or - # BridgeHubKusama zombienet-linux --provider native spawn ./zombienet/examples/bridge_hub_kusama_local_network.toml @@ -35,3 +250,6 @@ or # BridgeHubPolkadot zombienet-linux --provider native spawn ./zombienet/examples/bridge_hub_polkadot_local_network.toml ``` + +## How to test local BridgeHubPolkadot +TODO: from master diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml index 5eebeb0e523..9019f869324 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/Cargo.toml @@ -11,9 +11,9 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } hex-literal = { version = "0.4.1" } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } -serde = { version = "1.0.160", optional = true, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } +serde = { version = "1.0.163", optional = true, features = ["derive"] } smallvec = "1.8.1" # Substrate diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index 36bdfb22bd3..af00f3272e0 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -58,6 +58,7 @@ use frame_system::{ use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; +use xcm_builder::ProcessXcmMessage; use xcm_config::{FellowshipLocation, GovernanceLocation, XcmOriginToTransactDispatchOrigin}; #[cfg(any(feature = "std", test))] @@ -70,7 +71,7 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use parachains_common::{ impls::DealWithFees, opaque, - process_xcm_message::{ParaIdToSibling, ProcessFromSibling, ProcessXcmMessage}, + process_xcm_message::{ParaIdToSibling, ProcessFromSibling}, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; @@ -109,6 +110,9 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; +/// Migrations to apply on runtime upgrade. +pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1,); + /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -116,6 +120,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, + Migrations, >; impl_opaque_keys! { @@ -129,7 +134,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("bridge-hub-kusama"), impl_name: create_runtime_str!("bridge-hub-kusama"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 3, @@ -247,7 +252,7 @@ impl pallet_balances::Config for Runtime { type MaxLocks = ConstU32<50>; type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -255,7 +260,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -648,7 +653,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -686,7 +691,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( KsmRelayLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmRelayLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(KsmRelayLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; } @@ -700,7 +705,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(KsmRelayLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/cumulus_pallet_xcmp_queue.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/cumulus_pallet_xcmp_queue.rs index 05c98ddb5bd..7be09510301 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/cumulus_pallet_xcmp_queue.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/cumulus_pallet_xcmp_queue.rs @@ -31,7 +31,7 @@ // --pallet // cumulus_pallet_xcmp_queue // --extrinsic -// +// // --execution // native // --output @@ -44,9 +44,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_xcmp_queue`. pub struct WeightInfo(PhantomData); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/frame_system.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/frame_system.rs index 65925307177..854a7b9ba5f 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/frame_system.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/frame_system.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `frame_system` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `frame_system`. pub struct WeightInfo(PhantomData); @@ -52,22 +53,25 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_314_000 picoseconds. - Weight::from_parts(2_371_000, 0) + // Minimum execution time: 2_356_000 picoseconds. + Weight::from_parts(1_100_689, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(369, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(412, 0).saturating_mul(b.into())) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_667_000 picoseconds. - Weight::from_parts(7_755_000, 0) + // Minimum execution time: 7_879_000 picoseconds. + Weight::from_parts(8_041_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_414, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(1_451, 0).saturating_mul(b.into())) + } + fn set_code() -> Weight { + Weight::from_parts(1_000_000, 0) } /// Storage: System Digest (r:1 w:1) /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) @@ -77,8 +81,8 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 4_135_000 picoseconds. - Weight::from_parts(4_368_000, 0) + // Minimum execution time: 4_358_000 picoseconds. + Weight::from_parts(4_537_000, 0) .saturating_add(Weight::from_parts(0, 1485)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -90,11 +94,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_351_000 picoseconds. - Weight::from_parts(2_396_000, 0) + // Minimum execution time: 2_373_000 picoseconds. + Weight::from_parts(2_395_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_912 - .saturating_add(Weight::from_parts(729_478, 0).saturating_mul(i.into())) + // Standard Error: 1_727 + .saturating_add(Weight::from_parts(690_266, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -104,11 +108,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_417_000 picoseconds. - Weight::from_parts(2_546_000, 0) + // Minimum execution time: 2_513_000 picoseconds. + Weight::from_parts(2_540_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 842 - .saturating_add(Weight::from_parts(542_458, 0).saturating_mul(i.into())) + // Standard Error: 815 + .saturating_add(Weight::from_parts(505_090, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -118,11 +122,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `68 + p * (69 ±0)` // Estimated: `66 + p * (70 ±0)` - // Minimum execution time: 4_324_000 picoseconds. - Weight::from_parts(4_432_000, 0) + // Minimum execution time: 4_242_000 picoseconds. + Weight::from_parts(4_308_000, 0) .saturating_add(Weight::from_parts(0, 66)) - // Standard Error: 1_165 - .saturating_add(Weight::from_parts(1_070_662, 0).saturating_mul(p.into())) + // Standard Error: 1_130 + .saturating_add(Weight::from_parts(1_032_054, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_balances.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_balances.rs index 7ea0437075a..94ac23e26eb 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_balances.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_balances.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_balances`. pub struct WeightInfo(PhantomData); @@ -53,8 +54,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 34_147_000 picoseconds. - Weight::from_parts(34_681_000, 0) + // Minimum execution time: 53_880_000 picoseconds. + Weight::from_parts(54_466_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -65,8 +66,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 25_961_000 picoseconds. - Weight::from_parts(26_543_000, 0) + // Minimum execution time: 41_306_000 picoseconds. + Weight::from_parts(41_665_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -77,8 +78,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 15_954_000 picoseconds. - Weight::from_parts(16_276_000, 0) + // Minimum execution time: 16_599_000 picoseconds. + Weight::from_parts(16_864_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -89,8 +90,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 19_074_000 picoseconds. - Weight::from_parts(19_635_000, 0) + // Minimum execution time: 23_502_000 picoseconds. + Weight::from_parts(24_050_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -101,8 +102,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `6196` - // Minimum execution time: 36_772_000 picoseconds. - Weight::from_parts(37_193_000, 0) + // Minimum execution time: 55_856_000 picoseconds. + Weight::from_parts(56_352_000, 0) .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -113,25 +114,38 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 32_430_000 picoseconds. - Weight::from_parts(32_766_000, 0) + // Minimum execution time: 49_975_000 picoseconds. + Weight::from_parts(50_428_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn upgrade_accounts(_: u32) -> Weight { - Weight::from_parts(0, 0) - } fn force_unreserve() -> Weight { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 15_239_000 picoseconds. - Weight::from_parts(15_620_000, 0) + // Minimum execution time: 19_123_000 picoseconds. + Weight::from_parts(19_504_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + u * (136 ±0)` + // Estimated: `990 + u * (2603 ±0)` + // Minimum execution time: 18_190_000 picoseconds. + Weight::from_parts(18_547_000, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 10_152 + .saturating_add(Weight::from_parts(14_418_366, 0).saturating_mul(u.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_collator_selection.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_collator_selection.rs index 37d874e0b75..1d48699a2e8 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_collator_selection.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_collator_selection` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_collator_selection`. pub struct WeightInfo(PhantomData); @@ -56,11 +57,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `214 + b * (78 ±0)` // Estimated: `1203 + b * (2554 ±0)` - // Minimum execution time: 14_680_000 picoseconds. - Weight::from_parts(15_646_800, 0) + // Minimum execution time: 15_037_000 picoseconds. + Weight::from_parts(15_261_610, 0) .saturating_add(Weight::from_parts(0, 1203)) - // Standard Error: 4_021 - .saturating_add(Weight::from_parts(2_556_895, 0).saturating_mul(b.into())) + // Standard Error: 3_033 + .saturating_add(Weight::from_parts(2_590_070, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(Weight::from_parts(0, 2554).saturating_mul(b.into())) @@ -71,8 +72,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_979_000 picoseconds. - Weight::from_parts(7_322_000, 0) + // Minimum execution time: 7_317_000 picoseconds. + Weight::from_parts(7_493_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -82,8 +83,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_328_000 picoseconds. - Weight::from_parts(7_524_000, 0) + // Minimum execution time: 7_580_000 picoseconds. + Weight::from_parts(7_821_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,12 +104,12 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn register_as_candidate(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1104 + c * (48 ±0)` - // Estimated: `61672 + c * (49 ±0)` - // Minimum execution time: 37_388_000 picoseconds. - Weight::from_parts(30_491_072, 0) - .saturating_add(Weight::from_parts(0, 61672)) - // Standard Error: 1_155 - .saturating_add(Weight::from_parts(100_794, 0).saturating_mul(c.into())) + // Estimated: `49487 + c * (49 ±0)` + // Minimum execution time: 42_783_000 picoseconds. + Weight::from_parts(35_128_208, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 1_291 + .saturating_add(Weight::from_parts(109_890, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 49).saturating_mul(c.into())) @@ -122,11 +123,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `428 + c * (48 ±0)` // Estimated: `49487` - // Minimum execution time: 29_110_000 picoseconds. - Weight::from_parts(19_158_409, 0) + // Minimum execution time: 34_135_000 picoseconds. + Weight::from_parts(23_714_718, 0) .saturating_add(Weight::from_parts(0, 49487)) - // Standard Error: 1_269 - .saturating_add(Weight::from_parts(104_083, 0).saturating_mul(c.into())) + // Standard Error: 1_293 + .saturating_add(Weight::from_parts(108_542, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -139,13 +140,46 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn note_author() -> Weight { // Proof Size summary in bytes: // Measured: `155` - // Estimated: `7729` - // Minimum execution time: 29_086_000 picoseconds. - Weight::from_parts(29_931_000, 0) - .saturating_add(Weight::from_parts(0, 7729)) + // Estimated: `6196` + // Minimum execution time: 44_345_000 picoseconds. + Weight::from_parts(44_853_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) @@ -160,18 +194,18 @@ impl pallet_collator_selection::WeightInfo for WeightIn /// The range of component `c` is `[1, 1000]`. fn new_session(r: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `22815 + r * (116 ±0) + c * (97 ±0)` - // Estimated: `56697 + r * (2602 ±0) + c * (2520 ±0)` - // Minimum execution time: 16_710_000 picoseconds. - Weight::from_parts(16_907_000, 0) - .saturating_add(Weight::from_parts(0, 56697)) - // Standard Error: 800_677 - .saturating_add(Weight::from_parts(29_001_374, 0).saturating_mul(c.into())) + // Measured: `22815 + c * (97 ±0) + r * (116 ±0)` + // Estimated: `49487 + c * (2519 ±0) + r * (2602 ±0)` + // Minimum execution time: 16_932_000 picoseconds. + Weight::from_parts(17_022_000, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 901_942 + .saturating_add(Weight::from_parts(31_973_621, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2519).saturating_mul(c.into())) .saturating_add(Weight::from_parts(0, 2602).saturating_mul(r.into())) - .saturating_add(Weight::from_parts(0, 2520).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_multisig.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_multisig.rs index 56d954f12a0..f6a3b504a67 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_multisig.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_multisig.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_multisig` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_multisig`. pub struct WeightInfo(PhantomData); @@ -52,11 +53,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_068_000 picoseconds. - Weight::from_parts(12_319_883, 0) + // Minimum execution time: 11_985_000 picoseconds. + Weight::from_parts(12_506_234, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1 - .saturating_add(Weight::from_parts(493, 0).saturating_mul(z.into())) + // Standard Error: 2 + .saturating_add(Weight::from_parts(601, 0).saturating_mul(z.into())) } /// Storage: Multisig Multisigs (r:1 w:1) /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) @@ -66,13 +67,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `263 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 36_523_000 picoseconds. - Weight::from_parts(31_295_135, 0) + // Minimum execution time: 41_586_000 picoseconds. + Weight::from_parts(35_547_263, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 542 - .saturating_add(Weight::from_parts(60_423, 0).saturating_mul(s.into())) - // Standard Error: 5 - .saturating_add(Weight::from_parts(1_200, 0).saturating_mul(z.into())) + // Standard Error: 376 + .saturating_add(Weight::from_parts(69_533, 0).saturating_mul(s.into())) + // Standard Error: 3 + .saturating_add(Weight::from_parts(1_289, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -84,13 +85,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 27_342_000 picoseconds. - Weight::from_parts(21_614_247, 0) + // Minimum execution time: 27_819_000 picoseconds. + Weight::from_parts(21_900_751, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 546 - .saturating_add(Weight::from_parts(57_563, 0).saturating_mul(s.into())) - // Standard Error: 5 - .saturating_add(Weight::from_parts(1_202, 0).saturating_mul(z.into())) + // Standard Error: 292 + .saturating_add(Weight::from_parts(65_723, 0).saturating_mul(s.into())) + // Standard Error: 2 + .saturating_add(Weight::from_parts(1_301, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,14 +104,14 @@ impl pallet_multisig::WeightInfo for WeightInfo { fn as_multi_complete(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `388 + s * (33 ±0)` - // Estimated: `10404` - // Minimum execution time: 41_465_000 picoseconds. - Weight::from_parts(34_511_085, 0) - .saturating_add(Weight::from_parts(0, 10404)) - // Standard Error: 467 - .saturating_add(Weight::from_parts(78_918, 0).saturating_mul(s.into())) + // Estimated: `6811` + // Minimum execution time: 46_840_000 picoseconds. + Weight::from_parts(39_004_058, 0) + .saturating_add(Weight::from_parts(0, 6811)) + // Standard Error: 490 + .saturating_add(Weight::from_parts(86_465, 0).saturating_mul(s.into())) // Standard Error: 4 - .saturating_add(Weight::from_parts(1_201, 0).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(1_317, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -121,11 +122,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `263 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 27_868_000 picoseconds. - Weight::from_parts(29_407_652, 0) + // Minimum execution time: 32_549_000 picoseconds. + Weight::from_parts(33_945_862, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 632 - .saturating_add(Weight::from_parts(69_333, 0).saturating_mul(s.into())) + // Standard Error: 599 + .saturating_add(Weight::from_parts(74_298, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -136,11 +137,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 18_599_000 picoseconds. - Weight::from_parts(19_776_275, 0) + // Minimum execution time: 19_264_000 picoseconds. + Weight::from_parts(20_336_652, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 522 - .saturating_add(Weight::from_parts(64_680, 0).saturating_mul(s.into())) + // Standard Error: 420 + .saturating_add(Weight::from_parts(67_305, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -151,11 +152,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `454 + s * (1 ±0)` // Estimated: `6811` - // Minimum execution time: 28_857_000 picoseconds. - Weight::from_parts(30_337_509, 0) + // Minimum execution time: 33_469_000 picoseconds. + Weight::from_parts(35_060_138, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 652 - .saturating_add(Weight::from_parts(67_443, 0).saturating_mul(s.into())) + // Standard Error: 575 + .saturating_add(Weight::from_parts(72_357, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_session.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_session.rs index bef2a83bc7c..653161034d9 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_session.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_session.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_session` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_session`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn set_keys() -> Weight { // Proof Size summary in bytes: // Measured: `297` - // Estimated: `7524` - // Minimum execution time: 17_925_000 picoseconds. - Weight::from_parts(18_292_000, 0) - .saturating_add(Weight::from_parts(0, 7524)) + // Estimated: `3762` + // Minimum execution time: 17_971_000 picoseconds. + Weight::from_parts(18_440_000, 0) + .saturating_add(Weight::from_parts(0, 3762)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -68,10 +69,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn purge_keys() -> Weight { // Proof Size summary in bytes: // Measured: `279` - // Estimated: `4023` - // Minimum execution time: 13_384_000 picoseconds. - Weight::from_parts(13_788_000, 0) - .saturating_add(Weight::from_parts(0, 4023)) + // Estimated: `3744` + // Minimum execution time: 13_516_000 picoseconds. + Weight::from_parts(13_855_000, 0) + .saturating_add(Weight::from_parts(0, 3744)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_timestamp.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_timestamp.rs index c6b5b01504f..a7e0a69ca71 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_timestamp.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_timestamp.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_timestamp`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_timestamp::WeightInfo for WeightInfo { fn set() -> Weight { // Proof Size summary in bytes: // Measured: `49` - // Estimated: `2986` - // Minimum execution time: 7_946_000 picoseconds. - Weight::from_parts(8_181_000, 0) - .saturating_add(Weight::from_parts(0, 2986)) + // Estimated: `1493` + // Minimum execution time: 7_754_000 picoseconds. + Weight::from_parts(7_961_000, 0) + .saturating_add(Weight::from_parts(0, 1493)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +66,8 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `57` // Estimated: `0` - // Minimum execution time: 3_219_000 picoseconds. - Weight::from_parts(3_298_000, 0) + // Minimum execution time: 3_099_000 picoseconds. + Weight::from_parts(3_194_000, 0) .saturating_add(Weight::from_parts(0, 0)) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_utility.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_utility.rs index 93eaff447ae..b9ab2ec61e5 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_utility.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_utility.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_utility`. pub struct WeightInfo(PhantomData); @@ -52,18 +53,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_837_000 picoseconds. - Weight::from_parts(16_686_299, 0) + // Minimum execution time: 7_486_000 picoseconds. + Weight::from_parts(4_952_171, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_233 - .saturating_add(Weight::from_parts(4_587_331, 0).saturating_mul(c.into())) + // Standard Error: 2_744 + .saturating_add(Weight::from_parts(4_878_827, 0).saturating_mul(c.into())) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_582_000 picoseconds. - Weight::from_parts(5_700_000, 0) + // Minimum execution time: 5_441_000 picoseconds. + Weight::from_parts(5_550_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -71,18 +72,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_907_000 picoseconds. - Weight::from_parts(4_826_975, 0) + // Minimum execution time: 7_417_000 picoseconds. + Weight::from_parts(3_647_457, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_801 - .saturating_add(Weight::from_parts(4_836_457, 0).saturating_mul(c.into())) + // Standard Error: 3_303 + .saturating_add(Weight::from_parts(5_198_660, 0).saturating_mul(c.into())) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_998_000 picoseconds. - Weight::from_parts(9_220_000, 0) + // Minimum execution time: 9_828_000 picoseconds. + Weight::from_parts(10_044_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -90,10 +91,10 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_961_000 picoseconds. - Weight::from_parts(7_518_503, 0) + // Minimum execution time: 7_599_000 picoseconds. + Weight::from_parts(7_657_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_307 - .saturating_add(Weight::from_parts(4_649_665, 0).saturating_mul(c.into())) + // Standard Error: 1_773 + .saturating_add(Weight::from_parts(4_893_962, 0).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_xcm.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_xcm.rs index df103d9266b..ec1fd4a40d3 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_xcm.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/pallet_xcm.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); @@ -60,10 +61,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn send() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `9595` - // Minimum execution time: 26_368_000 picoseconds. - Weight::from_parts(27_314_000, 0) - .saturating_add(Weight::from_parts(0, 9595)) + // Estimated: `3503` + // Minimum execution time: 27_316_000 picoseconds. + Weight::from_parts(27_658_000, 0) + .saturating_add(Weight::from_parts(0, 3503)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +74,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `1489` - // Minimum execution time: 24_998_000 picoseconds. - Weight::from_parts(25_321_000, 0) + // Minimum execution time: 29_202_000 picoseconds. + Weight::from_parts(29_681_000, 0) .saturating_add(Weight::from_parts(0, 1489)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -104,8 +105,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_733_000 picoseconds. - Weight::from_parts(10_002_000, 0) + // Minimum execution time: 10_266_000 picoseconds. + Weight::from_parts(10_449_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -115,8 +116,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_073_000 picoseconds. - Weight::from_parts(3_178_000, 0) + // Minimum execution time: 3_095_000 picoseconds. + Weight::from_parts(3_171_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -139,10 +140,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `14659` - // Minimum execution time: 31_313_000 picoseconds. - Weight::from_parts(31_916_000, 0) - .saturating_add(Weight::from_parts(0, 14659)) + // Estimated: `3503` + // Minimum execution time: 31_614_000 picoseconds. + Weight::from_parts(32_390_000, 0) + .saturating_add(Weight::from_parts(0, 3503)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -163,19 +164,21 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `220` - // Estimated: `14410` - // Minimum execution time: 32_721_000 picoseconds. - Weight::from_parts(33_013_000, 0) - .saturating_add(Weight::from_parts(0, 14410)) + // Estimated: `3685` + // Minimum execution time: 33_334_000 picoseconds. + Weight::from_parts(33_789_000, 0) + .saturating_add(Weight::from_parts(0, 3685)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: PolkadotXcm XcmExecutionSuspended (r:0 w:1) + /// Proof Skipped: PolkadotXcm XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured) fn force_suspension() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_073_000 picoseconds. - Weight::from_parts(3_178_000, 0) + // Minimum execution time: 3_178_000 picoseconds. + Weight::from_parts(3_261_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -185,8 +188,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `95` // Estimated: `10985` - // Minimum execution time: 15_020_000 picoseconds. - Weight::from_parts(15_358_000, 0) + // Minimum execution time: 14_687_000 picoseconds. + Weight::from_parts(15_004_000, 0) .saturating_add(Weight::from_parts(0, 10985)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -197,8 +200,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `99` // Estimated: `10989` - // Minimum execution time: 15_095_000 picoseconds. - Weight::from_parts(15_309_000, 0) + // Minimum execution time: 14_595_000 picoseconds. + Weight::from_parts(14_813_000, 0) .saturating_add(Weight::from_parts(0, 10989)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -209,8 +212,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `13471` - // Minimum execution time: 15_809_000 picoseconds. - Weight::from_parts(16_139_000, 0) + // Minimum execution time: 14_926_000 picoseconds. + Weight::from_parts(15_337_000, 0) .saturating_add(Weight::from_parts(0, 13471)) .saturating_add(T::DbWeight::get().reads(5)) } @@ -229,10 +232,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn notify_current_targets() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `15981` - // Minimum execution time: 28_167_000 picoseconds. - Weight::from_parts(28_747_000, 0) - .saturating_add(Weight::from_parts(0, 15981)) + // Estimated: `6046` + // Minimum execution time: 28_680_000 picoseconds. + Weight::from_parts(29_159_000, 0) + .saturating_add(Weight::from_parts(0, 6046)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -242,8 +245,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `136` // Estimated: `8551` - // Minimum execution time: 8_484_000 picoseconds. - Weight::from_parts(8_776_000, 0) + // Minimum execution time: 8_124_000 picoseconds. + Weight::from_parts(8_299_000, 0) .saturating_add(Weight::from_parts(0, 8551)) .saturating_add(T::DbWeight::get().reads(3)) } @@ -253,8 +256,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `10996` - // Minimum execution time: 15_814_000 picoseconds. - Weight::from_parts(16_131_000, 0) + // Minimum execution time: 14_755_000 picoseconds. + Weight::from_parts(15_136_000, 0) .saturating_add(Weight::from_parts(0, 10996)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -274,10 +277,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: // Measured: `112` - // Estimated: `20967` - // Minimum execution time: 34_500_000 picoseconds. - Weight::from_parts(34_978_000, 0) - .saturating_add(Weight::from_parts(0, 20967)) + // Estimated: `11002` + // Minimum execution time: 34_250_000 picoseconds. + Weight::from_parts(34_888_000, 0) + .saturating_add(Weight::from_parts(0, 11002)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs index 7cf23e0610b..9d11b07e54e 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs @@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -53,7 +52,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -65,7 +64,7 @@ impl XcmWeightInfo for BridgeHubKusamaXcmWeight { // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -123,7 +122,7 @@ impl XcmWeightInfo for BridgeHubKusamaXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 648e0c7368a..c15e866ce9f 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::fungible` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: @@ -54,8 +54,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `101` // Estimated: `3593` - // Minimum execution time: 19_924_000 picoseconds. - Weight::from_parts(20_322_000, 3593) + // Minimum execution time: 25_169_000 picoseconds. + Weight::from_parts(25_584_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +65,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `153` // Estimated: `6196` - // Minimum execution time: 32_669_000 picoseconds. - Weight::from_parts(33_313_000, 6196) + // Minimum execution time: 50_714_000 picoseconds. + Weight::from_parts(51_324_000, 6196) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -87,9 +87,9 @@ impl WeightInfo { pub fn transfer_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `223` - // Estimated: `18205` - // Minimum execution time: 55_574_000 picoseconds. - Weight::from_parts(56_148_000, 18205) + // Estimated: `6196` + // Minimum execution time: 74_593_000 picoseconds. + Weight::from_parts(75_347_000, 6196) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -97,8 +97,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_271_000 picoseconds. - Weight::from_parts(4_338_000, 0) + // Minimum execution time: 4_485_000 picoseconds. + Weight::from_parts(4_562_000, 0) } // Storage: System Account (r:1 w:1) // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) @@ -106,8 +106,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `52` // Estimated: `3593` - // Minimum execution time: 23_972_000 picoseconds. - Weight::from_parts(24_305_000, 3593) + // Minimum execution time: 27_136_000 picoseconds. + Weight::from_parts(27_387_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -128,9 +128,9 @@ impl WeightInfo { pub fn deposit_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `122` - // Estimated: `15097` - // Minimum execution time: 53_095_000 picoseconds. - Weight::from_parts(53_586_000, 15097) + // Estimated: `3593` + // Minimum execution time: 53_591_000 picoseconds. + Weight::from_parts(54_268_000, 3593) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -149,9 +149,9 @@ impl WeightInfo { pub fn initiate_teleport() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 30_394_000 picoseconds. - Weight::from_parts(31_238_000, 11244) + // Estimated: `3535` + // Minimum execution time: 30_062_000 picoseconds. + Weight::from_parts(30_771_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 738940ca868..0b4b1174160 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-kusama-dev"), DB CACHE: 1024 // Executed Command: @@ -63,9 +63,9 @@ impl WeightInfo { pub fn report_holding() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 30_841_000 picoseconds. - Weight::from_parts(31_223_000, 11244) + // Estimated: `3535` + // Minimum execution time: 34_626_000 picoseconds. + Weight::from_parts(35_122_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +73,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_749_000 picoseconds. - Weight::from_parts(2_894_000, 0) + // Minimum execution time: 3_405_000 picoseconds. + Weight::from_parts(3_503_000, 0) } // Storage: PolkadotXcm Queries (r:1 w:0) // Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) @@ -82,58 +82,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 10_637_000 picoseconds. - Weight::from_parts(10_904_000, 3497) + // Minimum execution time: 11_296_000 picoseconds. + Weight::from_parts(11_550_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_587_000 picoseconds. - Weight::from_parts(12_882_000, 0) + // Minimum execution time: 13_932_000 picoseconds. + Weight::from_parts(14_220_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_088_000 picoseconds. - Weight::from_parts(3_165_000, 0) + // Minimum execution time: 3_640_000 picoseconds. + Weight::from_parts(3_732_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_748_000 picoseconds. - Weight::from_parts(2_868_000, 0) + // Minimum execution time: 3_195_000 picoseconds. + Weight::from_parts(3_298_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_897_000 picoseconds. - Weight::from_parts(2_970_000, 0) + // Minimum execution time: 3_217_000 picoseconds. + Weight::from_parts(3_304_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_793_000 picoseconds. - Weight::from_parts(2_883_000, 0) + // Minimum execution time: 3_237_000 picoseconds. + Weight::from_parts(3_273_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_690_000 picoseconds. - Weight::from_parts(3_745_000, 0) + // Minimum execution time: 4_292_000 picoseconds. + Weight::from_parts(4_373_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_760_000 picoseconds. - Weight::from_parts(2_807_000, 0) + // Minimum execution time: 3_198_000 picoseconds. + Weight::from_parts(3_271_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -150,9 +150,9 @@ impl WeightInfo { pub fn report_error() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 24_591_000 picoseconds. - Weight::from_parts(25_237_000, 11244) + // Estimated: `3535` + // Minimum execution time: 27_178_000 picoseconds. + Weight::from_parts(28_171_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -162,8 +162,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 14_596_000 picoseconds. - Weight::from_parts(15_010_000, 3555) + // Minimum execution time: 16_146_000 picoseconds. + Weight::from_parts(16_496_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -171,8 +171,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_770_000 picoseconds. - Weight::from_parts(2_860_000, 0) + // Minimum execution time: 3_189_000 picoseconds. + Weight::from_parts(3_298_000, 0) } // Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1) // Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) @@ -189,9 +189,9 @@ impl WeightInfo { pub fn subscribe_version() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `13098` - // Minimum execution time: 25_644_000 picoseconds. - Weight::from_parts(26_269_000, 13098) + // Estimated: `3503` + // Minimum execution time: 27_844_000 picoseconds. + Weight::from_parts(28_113_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -201,8 +201,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_969_000 picoseconds. - Weight::from_parts(5_167_000, 0) + // Minimum execution time: 5_563_000 picoseconds. + Weight::from_parts(5_718_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainInfo ParachainId (r:1 w:0) @@ -220,9 +220,9 @@ impl WeightInfo { pub fn initiate_reserve_withdraw() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 27_894_000 picoseconds. - Weight::from_parts(28_294_000, 11244) + // Estimated: `3535` + // Minimum execution time: 30_296_000 picoseconds. + Weight::from_parts(30_843_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -230,36 +230,36 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_595_000 picoseconds. - Weight::from_parts(4_709_000, 0) + // Minimum execution time: 5_340_000 picoseconds. + Weight::from_parts(5_390_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_957_000 picoseconds. - Weight::from_parts(3_035_000, 0) + // Minimum execution time: 3_312_000 picoseconds. + Weight::from_parts(3_411_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_091_000 picoseconds. - Weight::from_parts(3_197_000, 0) + // Minimum execution time: 3_294_000 picoseconds. + Weight::from_parts(3_374_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_953_000 picoseconds. - Weight::from_parts(3_036_000, 0) + // Minimum execution time: 3_197_000 picoseconds. + Weight::from_parts(3_261_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_275_000 picoseconds. - Weight::from_parts(3_382_000, 0) + // Minimum execution time: 3_465_000 picoseconds. + Weight::from_parts(3_541_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -276,9 +276,9 @@ impl WeightInfo { pub fn query_pallet() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 30_240_000 picoseconds. - Weight::from_parts(30_533_000, 11244) + // Estimated: `3535` + // Minimum execution time: 29_942_000 picoseconds. + Weight::from_parts(30_426_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -286,8 +286,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_276_000 picoseconds. - Weight::from_parts(5_363_000, 0) + // Minimum execution time: 5_454_000 picoseconds. + Weight::from_parts(5_906_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -304,9 +304,9 @@ impl WeightInfo { pub fn report_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 27_019_000 picoseconds. - Weight::from_parts(27_675_000, 11244) + // Estimated: `3535` + // Minimum execution time: 27_744_000 picoseconds. + Weight::from_parts(28_116_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -314,35 +314,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_136_000 picoseconds. - Weight::from_parts(3_210_000, 0) + // Minimum execution time: 3_204_000 picoseconds. + Weight::from_parts(3_352_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_989_000 picoseconds. - Weight::from_parts(3_067_000, 0) + // Minimum execution time: 3_180_000 picoseconds. + Weight::from_parts(3_245_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_004_000 picoseconds. - Weight::from_parts(3_101_000, 0) + // Minimum execution time: 3_195_000 picoseconds. + Weight::from_parts(3_299_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_996_000 picoseconds. - Weight::from_parts(3_068_000, 0) + // Minimum execution time: 3_185_000 picoseconds. + Weight::from_parts(3_279_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_102_000 picoseconds. - Weight::from_parts(3_210_000, 0) + // Minimum execution time: 3_308_000 picoseconds. + Weight::from_parts(3_463_000, 0) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index a8bd8f6f70a..0cbb379fa68 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -24,19 +24,16 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, -}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, - WithComputedOrigin, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, + DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, IsConcrete, ParentAsSuperuser, + ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -129,51 +126,54 @@ impl Contains for SafeCallFilter { } } - match call { + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true, - _ => false, - } + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. } | + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) + ) } } -pub type Barrier = DenyThenTry< - DenyReserveTransferToRelayChain, - ( - // Allow local users to buy weight credit. - TakeWeightCredit, - // Expected responses are OK. - AllowKnownQueryResponses, - WithComputedOrigin< - ( - // If the message is one that immediately attemps to pay for execution, then allow it. - AllowTopLevelPaidExecutionFrom, - // Parent and its pluralities (i.e. governance bodies) get free execution. - AllowExplicitUnpaidExecutionFrom, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, - ), - UniversalLocation, - ConstU32<8>, - >, - ), +pub type Barrier = TrailingSetTopicAsId< + DenyThenTry< + DenyReserveTransferToRelayChain, + ( + // Allow local users to buy weight credit. + TakeWeightCredit, + // Expected responses are OK. + AllowKnownQueryResponses, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Parent and its pluralities (i.e. governance bodies) get free execution. + AllowExplicitUnpaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, + ), + >, >; pub struct XcmConfig; @@ -217,12 +217,12 @@ pub type LocalOriginToLocation = SignedToAccountId32, // ..and XCMP to communicate with the sibling chains. XcmpQueue, -); +)>; #[cfg(feature = "runtime-benchmarks")] parameter_types! { @@ -260,6 +260,8 @@ impl pallet_xcm::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml index c6272150325..34d56206a85 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/Cargo.toml @@ -11,9 +11,9 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } hex-literal = { version = "0.4.1" } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } -serde = { version = "1.0.160", optional = true, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } +serde = { version = "1.0.163", optional = true, features = ["derive"] } smallvec = "1.8.1" # Substrate diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index cb814596020..fbb89276032 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -71,10 +71,12 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use parachains_common::{ impls::DealWithFees, opaque, - process_xcm_message::{ParaIdToSibling, ProcessFromSibling, ProcessXcmMessage}, + process_xcm_message::{ParaIdToSibling, ProcessFromSibling}, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; +use xcm_builder::ProcessXcmMessage; + // XCM Imports use xcm::latest::prelude::BodyId; @@ -109,6 +111,9 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; +/// Migrations to apply on runtime upgrade. +pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1,); + /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -116,6 +121,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, + Migrations, >; impl_opaque_keys! { @@ -129,7 +135,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("bridge-hub-polkadot"), impl_name: create_runtime_str!("bridge-hub-polkadot"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -247,7 +253,7 @@ impl pallet_balances::Config for Runtime { type MaxLocks = ConstU32<50>; type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -255,7 +261,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -650,7 +656,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -688,7 +694,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( DotRelayLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(DotRelayLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(DotRelayLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; } @@ -702,7 +708,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(DotRelayLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs index c45313ae34b..a87247bbe79 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs @@ -31,7 +31,7 @@ // --pallet // cumulus_pallet_xcmp_queue // --extrinsic -// +// // --execution // native // --output @@ -44,9 +44,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_xcmp_queue`. pub struct WeightInfo(PhantomData); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/frame_system.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/frame_system.rs index 6560a1546a5..7ca54d2e135 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/frame_system.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/frame_system.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `frame_system` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `frame_system`. pub struct WeightInfo(PhantomData); @@ -52,22 +53,22 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_129_000 picoseconds. - Weight::from_parts(2_213_000, 0) + // Minimum execution time: 2_432_000 picoseconds. + Weight::from_parts(2_458_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(370, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(367, 0).saturating_mul(b.into())) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_415_000 picoseconds. - Weight::from_parts(7_510_000, 0) + // Minimum execution time: 7_911_000 picoseconds. + Weight::from_parts(8_031_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_412, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(1_405, 0).saturating_mul(b.into())) } /// Storage: System Digest (r:1 w:1) /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) @@ -77,12 +78,15 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 4_227_000 picoseconds. - Weight::from_parts(4_495_000, 0) + // Minimum execution time: 4_304_000 picoseconds. + Weight::from_parts(4_553_000, 0) .saturating_add(Weight::from_parts(0, 1485)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } + fn set_code() -> Weight { + Weight::from_parts(1_000_000, 0) + } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `i` is `[0, 1000]`. @@ -90,11 +94,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_349_000 picoseconds. - Weight::from_parts(2_381_000, 0) + // Minimum execution time: 2_493_000 picoseconds. + Weight::from_parts(2_523_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_813 - .saturating_add(Weight::from_parts(685_377, 0).saturating_mul(i.into())) + // Standard Error: 1_594 + .saturating_add(Weight::from_parts(663_439, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -104,11 +108,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_250_000 picoseconds. - Weight::from_parts(2_317_000, 0) + // Minimum execution time: 2_492_000 picoseconds. + Weight::from_parts(2_526_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 911 - .saturating_add(Weight::from_parts(494_503, 0).saturating_mul(i.into())) + // Standard Error: 784 + .saturating_add(Weight::from_parts(493_844, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -118,11 +122,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `68 + p * (69 ±0)` // Estimated: `66 + p * (70 ±0)` - // Minimum execution time: 4_239_000 picoseconds. - Weight::from_parts(4_380_000, 0) + // Minimum execution time: 4_200_000 picoseconds. + Weight::from_parts(4_288_000, 0) .saturating_add(Weight::from_parts(0, 66)) - // Standard Error: 1_255 - .saturating_add(Weight::from_parts(1_012_115, 0).saturating_mul(p.into())) + // Standard Error: 1_195 + .saturating_add(Weight::from_parts(1_021_563, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_balances.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_balances.rs index a6547ab46fb..bcfe953f358 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_balances.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_balances.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_balances`. pub struct WeightInfo(PhantomData); @@ -53,8 +54,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 35_006_000 picoseconds. - Weight::from_parts(35_375_000, 0) + // Minimum execution time: 52_090_000 picoseconds. + Weight::from_parts(52_437_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -65,8 +66,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 25_755_000 picoseconds. - Weight::from_parts(26_176_000, 0) + // Minimum execution time: 39_798_000 picoseconds. + Weight::from_parts(40_230_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -77,8 +78,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 15_651_000 picoseconds. - Weight::from_parts(16_056_000, 0) + // Minimum execution time: 16_110_000 picoseconds. + Weight::from_parts(16_386_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -89,8 +90,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 18_932_000 picoseconds. - Weight::from_parts(19_186_000, 0) + // Minimum execution time: 22_460_000 picoseconds. + Weight::from_parts(23_030_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -101,8 +102,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `6196` - // Minimum execution time: 36_593_000 picoseconds. - Weight::from_parts(36_971_000, 0) + // Minimum execution time: 53_769_000 picoseconds. + Weight::from_parts(54_256_000, 0) .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -113,25 +114,38 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 31_795_000 picoseconds. - Weight::from_parts(32_237_000, 0) + // Minimum execution time: 48_582_000 picoseconds. + Weight::from_parts(49_294_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn upgrade_accounts(_: u32) -> Weight { - Weight::from_parts(0, 0) - } fn force_unreserve() -> Weight { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 15_120_000 picoseconds. - Weight::from_parts(15_360_000, 0) + // Minimum execution time: 19_364_000 picoseconds. + Weight::from_parts(19_571_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + u * (136 ±0)` + // Estimated: `990 + u * (2603 ±0)` + // Minimum execution time: 17_815_000 picoseconds. + Weight::from_parts(17_974_000, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 10_230 + .saturating_add(Weight::from_parts(14_059_882, 0).saturating_mul(u.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_collator_selection.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_collator_selection.rs index 5c35eff5f53..bae3a058100 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_collator_selection.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_collator_selection` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_collator_selection`. pub struct WeightInfo(PhantomData); @@ -56,11 +57,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `214 + b * (78 ±0)` // Estimated: `1203 + b * (2554 ±0)` - // Minimum execution time: 14_444_000 picoseconds. - Weight::from_parts(15_006_377, 0) + // Minimum execution time: 14_646_000 picoseconds. + Weight::from_parts(15_408_953, 0) .saturating_add(Weight::from_parts(0, 1203)) - // Standard Error: 2_965 - .saturating_add(Weight::from_parts(2_598_095, 0).saturating_mul(b.into())) + // Standard Error: 3_120 + .saturating_add(Weight::from_parts(2_562_646, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(Weight::from_parts(0, 2554).saturating_mul(b.into())) @@ -71,8 +72,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_886_000 picoseconds. - Weight::from_parts(7_053_000, 0) + // Minimum execution time: 7_277_000 picoseconds. + Weight::from_parts(7_557_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -82,8 +83,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_233_000 picoseconds. - Weight::from_parts(7_420_000, 0) + // Minimum execution time: 7_684_000 picoseconds. + Weight::from_parts(7_883_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,12 +104,12 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn register_as_candidate(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1104 + c * (48 ±0)` - // Estimated: `61672 + c * (49 ±0)` - // Minimum execution time: 37_455_000 picoseconds. - Weight::from_parts(29_651_534, 0) - .saturating_add(Weight::from_parts(0, 61672)) - // Standard Error: 1_287 - .saturating_add(Weight::from_parts(103_531, 0).saturating_mul(c.into())) + // Estimated: `49487 + c * (49 ±0)` + // Minimum execution time: 42_488_000 picoseconds. + Weight::from_parts(34_515_606, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 1_249 + .saturating_add(Weight::from_parts(103_597, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 49).saturating_mul(c.into())) @@ -122,11 +123,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `428 + c * (48 ±0)` // Estimated: `49487` - // Minimum execution time: 29_548_000 picoseconds. - Weight::from_parts(18_882_873, 0) + // Minimum execution time: 33_698_000 picoseconds. + Weight::from_parts(22_802_769, 0) .saturating_add(Weight::from_parts(0, 49487)) - // Standard Error: 1_273 - .saturating_add(Weight::from_parts(105_000, 0).saturating_mul(c.into())) + // Standard Error: 1_317 + .saturating_add(Weight::from_parts(107_072, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -139,13 +140,46 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn note_author() -> Weight { // Proof Size summary in bytes: // Measured: `155` - // Estimated: `7729` - // Minimum execution time: 28_960_000 picoseconds. - Weight::from_parts(29_435_000, 0) - .saturating_add(Weight::from_parts(0, 7729)) + // Estimated: `6196` + // Minimum execution time: 43_472_000 picoseconds. + Weight::from_parts(44_218_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) @@ -160,18 +194,18 @@ impl pallet_collator_selection::WeightInfo for WeightIn /// The range of component `c` is `[1, 1000]`. fn new_session(r: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `22815 + r * (116 ±0) + c * (97 ±0)` - // Estimated: `56697 + c * (2520 ±0) + r * (2602 ±0)` - // Minimum execution time: 16_727_000 picoseconds. - Weight::from_parts(16_932_000, 0) - .saturating_add(Weight::from_parts(0, 56697)) - // Standard Error: 798_306 - .saturating_add(Weight::from_parts(28_951_019, 0).saturating_mul(c.into())) + // Measured: `22815 + c * (97 ±0) + r * (116 ±0)` + // Estimated: `49487 + c * (2519 ±0) + r * (2602 ±0)` + // Minimum execution time: 17_280_000 picoseconds. + Weight::from_parts(17_471_000, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 866_180 + .saturating_add(Weight::from_parts(30_755_948, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) - .saturating_add(Weight::from_parts(0, 2520).saturating_mul(c.into())) + .saturating_add(Weight::from_parts(0, 2519).saturating_mul(c.into())) .saturating_add(Weight::from_parts(0, 2602).saturating_mul(r.into())) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_multisig.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_multisig.rs index 9ab2d5a58a6..7e5c5efcf3f 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_multisig.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_multisig.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_multisig` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_multisig`. pub struct WeightInfo(PhantomData); @@ -52,11 +53,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_761_000 picoseconds. - Weight::from_parts(12_373_119, 0) + // Minimum execution time: 11_575_000 picoseconds. + Weight::from_parts(12_064_176, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 3 - .saturating_add(Weight::from_parts(482, 0).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(500, 0).saturating_mul(z.into())) } /// Storage: Multisig Multisigs (r:1 w:1) /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) @@ -66,13 +67,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `263 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 36_964_000 picoseconds. - Weight::from_parts(31_553_347, 0) + // Minimum execution time: 40_911_000 picoseconds. + Weight::from_parts(34_976_854, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 571 - .saturating_add(Weight::from_parts(62_042, 0).saturating_mul(s.into())) - // Standard Error: 5 - .saturating_add(Weight::from_parts(1_178, 0).saturating_mul(z.into())) + // Standard Error: 418 + .saturating_add(Weight::from_parts(65_759, 0).saturating_mul(s.into())) + // Standard Error: 4 + .saturating_add(Weight::from_parts(1_190, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -84,13 +85,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 27_113_000 picoseconds. - Weight::from_parts(21_794_796, 0) + // Minimum execution time: 26_906_000 picoseconds. + Weight::from_parts(21_462_377, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 423 - .saturating_add(Weight::from_parts(59_156, 0).saturating_mul(s.into())) - // Standard Error: 4 - .saturating_add(Weight::from_parts(1_193, 0).saturating_mul(z.into())) + // Standard Error: 351 + .saturating_add(Weight::from_parts(59_241, 0).saturating_mul(s.into())) + // Standard Error: 3 + .saturating_add(Weight::from_parts(1_204, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,14 +104,14 @@ impl pallet_multisig::WeightInfo for WeightInfo { fn as_multi_complete(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `388 + s * (33 ±0)` - // Estimated: `10404` - // Minimum execution time: 41_979_000 picoseconds. - Weight::from_parts(34_970_639, 0) - .saturating_add(Weight::from_parts(0, 10404)) - // Standard Error: 481 - .saturating_add(Weight::from_parts(76_814, 0).saturating_mul(s.into())) - // Standard Error: 4 - .saturating_add(Weight::from_parts(1_191, 0).saturating_mul(z.into())) + // Estimated: `6811` + // Minimum execution time: 45_289_000 picoseconds. + Weight::from_parts(37_925_050, 0) + .saturating_add(Weight::from_parts(0, 6811)) + // Standard Error: 675 + .saturating_add(Weight::from_parts(81_154, 0).saturating_mul(s.into())) + // Standard Error: 6 + .saturating_add(Weight::from_parts(1_237, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -121,11 +122,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `263 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 28_113_000 picoseconds. - Weight::from_parts(29_657_007, 0) + // Minimum execution time: 31_995_000 picoseconds. + Weight::from_parts(33_377_255, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 746 - .saturating_add(Weight::from_parts(67_176, 0).saturating_mul(s.into())) + // Standard Error: 571 + .saturating_add(Weight::from_parts(69_665, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -136,11 +137,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 19_227_000 picoseconds. - Weight::from_parts(20_043_765, 0) + // Minimum execution time: 18_656_000 picoseconds. + Weight::from_parts(19_906_362, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 1_458 - .saturating_add(Weight::from_parts(70_065, 0).saturating_mul(s.into())) + // Standard Error: 431 + .saturating_add(Weight::from_parts(62_284, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -151,11 +152,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `454 + s * (1 ±0)` // Estimated: `6811` - // Minimum execution time: 29_358_000 picoseconds. - Weight::from_parts(30_953_779, 0) + // Minimum execution time: 32_875_000 picoseconds. + Weight::from_parts(34_341_729, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 662 - .saturating_add(Weight::from_parts(62_100, 0).saturating_mul(s.into())) + // Standard Error: 924 + .saturating_add(Weight::from_parts(72_829, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_session.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_session.rs index cd7f40253b5..c97705a6794 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_session.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_session.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_session` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_session`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn set_keys() -> Weight { // Proof Size summary in bytes: // Measured: `297` - // Estimated: `7524` - // Minimum execution time: 17_305_000 picoseconds. - Weight::from_parts(17_673_000, 0) - .saturating_add(Weight::from_parts(0, 7524)) + // Estimated: `3762` + // Minimum execution time: 17_610_000 picoseconds. + Weight::from_parts(18_124_000, 0) + .saturating_add(Weight::from_parts(0, 3762)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -68,10 +69,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn purge_keys() -> Weight { // Proof Size summary in bytes: // Measured: `279` - // Estimated: `4023` - // Minimum execution time: 13_593_000 picoseconds. - Weight::from_parts(13_826_000, 0) - .saturating_add(Weight::from_parts(0, 4023)) + // Estimated: `3744` + // Minimum execution time: 13_143_000 picoseconds. + Weight::from_parts(13_552_000, 0) + .saturating_add(Weight::from_parts(0, 3744)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_timestamp.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_timestamp.rs index b22fe963f12..4b5d0156670 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_timestamp.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_timestamp.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_timestamp`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_timestamp::WeightInfo for WeightInfo { fn set() -> Weight { // Proof Size summary in bytes: // Measured: `49` - // Estimated: `2986` - // Minimum execution time: 7_665_000 picoseconds. - Weight::from_parts(7_892_000, 0) - .saturating_add(Weight::from_parts(0, 2986)) + // Estimated: `1493` + // Minimum execution time: 7_574_000 picoseconds. + Weight::from_parts(7_792_000, 0) + .saturating_add(Weight::from_parts(0, 1493)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +66,8 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `57` // Estimated: `0` - // Minimum execution time: 3_226_000 picoseconds. - Weight::from_parts(3_339_000, 0) + // Minimum execution time: 3_081_000 picoseconds. + Weight::from_parts(3_148_000, 0) .saturating_add(Weight::from_parts(0, 0)) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_utility.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_utility.rs index 34c36b874a1..816c705a772 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_utility.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_utility.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_utility`. pub struct WeightInfo(PhantomData); @@ -52,18 +53,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_083_000 picoseconds. - Weight::from_parts(13_037_767, 0) + // Minimum execution time: 7_261_000 picoseconds. + Weight::from_parts(8_284_145, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_155 - .saturating_add(Weight::from_parts(4_503_244, 0).saturating_mul(c.into())) + // Standard Error: 3_294 + .saturating_add(Weight::from_parts(4_497_661, 0).saturating_mul(c.into())) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_705_000 picoseconds. - Weight::from_parts(5_799_000, 0) + // Minimum execution time: 5_294_000 picoseconds. + Weight::from_parts(5_475_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -71,18 +72,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_248_000 picoseconds. - Weight::from_parts(14_495_670, 0) + // Minimum execution time: 7_042_000 picoseconds. + Weight::from_parts(5_814_168, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_240 - .saturating_add(Weight::from_parts(4_790_508, 0).saturating_mul(c.into())) + // Standard Error: 2_914 + .saturating_add(Weight::from_parts(4_802_976, 0).saturating_mul(c.into())) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_355_000 picoseconds. - Weight::from_parts(9_596_000, 0) + // Minimum execution time: 9_260_000 picoseconds. + Weight::from_parts(9_406_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -90,10 +91,10 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_985_000 picoseconds. - Weight::from_parts(17_435_570, 0) + // Minimum execution time: 7_109_000 picoseconds. + Weight::from_parts(3_793_543, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_165 - .saturating_add(Weight::from_parts(4_492_577, 0).saturating_mul(c.into())) + // Standard Error: 2_940 + .saturating_add(Weight::from_parts(4_479_763, 0).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_xcm.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_xcm.rs index 05bfdc8339e..fdbde818da9 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_xcm.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/pallet_xcm.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); @@ -60,10 +61,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn send() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `9595` - // Minimum execution time: 25_890_000 picoseconds. - Weight::from_parts(26_601_000, 0) - .saturating_add(Weight::from_parts(0, 9595)) + // Estimated: `3503` + // Minimum execution time: 25_921_000 picoseconds. + Weight::from_parts(26_233_000, 0) + .saturating_add(Weight::from_parts(0, 3503)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +74,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `1489` - // Minimum execution time: 24_961_000 picoseconds. - Weight::from_parts(25_332_000, 0) + // Minimum execution time: 26_254_000 picoseconds. + Weight::from_parts(26_615_000, 0) .saturating_add(Weight::from_parts(0, 1489)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -104,8 +105,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_662_000 picoseconds. - Weight::from_parts(9_844_000, 0) + // Minimum execution time: 9_756_000 picoseconds. + Weight::from_parts(9_989_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -115,8 +116,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_994_000 picoseconds. - Weight::from_parts(3_160_000, 0) + // Minimum execution time: 3_147_000 picoseconds. + Weight::from_parts(3_248_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -139,10 +140,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `14659` - // Minimum execution time: 31_632_000 picoseconds. - Weight::from_parts(31_919_000, 0) - .saturating_add(Weight::from_parts(0, 14659)) + // Estimated: `3503` + // Minimum execution time: 31_089_000 picoseconds. + Weight::from_parts(31_503_000, 0) + .saturating_add(Weight::from_parts(0, 3503)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -163,19 +164,21 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `220` - // Estimated: `14410` - // Minimum execution time: 32_570_000 picoseconds. - Weight::from_parts(33_292_000, 0) - .saturating_add(Weight::from_parts(0, 14410)) + // Estimated: `3685` + // Minimum execution time: 33_219_000 picoseconds. + Weight::from_parts(33_708_000, 0) + .saturating_add(Weight::from_parts(0, 3685)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: PolkadotXcm XcmExecutionSuspended (r:0 w:1) + /// Proof Skipped: PolkadotXcm XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured) fn force_suspension() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_994_000 picoseconds. - Weight::from_parts(3_160_000, 0) + // Minimum execution time: 3_042_000 picoseconds. + Weight::from_parts(3_175_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -185,8 +188,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `95` // Estimated: `10985` - // Minimum execution time: 14_829_000 picoseconds. - Weight::from_parts(15_171_000, 0) + // Minimum execution time: 15_040_000 picoseconds. + Weight::from_parts(15_455_000, 0) .saturating_add(Weight::from_parts(0, 10985)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -197,8 +200,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `99` // Estimated: `10989` - // Minimum execution time: 14_774_000 picoseconds. - Weight::from_parts(15_232_000, 0) + // Minimum execution time: 14_999_000 picoseconds. + Weight::from_parts(15_417_000, 0) .saturating_add(Weight::from_parts(0, 10989)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -209,8 +212,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `13471` - // Minimum execution time: 15_289_000 picoseconds. - Weight::from_parts(15_543_000, 0) + // Minimum execution time: 15_694_000 picoseconds. + Weight::from_parts(15_916_000, 0) .saturating_add(Weight::from_parts(0, 13471)) .saturating_add(T::DbWeight::get().reads(5)) } @@ -229,10 +232,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn notify_current_targets() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `15981` - // Minimum execution time: 27_849_000 picoseconds. - Weight::from_parts(28_243_000, 0) - .saturating_add(Weight::from_parts(0, 15981)) + // Estimated: `6046` + // Minimum execution time: 28_164_000 picoseconds. + Weight::from_parts(28_489_000, 0) + .saturating_add(Weight::from_parts(0, 6046)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -242,8 +245,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `136` // Estimated: `8551` - // Minimum execution time: 8_260_000 picoseconds. - Weight::from_parts(8_477_000, 0) + // Minimum execution time: 8_273_000 picoseconds. + Weight::from_parts(8_471_000, 0) .saturating_add(Weight::from_parts(0, 8551)) .saturating_add(T::DbWeight::get().reads(3)) } @@ -253,8 +256,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `10996` - // Minimum execution time: 15_132_000 picoseconds. - Weight::from_parts(15_581_000, 0) + // Minimum execution time: 15_009_000 picoseconds. + Weight::from_parts(15_459_000, 0) .saturating_add(Weight::from_parts(0, 10996)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -274,10 +277,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: // Measured: `112` - // Estimated: `20967` - // Minimum execution time: 34_016_000 picoseconds. - Weight::from_parts(34_627_000, 0) - .saturating_add(Weight::from_parts(0, 20967)) + // Estimated: `11002` + // Minimum execution time: 33_647_000 picoseconds. + Weight::from_parts(34_065_000, 0) + .saturating_add(Weight::from_parts(0, 11002)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs index e9b1c70bf6a..27bdb510ba0 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs @@ -33,8 +33,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -53,7 +52,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -65,7 +64,7 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight { // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -123,7 +122,7 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } @@ -150,7 +149,7 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight { _xcm: &Xcm<()>, ) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(200_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(200_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::initiate_teleport()); hardcoded_weight.min(weight) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 16110f554b2..e91a3d7f59f 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::fungible` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -54,8 +54,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `101` // Estimated: `3593` - // Minimum execution time: 20_647_000 picoseconds. - Weight::from_parts(20_978_000, 3593) + // Minimum execution time: 23_577_000 picoseconds. + Weight::from_parts(24_152_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +65,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `153` // Estimated: `6196` - // Minimum execution time: 32_995_000 picoseconds. - Weight::from_parts(33_365_000, 6196) + // Minimum execution time: 49_336_000 picoseconds. + Weight::from_parts(49_673_000, 6196) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -87,9 +87,9 @@ impl WeightInfo { pub fn transfer_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `223` - // Estimated: `18205` - // Minimum execution time: 56_568_000 picoseconds. - Weight::from_parts(57_462_000, 18205) + // Estimated: `6196` + // Minimum execution time: 72_360_000 picoseconds. + Weight::from_parts(72_916_000, 6196) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -97,8 +97,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_070_000 picoseconds. - Weight::from_parts(4_200_000, 0) + // Minimum execution time: 3_838_000 picoseconds. + Weight::from_parts(3_928_000, 0) } // Storage: System Account (r:1 w:1) // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) @@ -106,8 +106,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `52` // Estimated: `3593` - // Minimum execution time: 24_036_000 picoseconds. - Weight::from_parts(24_587_000, 3593) + // Minimum execution time: 26_214_000 picoseconds. + Weight::from_parts(26_718_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -128,9 +128,9 @@ impl WeightInfo { pub fn deposit_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `122` - // Estimated: `15097` - // Minimum execution time: 49_836_000 picoseconds. - Weight::from_parts(50_507_000, 15097) + // Estimated: `3593` + // Minimum execution time: 52_341_000 picoseconds. + Weight::from_parts(52_801_000, 3593) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -149,9 +149,9 @@ impl WeightInfo { pub fn initiate_teleport() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 28_353_000 picoseconds. - Weight::from_parts(29_151_000, 11244) + // Estimated: `3535` + // Minimum execution time: 28_785_000 picoseconds. + Weight::from_parts(29_133_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index f8320dad59b..3cf25c1e8f8 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -63,9 +63,9 @@ impl WeightInfo { pub fn report_holding() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 30_983_000 picoseconds. - Weight::from_parts(31_396_000, 11244) + // Estimated: `3535` + // Minimum execution time: 31_194_000 picoseconds. + Weight::from_parts(31_563_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +73,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_966_000 picoseconds. - Weight::from_parts(3_066_000, 0) + // Minimum execution time: 2_905_000 picoseconds. + Weight::from_parts(3_006_000, 0) } // Storage: PolkadotXcm Queries (r:1 w:0) // Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) @@ -82,58 +82,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 11_159_000 picoseconds. - Weight::from_parts(11_390_000, 3497) + // Minimum execution time: 10_292_000 picoseconds. + Weight::from_parts(10_503_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_987_000 picoseconds. - Weight::from_parts(13_337_000, 0) + // Minimum execution time: 12_198_000 picoseconds. + Weight::from_parts(12_445_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_107_000 picoseconds. - Weight::from_parts(3_182_000, 0) + // Minimum execution time: 3_199_000 picoseconds. + Weight::from_parts(3_286_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_957_000 picoseconds. - Weight::from_parts(3_022_000, 0) + // Minimum execution time: 2_780_000 picoseconds. + Weight::from_parts(2_847_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_979_000 picoseconds. - Weight::from_parts(3_088_000, 0) + // Minimum execution time: 2_787_000 picoseconds. + Weight::from_parts(2_835_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_934_000 picoseconds. - Weight::from_parts(2_989_000, 0) + // Minimum execution time: 2_822_000 picoseconds. + Weight::from_parts(2_853_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_817_000 picoseconds. - Weight::from_parts(3_898_000, 0) + // Minimum execution time: 3_671_000 picoseconds. + Weight::from_parts(3_746_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_021_000 picoseconds. - Weight::from_parts(3_083_000, 0) + // Minimum execution time: 2_748_000 picoseconds. + Weight::from_parts(2_818_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -150,9 +150,9 @@ impl WeightInfo { pub fn report_error() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 25_036_000 picoseconds. - Weight::from_parts(25_379_000, 11244) + // Estimated: `3535` + // Minimum execution time: 24_294_000 picoseconds. + Weight::from_parts(24_640_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -162,8 +162,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 15_074_000 picoseconds. - Weight::from_parts(15_310_000, 3555) + // Minimum execution time: 14_359_000 picoseconds. + Weight::from_parts(14_550_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -171,8 +171,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_996_000 picoseconds. - Weight::from_parts(3_040_000, 0) + // Minimum execution time: 2_792_000 picoseconds. + Weight::from_parts(2_884_000, 0) } // Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1) // Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) @@ -189,9 +189,9 @@ impl WeightInfo { pub fn subscribe_version() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `13098` - // Minimum execution time: 26_142_000 picoseconds. - Weight::from_parts(26_578_000, 13098) + // Estimated: `3503` + // Minimum execution time: 25_925_000 picoseconds. + Weight::from_parts(26_130_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -201,8 +201,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_216_000 picoseconds. - Weight::from_parts(5_304_000, 0) + // Minimum execution time: 5_004_000 picoseconds. + Weight::from_parts(5_141_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainInfo ParachainId (r:1 w:0) @@ -220,9 +220,9 @@ impl WeightInfo { pub fn initiate_reserve_withdraw() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 28_236_000 picoseconds. - Weight::from_parts(28_614_000, 11244) + // Estimated: `3535` + // Minimum execution time: 27_163_000 picoseconds. + Weight::from_parts(27_722_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -230,36 +230,36 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_701_000 picoseconds. - Weight::from_parts(4_783_000, 0) + // Minimum execution time: 4_430_000 picoseconds. + Weight::from_parts(4_492_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_121_000 picoseconds. - Weight::from_parts(3_177_000, 0) + // Minimum execution time: 2_870_000 picoseconds. + Weight::from_parts(2_998_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_106_000 picoseconds. - Weight::from_parts(3_343_000, 0) + // Minimum execution time: 2_845_000 picoseconds. + Weight::from_parts(2_893_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_151_000 picoseconds. - Weight::from_parts(3_226_000, 0) + // Minimum execution time: 2_753_000 picoseconds. + Weight::from_parts(2_816_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_362_000 picoseconds. - Weight::from_parts(3_453_000, 0) + // Minimum execution time: 2_992_000 picoseconds. + Weight::from_parts(3_068_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -276,9 +276,9 @@ impl WeightInfo { pub fn query_pallet() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 30_472_000 picoseconds. - Weight::from_parts(30_906_000, 11244) + // Estimated: `3535` + // Minimum execution time: 27_324_000 picoseconds. + Weight::from_parts(27_656_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -286,8 +286,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_383_000 picoseconds. - Weight::from_parts(5_496_000, 0) + // Minimum execution time: 4_830_000 picoseconds. + Weight::from_parts(4_903_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -304,9 +304,9 @@ impl WeightInfo { pub fn report_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 26_946_000 picoseconds. - Weight::from_parts(27_774_000, 11244) + // Estimated: `3535` + // Minimum execution time: 24_428_000 picoseconds. + Weight::from_parts(24_732_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -314,35 +314,35 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_192_000 picoseconds. - Weight::from_parts(3_262_000, 0) + // Minimum execution time: 2_779_000 picoseconds. + Weight::from_parts(2_822_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_129_000 picoseconds. - Weight::from_parts(3_199_000, 0) + // Minimum execution time: 2_789_000 picoseconds. + Weight::from_parts(2_873_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_156_000 picoseconds. - Weight::from_parts(3_202_000, 0) + // Minimum execution time: 2_819_000 picoseconds. + Weight::from_parts(2_904_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_114_000 picoseconds. - Weight::from_parts(3_208_000, 0) + // Minimum execution time: 2_788_000 picoseconds. + Weight::from_parts(2_887_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_315_000 picoseconds. - Weight::from_parts(3_374_000, 0) + // Minimum execution time: 3_006_000 picoseconds. + Weight::from_parts(3_078_000, 0) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index a09903b3e26..64704d05e02 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -24,19 +24,16 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, -}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, - WithComputedOrigin, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, + DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, IsConcrete, ParentAsSuperuser, + ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + UsingComponents, WeightInfoBounds, WithComputedOrigin, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -132,28 +129,29 @@ impl Contains for SafeCallFilter { } } - match call { + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true, - _ => false, - } + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. } | + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) + ) } } @@ -263,6 +261,8 @@ impl pallet_xcm::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index c87a38c4ec9..26418f38f16 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -11,9 +11,9 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } hex-literal = { version = "0.4.1" } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } -serde = { version = "1.0.160", optional = true, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } +serde = { version = "1.0.163", optional = true, features = ["derive"] } smallvec = "1.8.1" # Substrate @@ -72,14 +72,43 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } parachains-common = { path = "../../../../parachains/common", default-features = false } +# Bridges +bp-bridge-hub-rococo = { path = "../../../../bridges/primitives/chain-bridge-hub-rococo", default-features = false } +bp-bridge-hub-wococo = { path = "../../../../bridges/primitives/chain-bridge-hub-wococo", default-features = false } +bp-messages = { path = "../../../../bridges/primitives/messages", default-features = false } +bp-parachains = { path = "../../../../bridges/primitives/parachains", default-features = false } +bp-polkadot-core = { path = "../../../../bridges/primitives/polkadot-core", default-features = false } +bp-relayers = { path = "../../../../bridges/primitives/relayers", default-features = false } +bp-runtime = { path = "../../../../bridges/primitives/runtime", default-features = false } +bp-rococo = { path = "../../../../bridges/primitives/chain-rococo", default-features = false } +bp-wococo = { path = "../../../../bridges/primitives/chain-wococo", default-features = false } +pallet-bridge-grandpa = { path = "../../../../bridges/modules/grandpa", default-features = false } +pallet-bridge-messages = { path = "../../../../bridges/modules/messages", default-features = false } +pallet-bridge-parachains = { path = "../../../../bridges/modules/parachains", default-features = false } +pallet-bridge-relayers = { path = "../../../../bridges/modules/relayers", default-features = false } +bridge-runtime-common = { path = "../../../../bridges/bin/runtime-common", default-features = false } + [dev-dependencies] +static_assertions = "1.1" bridge-hub-test-utils = { path = "../test-utils"} +bridge-runtime-common = { path = "../../../../bridges/bin/runtime-common", features = ["integrity-test"] } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } [features] default = [ "std", ] std = [ + "bp-bridge-hub-rococo/std", + "bp-bridge-hub-wococo/std", + "bp-messages/std", + "bp-parachains/std", + "bp-polkadot-core/std", + "bp-relayers/std", + "bp-runtime/std", + "bp-rococo/std", + "bp-wococo/std", + "bridge-runtime-common/std", "codec/std", "log/std", "scale-info/std", @@ -92,6 +121,7 @@ std = [ "cumulus-primitives-core/std", "cumulus-primitives-timestamp/std", "cumulus-primitives-utility/std", + "frame-benchmarking/std", "frame-executive/std", "frame-support/std", "frame-system-rpc-runtime-api/std", @@ -99,6 +129,10 @@ std = [ "pallet-aura/std", "pallet-authorship/std", "pallet-balances/std", + "pallet-bridge-grandpa/std", + "pallet-bridge-messages/std", + "pallet-bridge-parachains/std", + "pallet-bridge-relayers/std", "pallet-collator-selection/std", "pallet-multisig/std", "pallet-session/std", @@ -132,12 +166,19 @@ std = [ ] runtime-benchmarks = [ + "bridge-runtime-common/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", "pallet-balances/runtime-benchmarks", + "pallet-bridge-grandpa/runtime-benchmarks", + "pallet-bridge-messages/runtime-benchmarks", + "pallet-bridge-parachains/runtime-benchmarks", + "pallet-bridge-relayers/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", + "cumulus-pallet-parachain-system/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", @@ -145,13 +186,16 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", - "pallet-collator-selection/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", "pallet-xcm-benchmarks/runtime-benchmarks", "cumulus-primitives-core/runtime-benchmarks", ] try-runtime = [ + "pallet-bridge-grandpa/try-runtime", + "pallet-bridge-messages/try-runtime", + "pallet-bridge-parachains/try-runtime", + "pallet-bridge-relayers/try-runtime", "cumulus-pallet-aura-ext/try-runtime", "pallet-message-queue/try-runtime", "cumulus-pallet-parachain-system/try-runtime", diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs new file mode 100644 index 00000000000..8a85076e33e --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_rococo_config.rs @@ -0,0 +1,213 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Bridge definitions that are used on Rococo to bridge with Wococo. + +use crate::{ + BridgeParachainWococoInstance, ParachainInfo, Runtime, WithBridgeHubWococoMessagesInstance, + XcmRouter, +}; +use bp_messages::LaneId; +use bridge_runtime_common::{ + messages, + messages::{ + source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, + MessageBridge, ThisChainWithMessages, UnderlyingChainProvider, + }, + messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}, + refund_relayer_extension::{ + ActualFeeRefund, RefundBridgedParachainMessages, RefundableMessagesLane, + RefundableParachain, + }, +}; +use frame_support::{parameter_types, RuntimeDebug}; +use xcm::{ + latest::prelude::*, + prelude::{InteriorMultiLocation, NetworkId}, +}; +use xcm_builder::{BridgeBlobDispatcher, HaulBlobExporter}; + +parameter_types! { + pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce = + bp_bridge_hub_rococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; + pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce = + bp_bridge_hub_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; + pub const BridgeHubWococoChainId: bp_runtime::ChainId = bp_runtime::BRIDGE_HUB_WOCOCO_CHAIN_ID; + pub BridgeHubRococoUniversalLocation: InteriorMultiLocation = X2(GlobalConsensus(Rococo), Parachain(ParachainInfo::parachain_id().into())); + pub WococoGlobalConsensusNetwork: NetworkId = NetworkId::Wococo; + pub ActiveOutboundLanesToBridgeHubWococo: &'static [bp_messages::LaneId] = &[DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO]; + pub PriorityBoostPerMessage: u64 = 921_900_294; +} + +/// Proof of messages, coming from Wococo. +pub type FromWococoBridgeHubMessagesProof = + FromBridgedChainMessagesProof; +/// Messages delivery proof for Rococo Bridge Hub -> Wococo Bridge Hub messages. +pub type ToWococoBridgeHubMessagesDeliveryProof = + FromBridgedChainMessagesDeliveryProof; + +/// Dispatches received XCM messages from other bridge +pub type OnBridgeHubRococoBlobDispatcher = + BridgeBlobDispatcher; + +/// Export XCM messages to be relayed to the otherside +pub type ToBridgeHubWococoHaulBlobExporter = HaulBlobExporter< + XcmBlobHaulerAdapter, + WococoGlobalConsensusNetwork, + (), +>; +pub struct ToBridgeHubWococoXcmBlobHauler; +impl XcmBlobHauler for ToBridgeHubWococoXcmBlobHauler { + type MessageSender = + pallet_bridge_messages::Pallet; + + type MessageSenderOrigin = super::RuntimeOrigin; + + fn message_sender_origin() -> Self::MessageSenderOrigin { + pallet_xcm::Origin::from(MultiLocation::new(1, crate::xcm_config::UniversalLocation::get())) + .into() + } + + fn xcm_lane() -> LaneId { + DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO + } +} +pub const DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO: LaneId = LaneId([0, 0, 0, 1]); + +/// Messaging Bridge configuration for BridgeHubRococo -> BridgeHubWococo +pub struct WithBridgeHubWococoMessageBridge; +impl MessageBridge for WithBridgeHubWococoMessageBridge { + const BRIDGED_MESSAGES_PALLET_NAME: &'static str = + bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME; + type ThisChain = BridgeHubRococo; + type BridgedChain = BridgeHubWococo; + type BridgedHeaderChain = pallet_bridge_parachains::ParachainHeaders< + Runtime, + BridgeParachainWococoInstance, + bp_bridge_hub_wococo::BridgeHubWococo, + >; +} + +/// Message verifier for BridgeHubWococo messages sent from BridgeHubRococo +pub type ToBridgeHubWococoMessageVerifier = + messages::source::FromThisChainMessageVerifier; + +/// Maximal outbound payload size of BridgeHubRococo -> BridgeHubWococo messages. +pub type ToBridgeHubWococoMaximalOutboundPayloadSize = + messages::source::FromThisChainMaximalOutboundPayloadSize; + +/// BridgeHubWococo chain from message lane point of view. +#[derive(RuntimeDebug, Clone, Copy)] +pub struct BridgeHubWococo; + +impl UnderlyingChainProvider for BridgeHubWococo { + type Chain = bp_bridge_hub_wococo::BridgeHubWococo; +} + +impl messages::BridgedChainWithMessages for BridgeHubWococo {} + +/// BridgeHubRococo chain from message lane point of view. +#[derive(RuntimeDebug, Clone, Copy)] +pub struct BridgeHubRococo; + +impl UnderlyingChainProvider for BridgeHubRococo { + type Chain = bp_bridge_hub_rococo::BridgeHubRococo; +} + +impl ThisChainWithMessages for BridgeHubRococo { + type RuntimeOrigin = crate::RuntimeOrigin; +} + +/// Signed extension that refunds relayers that are delivering messages from the Wococo parachain. +pub type BridgeRefundBridgeHubWococoMessages = RefundBridgedParachainMessages< + Runtime, + RefundableParachain, + RefundableMessagesLane, + ActualFeeRefund, + PriorityBoostPerMessage, + StrBridgeRefundBridgeHubWococoMessages, +>; +bp_runtime::generate_static_str_provider!(BridgeRefundBridgeHubWococoMessages); + +parameter_types! { + pub const BridgeHubWococoMessagesLane: bp_messages::LaneId = DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO; +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::BridgeGrandpaWococoInstance; + use bridge_runtime_common::{ + assert_complete_bridge_types, + integrity::{ + assert_complete_bridge_constants, check_message_lane_weights, + AssertBridgeMessagesPalletConstants, AssertBridgePalletNames, AssertChainConstants, + AssertCompleteBridgeConstants, + }, + }; + + #[test] + fn ensure_bridge_hub_rococo_message_lane_weights_are_correct() { + check_message_lane_weights::< + bp_bridge_hub_rococo::BridgeHubRococo, + Runtime, + WithBridgeHubWococoMessagesInstance, + >( + bp_bridge_hub_wococo::EXTRA_STORAGE_PROOF_SIZE, + bp_bridge_hub_rococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, + bp_bridge_hub_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + true, + ); + } + + #[test] + fn ensure_bridge_integrity() { + assert_complete_bridge_types!( + runtime: Runtime, + with_bridged_chain_grandpa_instance: BridgeGrandpaWococoInstance, + with_bridged_chain_messages_instance: WithBridgeHubWococoMessagesInstance, + bridge: WithBridgeHubWococoMessageBridge, + this_chain: bp_rococo::Rococo, + bridged_chain: bp_wococo::Wococo, + ); + + assert_complete_bridge_constants::< + Runtime, + BridgeGrandpaWococoInstance, + WithBridgeHubWococoMessagesInstance, + WithBridgeHubWococoMessageBridge, + >(AssertCompleteBridgeConstants { + this_chain_constants: AssertChainConstants { + block_length: bp_bridge_hub_rococo::BlockLength::get(), + block_weights: bp_bridge_hub_rococo::BlockWeights::get(), + }, + messages_pallet_constants: AssertBridgeMessagesPalletConstants { + max_unrewarded_relayers_in_bridged_confirmation_tx: + bp_bridge_hub_wococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, + max_unconfirmed_messages_in_bridged_confirmation_tx: + bp_bridge_hub_wococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + bridged_chain_id: bp_runtime::BRIDGE_HUB_WOCOCO_CHAIN_ID, + }, + pallet_names: AssertBridgePalletNames { + with_this_chain_messages_pallet_name: + bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME, + with_bridged_chain_grandpa_pallet_name: bp_wococo::WITH_WOCOCO_GRANDPA_PALLET_NAME, + with_bridged_chain_messages_pallet_name: + bp_bridge_hub_wococo::WITH_BRIDGE_HUB_WOCOCO_MESSAGES_PALLET_NAME, + }, + }); + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs new file mode 100644 index 00000000000..025486d43ca --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_hub_wococo_config.rs @@ -0,0 +1,213 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Bridge definitions that are used on Wococo to bridge with Rococo. + +use crate::{ + BridgeParachainRococoInstance, ParachainInfo, Runtime, WithBridgeHubRococoMessagesInstance, + XcmRouter, +}; +use bp_messages::LaneId; +use bridge_runtime_common::{ + messages, + messages::{ + source::FromBridgedChainMessagesDeliveryProof, target::FromBridgedChainMessagesProof, + MessageBridge, ThisChainWithMessages, UnderlyingChainProvider, + }, + messages_xcm_extension::{XcmBlobHauler, XcmBlobHaulerAdapter}, + refund_relayer_extension::{ + ActualFeeRefund, RefundBridgedParachainMessages, RefundableMessagesLane, + RefundableParachain, + }, +}; +use frame_support::{parameter_types, RuntimeDebug}; +use xcm::{ + latest::prelude::*, + prelude::{InteriorMultiLocation, NetworkId}, +}; +use xcm_builder::{BridgeBlobDispatcher, HaulBlobExporter}; + +parameter_types! { + pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce = + bp_bridge_hub_wococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX; + pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce = + bp_bridge_hub_wococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX; + pub const BridgeHubRococoChainId: bp_runtime::ChainId = bp_runtime::BRIDGE_HUB_ROCOCO_CHAIN_ID; + pub BridgeHubWococoUniversalLocation: InteriorMultiLocation = X2(GlobalConsensus(Wococo), Parachain(ParachainInfo::parachain_id().into())); + pub RococoGlobalConsensusNetwork: NetworkId = NetworkId::Rococo; + pub ActiveOutboundLanesToBridgeHubRococo: &'static [bp_messages::LaneId] = &[DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO]; + pub PriorityBoostPerMessage: u64 = 921_900_294; +} + +/// Proof of messages, coming from Rococo. +pub type FromRococoBridgeHubMessagesProof = + FromBridgedChainMessagesProof; +/// Messages delivery proof for Rococo Bridge Hub -> Wococo Bridge Hub messages. +pub type ToRococoBridgeHubMessagesDeliveryProof = + FromBridgedChainMessagesDeliveryProof; + +/// Dispatches received XCM messages from other bridge +pub type OnBridgeHubWococoBlobDispatcher = + BridgeBlobDispatcher; + +/// Export XCM messages to be relayed to the otherside +pub type ToBridgeHubRococoHaulBlobExporter = HaulBlobExporter< + XcmBlobHaulerAdapter, + RococoGlobalConsensusNetwork, + (), +>; +pub struct ToBridgeHubRococoXcmBlobHauler; +impl XcmBlobHauler for ToBridgeHubRococoXcmBlobHauler { + type MessageSender = + pallet_bridge_messages::Pallet; + + type MessageSenderOrigin = super::RuntimeOrigin; + + fn message_sender_origin() -> super::RuntimeOrigin { + pallet_xcm::Origin::from(MultiLocation::new(1, crate::xcm_config::UniversalLocation::get())) + .into() + } + + fn xcm_lane() -> LaneId { + DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO + } +} +pub const DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO: LaneId = LaneId([0, 0, 0, 1]); + +/// Messaging Bridge configuration for BridgeHubWococo -> BridgeHubRococo +pub struct WithBridgeHubRococoMessageBridge; +impl MessageBridge for WithBridgeHubRococoMessageBridge { + const BRIDGED_MESSAGES_PALLET_NAME: &'static str = + bp_bridge_hub_wococo::WITH_BRIDGE_HUB_WOCOCO_MESSAGES_PALLET_NAME; + type ThisChain = BridgeHubWococo; + type BridgedChain = BridgeHubRococo; + type BridgedHeaderChain = pallet_bridge_parachains::ParachainHeaders< + Runtime, + BridgeParachainRococoInstance, + bp_bridge_hub_rococo::BridgeHubRococo, + >; +} + +/// Message verifier for BridgeHubRococo messages sent from BridgeHubWococo +pub type ToBridgeHubRococoMessageVerifier = + messages::source::FromThisChainMessageVerifier; + +/// Maximal outbound payload size of BridgeHubWococo -> BridgeHubRococo messages. +pub type ToBridgeHubRococoMaximalOutboundPayloadSize = + messages::source::FromThisChainMaximalOutboundPayloadSize; + +/// BridgeHubRococo chain from message lane point of view. +#[derive(RuntimeDebug, Clone, Copy)] +pub struct BridgeHubRococo; + +impl UnderlyingChainProvider for BridgeHubRococo { + type Chain = bp_bridge_hub_rococo::BridgeHubRococo; +} + +impl messages::BridgedChainWithMessages for BridgeHubRococo {} + +/// BridgeHubWococo chain from message lane point of view. +#[derive(RuntimeDebug, Clone, Copy)] +pub struct BridgeHubWococo; + +impl UnderlyingChainProvider for BridgeHubWococo { + type Chain = bp_bridge_hub_wococo::BridgeHubWococo; +} + +impl ThisChainWithMessages for BridgeHubWococo { + type RuntimeOrigin = crate::RuntimeOrigin; +} + +/// Signed extension that refunds relayers that are delivering messages from the Rococo parachain. +pub type BridgeRefundBridgeHubRococoMessages = RefundBridgedParachainMessages< + Runtime, + RefundableParachain, + RefundableMessagesLane, + ActualFeeRefund, + PriorityBoostPerMessage, + StrBridgeRefundBridgeHubRococoMessages, +>; +bp_runtime::generate_static_str_provider!(BridgeRefundBridgeHubRococoMessages); + +parameter_types! { + pub const BridgeHubRococoMessagesLane: bp_messages::LaneId = DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO; +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::BridgeGrandpaRococoInstance; + use bridge_runtime_common::{ + assert_complete_bridge_types, + integrity::{ + assert_complete_bridge_constants, check_message_lane_weights, + AssertBridgeMessagesPalletConstants, AssertBridgePalletNames, AssertChainConstants, + AssertCompleteBridgeConstants, + }, + }; + + #[test] + fn ensure_bridge_hub_wococo_message_lane_weights_are_correct() { + check_message_lane_weights::< + bp_bridge_hub_wococo::BridgeHubWococo, + Runtime, + WithBridgeHubRococoMessagesInstance, + >( + bp_bridge_hub_rococo::EXTRA_STORAGE_PROOF_SIZE, + bp_bridge_hub_wococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, + bp_bridge_hub_wococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + true, + ); + } + + #[test] + fn ensure_bridge_integrity() { + assert_complete_bridge_types!( + runtime: Runtime, + with_bridged_chain_grandpa_instance: BridgeGrandpaRococoInstance, + with_bridged_chain_messages_instance: WithBridgeHubRococoMessagesInstance, + bridge: WithBridgeHubRococoMessageBridge, + this_chain: bp_wococo::Wococo, + bridged_chain: bp_rococo::Rococo, + ); + + assert_complete_bridge_constants::< + Runtime, + BridgeGrandpaRococoInstance, + WithBridgeHubRococoMessagesInstance, + WithBridgeHubRococoMessageBridge, + >(AssertCompleteBridgeConstants { + this_chain_constants: AssertChainConstants { + block_length: bp_bridge_hub_wococo::BlockLength::get(), + block_weights: bp_bridge_hub_wococo::BlockWeights::get(), + }, + messages_pallet_constants: AssertBridgeMessagesPalletConstants { + max_unrewarded_relayers_in_bridged_confirmation_tx: + bp_bridge_hub_rococo::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, + max_unconfirmed_messages_in_bridged_confirmation_tx: + bp_bridge_hub_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, + bridged_chain_id: bp_runtime::BRIDGE_HUB_ROCOCO_CHAIN_ID, + }, + pallet_names: AssertBridgePalletNames { + with_this_chain_messages_pallet_name: + bp_bridge_hub_wococo::WITH_BRIDGE_HUB_WOCOCO_MESSAGES_PALLET_NAME, + with_bridged_chain_grandpa_pallet_name: bp_rococo::WITH_ROCOCO_GRANDPA_PALLET_NAME, + with_bridged_chain_messages_pallet_name: + bp_bridge_hub_rococo::WITH_BRIDGE_HUB_ROCOCO_MESSAGES_PALLET_NAME, + }, + }); + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/constants.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/constants.rs index 86cf8d6f7d3..ba80cd2b6da 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/constants.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/constants.rs @@ -22,6 +22,7 @@ pub mod currency { pub const UNITS: Balance = constants::currency::UNITS; pub const CENTS: Balance = constants::currency::CENTS; + pub const MILLICENTS: Balance = constants::currency::MILLICENTS; pub const fn deposit(items: u32, bytes: u32) -> Balance { // map to 1/100 of what the rococo relay chain charges diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index a8cf047a467..84a5eb71648 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -22,12 +22,14 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +pub mod bridge_hub_rococo_config; +pub mod bridge_hub_wococo_config; pub mod constants; mod weights; pub mod xcm_config; +use constants::currency::*; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -use smallvec::smallvec; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ @@ -42,40 +44,51 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use constants::currency::*; use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use frame_support::{ construct_runtime, dispatch::DispatchClass, - pallet_prelude::Weight, parameter_types, traits::{ConstU32, ConstU64, ConstU8, Everything, TransformOrigin}, - weights::{ - ConstantMultiplier, FeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, - WeightToFeePolynomial, - }, + weights::{ConstantMultiplier, Weight}, PalletId, }; use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, }; -use parachains_common::process_xcm_message::{ - ParaIdToSibling, ProcessFromSibling, ProcessXcmMessage, -}; +use parachains_common::process_xcm_message::{ParaIdToSibling, ProcessFromSibling}; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; +use xcm_builder::ProcessXcmMessage; use xcm_config::XcmOriginToTransactDispatchOrigin; +use bp_parachains::SingleParaStoredHeaderDataBuilder; +use bp_runtime::HeaderId; + #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -// Polkadot imports use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; -// XCM Imports +use crate::{ + bridge_hub_rococo_config::{ + BridgeRefundBridgeHubWococoMessages, OnBridgeHubRococoBlobDispatcher, + WithBridgeHubWococoMessageBridge, + }, + bridge_hub_wococo_config::{ + BridgeRefundBridgeHubRococoMessages, OnBridgeHubWococoBlobDispatcher, + WithBridgeHubRococoMessageBridge, + }, + constants::fee::WeightToFee, + xcm_config::XcmRouter, +}; +use bridge_runtime_common::{ + messages::{source::TargetHeaderChainAdapter, target::SourceHeaderChainAdapter}, + messages_xcm_extension::{XcmAsPlainPayload, XcmBlobMessageDispatch}, +}; use parachains_common::{ impls::DealWithFees, opaque, AccountId, Balance, BlockNumber, Hash, Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, @@ -103,14 +116,16 @@ pub type SignedExtra = ( frame_system::CheckNonce, frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, + BridgeRejectObsoleteHeadersAndMessages, + (BridgeRefundBridgeHubRococoMessages, BridgeRefundBridgeHubWococoMessages), ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; +/// Migrations to apply on runtime upgrade. +pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1,); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -119,66 +134,9 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, + Migrations, >; -/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the -/// node's balance type. -/// -/// This should typically create a mapping between the following ranges: -/// - `[0, MAXIMUM_BLOCK_WEIGHT]` -/// - `[Balance::min, Balance::max]` -/// -/// Yet, it can be used for any other sort of change to weight-fee. Some examples being: -/// - Setting it to `0` will essentially disable the weight fee. -/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. -pub struct WeightToFee; -impl frame_support::weights::WeightToFee for WeightToFee { - type Balance = Balance; - - fn weight_to_fee(weight: &Weight) -> Self::Balance { - let time_poly: FeePolynomial = RefTimeToFee::polynomial().into(); - let proof_poly: FeePolynomial = ProofSizeToFee::polynomial().into(); - - // Take the maximum instead of the sum to charge by the more scarce resource. - time_poly.eval(weight.ref_time()).max(proof_poly.eval(weight.proof_size())) - } -} - -/// Maps the reference time component of `Weight` to a fee. -pub struct RefTimeToFee; -impl WeightToFeePolynomial for RefTimeToFee { - type Balance = Balance; - fn polynomial() -> WeightToFeeCoefficients { - let p = MILLIUNIT / 10; - let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); - - smallvec![WeightToFeeCoefficient { - degree: 1, - negative: false, - coeff_frac: Perbill::from_rational(p % q, q), - coeff_integer: p / q, - }] - } -} - -/// Maps the proof size component of `Weight` to a fee. -pub struct ProofSizeToFee; -impl WeightToFeePolynomial for ProofSizeToFee { - type Balance = Balance; - fn polynomial() -> WeightToFeeCoefficients { - // Map 10kb proof to 1/10 MILLIUNIT. - let p = MILLIUNIT / 10; - let q = 10_000; - - smallvec![WeightToFeeCoefficient { - degree: 1, - negative: false, - coeff_frac: Perbill::from_rational(p % q, q), - coeff_integer: p / q, - }] - } -} - impl_opaque_keys! { pub struct SessionKeys { pub aura: Aura, @@ -190,20 +148,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("bridge-hub-rococo"), impl_name: create_runtime_str!("bridge-hub-rococo"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 3, state_version: 1, }; -// Unit = the base number of indivisible units for balances -pub const MILLIUNIT: Balance = 1_000_000_000; -pub const MICROUNIT: Balance = 1_000_000; - -/// The existential deposit. Set to 1/10 of the Connected Relay Chain. -pub const EXISTENTIAL_DEPOSIT: Balance = MILLIUNIT; - /// The version information used to identify this runtime when compiled natively. #[cfg(feature = "std")] pub fn native_version() -> NativeVersion { @@ -284,7 +235,7 @@ impl frame_system::Config for Runtime { type SS58Prefix = SS58Prefix; /// The action to take on a Runtime Upgrade type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; - type MaxConsumers = ConstU32<16>; + type MaxConsumers = frame_support::traits::ConstU32<16>; } impl pallet_timestamp::Config for Runtime { @@ -316,7 +267,7 @@ impl pallet_balances::Config for Runtime { type MaxLocks = ConstU32<50>; type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -324,7 +275,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 10 * MICROUNIT; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -481,6 +432,153 @@ impl pallet_utility::Config for Runtime { type WeightInfo = weights::pallet_utility::WeightInfo; } +// Add bridge pallets (GPA) + +/// Add GRANDPA bridge pallet to track Wococo relay chain on Rococo BridgeHub +pub type BridgeGrandpaWococoInstance = pallet_bridge_grandpa::Instance1; +impl pallet_bridge_grandpa::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type BridgedChain = bp_wococo::Wococo; + type MaxFreeMandatoryHeadersPerBlock = ConstU32<4>; + type HeadersToKeep = RelayChainHeadersToKeep; + type WeightInfo = weights::pallet_bridge_grandpa_bridge_wococo_grandpa::WeightInfo; +} + +/// Add GRANDPA bridge pallet to track Rococo relay chain on Wococo BridgeHub +pub type BridgeGrandpaRococoInstance = pallet_bridge_grandpa::Instance2; +impl pallet_bridge_grandpa::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type BridgedChain = bp_rococo::Rococo; + type MaxFreeMandatoryHeadersPerBlock = ConstU32<4>; + type HeadersToKeep = RelayChainHeadersToKeep; + type WeightInfo = weights::pallet_bridge_grandpa_bridge_rococo_grandpa::WeightInfo; +} + +parameter_types! { + pub const RelayChainHeadersToKeep: u32 = 1024; + pub const ParachainHeadsToKeep: u32 = 64; + pub const RelayerStakeLease: u32 = 8; + + pub const RococoBridgeParachainPalletName: &'static str = "Paras"; + pub const WococoBridgeParachainPalletName: &'static str = "Paras"; + pub const MaxRococoParaHeadDataSize: u32 = bp_rococo::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE; + pub const MaxWococoParaHeadDataSize: u32 = bp_wococo::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE; + + pub storage DeliveryRewardInBalance: u64 = 1_000_000; + pub storage RequiredStakeForStakeAndSlash: Balance = 1_000_000; + + pub const RelayerStakeReserveId: [u8; 8] = *b"brdgrlrs"; +} + +/// Add parachain bridge pallet to track Wococo bridge hub parachain +pub type BridgeParachainWococoInstance = pallet_bridge_parachains::Instance1; +impl pallet_bridge_parachains::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance::WeightInfo; + type BridgesGrandpaPalletInstance = BridgeGrandpaWococoInstance; + type ParasPalletName = WococoBridgeParachainPalletName; + type ParaStoredHeaderDataBuilder = + SingleParaStoredHeaderDataBuilder; + type HeadsToKeep = ParachainHeadsToKeep; + type MaxParaHeadDataSize = MaxWococoParaHeadDataSize; +} + +/// Add parachain bridge pallet to track Rococo bridge hub parachain +pub type BridgeParachainRococoInstance = pallet_bridge_parachains::Instance2; +impl pallet_bridge_parachains::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance::WeightInfo; + type BridgesGrandpaPalletInstance = BridgeGrandpaRococoInstance; + type ParasPalletName = RococoBridgeParachainPalletName; + type ParaStoredHeaderDataBuilder = + SingleParaStoredHeaderDataBuilder; + type HeadsToKeep = ParachainHeadsToKeep; + type MaxParaHeadDataSize = MaxRococoParaHeadDataSize; +} + +/// Add XCM messages support for BridgeHubRococo to support Rococo->Wococo XCM messages +pub type WithBridgeHubWococoMessagesInstance = pallet_bridge_messages::Instance1; +impl pallet_bridge_messages::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance::WeightInfo; + type BridgedChainId = bridge_hub_rococo_config::BridgeHubWococoChainId; + type ActiveOutboundLanes = bridge_hub_rococo_config::ActiveOutboundLanesToBridgeHubWococo; + type MaxUnrewardedRelayerEntriesAtInboundLane = + bridge_hub_rococo_config::MaxUnrewardedRelayerEntriesAtInboundLane; + type MaxUnconfirmedMessagesAtInboundLane = + bridge_hub_rococo_config::MaxUnconfirmedMessagesAtInboundLane; + + type MaximalOutboundPayloadSize = + bridge_hub_rococo_config::ToBridgeHubWococoMaximalOutboundPayloadSize; + type OutboundPayload = XcmAsPlainPayload; + + type InboundPayload = XcmAsPlainPayload; + type InboundRelayer = AccountId; + type DeliveryPayments = (); + + type TargetHeaderChain = TargetHeaderChainAdapter; + type LaneMessageVerifier = bridge_hub_rococo_config::ToBridgeHubWococoMessageVerifier; + type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter< + Runtime, + WithBridgeHubWococoMessagesInstance, + DeliveryRewardInBalance, + >; + + type SourceHeaderChain = SourceHeaderChainAdapter; + type MessageDispatch = + XcmBlobMessageDispatch; +} + +/// Add XCM messages support for BridgeHubWococo to support Wococo->Rococo XCM messages +pub type WithBridgeHubRococoMessagesInstance = pallet_bridge_messages::Instance2; +impl pallet_bridge_messages::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance::WeightInfo; + type BridgedChainId = bridge_hub_wococo_config::BridgeHubRococoChainId; + type ActiveOutboundLanes = bridge_hub_wococo_config::ActiveOutboundLanesToBridgeHubRococo; + type MaxUnrewardedRelayerEntriesAtInboundLane = + bridge_hub_wococo_config::MaxUnrewardedRelayerEntriesAtInboundLane; + type MaxUnconfirmedMessagesAtInboundLane = + bridge_hub_wococo_config::MaxUnconfirmedMessagesAtInboundLane; + + type MaximalOutboundPayloadSize = + bridge_hub_wococo_config::ToBridgeHubRococoMaximalOutboundPayloadSize; + type OutboundPayload = XcmAsPlainPayload; + + type InboundPayload = XcmAsPlainPayload; + type InboundRelayer = AccountId; + type DeliveryPayments = (); + + type TargetHeaderChain = TargetHeaderChainAdapter; + type LaneMessageVerifier = bridge_hub_wococo_config::ToBridgeHubRococoMessageVerifier; + type DeliveryConfirmationPayments = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter< + Runtime, + WithBridgeHubRococoMessagesInstance, + DeliveryRewardInBalance, + >; + + type SourceHeaderChain = SourceHeaderChainAdapter; + type MessageDispatch = + XcmBlobMessageDispatch; +} + +/// Allows collect and claim rewards for relayers +impl pallet_bridge_relayers::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Reward = Balance; + type PaymentProcedure = + bp_relayers::PayRewardFromAccount, AccountId>; + type StakeAndSlash = pallet_bridge_relayers::StakeAndSlashNamed< + AccountId, + BlockNumber, + Balances, + RelayerStakeReserveId, + RequiredStakeForStakeAndSlash, + RelayerStakeLease, + >; + type WeightInfo = weights::pallet_bridge_relayers::WeightInfo; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -515,10 +613,36 @@ construct_runtime!( // Handy utilities. Utility: pallet_utility::{Pallet, Call, Event} = 40, - Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 41, + Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 36, + + // Rococo and Wococo Bridge Hubs are sharing the runtime, so this runtime has two sets of + // bridge pallets. Both are deployed at both runtimes, but only one set is actually used + // at particular runtime. + + // With-Wococo bridge modules that are active (used) at Rococo Bridge Hub runtime. + BridgeWococoGrandpa: pallet_bridge_grandpa::::{Pallet, Call, Storage, Event, Config} = 41, + BridgeWococoParachain: pallet_bridge_parachains::::{Pallet, Call, Storage, Event} = 42, + BridgeWococoMessages: pallet_bridge_messages::::{Pallet, Call, Storage, Event, Config} = 46, + + // With-Rococo bridge modules that are active (used) at Wococo Bridge Hub runtime. + BridgeRococoGrandpa: pallet_bridge_grandpa::::{Pallet, Call, Storage, Event, Config} = 43, + BridgeRococoParachain: pallet_bridge_parachains::::{Pallet, Call, Storage, Event} = 44, + BridgeRococoMessages: pallet_bridge_messages::::{Pallet, Call, Storage, Event, Config} = 45, + + BridgeRelayers: pallet_bridge_relayers::{Pallet, Call, Storage, Event} = 47, } ); +bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! { + RuntimeCall, AccountId, + // Grandpa + BridgeRococoGrandpa, BridgeWococoGrandpa, + // Parachains + BridgeRococoParachain, BridgeWococoParachain, + // Messages + BridgeRococoMessages, BridgeWococoMessages +} + #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -537,6 +661,16 @@ mod benches { // NOTE: Make sure you point to the individual modules below. [pallet_xcm_benchmarks::fungible, XcmBalances] [pallet_xcm_benchmarks::generic, XcmGeneric] + // Bridge pallets at Rococo + [pallet_bridge_grandpa, BridgeWococoGrandpa] + [pallet_bridge_parachains, BridgeParachainsBench::] + [pallet_bridge_messages, BridgeMessagesBench::] + // Bridge pallets at Wococo + [pallet_bridge_grandpa, BridgeRococoGrandpa] + [pallet_bridge_parachains, BridgeParachainsBench::] + [pallet_bridge_messages, BridgeMessagesBench::] + // Bridge relayer pallets + [pallet_bridge_relayers, BridgeRelayersBench::] ); } @@ -661,6 +795,89 @@ impl_runtime_apis! { } } + impl bp_rococo::RococoFinalityApi for Runtime { + fn best_finalized() -> Option> { + BridgeRococoGrandpa::best_finalized() + } + } + + impl bp_wococo::WococoFinalityApi for Runtime { + fn best_finalized() -> Option> { + BridgeWococoGrandpa::best_finalized() + } + } + + + impl bp_bridge_hub_rococo::BridgeHubRococoFinalityApi for Runtime { + fn best_finalized() -> Option> { + BridgeRococoParachain::best_parachain_head_id::< + bp_bridge_hub_rococo::BridgeHubRococo + >().unwrap_or(None) + } + } + + impl bp_bridge_hub_wococo::BridgeHubWococoFinalityApi for Runtime { + fn best_finalized() -> Option> { + BridgeWococoParachain::best_parachain_head_id::< + bp_bridge_hub_wococo::BridgeHubWococo + >().unwrap_or(None) + } + } + + // This exposed by BridgeHubRococo + impl bp_bridge_hub_wococo::FromBridgeHubWococoInboundLaneApi for Runtime { + fn message_details( + lane: bp_messages::LaneId, + messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>, + ) -> Vec { + bridge_runtime_common::messages_api::inbound_message_details::< + Runtime, + WithBridgeHubWococoMessagesInstance, + >(lane, messages) + } + } + + // This exposed by BridgeHubRococo + impl bp_bridge_hub_wococo::ToBridgeHubWococoOutboundLaneApi for Runtime { + fn message_details( + lane: bp_messages::LaneId, + begin: bp_messages::MessageNonce, + end: bp_messages::MessageNonce, + ) -> Vec { + bridge_runtime_common::messages_api::outbound_message_details::< + Runtime, + WithBridgeHubWococoMessagesInstance, + >(lane, begin, end) + } + } + + // This is exposed by BridgeHubWococo + impl bp_bridge_hub_rococo::FromBridgeHubRococoInboundLaneApi for Runtime { + fn message_details( + lane: bp_messages::LaneId, + messages: Vec<(bp_messages::MessagePayload, bp_messages::OutboundMessageDetails)>, + ) -> Vec { + bridge_runtime_common::messages_api::inbound_message_details::< + Runtime, + WithBridgeHubRococoMessagesInstance, + >(lane, messages) + } + } + + // This is exposed by BridgeHubWococo + impl bp_bridge_hub_rococo::ToBridgeHubRococoOutboundLaneApi for Runtime { + fn message_details( + lane: bp_messages::LaneId, + begin: bp_messages::MessageNonce, + end: bp_messages::MessageNonce, + ) -> Vec { + bridge_runtime_common::messages_api::outbound_message_details::< + Runtime, + WithBridgeHubRococoMessagesInstance, + >(lane, begin, end) + } + } + #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { @@ -697,11 +914,15 @@ impl_runtime_apis! { type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; + use pallet_bridge_parachains::benchmarking::Pallet as BridgeParachainsBench; + use pallet_bridge_messages::benchmarking::Pallet as BridgeMessagesBench; + use pallet_bridge_relayers::benchmarking::Pallet as BridgeRelayersBench; + let mut list = Vec::::new(); list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -739,7 +960,7 @@ impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( RelayLocation::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(RelayLocation::get()) }, + MultiAsset { fun: Fungible(UNITS), id: Concrete(RelayLocation::get()) }, )); pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; } @@ -753,7 +974,7 @@ impl_runtime_apis! { fn get_multi_asset() -> MultiAsset { MultiAsset { id: Concrete(RelayLocation::get()), - fun: Fungible(1 * UNITS), + fun: Fungible(UNITS), } } } @@ -794,13 +1015,183 @@ impl_runtime_apis! { fn export_message_origin_and_destination( ) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> { - Err(BenchmarkError::Skip) + Ok((RelayLocation::get(), NetworkId::Wococo, X1(Parachain(100)))) } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; + use bridge_runtime_common::messages_benchmarking::{prepare_message_delivery_proof_from_parachain, prepare_message_proof_from_parachain}; + use pallet_bridge_messages::benchmarking::{ + Config as BridgeMessagesConfig, + Pallet as BridgeMessagesBench, + MessageDeliveryProofParams, + MessageProofParams, + }; + + impl BridgeMessagesConfig for Runtime { + fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool { + let bench_lane_id = >::bench_lane_id(); + let bridged_chain_id = bp_runtime::BRIDGE_HUB_WOCOCO_CHAIN_ID; + pallet_bridge_relayers::Pallet::::relayer_reward( + relayer, + bp_relayers::RewardsAccountParams::new( + bench_lane_id, + bridged_chain_id, + bp_relayers::RewardsAccountOwner::BridgedChain + ) + ).is_some() + } + + fn prepare_message_proof( + params: MessageProofParams, + ) -> (bridge_hub_rococo_config::FromWococoBridgeHubMessagesProof, Weight) { + use cumulus_primitives_core::XcmpMessageSource; + assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty()); + ParachainSystem::open_outbound_hrmp_channel_for_benchmarks(42.into()); + prepare_message_proof_from_parachain::< + Runtime, + BridgeGrandpaWococoInstance, + bridge_hub_rococo_config::WithBridgeHubWococoMessageBridge, + >(params, X2(GlobalConsensus(Rococo), Parachain(42))) + } + + fn prepare_message_delivery_proof( + params: MessageDeliveryProofParams, + ) -> bridge_hub_rococo_config::ToWococoBridgeHubMessagesDeliveryProof { + prepare_message_delivery_proof_from_parachain::< + Runtime, + BridgeGrandpaWococoInstance, + bridge_hub_rococo_config::WithBridgeHubWococoMessageBridge, + >(params) + } + + fn is_message_successfully_dispatched(_nonce: bp_messages::MessageNonce) -> bool { + use cumulus_primitives_core::XcmpMessageSource; + !XcmpQueue::take_outbound_messages(usize::MAX).is_empty() + } + } + + impl BridgeMessagesConfig for Runtime { + fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool { + let bench_lane_id = >::bench_lane_id(); + let bridged_chain_id = bp_runtime::BRIDGE_HUB_ROCOCO_CHAIN_ID; + pallet_bridge_relayers::Pallet::::relayer_reward( + relayer, + bp_relayers::RewardsAccountParams::new( + bench_lane_id, + bridged_chain_id, + bp_relayers::RewardsAccountOwner::BridgedChain + ) + ).is_some() + } + + fn prepare_message_proof( + params: MessageProofParams, + ) -> (bridge_hub_wococo_config::FromRococoBridgeHubMessagesProof, Weight) { + use cumulus_primitives_core::XcmpMessageSource; + assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty()); + ParachainSystem::open_outbound_hrmp_channel_for_benchmarks(42.into()); + prepare_message_proof_from_parachain::< + Runtime, + BridgeGrandpaRococoInstance, + bridge_hub_wococo_config::WithBridgeHubRococoMessageBridge, + >(params, X2(GlobalConsensus(Wococo), Parachain(42))) + } + + fn prepare_message_delivery_proof( + params: MessageDeliveryProofParams, + ) -> bridge_hub_wococo_config::ToRococoBridgeHubMessagesDeliveryProof { + prepare_message_delivery_proof_from_parachain::< + Runtime, + BridgeGrandpaRococoInstance, + bridge_hub_wococo_config::WithBridgeHubRococoMessageBridge, + >(params) + } + + fn is_message_successfully_dispatched(_nonce: bp_messages::MessageNonce) -> bool { + use cumulus_primitives_core::XcmpMessageSource; + !XcmpQueue::take_outbound_messages(usize::MAX).is_empty() + } + } + + use bridge_runtime_common::parachains_benchmarking::prepare_parachain_heads_proof; + use pallet_bridge_parachains::benchmarking::{ + Config as BridgeParachainsConfig, + Pallet as BridgeParachainsBench, + }; + use pallet_bridge_relayers::benchmarking::{ + Pallet as BridgeRelayersBench, + Config as BridgeRelayersConfig, + }; + + impl BridgeParachainsConfig for Runtime { + fn parachains() -> Vec { + use bp_runtime::Parachain; + vec![bp_polkadot_core::parachains::ParaId(bp_bridge_hub_wococo::BridgeHubWococo::PARACHAIN_ID)] + } + + fn prepare_parachain_heads_proof( + parachains: &[bp_polkadot_core::parachains::ParaId], + parachain_head_size: u32, + proof_size: bp_runtime::StorageProofSize, + ) -> ( + pallet_bridge_parachains::RelayBlockNumber, + pallet_bridge_parachains::RelayBlockHash, + bp_polkadot_core::parachains::ParaHeadsProof, + Vec<(bp_polkadot_core::parachains::ParaId, bp_polkadot_core::parachains::ParaHash)>, + ) { + prepare_parachain_heads_proof::( + parachains, + parachain_head_size, + proof_size, + ) + } + } + + impl BridgeParachainsConfig for Runtime { + fn parachains() -> Vec { + use bp_runtime::Parachain; + vec![bp_polkadot_core::parachains::ParaId(bp_bridge_hub_rococo::BridgeHubRococo::PARACHAIN_ID)] + } + + fn prepare_parachain_heads_proof( + parachains: &[bp_polkadot_core::parachains::ParaId], + parachain_head_size: u32, + proof_size: bp_runtime::StorageProofSize, + ) -> ( + pallet_bridge_parachains::RelayBlockNumber, + pallet_bridge_parachains::RelayBlockHash, + bp_polkadot_core::parachains::ParaHeadsProof, + Vec<(bp_polkadot_core::parachains::ParaId, bp_polkadot_core::parachains::ParaHash)>, + ) { + prepare_parachain_heads_proof::( + parachains, + parachain_head_size, + proof_size, + ) + } + } + + impl BridgeRelayersConfig for Runtime { + fn prepare_rewards_account( + account_params: bp_relayers::RewardsAccountParams, + reward: Balance, + ) { + let rewards_account = bp_relayers::PayRewardFromAccount::< + Balances, + AccountId + >::rewards_account(account_params); + Self::deposit_account(rewards_account, reward); + } + + fn deposit_account(account: AccountId, balance: Balance) { + use frame_support::traits::fungible::Mutate; + Balances::mint_into(&account, balance.saturating_add(ExistentialDeposit::get())).unwrap(); + } + } + let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), @@ -851,3 +1242,59 @@ cumulus_pallet_parachain_system::register_validate_block! { BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, CheckInherents = CheckInherents, } + +#[cfg(test)] +mod tests { + use super::*; + use bp_runtime::TransactionEra; + use bridge_hub_test_utils::test_header; + use codec::Encode; + + pub type TestBlockHeader = + sp_runtime::generic::Header; + + #[test] + fn ensure_signed_extension_definition_is_compatible_with_relay() { + let payload: SignedExtra = ( + frame_system::CheckNonZeroSender::new(), + frame_system::CheckSpecVersion::new(), + frame_system::CheckTxVersion::new(), + frame_system::CheckGenesis::new(), + frame_system::CheckEra::from(sp_runtime::generic::Era::Immortal), + frame_system::CheckNonce::from(10), + frame_system::CheckWeight::new(), + pallet_transaction_payment::ChargeTransactionPayment::from(10), + BridgeRejectObsoleteHeadersAndMessages {}, + ( + BridgeRefundBridgeHubRococoMessages::default(), + BridgeRefundBridgeHubWococoMessages::default(), + ), + ); + + { + use bp_bridge_hub_rococo::BridgeHubSignedExtension; + let bhr_indirect_payload = bp_bridge_hub_rococo::SignedExtension::from_params( + 10, + 10, + TransactionEra::Immortal, + test_header::(1).hash(), + 10, + 10, + ); + assert_eq!(payload.encode(), bhr_indirect_payload.encode()); + } + + { + use bp_bridge_hub_wococo::BridgeHubSignedExtension; + let bhw_indirect_payload = bp_bridge_hub_wococo::SignedExtension::from_params( + 10, + 10, + TransactionEra::Immortal, + test_header::(1).hash(), + 10, + 10, + ); + assert_eq!(payload.encode(), bhw_indirect_payload.encode()); + } + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/cumulus_pallet_xcmp_queue.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/cumulus_pallet_xcmp_queue.rs index 3e580ddf5b8..7422506f4cc 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/cumulus_pallet_xcmp_queue.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/cumulus_pallet_xcmp_queue.rs @@ -31,7 +31,7 @@ // --pallet // cumulus_pallet_xcmp_queue // --extrinsic -// +// // --execution // native // --output @@ -44,9 +44,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_xcmp_queue`. pub struct WeightInfo(PhantomData); diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/frame_system.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/frame_system.rs index ed5e6270415..a7d6083d2a6 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/frame_system.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/frame_system.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `frame_system` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `frame_system`. pub struct WeightInfo(PhantomData); @@ -52,22 +53,25 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_311_000 picoseconds. - Weight::from_parts(2_347_000, 0) + // Minimum execution time: 2_299_000 picoseconds. + Weight::from_parts(2_329_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(370, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(369, 0).saturating_mul(b.into())) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_875_000 picoseconds. - Weight::from_parts(7_972_000, 0) + // Minimum execution time: 7_960_000 picoseconds. + Weight::from_parts(8_041_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_410, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(1_404, 0).saturating_mul(b.into())) + } + fn set_code() -> Weight { + Weight::from_parts(1_000_000, 0) } /// Storage: System Digest (r:1 w:1) /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) @@ -77,8 +81,8 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 4_309_000 picoseconds. - Weight::from_parts(4_457_000, 0) + // Minimum execution time: 4_340_000 picoseconds. + Weight::from_parts(4_506_000, 0) .saturating_add(Weight::from_parts(0, 1485)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -90,11 +94,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_526_000 picoseconds. - Weight::from_parts(2_564_000, 0) + // Minimum execution time: 2_455_000 picoseconds. + Weight::from_parts(2_517_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_869 - .saturating_add(Weight::from_parts(678_765, 0).saturating_mul(i.into())) + // Standard Error: 1_927 + .saturating_add(Weight::from_parts(673_981, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -104,11 +108,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_526_000 picoseconds. - Weight::from_parts(2_603_000, 0) + // Minimum execution time: 2_502_000 picoseconds. + Weight::from_parts(2_546_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 899 - .saturating_add(Weight::from_parts(497_948, 0).saturating_mul(i.into())) + // Standard Error: 839 + .saturating_add(Weight::from_parts(492_306, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -118,11 +122,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `68 + p * (69 ±0)` // Estimated: `66 + p * (70 ±0)` - // Minimum execution time: 4_280_000 picoseconds. - Weight::from_parts(4_398_000, 0) + // Minimum execution time: 4_106_000 picoseconds. + Weight::from_parts(4_196_000, 0) .saturating_add(Weight::from_parts(0, 66)) - // Standard Error: 1_108 - .saturating_add(Weight::from_parts(1_011_188, 0).saturating_mul(p.into())) + // Standard Error: 1_231 + .saturating_add(Weight::from_parts(1_030_791, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs index f6093716b31..5d0f458de53 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/mod.rs @@ -23,6 +23,13 @@ pub mod cumulus_pallet_xcmp_queue; pub mod extrinsic_weights; pub mod frame_system; pub mod pallet_balances; +pub mod pallet_bridge_grandpa_bridge_rococo_grandpa; +pub mod pallet_bridge_grandpa_bridge_wococo_grandpa; +pub mod pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance; +pub mod pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance; +pub mod pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance; +pub mod pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance; +pub mod pallet_bridge_relayers; pub mod pallet_collator_selection; pub mod pallet_message_queue; pub mod pallet_multisig; @@ -38,3 +45,49 @@ pub use block_weights::constants::BlockExecutionWeight; pub use extrinsic_weights::constants::ExtrinsicBaseWeight; pub use paritydb_weights::constants::ParityDbWeight; pub use rocksdb_weights::constants::RocksDbWeight; + +use crate::Runtime; +use frame_support::weights::Weight; + +// import trait from dependency module +use ::pallet_bridge_relayers::WeightInfoExt as _; + +impl pallet_bridge_messages::WeightInfoExt for pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance::WeightInfo { + fn expected_extra_storage_proof_size() -> u32 { + bp_bridge_hub_rococo::EXTRA_STORAGE_PROOF_SIZE + } + + fn receive_messages_proof_overhead_from_runtime() -> Weight { + pallet_bridge_relayers::WeightInfo::::receive_messages_proof_overhead_from_runtime() + } + + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { + pallet_bridge_relayers::WeightInfo::::receive_messages_delivery_proof_overhead_from_runtime() + } +} + +impl pallet_bridge_messages::WeightInfoExt for pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance::WeightInfo { + fn expected_extra_storage_proof_size() -> u32 { + bp_bridge_hub_wococo::EXTRA_STORAGE_PROOF_SIZE + } + + fn receive_messages_proof_overhead_from_runtime() -> Weight { + pallet_bridge_relayers::WeightInfo::::receive_messages_proof_overhead_from_runtime() + } + + fn receive_messages_delivery_proof_overhead_from_runtime() -> Weight { + pallet_bridge_relayers::WeightInfo::::receive_messages_delivery_proof_overhead_from_runtime() + } +} + +impl pallet_bridge_parachains::WeightInfoExt for pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance::WeightInfo { + fn expected_extra_storage_proof_size() -> u32 { + bp_bridge_hub_rococo::EXTRA_STORAGE_PROOF_SIZE + } +} + +impl pallet_bridge_parachains::WeightInfoExt for pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance::WeightInfo { + fn expected_extra_storage_proof_size() -> u32 { + bp_bridge_hub_wococo::EXTRA_STORAGE_PROOF_SIZE + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_balances.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_balances.rs index 5b57a5b7b4d..bba8bf0318e 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_balances.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_balances.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_balances`. pub struct WeightInfo(PhantomData); @@ -53,8 +54,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 35_746_000 picoseconds. - Weight::from_parts(36_167_000, 0) + // Minimum execution time: 54_781_000 picoseconds. + Weight::from_parts(55_287_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -65,8 +66,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 26_301_000 picoseconds. - Weight::from_parts(26_847_000, 0) + // Minimum execution time: 41_473_000 picoseconds. + Weight::from_parts(41_749_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -77,8 +78,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 16_073_000 picoseconds. - Weight::from_parts(16_292_000, 0) + // Minimum execution time: 16_997_000 picoseconds. + Weight::from_parts(17_207_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -89,8 +90,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 19_589_000 picoseconds. - Weight::from_parts(20_034_000, 0) + // Minimum execution time: 23_998_000 picoseconds. + Weight::from_parts(24_245_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -101,8 +102,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `6196` - // Minimum execution time: 37_416_000 picoseconds. - Weight::from_parts(37_894_000, 0) + // Minimum execution time: 56_390_000 picoseconds. + Weight::from_parts(56_963_000, 0) .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -113,25 +114,38 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 32_565_000 picoseconds. - Weight::from_parts(33_087_000, 0) + // Minimum execution time: 50_769_000 picoseconds. + Weight::from_parts(51_077_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn upgrade_accounts(_: u32) -> Weight { - Weight::from_parts(0, 0) - } fn force_unreserve() -> Weight { // Proof Size summary in bytes: // Measured: `174` // Estimated: `3593` - // Minimum execution time: 15_291_000 picoseconds. - Weight::from_parts(15_614_000, 0) + // Minimum execution time: 19_617_000 picoseconds. + Weight::from_parts(19_827_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + u * (136 ±0)` + // Estimated: `990 + u * (2603 ±0)` + // Minimum execution time: 18_453_000 picoseconds. + Weight::from_parts(18_528_000, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 10_749 + .saturating_add(Weight::from_parts(14_321_237, 0).saturating_mul(u.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_rococo_grandpa.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_rococo_grandpa.rs new file mode 100644 index 00000000000..68e540adb7b --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_rococo_grandpa.rs @@ -0,0 +1,80 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_grandpa` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_grandpa +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_bridge_grandpa`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_grandpa::WeightInfo for WeightInfo { + /// Storage: BridgeRococoGrandpa PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoGrandpa PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BridgeRococoGrandpa BestFinalized (r:1 w:1) + /// Proof: BridgeRococoGrandpa BestFinalized (max_values: Some(1), max_size: Some(36), added: 531, mode: MaxEncodedLen) + /// Storage: BridgeRococoGrandpa CurrentAuthoritySet (r:1 w:0) + /// Proof: BridgeRococoGrandpa CurrentAuthoritySet (max_values: Some(1), max_size: Some(50250), added: 50745, mode: MaxEncodedLen) + /// Storage: BridgeRococoGrandpa ImportedHashesPointer (r:1 w:1) + /// Proof: BridgeRococoGrandpa ImportedHashesPointer (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BridgeRococoGrandpa ImportedHashes (r:1 w:1) + /// Proof: BridgeRococoGrandpa ImportedHashes (max_values: Some(1024), max_size: Some(36), added: 1521, mode: MaxEncodedLen) + /// Storage: BridgeRococoGrandpa ImportedHeaders (r:0 w:2) + /// Proof: BridgeRococoGrandpa ImportedHeaders (max_values: Some(1024), max_size: Some(68), added: 1553, mode: MaxEncodedLen) + /// The range of component `p` is `[1, 838]`. + /// The range of component `v` is `[50, 100]`. + /// The range of component `p` is `[1, 838]`. + /// The range of component `v` is `[50, 100]`. + fn submit_finality_proof(p: u32, _v: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `231 + p * (60 ±0)` + // Estimated: `51735` + // Minimum execution time: 224_590_000 picoseconds. + Weight::from_parts(225_581_000, 0) + .saturating_add(Weight::from_parts(0, 51735)) + // Standard Error: 5_887 + .saturating_add(Weight::from_parts(47_424_657, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_wococo_grandpa.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_wococo_grandpa.rs new file mode 100644 index 00000000000..1c3bfb2feef --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_grandpa_bridge_wococo_grandpa.rs @@ -0,0 +1,80 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_grandpa` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_grandpa +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_bridge_grandpa`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_grandpa::WeightInfo for WeightInfo { + /// Storage: BridgeWococoGrandpa PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoGrandpa PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BridgeWococoGrandpa BestFinalized (r:1 w:1) + /// Proof: BridgeWococoGrandpa BestFinalized (max_values: Some(1), max_size: Some(36), added: 531, mode: MaxEncodedLen) + /// Storage: BridgeWococoGrandpa CurrentAuthoritySet (r:1 w:0) + /// Proof: BridgeWococoGrandpa CurrentAuthoritySet (max_values: Some(1), max_size: Some(50250), added: 50745, mode: MaxEncodedLen) + /// Storage: BridgeWococoGrandpa ImportedHashesPointer (r:1 w:1) + /// Proof: BridgeWococoGrandpa ImportedHashesPointer (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BridgeWococoGrandpa ImportedHashes (r:1 w:1) + /// Proof: BridgeWococoGrandpa ImportedHashes (max_values: Some(1024), max_size: Some(36), added: 1521, mode: MaxEncodedLen) + /// Storage: BridgeWococoGrandpa ImportedHeaders (r:0 w:2) + /// Proof: BridgeWococoGrandpa ImportedHeaders (max_values: Some(1024), max_size: Some(68), added: 1553, mode: MaxEncodedLen) + /// The range of component `p` is `[1, 838]`. + /// The range of component `v` is `[50, 100]`. + /// The range of component `p` is `[1, 838]`. + /// The range of component `v` is `[50, 100]`. + fn submit_finality_proof(p: u32, _v: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `268 + p * (60 ±0)` + // Estimated: `51735` + // Minimum execution time: 224_665_000 picoseconds. + Weight::from_parts(225_737_000, 0) + .saturating_add(Weight::from_parts(0, 51735)) + // Standard Error: 5_325 + .saturating_add(Weight::from_parts(47_412_944, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance.rs new file mode 100644 index 00000000000..47d1ec8d47c --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_rococo_messages_instance.rs @@ -0,0 +1,232 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_messages` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_messages +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_bridge_messages`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_messages::WeightInfo for WeightInfo { + /// Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeRococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn receive_single_message_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `367` + // Estimated: `52645` + // Minimum execution time: 42_364_000 picoseconds. + Weight::from_parts(43_780_000, 0) + .saturating_add(Weight::from_parts(0, 52645)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeRococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn receive_two_messages_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `367` + // Estimated: `52645` + // Minimum execution time: 54_010_000 picoseconds. + Weight::from_parts(66_691_000, 0) + .saturating_add(Weight::from_parts(0, 52645)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeRococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn receive_single_message_proof_with_outbound_lane_state() -> Weight { + // Proof Size summary in bytes: + // Measured: `367` + // Estimated: `52645` + // Minimum execution time: 48_066_000 picoseconds. + Weight::from_parts(48_635_000, 0) + .saturating_add(Weight::from_parts(0, 52645)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeRococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_1_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `335` + // Estimated: `52645` + // Minimum execution time: 40_997_000 picoseconds. + Weight::from_parts(41_710_000, 0) + .saturating_add(Weight::from_parts(0, 52645)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeRococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_16_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `335` + // Estimated: `52645` + // Minimum execution time: 67_556_000 picoseconds. + Weight::from_parts(68_573_000, 0) + .saturating_add(Weight::from_parts(0, 52645)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeRococoMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeRococoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Proof Skipped: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + fn receive_delivery_proof_for_single_message() -> Weight { + // Proof Size summary in bytes: + // Measured: `339` + // Estimated: `3804` + // Minimum execution time: 32_221_000 picoseconds. + Weight::from_parts(32_582_000, 0) + .saturating_add(Weight::from_parts(0, 3804)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeRococoMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeRococoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Proof Skipped: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { + // Proof Size summary in bytes: + // Measured: `339` + // Estimated: `3804` + // Minimum execution time: 32_395_000 picoseconds. + Weight::from_parts(32_703_000, 0) + .saturating_add(Weight::from_parts(0, 3804)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeRococoMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeRococoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Proof Skipped: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Storage: BridgeRelayers RelayerRewards (r:2 w:2) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { + // Proof Size summary in bytes: + // Measured: `339` + // Estimated: `6086` + // Minimum execution time: 34_409_000 picoseconds. + Weight::from_parts(34_927_000, 0) + .saturating_add(Weight::from_parts(0, 6086)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: BridgeRococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeRococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeRococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem RelevantMessagingState (r:1 w:0) + /// Proof Skipped: ParachainSystem RelevantMessagingState (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: XcmpQueue OutboundXcmpStatus (r:1 w:1) + /// Proof Skipped: XcmpQueue OutboundXcmpStatus (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: XcmpQueue OutboundXcmpMessages (r:0 w:1) + /// Proof Skipped: XcmpQueue OutboundXcmpMessages (max_values: None, max_size: None, mode: Measured) + /// The range of component `i` is `[128, 2048]`. + /// The range of component `i` is `[128, 2048]`. + fn receive_single_message_proof_with_dispatch(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `635` + // Estimated: `52645` + // Minimum execution time: 129_154_000 picoseconds. + Weight::from_parts(103_525_480, 0) + .saturating_add(Weight::from_parts(0, 52645)) + // Standard Error: 2_595 + .saturating_add(Weight::from_parts(536_761, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance.rs new file mode 100644 index 00000000000..0b2aceb489e --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_messages_bridge_messages_bench_runtime_with_bridge_hub_wococo_messages_instance.rs @@ -0,0 +1,232 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_messages` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_messages +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_bridge_messages`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_messages::WeightInfo for WeightInfo { + /// Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeWococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeWococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn receive_single_message_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `404` + // Estimated: `52645` + // Minimum execution time: 43_745_000 picoseconds. + Weight::from_parts(45_462_000, 0) + .saturating_add(Weight::from_parts(0, 52645)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeWococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeWococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn receive_two_messages_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `404` + // Estimated: `52645` + // Minimum execution time: 55_455_000 picoseconds. + Weight::from_parts(65_023_000, 0) + .saturating_add(Weight::from_parts(0, 52645)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeWococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeWococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn receive_single_message_proof_with_outbound_lane_state() -> Weight { + // Proof Size summary in bytes: + // Measured: `404` + // Estimated: `52645` + // Minimum execution time: 48_603_000 picoseconds. + Weight::from_parts(50_377_000, 0) + .saturating_add(Weight::from_parts(0, 52645)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeWococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeWococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_1_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `372` + // Estimated: `52645` + // Minimum execution time: 42_777_000 picoseconds. + Weight::from_parts(43_499_000, 0) + .saturating_add(Weight::from_parts(0, 52645)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeWococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeWococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + fn receive_single_message_proof_16_kb() -> Weight { + // Proof Size summary in bytes: + // Measured: `372` + // Estimated: `52645` + // Minimum execution time: 69_408_000 picoseconds. + Weight::from_parts(69_916_000, 0) + .saturating_add(Weight::from_parts(0, 52645)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeWococoMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeWococoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Proof Skipped: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + fn receive_delivery_proof_for_single_message() -> Weight { + // Proof Size summary in bytes: + // Measured: `376` + // Estimated: `3841` + // Minimum execution time: 33_122_000 picoseconds. + Weight::from_parts(34_379_000, 0) + .saturating_add(Weight::from_parts(0, 3841)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeWococoMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeWococoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Proof Skipped: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight { + // Proof Size summary in bytes: + // Measured: `376` + // Estimated: `3841` + // Minimum execution time: 33_049_000 picoseconds. + Weight::from_parts(33_747_000, 0) + .saturating_add(Weight::from_parts(0, 3841)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeWococoMessages OutboundLanes (r:1 w:1) + /// Proof: BridgeWococoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + /// Storage: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Proof Skipped: unknown `0x6e0a18b62a1de81c5f519181cc611e18` (r:1 w:0) + /// Storage: BridgeRelayers RelayerRewards (r:2 w:2) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight { + // Proof Size summary in bytes: + // Measured: `376` + // Estimated: `6086` + // Minimum execution time: 35_578_000 picoseconds. + Weight::from_parts(36_007_000, 0) + .saturating_add(Weight::from_parts(0, 6086)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:1 w:0) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// Storage: BridgeWococoMessages InboundLanes (r:1 w:1) + /// Proof: BridgeWococoMessages InboundLanes (max_values: None, max_size: Some(49180), added: 51655, mode: MaxEncodedLen) + /// Storage: ParachainInfo ParachainId (r:1 w:0) + /// Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: PolkadotXcm SupportedVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) + /// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1) + /// Proof Skipped: PolkadotXcm VersionDiscoveryQueue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0) + /// Proof Skipped: PolkadotXcm SafeXcmVersion (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ParachainSystem RelevantMessagingState (r:1 w:0) + /// Proof Skipped: ParachainSystem RelevantMessagingState (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: XcmpQueue OutboundXcmpStatus (r:1 w:1) + /// Proof Skipped: XcmpQueue OutboundXcmpStatus (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: XcmpQueue OutboundXcmpMessages (r:0 w:1) + /// Proof Skipped: XcmpQueue OutboundXcmpMessages (max_values: None, max_size: None, mode: Measured) + /// The range of component `i` is `[128, 2048]`. + /// The range of component `i` is `[128, 2048]`. + fn receive_single_message_proof_with_dispatch(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `672` + // Estimated: `52645` + // Minimum execution time: 130_070_000 picoseconds. + Weight::from_parts(104_597_637, 0) + .saturating_add(Weight::from_parts(0, 52645)) + // Standard Error: 2_607 + .saturating_add(Weight::from_parts(538_698, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(4)) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance.rs new file mode 100644 index 00000000000..9e88bd08b7f --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_rococo_instance.rs @@ -0,0 +1,114 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_parachains` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_parachains +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_bridge_parachains`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_parachains::WeightInfo for WeightInfo { + /// Storage: BridgeRococoParachain PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoParachain PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BridgeRococoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRococoGrandpa ImportedHeaders (max_values: Some(1024), max_size: Some(68), added: 1553, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ParasInfo (r:1 w:1) + /// Proof: BridgeRococoParachain ParasInfo (max_values: Some(1), max_size: Some(60), added: 555, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHashes (r:1 w:1) + /// Proof: BridgeRococoParachain ImportedParaHashes (max_values: Some(64), max_size: Some(64), added: 1054, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:0 w:1) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// The range of component `p` is `[1, 2]`. + /// The range of component `p` is `[1, 2]`. + fn submit_parachain_heads_with_n_parachains(_p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `294` + // Estimated: `2543` + // Minimum execution time: 33_300_000 picoseconds. + Weight::from_parts(34_117_420, 0) + .saturating_add(Weight::from_parts(0, 2543)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: BridgeRococoParachain PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoParachain PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BridgeRococoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRococoGrandpa ImportedHeaders (max_values: Some(1024), max_size: Some(68), added: 1553, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ParasInfo (r:1 w:1) + /// Proof: BridgeRococoParachain ParasInfo (max_values: Some(1), max_size: Some(60), added: 555, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHashes (r:1 w:1) + /// Proof: BridgeRococoParachain ImportedParaHashes (max_values: Some(64), max_size: Some(64), added: 1054, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:0 w:1) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + fn submit_parachain_heads_with_1kb_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `294` + // Estimated: `2543` + // Minimum execution time: 34_550_000 picoseconds. + Weight::from_parts(35_046_000, 0) + .saturating_add(Weight::from_parts(0, 2543)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: BridgeRococoParachain PalletOperatingMode (r:1 w:0) + /// Proof: BridgeRococoParachain PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BridgeRococoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeRococoGrandpa ImportedHeaders (max_values: Some(1024), max_size: Some(68), added: 1553, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ParasInfo (r:1 w:1) + /// Proof: BridgeRococoParachain ParasInfo (max_values: Some(1), max_size: Some(60), added: 555, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHashes (r:1 w:1) + /// Proof: BridgeRococoParachain ImportedParaHashes (max_values: Some(64), max_size: Some(64), added: 1054, mode: MaxEncodedLen) + /// Storage: BridgeRococoParachain ImportedParaHeads (r:0 w:1) + /// Proof: BridgeRococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + fn submit_parachain_heads_with_16kb_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `294` + // Estimated: `2543` + // Minimum execution time: 61_071_000 picoseconds. + Weight::from_parts(61_554_000, 0) + .saturating_add(Weight::from_parts(0, 2543)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance.rs new file mode 100644 index 00000000000..238fa8725d3 --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_parachains_bridge_parachains_bench_runtime_bridge_parachain_wococo_instance.rs @@ -0,0 +1,114 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_parachains` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_parachains +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_bridge_parachains`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_parachains::WeightInfo for WeightInfo { + /// Storage: BridgeWococoParachain PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoParachain PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BridgeWococoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeWococoGrandpa ImportedHeaders (max_values: Some(1024), max_size: Some(68), added: 1553, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ParasInfo (r:1 w:1) + /// Proof: BridgeWococoParachain ParasInfo (max_values: Some(1), max_size: Some(60), added: 555, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHashes (r:1 w:1) + /// Proof: BridgeWococoParachain ImportedParaHashes (max_values: Some(64), max_size: Some(64), added: 1054, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:0 w:1) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + /// The range of component `p` is `[1, 2]`. + /// The range of component `p` is `[1, 2]`. + fn submit_parachain_heads_with_n_parachains(_p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `367` + // Estimated: `2543` + // Minimum execution time: 34_469_000 picoseconds. + Weight::from_parts(35_382_374, 0) + .saturating_add(Weight::from_parts(0, 2543)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: BridgeWococoParachain PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoParachain PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BridgeWococoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeWococoGrandpa ImportedHeaders (max_values: Some(1024), max_size: Some(68), added: 1553, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ParasInfo (r:1 w:1) + /// Proof: BridgeWococoParachain ParasInfo (max_values: Some(1), max_size: Some(60), added: 555, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHashes (r:1 w:1) + /// Proof: BridgeWococoParachain ImportedParaHashes (max_values: Some(64), max_size: Some(64), added: 1054, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:0 w:1) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + fn submit_parachain_heads_with_1kb_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `367` + // Estimated: `2543` + // Minimum execution time: 35_690_000 picoseconds. + Weight::from_parts(36_400_000, 0) + .saturating_add(Weight::from_parts(0, 2543)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: BridgeWococoParachain PalletOperatingMode (r:1 w:0) + /// Proof: BridgeWococoParachain PalletOperatingMode (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BridgeWococoGrandpa ImportedHeaders (r:1 w:0) + /// Proof: BridgeWococoGrandpa ImportedHeaders (max_values: Some(1024), max_size: Some(68), added: 1553, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ParasInfo (r:1 w:1) + /// Proof: BridgeWococoParachain ParasInfo (max_values: Some(1), max_size: Some(60), added: 555, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHashes (r:1 w:1) + /// Proof: BridgeWococoParachain ImportedParaHashes (max_values: Some(64), max_size: Some(64), added: 1054, mode: MaxEncodedLen) + /// Storage: BridgeWococoParachain ImportedParaHeads (r:0 w:1) + /// Proof: BridgeWococoParachain ImportedParaHeads (max_values: Some(64), max_size: Some(196), added: 1186, mode: MaxEncodedLen) + fn submit_parachain_heads_with_16kb_proof() -> Weight { + // Proof Size summary in bytes: + // Measured: `367` + // Estimated: `2543` + // Minimum execution time: 62_242_000 picoseconds. + Weight::from_parts(62_690_000, 0) + .saturating_add(Weight::from_parts(0, 2543)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_relayers.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_relayers.rs new file mode 100644 index 00000000000..418f1326766 --- /dev/null +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_bridge_relayers.rs @@ -0,0 +1,124 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Autogenerated weights for `pallet_bridge_relayers` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_bridge_relayers +// --chain=bridge-hub-rococo-dev +// --header=./file_header.txt +// --output=./parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_bridge_relayers`. +pub struct WeightInfo(PhantomData); +impl pallet_bridge_relayers::WeightInfo for WeightInfo { + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn claim_rewards() -> Weight { + // Proof Size summary in bytes: + // Measured: `207` + // Estimated: `3593` + // Minimum execution time: 53_286_000 picoseconds. + Weight::from_parts(53_905_000, 0) + .saturating_add(Weight::from_parts(0, 3593)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: unknown `0x1e8445dc201eeb8560e5579a5dd54655` (r:1 w:0) + /// Proof Skipped: unknown `0x1e8445dc201eeb8560e5579a5dd54655` (r:1 w:0) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + fn register() -> Weight { + // Proof Size summary in bytes: + // Measured: `61` + // Estimated: `4714` + // Minimum execution time: 29_145_000 picoseconds. + Weight::from_parts(29_698_000, 0) + .saturating_add(Weight::from_parts(0, 4714)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + fn deregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `4714` + // Minimum execution time: 30_298_000 picoseconds. + Weight::from_parts(30_754_000, 0) + .saturating_add(Weight::from_parts(0, 4714)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: BridgeRelayers RegisteredRelayers (r:1 w:1) + /// Proof: BridgeRelayers RegisteredRelayers (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn slash_and_deregister() -> Weight { + // Proof Size summary in bytes: + // Measured: `263` + // Estimated: `4714` + // Minimum execution time: 30_109_000 picoseconds. + Weight::from_parts(30_330_000, 0) + .saturating_add(Weight::from_parts(0, 4714)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: BridgeRelayers RelayerRewards (r:1 w:1) + /// Proof: BridgeRelayers RelayerRewards (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + fn register_relayer_reward() -> Weight { + // Proof Size summary in bytes: + // Measured: `6` + // Estimated: `3538` + // Minimum execution time: 3_016_000 picoseconds. + Weight::from_parts(3_130_000, 0) + .saturating_add(Weight::from_parts(0, 3538)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_collator_selection.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_collator_selection.rs index cf4ee2028f7..b66a8635e40 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_collator_selection.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_collator_selection` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_collator_selection`. pub struct WeightInfo(PhantomData); @@ -56,11 +57,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `214 + b * (78 ±0)` // Estimated: `1203 + b * (2554 ±0)` - // Minimum execution time: 14_833_000 picoseconds. - Weight::from_parts(15_349_415, 0) + // Minimum execution time: 15_056_000 picoseconds. + Weight::from_parts(15_300_844, 0) .saturating_add(Weight::from_parts(0, 1203)) - // Standard Error: 3_477 - .saturating_add(Weight::from_parts(2_639_530, 0).saturating_mul(b.into())) + // Standard Error: 2_903 + .saturating_add(Weight::from_parts(2_591_470, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(Weight::from_parts(0, 2554).saturating_mul(b.into())) @@ -71,8 +72,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_190_000 picoseconds. - Weight::from_parts(7_558_000, 0) + // Minimum execution time: 7_296_000 picoseconds. + Weight::from_parts(7_526_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -82,8 +83,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_435_000 picoseconds. - Weight::from_parts(7_790_000, 0) + // Minimum execution time: 7_483_000 picoseconds. + Weight::from_parts(7_694_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,12 +104,12 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn register_as_candidate(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1104 + c * (48 ±0)` - // Estimated: `61672 + c * (49 ±0)` - // Minimum execution time: 38_999_000 picoseconds. - Weight::from_parts(31_254_595, 0) - .saturating_add(Weight::from_parts(0, 61672)) - // Standard Error: 1_266 - .saturating_add(Weight::from_parts(108_612, 0).saturating_mul(c.into())) + // Estimated: `49487 + c * (49 ±0)` + // Minimum execution time: 42_882_000 picoseconds. + Weight::from_parts(34_865_364, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 1_292 + .saturating_add(Weight::from_parts(107_420, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 49).saturating_mul(c.into())) @@ -122,11 +123,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `428 + c * (48 ±0)` // Estimated: `49487` - // Minimum execution time: 29_894_000 picoseconds. - Weight::from_parts(19_491_329, 0) + // Minimum execution time: 34_025_000 picoseconds. + Weight::from_parts(23_170_113, 0) .saturating_add(Weight::from_parts(0, 49487)) - // Standard Error: 1_328 - .saturating_add(Weight::from_parts(109_217, 0).saturating_mul(c.into())) + // Standard Error: 1_333 + .saturating_add(Weight::from_parts(108_636, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -139,13 +140,46 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn note_author() -> Weight { // Proof Size summary in bytes: // Measured: `155` - // Estimated: `7729` - // Minimum execution time: 29_666_000 picoseconds. - Weight::from_parts(30_017_000, 0) - .saturating_add(Weight::from_parts(0, 7729)) + // Estimated: `6196` + // Minimum execution time: 45_689_000 picoseconds. + Weight::from_parts(46_236_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) @@ -160,18 +194,18 @@ impl pallet_collator_selection::WeightInfo for WeightIn /// The range of component `c` is `[1, 1000]`. fn new_session(r: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `22815 + r * (116 ±0) + c * (97 ±0)` - // Estimated: `56697 + r * (2602 ±0) + c * (2520 ±0)` - // Minimum execution time: 17_009_000 picoseconds. - Weight::from_parts(17_119_000, 0) - .saturating_add(Weight::from_parts(0, 56697)) - // Standard Error: 839_085 - .saturating_add(Weight::from_parts(30_312_617, 0).saturating_mul(c.into())) + // Measured: `22815 + c * (97 ±0) + r * (116 ±0)` + // Estimated: `49487 + c * (2519 ±0) + r * (2602 ±0)` + // Minimum execution time: 16_853_000 picoseconds. + Weight::from_parts(16_995_000, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 900_191 + .saturating_add(Weight::from_parts(31_884_166, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2519).saturating_mul(c.into())) .saturating_add(Weight::from_parts(0, 2602).saturating_mul(r.into())) - .saturating_add(Weight::from_parts(0, 2520).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_multisig.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_multisig.rs index df58cf7952a..deda8024527 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_multisig.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_multisig.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_multisig` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_multisig`. pub struct WeightInfo(PhantomData); @@ -52,11 +53,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 12_203_000 picoseconds. - Weight::from_parts(12_687_394, 0) + // Minimum execution time: 11_833_000 picoseconds. + Weight::from_parts(12_347_180, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 2 - .saturating_add(Weight::from_parts(556, 0).saturating_mul(z.into())) + // Standard Error: 1 + .saturating_add(Weight::from_parts(554, 0).saturating_mul(z.into())) } /// Storage: Multisig Multisigs (r:1 w:1) /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) @@ -66,13 +67,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `263 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 37_793_000 picoseconds. - Weight::from_parts(32_841_866, 0) + // Minimum execution time: 41_899_000 picoseconds. + Weight::from_parts(35_770_287, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 973 - .saturating_add(Weight::from_parts(64_271, 0).saturating_mul(s.into())) - // Standard Error: 9 - .saturating_add(Weight::from_parts(1_189, 0).saturating_mul(z.into())) + // Standard Error: 542 + .saturating_add(Weight::from_parts(67_778, 0).saturating_mul(s.into())) + // Standard Error: 5 + .saturating_add(Weight::from_parts(1_239, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -84,13 +85,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 27_835_000 picoseconds. - Weight::from_parts(22_419_199, 0) + // Minimum execution time: 27_916_000 picoseconds. + Weight::from_parts(22_006_035, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 535 - .saturating_add(Weight::from_parts(59_729, 0).saturating_mul(s.into())) - // Standard Error: 5 - .saturating_add(Weight::from_parts(1_259, 0).saturating_mul(z.into())) + // Standard Error: 311 + .saturating_add(Weight::from_parts(63_189, 0).saturating_mul(s.into())) + // Standard Error: 3 + .saturating_add(Weight::from_parts(1_244, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,14 +104,14 @@ impl pallet_multisig::WeightInfo for WeightInfo { fn as_multi_complete(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `388 + s * (33 ±0)` - // Estimated: `10404` - // Minimum execution time: 43_060_000 picoseconds. - Weight::from_parts(36_326_276, 0) - .saturating_add(Weight::from_parts(0, 10404)) - // Standard Error: 497 - .saturating_add(Weight::from_parts(76_443, 0).saturating_mul(s.into())) + // Estimated: `6811` + // Minimum execution time: 46_594_000 picoseconds. + Weight::from_parts(38_993_543, 0) + .saturating_add(Weight::from_parts(0, 6811)) + // Standard Error: 498 + .saturating_add(Weight::from_parts(84_584, 0).saturating_mul(s.into())) // Standard Error: 4 - .saturating_add(Weight::from_parts(1_257, 0).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(1_271, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -121,11 +122,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `263 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 29_242_000 picoseconds. - Weight::from_parts(30_673_516, 0) + // Minimum execution time: 32_894_000 picoseconds. + Weight::from_parts(33_904_403, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 651 - .saturating_add(Weight::from_parts(67_820, 0).saturating_mul(s.into())) + // Standard Error: 801 + .saturating_add(Weight::from_parts(76_776, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -136,11 +137,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `282` // Estimated: `6811` - // Minimum execution time: 19_344_000 picoseconds. - Weight::from_parts(20_956_909, 0) + // Minimum execution time: 19_290_000 picoseconds. + Weight::from_parts(20_348_418, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 781 - .saturating_add(Weight::from_parts(65_374, 0).saturating_mul(s.into())) + // Standard Error: 465 + .saturating_add(Weight::from_parts(66_913, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -151,11 +152,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `454 + s * (1 ±0)` // Estimated: `6811` - // Minimum execution time: 30_222_000 picoseconds. - Weight::from_parts(31_457_558, 0) + // Minimum execution time: 33_275_000 picoseconds. + Weight::from_parts(34_932_596, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 648 - .saturating_add(Weight::from_parts(67_068, 0).saturating_mul(s.into())) + // Standard Error: 564 + .saturating_add(Weight::from_parts(71_231, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_session.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_session.rs index 67883fab331..fd1e6b2034b 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_session.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_session.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_session` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_session`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn set_keys() -> Weight { // Proof Size summary in bytes: // Measured: `297` - // Estimated: `7524` - // Minimum execution time: 17_590_000 picoseconds. - Weight::from_parts(18_134_000, 0) - .saturating_add(Weight::from_parts(0, 7524)) + // Estimated: `3762` + // Minimum execution time: 17_753_000 picoseconds. + Weight::from_parts(18_269_000, 0) + .saturating_add(Weight::from_parts(0, 3762)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -68,10 +69,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn purge_keys() -> Weight { // Proof Size summary in bytes: // Measured: `279` - // Estimated: `4023` - // Minimum execution time: 13_479_000 picoseconds. - Weight::from_parts(13_956_000, 0) - .saturating_add(Weight::from_parts(0, 4023)) + // Estimated: `3744` + // Minimum execution time: 13_403_000 picoseconds. + Weight::from_parts(13_821_000, 0) + .saturating_add(Weight::from_parts(0, 3744)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_timestamp.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_timestamp.rs index 7be7f6691f0..4a40dc1c75d 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_timestamp.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_timestamp.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_timestamp`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_timestamp::WeightInfo for WeightInfo { fn set() -> Weight { // Proof Size summary in bytes: // Measured: `49` - // Estimated: `2986` - // Minimum execution time: 7_610_000 picoseconds. - Weight::from_parts(7_887_000, 0) - .saturating_add(Weight::from_parts(0, 2986)) + // Estimated: `1493` + // Minimum execution time: 7_595_000 picoseconds. + Weight::from_parts(7_831_000, 0) + .saturating_add(Weight::from_parts(0, 1493)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +66,8 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `57` // Estimated: `0` - // Minimum execution time: 3_100_000 picoseconds. - Weight::from_parts(3_180_000, 0) + // Minimum execution time: 3_169_000 picoseconds. + Weight::from_parts(3_316_000, 0) .saturating_add(Weight::from_parts(0, 0)) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_utility.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_utility.rs index 2420a70d1fb..ec43ac02ac1 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_utility.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_utility.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_utility`. pub struct WeightInfo(PhantomData); @@ -52,18 +53,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_051_000 picoseconds. - Weight::from_parts(10_722_806, 0) + // Minimum execution time: 7_483_000 picoseconds. + Weight::from_parts(10_302_924, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 4_213 - .saturating_add(Weight::from_parts(4_992_366, 0).saturating_mul(c.into())) + // Standard Error: 2_285 + .saturating_add(Weight::from_parts(4_760_910, 0).saturating_mul(c.into())) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_831_000 picoseconds. - Weight::from_parts(6_014_000, 0) + // Minimum execution time: 5_768_000 picoseconds. + Weight::from_parts(5_879_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -71,18 +72,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_394_000 picoseconds. - Weight::from_parts(15_396_332, 0) + // Minimum execution time: 7_566_000 picoseconds. + Weight::from_parts(653_292, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_533 - .saturating_add(Weight::from_parts(5_302_383, 0).saturating_mul(c.into())) + // Standard Error: 2_989 + .saturating_add(Weight::from_parts(5_103_611, 0).saturating_mul(c.into())) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_730_000 picoseconds. - Weight::from_parts(9_988_000, 0) + // Minimum execution time: 9_656_000 picoseconds. + Weight::from_parts(9_902_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -90,10 +91,10 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_395_000 picoseconds. - Weight::from_parts(14_933_943, 0) + // Minimum execution time: 7_524_000 picoseconds. + Weight::from_parts(1_487_243, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_208 - .saturating_add(Weight::from_parts(4_963_051, 0).saturating_mul(c.into())) + // Standard Error: 3_565 + .saturating_add(Weight::from_parts(4_841_130, 0).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs index 23f4f1cb27b..efaf8232a35 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/pallet_xcm.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); @@ -60,10 +61,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn send() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `9595` - // Minimum execution time: 27_429_000 picoseconds. - Weight::from_parts(28_626_000, 0) - .saturating_add(Weight::from_parts(0, 9595)) + // Estimated: `3503` + // Minimum execution time: 27_565_000 picoseconds. + Weight::from_parts(28_064_000, 0) + .saturating_add(Weight::from_parts(0, 3503)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +74,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `1489` - // Minimum execution time: 27_626_000 picoseconds. - Weight::from_parts(28_561_000, 0) + // Minimum execution time: 29_361_000 picoseconds. + Weight::from_parts(29_771_000, 0) .saturating_add(Weight::from_parts(0, 1489)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -104,8 +105,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 10_264_000 picoseconds. - Weight::from_parts(10_601_000, 0) + // Minimum execution time: 10_098_000 picoseconds. + Weight::from_parts(10_440_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -115,8 +116,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_218_000 picoseconds. - Weight::from_parts(3_311_000, 0) + // Minimum execution time: 3_142_000 picoseconds. + Weight::from_parts(3_262_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -139,10 +140,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `14659` - // Minimum execution time: 33_037_000 picoseconds. - Weight::from_parts(33_559_000, 0) - .saturating_add(Weight::from_parts(0, 14659)) + // Estimated: `3503` + // Minimum execution time: 32_356_000 picoseconds. + Weight::from_parts(32_859_000, 0) + .saturating_add(Weight::from_parts(0, 3503)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -163,19 +164,21 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: // Measured: `220` - // Estimated: `14410` - // Minimum execution time: 34_280_000 picoseconds. - Weight::from_parts(34_943_000, 0) - .saturating_add(Weight::from_parts(0, 14410)) + // Estimated: `3685` + // Minimum execution time: 33_773_000 picoseconds. + Weight::from_parts(34_410_000, 0) + .saturating_add(Weight::from_parts(0, 3685)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: PolkadotXcm XcmExecutionSuspended (r:0 w:1) + /// Proof Skipped: PolkadotXcm XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured) fn force_suspension() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_218_000 picoseconds. - Weight::from_parts(3_311_000, 0) + // Minimum execution time: 3_127_000 picoseconds. + Weight::from_parts(3_240_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -185,8 +188,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `95` // Estimated: `10985` - // Minimum execution time: 15_106_000 picoseconds. - Weight::from_parts(15_383_000, 0) + // Minimum execution time: 14_941_000 picoseconds. + Weight::from_parts(15_378_000, 0) .saturating_add(Weight::from_parts(0, 10985)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -197,8 +200,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `99` // Estimated: `10989` - // Minimum execution time: 15_129_000 picoseconds. - Weight::from_parts(15_489_000, 0) + // Minimum execution time: 14_750_000 picoseconds. + Weight::from_parts(14_903_000, 0) .saturating_add(Weight::from_parts(0, 10989)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -209,8 +212,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `13471` - // Minimum execution time: 15_526_000 picoseconds. - Weight::from_parts(15_778_000, 0) + // Minimum execution time: 15_360_000 picoseconds. + Weight::from_parts(15_593_000, 0) .saturating_add(Weight::from_parts(0, 13471)) .saturating_add(T::DbWeight::get().reads(5)) } @@ -229,10 +232,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn notify_current_targets() -> Weight { // Proof Size summary in bytes: // Measured: `106` - // Estimated: `15981` - // Minimum execution time: 29_457_000 picoseconds. - Weight::from_parts(29_970_000, 0) - .saturating_add(Weight::from_parts(0, 15981)) + // Estimated: `6046` + // Minimum execution time: 28_886_000 picoseconds. + Weight::from_parts(29_140_000, 0) + .saturating_add(Weight::from_parts(0, 6046)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -242,8 +245,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `136` // Estimated: `8551` - // Minimum execution time: 8_264_000 picoseconds. - Weight::from_parts(8_518_000, 0) + // Minimum execution time: 8_045_000 picoseconds. + Weight::from_parts(8_301_000, 0) .saturating_add(Weight::from_parts(0, 8551)) .saturating_add(T::DbWeight::get().reads(3)) } @@ -253,8 +256,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `10996` - // Minimum execution time: 15_633_000 picoseconds. - Weight::from_parts(16_006_000, 0) + // Minimum execution time: 14_763_000 picoseconds. + Weight::from_parts(15_186_000, 0) .saturating_add(Weight::from_parts(0, 10996)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) @@ -274,10 +277,10 @@ impl pallet_xcm::WeightInfo for WeightInfo { fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: // Measured: `112` - // Estimated: `20967` - // Minimum execution time: 35_849_000 picoseconds. - Weight::from_parts(36_545_000, 0) - .saturating_add(Weight::from_parts(0, 20967)) + // Estimated: `11002` + // Minimum execution time: 34_652_000 picoseconds. + Weight::from_parts(34_888_000, 0) + .saturating_add(Weight::from_parts(0, 11002)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs index b05c554580d..9efbef18363 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/mod.rs @@ -18,6 +18,7 @@ mod pallet_xcm_benchmarks_fungible; mod pallet_xcm_benchmarks_generic; use crate::{xcm_config::MaxAssetsIntoHolding, Runtime}; +use codec::Encode; use frame_support::weights::Weight; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; @@ -33,8 +34,7 @@ const MAX_ASSETS: u64 = 100; impl WeighMultiAssets for MultiAssetFilter { fn weigh_multi_assets(&self, weight: Weight) -> Weight { match self { - Self::Definite(assets) => - weight.saturating_mul(assets.inner().into_iter().count() as u64), + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { All => weight.saturating_mul(MAX_ASSETS), AllOf { fun, .. } => match fun { @@ -53,7 +53,7 @@ impl WeighMultiAssets for MultiAssetFilter { impl WeighMultiAssets for MultiAssets { fn weigh_multi_assets(&self, weight: Weight) -> Weight { - weight.saturating_mul(self.inner().into_iter().count() as u64) + weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -65,7 +65,7 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { // Currently there is no trusted reserve fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight { // TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974 - Weight::from_parts(1_000_000_000 as u64, 0) + Weight::from_parts(1_000_000_000_u64, 0) } fn receive_teleported_asset(assets: &MultiAssets) -> Weight { assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) @@ -123,7 +123,7 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { // Hardcoded till the XCM pallet is fixed - let hardcoded_weight = Weight::from_parts(1_000_000_000 as u64, 0); + let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0); let weight = assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()); hardcoded_weight.min(weight) } @@ -217,8 +217,9 @@ impl XcmWeightInfo for BridgeHubRococoXcmWeight { fn universal_origin(_: &Junction) -> Weight { Weight::MAX } - fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { - Weight::MAX + fn export_message(_: &NetworkId, _: &Junctions, inner: &Xcm<()>) -> Weight { + let inner_encoded_len = inner.encode().len() as u32; + XcmGeneric::::export_message(inner_encoded_len) } fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { Weight::MAX diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 731111e358e..ad69bf08427 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::fungible` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -54,8 +54,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `101` // Estimated: `3593` - // Minimum execution time: 21_045_000 picoseconds. - Weight::from_parts(21_781_000, 3593) + // Minimum execution time: 24_766_000 picoseconds. + Weight::from_parts(25_113_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +65,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `153` // Estimated: `6196` - // Minimum execution time: 33_123_000 picoseconds. - Weight::from_parts(33_378_000, 6196) + // Minimum execution time: 51_440_000 picoseconds. + Weight::from_parts(51_960_000, 6196) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -87,9 +87,9 @@ impl WeightInfo { pub fn transfer_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `223` - // Estimated: `18205` - // Minimum execution time: 57_689_000 picoseconds. - Weight::from_parts(58_320_000, 18205) + // Estimated: `6196` + // Minimum execution time: 76_002_000 picoseconds. + Weight::from_parts(76_826_000, 6196) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -97,8 +97,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_838_000 picoseconds. - Weight::from_parts(4_906_000, 0) + // Minimum execution time: 4_644_000 picoseconds. + Weight::from_parts(4_754_000, 0) } // Storage: System Account (r:1 w:1) // Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) @@ -106,8 +106,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `52` // Estimated: `3593` - // Minimum execution time: 25_197_000 picoseconds. - Weight::from_parts(25_562_000, 3593) + // Minimum execution time: 27_398_000 picoseconds. + Weight::from_parts(27_947_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -128,9 +128,9 @@ impl WeightInfo { pub fn deposit_reserve_asset() -> Weight { // Proof Size summary in bytes: // Measured: `122` - // Estimated: `15097` - // Minimum execution time: 52_159_000 picoseconds. - Weight::from_parts(52_637_000, 15097) + // Estimated: `3593` + // Minimum execution time: 54_445_000 picoseconds. + Weight::from_parts(55_026_000, 3593) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -149,9 +149,9 @@ impl WeightInfo { pub fn initiate_teleport() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 30_471_000 picoseconds. - Weight::from_parts(31_112_000, 11244) + // Estimated: `3535` + // Minimum execution time: 30_770_000 picoseconds. + Weight::from_parts(31_269_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 8572163a52b..0b06968e441 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bridge-hub-rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -63,9 +63,9 @@ impl WeightInfo { pub fn report_holding() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 34_238_000 picoseconds. - Weight::from_parts(34_851_000, 11244) + // Estimated: `3535` + // Minimum execution time: 34_120_000 picoseconds. + Weight::from_parts(34_618_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +73,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_358_000 picoseconds. - Weight::from_parts(3_437_000, 0) + // Minimum execution time: 3_285_000 picoseconds. + Weight::from_parts(3_426_000, 0) } // Storage: PolkadotXcm Queries (r:1 w:0) // Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) @@ -82,58 +82,58 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `3497` - // Minimum execution time: 11_623_000 picoseconds. - Weight::from_parts(11_814_000, 3497) + // Minimum execution time: 11_025_000 picoseconds. + Weight::from_parts(11_293_000, 3497) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_934_000 picoseconds. - Weight::from_parts(14_111_000, 0) + // Minimum execution time: 13_451_000 picoseconds. + Weight::from_parts(13_625_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_562_000 picoseconds. - Weight::from_parts(3_689_000, 0) + // Minimum execution time: 3_578_000 picoseconds. + Weight::from_parts(3_639_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_280_000 picoseconds. - Weight::from_parts(3_345_000, 0) + // Minimum execution time: 3_123_000 picoseconds. + Weight::from_parts(3_190_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_243_000 picoseconds. - Weight::from_parts(3_335_000, 0) + // Minimum execution time: 3_176_000 picoseconds. + Weight::from_parts(3_223_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_280_000 picoseconds. - Weight::from_parts(3_347_000, 0) + // Minimum execution time: 3_142_000 picoseconds. + Weight::from_parts(3_200_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_270_000 picoseconds. - Weight::from_parts(4_358_000, 0) + // Minimum execution time: 4_308_000 picoseconds. + Weight::from_parts(4_392_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_245_000 picoseconds. - Weight::from_parts(3_320_000, 0) + // Minimum execution time: 3_114_000 picoseconds. + Weight::from_parts(3_189_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -150,9 +150,9 @@ impl WeightInfo { pub fn report_error() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 26_653_000 picoseconds. - Weight::from_parts(27_139_000, 11244) + // Estimated: `3535` + // Minimum execution time: 26_422_000 picoseconds. + Weight::from_parts(26_959_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -162,8 +162,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `90` // Estimated: `3555` - // Minimum execution time: 15_478_000 picoseconds. - Weight::from_parts(15_763_000, 3555) + // Minimum execution time: 15_625_000 picoseconds. + Weight::from_parts(15_828_000, 3555) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -171,8 +171,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_237_000 picoseconds. - Weight::from_parts(3_314_000, 0) + // Minimum execution time: 3_187_000 picoseconds. + Weight::from_parts(3_238_000, 0) } // Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1) // Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) @@ -189,9 +189,9 @@ impl WeightInfo { pub fn subscribe_version() -> Weight { // Proof Size summary in bytes: // Measured: `38` - // Estimated: `13098` - // Minimum execution time: 29_098_000 picoseconds. - Weight::from_parts(29_368_000, 13098) + // Estimated: `3503` + // Minimum execution time: 27_154_000 picoseconds. + Weight::from_parts(27_761_000, 3503) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -201,8 +201,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_253_000 picoseconds. - Weight::from_parts(6_467_000, 0) + // Minimum execution time: 5_268_000 picoseconds. + Weight::from_parts(5_412_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainInfo ParachainId (r:1 w:0) @@ -220,9 +220,9 @@ impl WeightInfo { pub fn initiate_reserve_withdraw() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 35_061_000 picoseconds. - Weight::from_parts(35_510_000, 11244) + // Estimated: `3535` + // Minimum execution time: 30_515_000 picoseconds. + Weight::from_parts(31_095_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -230,36 +230,36 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_154_000 picoseconds. - Weight::from_parts(6_266_000, 0) + // Minimum execution time: 5_148_000 picoseconds. + Weight::from_parts(5_224_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 4_009_000 picoseconds. - Weight::from_parts(4_088_000, 0) + // Minimum execution time: 3_220_000 picoseconds. + Weight::from_parts(3_312_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_873_000 picoseconds. - Weight::from_parts(3_996_000, 0) + // Minimum execution time: 3_226_000 picoseconds. + Weight::from_parts(3_309_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_759_000 picoseconds. - Weight::from_parts(3_820_000, 0) + // Minimum execution time: 3_095_000 picoseconds. + Weight::from_parts(3_177_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_985_000 picoseconds. - Weight::from_parts(4_132_000, 0) + // Minimum execution time: 3_349_000 picoseconds. + Weight::from_parts(3_447_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -276,9 +276,9 @@ impl WeightInfo { pub fn query_pallet() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 34_686_000 picoseconds. - Weight::from_parts(35_233_000, 11244) + // Estimated: `3535` + // Minimum execution time: 29_644_000 picoseconds. + Weight::from_parts(30_110_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -286,8 +286,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_129_000 picoseconds. - Weight::from_parts(6_244_000, 0) + // Minimum execution time: 5_304_000 picoseconds. + Weight::from_parts(5_369_000, 0) } // Storage: ParachainInfo ParachainId (r:1 w:0) // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) @@ -304,9 +304,9 @@ impl WeightInfo { pub fn report_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `70` - // Estimated: `11244` - // Minimum execution time: 31_502_000 picoseconds. - Weight::from_parts(32_131_000, 11244) + // Estimated: `3535` + // Minimum execution time: 26_617_000 picoseconds. + Weight::from_parts(27_011_000, 3535) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -314,35 +314,50 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_747_000 picoseconds. - Weight::from_parts(3_832_000, 0) + // Minimum execution time: 3_133_000 picoseconds. + Weight::from_parts(3_229_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_825_000 picoseconds. - Weight::from_parts(3_857_000, 0) + // Minimum execution time: 3_110_000 picoseconds. + Weight::from_parts(3_203_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_777_000 picoseconds. - Weight::from_parts(3_868_000, 0) + // Minimum execution time: 3_138_000 picoseconds. + Weight::from_parts(3_201_000, 0) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_710_000 picoseconds. - Weight::from_parts(3_820_000, 0) + // Minimum execution time: 3_116_000 picoseconds. + Weight::from_parts(3_187_000, 0) + } + // Storage: ParachainInfo ParachainId (r:1 w:0) + // Proof: ParachainInfo ParachainId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + // Storage: BridgeWococoMessages PalletOperatingMode (r:1 w:0) + // Proof: BridgeWococoMessages PalletOperatingMode (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + // Storage: BridgeWococoMessages OutboundLanes (r:1 w:1) + // Proof: BridgeWococoMessages OutboundLanes (max_values: Some(1), max_size: Some(44), added: 539, mode: MaxEncodedLen) + // Storage: BridgeWococoMessages OutboundMessages (r:0 w:1) + // Proof: BridgeWococoMessages OutboundMessages (max_values: None, max_size: Some(2621472), added: 2623947, mode: MaxEncodedLen) + pub(crate) fn export_message(x: u32, ) -> Weight { + Weight::from_parts(31_677_716_u64, 0) + // Standard Error: 4_158 + .saturating_add(Weight::from_parts(123_901, 0).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_876_000 picoseconds. - Weight::from_parts(4_012_000, 0) + // Minimum execution time: 3_364_000 picoseconds. + Weight::from_parts(3_429_000, 0) } } diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 0dbd5f63443..eb8d623a0b4 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -15,8 +15,14 @@ // along with Cumulus. If not, see . use super::{ - AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, - Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue, + AccountId, AllPalletsWithSystem, Balances, BridgeGrandpaRococoInstance, + BridgeGrandpaWococoInstance, DeliveryRewardInBalance, ParachainInfo, ParachainSystem, + PolkadotXcm, RequiredStakeForStakeAndSlash, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, + WeightToFee, XcmpQueue, +}; +use crate::{ + bridge_hub_rococo_config::ToBridgeHubWococoHaulBlobExporter, + bridge_hub_wococo_config::ToBridgeHubRococoHaulBlobExporter, }; use frame_support::{ match_types, parameter_types, @@ -24,32 +30,49 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, -}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom}; use polkadot_parachain::primitives::Sibling; +use sp_core::Get; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, + CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, IsConcrete, + ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, - WithComputedOrigin, + SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, + WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, +}; +use xcm_executor::{ + traits::{ExportXcm, WithOriginFilter}, + XcmExecutor, }; -use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); - pub const RelayNetwork: Option = Some(NetworkId::Rococo); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = - X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into())); + X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } +pub struct RelayNetwork; +impl Get> for RelayNetwork { + fn get() -> Option { + Some(Self::get()) + } +} +impl Get for RelayNetwork { + fn get() -> NetworkId { + match u32::from(ParachainInfo::parachain_id()) { + bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID => NetworkId::Rococo, + bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID => NetworkId::Wococo, + para_id => unreachable!("Not supported for para_id: {}", para_id), + } + } +} + /// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used /// when determining ownership of accounts for asset transacting and when attempting to use XCM /// `Transact` in order to determine the dispatch Origin. @@ -84,7 +107,7 @@ pub type XcmOriginToTransactDispatchOrigin = ( // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for // foreign chains who want to have a local sovereign account on this chain which they control. SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when + // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when // recognized. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when @@ -128,51 +151,76 @@ impl Contains for SafeCallFilter { } } + // Allow to change dedicated storage items (called by governance-like) match call { + RuntimeCall::System(frame_system::Call::set_storage { items }) + if items.iter().any(|(k, _)| { + k.eq(&DeliveryRewardInBalance::key()) | + k.eq(&RequiredStakeForStakeAndSlash::key()) + }) => + return true, + _ => (), + }; + + matches!( + call, RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::System( - frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) => true, - _ => false, - } + RuntimeCall::System( + frame_system::Call::set_heap_pages { .. } | + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. } | + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::BridgeRococoGrandpa(pallet_bridge_grandpa::Call::< + Runtime, + BridgeGrandpaRococoInstance, + >::initialize { .. }) | + RuntimeCall::BridgeWococoGrandpa(pallet_bridge_grandpa::Call::< + Runtime, + BridgeGrandpaWococoInstance, + >::initialize { .. }) + ) } } -pub type Barrier = DenyThenTry< - DenyReserveTransferToRelayChain, - ( - // Allow local users to buy weight credit. - TakeWeightCredit, - // Expected responses are OK. - AllowKnownQueryResponses, - WithComputedOrigin< - ( - // If the message is one that immediately attemps to pay for execution, then allow it. - AllowTopLevelPaidExecutionFrom, - // Parent and its pluralities (i.e. governance bodies) get free execution. - AllowExplicitUnpaidExecutionFrom, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, - ), - UniversalLocation, - ConstU32<8>, - >, - ), +pub type Barrier = TrailingSetTopicAsId< + DenyThenTry< + DenyReserveTransferToRelayChain, + ( + // Allow local users to buy weight credit. + TakeWeightCredit, + // Expected responses are OK. + AllowKnownQueryResponses, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Parent and its pluralities (i.e. governance bodies) get free execution. + AllowExplicitUnpaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, + // TODO:check-parameter - (https://github.com/paritytech/parity-bridges-common/issues/2084) + // remove this and extend `AllowExplicitUnpaidExecutionFrom` with "or SystemParachains" once merged https://github.com/paritytech/polkadot/pull/7005 + AllowUnpaidExecutionFrom, + ), + >, >; pub struct XcmConfig; @@ -197,14 +245,14 @@ impl xcm_executor::Config for XcmConfig { UsingComponents>; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; + type AssetLocker = (); + type AssetExchanger = (); type AssetClaims = PolkadotXcm; type SubscriptionService = PolkadotXcm; type PalletInstancesInfo = AllPalletsWithSystem; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type AssetLocker = (); - type AssetExchanger = (); type FeeManager = (); - type MessageExporter = (); + type MessageExporter = BridgeHubRococoOrBridgeHubWococoSwitchExporter; type UniversalAliases = Nothing; type CallDispatcher = WithOriginFilter; type SafeCallFilter = SafeCallFilter; @@ -216,12 +264,12 @@ pub type LocalOriginToLocation = SignedToAccountId32, // ..and XCMP to communicate with the sibling chains. XcmpQueue, -); +)>; #[cfg(feature = "runtime-benchmarks")] parameter_types! { @@ -230,12 +278,11 @@ parameter_types! { impl pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; + type XcmRouter = XcmRouter; // We want to disallow users sending (arbitrary) XCMs from this chain. type SendXcmOrigin = EnsureXcmOrigin; - type XcmRouter = XcmRouter; // We support local origins dispatching XCM executions in principle... type ExecuteXcmOrigin = EnsureXcmOrigin; - // ... but disallow generic XCM execution. As a result only teleports are allowed. type XcmExecuteFilter = Nothing; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; @@ -259,9 +306,54 @@ impl pallet_xcm::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type XcmExecutor = XcmExecutor; } + +/// Hacky switch implementation, because we have just one runtime for Rococo and Wococo BridgeHub, so it means we have just one XcmConfig +pub struct BridgeHubRococoOrBridgeHubWococoSwitchExporter; +impl ExportXcm for BridgeHubRococoOrBridgeHubWococoSwitchExporter { + type Ticket = (NetworkId, (sp_std::prelude::Vec, XcmHash)); + + fn validate( + network: NetworkId, + channel: u32, + universal_source: &mut Option, + destination: &mut Option, + message: &mut Option>, + ) -> SendResult { + match network { + Rococo => ToBridgeHubRococoHaulBlobExporter::validate( + network, + channel, + universal_source, + destination, + message, + ) + .map(|result| ((Rococo, result.0), result.1)), + Wococo => ToBridgeHubWococoHaulBlobExporter::validate( + network, + channel, + universal_source, + destination, + message, + ) + .map(|result| ((Wococo, result.0), result.1)), + _ => unimplemented!("Unsupported network: {:?}", network), + } + } + + fn deliver(ticket: Self::Ticket) -> Result { + let (network, ticket) = ticket; + match network { + Rococo => ToBridgeHubRococoHaulBlobExporter::deliver(ticket), + Wococo => ToBridgeHubWococoHaulBlobExporter::deliver(ticket), + _ => unimplemented!("Unsupported network: {:?}", network), + } + } +} diff --git a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs index bf899b567d8..6a1ec2793f2 100644 --- a/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs +++ b/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs @@ -14,43 +14,431 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -pub use bridge_hub_rococo_runtime::{ - constants::fee::WeightToFee, xcm_config::XcmConfig, Balances, ExistentialDeposit, - ParachainSystem, PolkadotXcm, Runtime, RuntimeEvent, SessionKeys, +#![cfg(test)] + +use bp_polkadot_core::Signature; +use bridge_hub_rococo_runtime::{ + bridge_hub_rococo_config, bridge_hub_wococo_config, + constants::fee::WeightToFee, + xcm_config::{RelayNetwork, XcmConfig}, + BridgeRejectObsoleteHeadersAndMessages, DeliveryRewardInBalance, Executive, ExistentialDeposit, + ParachainSystem, PolkadotXcm, RequiredStakeForStakeAndSlash, Runtime, RuntimeCall, + RuntimeEvent, SessionKeys, SignedExtra, UncheckedExtrinsic, }; -use codec::Decode; +use codec::{Decode, Encode}; use frame_support::parameter_types; -use parachains_common::{AccountId, AuraId}; +use parachains_common::{AccountId, AuraId, Balance}; +use sp_keyring::AccountKeyring::Alice; +use sp_runtime::{ + generic::{Era, SignedPayload}, + AccountId32, +}; +use xcm::latest::prelude::*; -const ALICE: [u8; 32] = [1u8; 32]; +// Para id of sibling chain (Rockmine/Wockmint) used in tests. +pub const SIBLING_PARACHAIN_ID: u32 = 1000; parameter_types! { pub CheckingAccount: AccountId = PolkadotXcm::check_account(); } -bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!( - Runtime, - XcmConfig, - CheckingAccount, - WeightToFee, - ParachainSystem, +fn construct_extrinsic( + sender: sp_keyring::AccountKeyring, + call: RuntimeCall, +) -> UncheckedExtrinsic { + let extra: SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(Era::immortal()), + frame_system::CheckNonce::::from(0), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::::from(0), + BridgeRejectObsoleteHeadersAndMessages {}, + ( + bridge_hub_wococo_config::BridgeRefundBridgeHubRococoMessages::default(), + bridge_hub_rococo_config::BridgeRefundBridgeHubWococoMessages::default(), + ), + ); + let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap(); + let signature = payload.using_encoded(|e| sender.sign(e)); + UncheckedExtrinsic::new_signed( + call, + AccountId32::from(sender.public()).into(), + Signature::Sr25519(signature.clone()), + extra, + ) +} + +fn construct_and_apply_extrinsic( + relayer_at_target: sp_keyring::AccountKeyring, + batch: pallet_utility::Call, +) -> sp_runtime::DispatchOutcome { + let batch_call = RuntimeCall::Utility(batch); + let xt = construct_extrinsic(relayer_at_target, batch_call); + let r = Executive::apply_extrinsic(xt); + r.unwrap() +} + +fn executive_init_block(header: &::Header) { + Executive::initialize_block(header) +} + +fn collator_session_keys() -> bridge_hub_test_utils::CollatorSessionKeys { bridge_hub_test_utils::CollatorSessionKeys::new( - AccountId::from(ALICE), - AccountId::from(ALICE), - SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) } - ), - ExistentialDeposit::get(), - Box::new(|runtime_event_encoded: Vec| { - match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { - Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event), - _ => None, - } - }), - Box::new(|runtime_event_encoded: Vec| { - match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { - Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), - _ => None, - } - }), - 1013 -); + AccountId::from(Alice), + AccountId::from(Alice), + SessionKeys { aura: AuraId::from(Alice.public()) }, + ) +} + +mod bridge_hub_rococo_tests { + use super::*; + use bridge_hub_rococo_config::{ + WithBridgeHubWococoMessageBridge, DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO, + }; + use bridge_hub_rococo_runtime::{ + BridgeGrandpaWococoInstance, BridgeParachainWococoInstance, + WithBridgeHubWococoMessagesInstance, + }; + + bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!( + Runtime, + XcmConfig, + CheckingAccount, + WeightToFee, + ParachainSystem, + collator_session_keys(), + ExistentialDeposit::get(), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event), + _ => None, + } + }), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), + _ => None, + } + }), + bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID + ); + + #[test] + fn initialize_bridge_by_governance_works() { + bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::< + Runtime, + BridgeGrandpaWococoInstance, + >( + collator_session_keys(), + bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, + Box::new(|call| RuntimeCall::BridgeWococoGrandpa(call).encode()), + ) + } + + #[test] + fn change_delivery_reward_by_governance_works() { + bridge_hub_test_utils::test_cases::change_storage_constant_by_governance_works::< + Runtime, + DeliveryRewardInBalance, + u64, + >( + collator_session_keys(), + bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, + Box::new(|call| RuntimeCall::System(call).encode()), + || (DeliveryRewardInBalance::key().to_vec(), DeliveryRewardInBalance::get()), + |old_value| old_value.checked_mul(2).unwrap(), + ) + } + + #[test] + fn change_required_stake_by_governance_works() { + bridge_hub_test_utils::test_cases::change_storage_constant_by_governance_works::< + Runtime, + RequiredStakeForStakeAndSlash, + Balance, + >( + collator_session_keys(), + bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, + Box::new(|call| RuntimeCall::System(call).encode()), + || { + ( + RequiredStakeForStakeAndSlash::key().to_vec(), + RequiredStakeForStakeAndSlash::get(), + ) + }, + |old_value| old_value.checked_mul(2).unwrap(), + ) + } + + #[test] + fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() { + bridge_hub_test_utils::test_cases::handle_export_message_from_system_parachain_to_outbound_queue_works::< + Runtime, + XcmConfig, + WithBridgeHubWococoMessagesInstance, + >( + collator_session_keys(), + bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, + SIBLING_PARACHAIN_ID, + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::BridgeWococoMessages(event)) => Some(event), + _ => None, + } + }), + || ExportMessage { network: Wococo, destination: X1(Parachain(1234)), xcm: Xcm(vec![]) }, + bridge_hub_rococo_config::DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO + ) + } + + #[test] + fn message_dispatch_routing_works() { + bridge_hub_test_utils::test_cases::message_dispatch_routing_works::< + Runtime, + XcmConfig, + ParachainSystem, + WithBridgeHubWococoMessagesInstance, + RelayNetwork, + bridge_hub_rococo_config::WococoGlobalConsensusNetwork, + >( + collator_session_keys(), + bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, + SIBLING_PARACHAIN_ID, + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::ParachainSystem(event)) => Some(event), + _ => None, + } + }), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), + _ => None, + } + }), + bridge_hub_rococo_config::DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO, + ) + } + + #[test] + fn relayed_incoming_message_works() { + bridge_hub_test_utils::test_cases::relayed_incoming_message_works::< + Runtime, + XcmConfig, + ParachainSystem, + BridgeGrandpaWococoInstance, + BridgeParachainWococoInstance, + WithBridgeHubWococoMessagesInstance, + WithBridgeHubWococoMessageBridge, + >( + collator_session_keys(), + bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, + bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID, + SIBLING_PARACHAIN_ID, + Rococo, + DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO, + ) + } + + #[test] + pub fn complex_relay_extrinsic_works() { + bridge_hub_test_utils::test_cases::complex_relay_extrinsic_works::< + Runtime, + XcmConfig, + ParachainSystem, + BridgeGrandpaWococoInstance, + BridgeParachainWococoInstance, + WithBridgeHubWococoMessagesInstance, + WithBridgeHubWococoMessageBridge, + >( + collator_session_keys(), + bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, + bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID, + SIBLING_PARACHAIN_ID, + bridge_hub_rococo_config::BridgeHubWococoChainId::get(), + Rococo, + DEFAULT_XCM_LANE_TO_BRIDGE_HUB_WOCOCO, + ExistentialDeposit::get(), + executive_init_block, + construct_and_apply_extrinsic, + ); + } +} + +mod bridge_hub_wococo_tests { + use super::*; + use bridge_hub_rococo_runtime::{ + BridgeGrandpaRococoInstance, BridgeParachainRococoInstance, + WithBridgeHubRococoMessagesInstance, + }; + use bridge_hub_wococo_config::{ + WithBridgeHubRococoMessageBridge, DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO, + }; + + bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!( + Runtime, + XcmConfig, + CheckingAccount, + WeightToFee, + ParachainSystem, + collator_session_keys(), + ExistentialDeposit::get(), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::PolkadotXcm(event)) => Some(event), + _ => None, + } + }), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), + _ => None, + } + }), + bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID + ); + + #[test] + fn initialize_bridge_by_governance_works() { + bridge_hub_test_utils::test_cases::initialize_bridge_by_governance_works::< + Runtime, + BridgeGrandpaRococoInstance, + >( + collator_session_keys(), + bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID, + Box::new(|call| RuntimeCall::BridgeRococoGrandpa(call).encode()), + ) + } + + #[test] + fn change_delivery_reward_by_governance_works() { + bridge_hub_test_utils::test_cases::change_storage_constant_by_governance_works::< + Runtime, + DeliveryRewardInBalance, + u64, + >( + collator_session_keys(), + bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID, + Box::new(|call| RuntimeCall::System(call).encode()), + || (DeliveryRewardInBalance::key().to_vec(), DeliveryRewardInBalance::get()), + |old_value| old_value.checked_mul(2).unwrap(), + ) + } + + #[test] + fn change_required_stake_by_governance_works() { + bridge_hub_test_utils::test_cases::change_storage_constant_by_governance_works::< + Runtime, + RequiredStakeForStakeAndSlash, + Balance, + >( + collator_session_keys(), + bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID, + Box::new(|call| RuntimeCall::System(call).encode()), + || { + ( + RequiredStakeForStakeAndSlash::key().to_vec(), + RequiredStakeForStakeAndSlash::get(), + ) + }, + |old_value| old_value.checked_mul(2).unwrap(), + ) + } + + #[test] + fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() { + bridge_hub_test_utils::test_cases::handle_export_message_from_system_parachain_to_outbound_queue_works::< + Runtime, + XcmConfig, + WithBridgeHubRococoMessagesInstance, + >( + collator_session_keys(), + bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID, + SIBLING_PARACHAIN_ID, + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::BridgeRococoMessages(event)) => Some(event), + _ => None, + } + }), + || ExportMessage { network: Rococo, destination: X1(Parachain(4321)), xcm: Xcm(vec![]) }, + bridge_hub_wococo_config::DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO + ) + } + + #[test] + fn message_dispatch_routing_works() { + bridge_hub_test_utils::test_cases::message_dispatch_routing_works::< + Runtime, + XcmConfig, + ParachainSystem, + WithBridgeHubRococoMessagesInstance, + RelayNetwork, + bridge_hub_wococo_config::RococoGlobalConsensusNetwork, + >( + collator_session_keys(), + bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID, + SIBLING_PARACHAIN_ID, + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::ParachainSystem(event)) => Some(event), + _ => None, + } + }), + Box::new(|runtime_event_encoded: Vec| { + match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) { + Ok(RuntimeEvent::XcmpQueue(event)) => Some(event), + _ => None, + } + }), + bridge_hub_wococo_config::DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO, + ) + } + + #[test] + fn relayed_incoming_message_works() { + bridge_hub_test_utils::test_cases::relayed_incoming_message_works::< + Runtime, + XcmConfig, + ParachainSystem, + BridgeGrandpaRococoInstance, + BridgeParachainRococoInstance, + WithBridgeHubRococoMessagesInstance, + WithBridgeHubRococoMessageBridge, + >( + collator_session_keys(), + bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID, + bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, + SIBLING_PARACHAIN_ID, + Wococo, + DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO, + ) + } + + #[test] + pub fn complex_relay_extrinsic_works() { + bridge_hub_test_utils::test_cases::complex_relay_extrinsic_works::< + Runtime, + XcmConfig, + ParachainSystem, + BridgeGrandpaRococoInstance, + BridgeParachainRococoInstance, + WithBridgeHubRococoMessagesInstance, + WithBridgeHubRococoMessageBridge, + >( + collator_session_keys(), + bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID, + bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, + SIBLING_PARACHAIN_ID, + bridge_hub_wococo_config::BridgeHubRococoChainId::get(), + Wococo, + DEFAULT_XCM_LANE_TO_BRIDGE_HUB_ROCOCO, + ExistentialDeposit::get(), + executive_init_block, + construct_and_apply_extrinsic, + ); + } +} diff --git a/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml b/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml index ccee28f82cf..42ccd6c5116 100644 --- a/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml +++ b/parachains/runtimes/bridge-hubs/test-utils/Cargo.toml @@ -6,12 +6,90 @@ edition = "2021" description = "Utils for BridgeHub testing" [dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } +log = { version = "0.4.17", default-features = false } +assert_matches = "1.4.0" + +# Substrate +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } +frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } # Cumulus asset-test-utils = { path = "../../assets/test-utils"} +cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false } +cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false } +pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false } +parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false } +parachains-runtimes-test-utils = { path = "../../test-utils", default-features = false } + +# Polkadot +pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +pallet-xcm-benchmarks = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false, optional = true } +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } + +# Bridges +bp-bridge-hub-rococo = { path = "../../../../bridges/primitives/chain-bridge-hub-rococo", default-features = false } +bp-bridge-hub-wococo = { path = "../../../../bridges/primitives/chain-bridge-hub-wococo", default-features = false } +bp-header-chain = { path = "../../../../bridges/primitives/header-chain", default-features = false } +bp-messages = { path = "../../../../bridges/primitives/messages", default-features = false } +bp-parachains = { path = "../../../../bridges/primitives/parachains", default-features = false } +bp-polkadot-core = { path = "../../../../bridges/primitives/polkadot-core", default-features = false } +bp-relayers = { path = "../../../../bridges/primitives/relayers", default-features = false } +bp-runtime = { path = "../../../../bridges/primitives/runtime", default-features = false } +bp-test-utils = { path = "../../../../bridges/primitives/test-utils", default-features = false } +pallet-bridge-grandpa = { path = "../../../../bridges/modules/grandpa", default-features = false } +pallet-bridge-parachains = { path = "../../../../bridges/modules/parachains", default-features = false } +pallet-bridge-messages = { path = "../../../../bridges/modules/messages", default-features = false } +pallet-bridge-relayers = { path = "../../../../bridges/modules/relayers", default-features = false } +bridge-runtime-common = { path = "../../../../bridges/bin/runtime-common", default-features = false } [features] default = [ "std" ] std = [ + "codec/std", + "log/std", + "frame-benchmarking/std", + "frame-executive/std", + "frame-support/std", + "frame-system/std", + "bp-bridge-hub-rococo/std", + "bp-bridge-hub-wococo/std", + "bp-messages/std", + "bp-parachains/std", + "bp-polkadot-core/std", + "bp-header-chain/std", + "bp-relayers/std", + "bp-runtime/std", + "bp-test-utils/std", + "bridge-runtime-common/std", + "pallet-bridge-grandpa/std", + "pallet-bridge-parachains/std", + "pallet-bridge-messages/std", + "pallet-bridge-relayers/std", + "parachain-info/std", + "parachains-runtimes-test-utils/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcmp-queue/std", + "pallet-xcm/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "xcm/std", + "xcm-builder/std", + "xcm-executor/std", "asset-test-utils/std", + "pallet-session/std", + "pallet-balances/std", + "pallet-utility/std", ] diff --git a/parachains/runtimes/bridge-hubs/test-utils/src/lib.rs b/parachains/runtimes/bridge-hubs/test-utils/src/lib.rs index 882910b5fc0..289d3f5b4d3 100644 --- a/parachains/runtimes/bridge-hubs/test-utils/src/lib.rs +++ b/parachains/runtimes/bridge-hubs/test-utils/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2023 Parity Technologies (UK) Ltd. +// Copyright Parity Technologies (UK) Ltd. // This file is part of Cumulus. // Cumulus is free software: you can redistribute it and/or modify @@ -14,5 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . +//! Module contains predefined test-case scenarios for "BridgeHub" `Runtime`s. + pub mod test_cases; -pub use test_cases::CollatorSessionKeys; +pub use bp_test_utils::test_header; +pub use parachains_runtimes_test_utils::*; diff --git a/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs b/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs index cdbeb65fab1..fe5495944f4 100644 --- a/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs +++ b/parachains/runtimes/bridge-hubs/test-utils/src/test_cases.rs @@ -16,5 +16,955 @@ //! Module contains predefined test-case scenarios for `Runtime` with bridging capabilities. -// Re-export test_cases from assets -pub use asset_test_utils::{include_teleports_for_native_asset_works, CollatorSessionKeys}; +use assert_matches::assert_matches; +use bp_messages::{ + target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch, SourceHeaderChain}, + LaneId, MessageKey, OutboundLaneData, Weight, +}; +use bp_parachains::{BestParaHeadHash, ParaInfo}; +use bp_polkadot_core::parachains::{ParaHash, ParaId}; +use bp_relayers::{RewardsAccountOwner, RewardsAccountParams}; +use bp_runtime::{HeaderOf, Parachain, StorageProofSize, UnderlyingChainOf}; +use bp_test_utils::{make_default_justification, prepare_parachain_heads_proof}; +use bridge_runtime_common::{ + messages::{ + target::FromBridgedChainMessagesProof, BridgedChain as MessageBridgedChain, MessageBridge, + }, + messages_generation::{encode_all_messages, encode_lane_data, prepare_messages_storage_proof}, + messages_xcm_extension::{XcmAsPlainPayload, XcmBlobMessageDispatchResult}, +}; +use codec::Encode; +use frame_support::{ + assert_ok, + traits::{Get, OriginTrait}, +}; +use pallet_bridge_grandpa::BridgedHeader; +use parachains_runtimes_test_utils::{ + mock_open_hrmp_channel, AccountIdOf, BalanceOf, CollatorSessionKeys, ExtBuilder, RuntimeHelper, + ValidatorIdOf, XcmReceivedFrom, +}; +use sp_core::H256; +use sp_keyring::AccountKeyring::*; +use sp_runtime::{traits::Header as HeaderT, AccountId32}; +use xcm::latest::prelude::*; +use xcm_builder::DispatchBlobError; +use xcm_executor::XcmExecutor; + +// Re-export test_case from assets +pub use asset_test_utils::include_teleports_for_native_asset_works; + +/// Test-case makes sure that `Runtime` can process bridging initialize via governance-like call +pub fn initialize_bridge_by_governance_works( + collator_session_key: CollatorSessionKeys, + runtime_para_id: u32, + runtime_call_encode: Box< + dyn Fn(pallet_bridge_grandpa::Call) -> Vec, + >, +) where + Runtime: frame_system::Config + + pallet_balances::Config + + pallet_session::Config + + pallet_xcm::Config + + parachain_info::Config + + pallet_collator_selection::Config + + cumulus_pallet_parachain_system::Config + + pallet_bridge_grandpa::Config, + GrandpaPalletInstance: 'static, + ValidatorIdOf: From>, +{ + ExtBuilder::::default() + .with_collators(collator_session_key.collators()) + .with_session_keys(collator_session_key.session_keys()) + .with_para_id(runtime_para_id.into()) + .with_tracing() + .build() + .execute_with(|| { + // check mode before + assert_eq!( + pallet_bridge_grandpa::PalletOperatingMode::::try_get(), + Err(()) + ); + + // encode `initialize` call + let initialize_call = runtime_call_encode(pallet_bridge_grandpa::Call::< + Runtime, + GrandpaPalletInstance, + >::initialize { + init_data: test_data::initialization_data::(12345), + }); + + // overestimate - check weight for `pallet_bridge_grandpa::Pallet::initialize()` call + let require_weight_at_most = + ::DbWeight::get().reads_writes(7, 7); + + // execute XCM with Transacts to `initialize bridge` as governance does + assert_ok!(RuntimeHelper::::execute_as_governance( + initialize_call, + require_weight_at_most + ) + .ensure_complete()); + + // check mode after + assert_eq!( + pallet_bridge_grandpa::PalletOperatingMode::::try_get(), + Ok(bp_runtime::BasicOperatingMode::Normal) + ); + }) +} + +/// Test-case makes sure that `Runtime` can change storage constant via governance-like call +pub fn change_storage_constant_by_governance_works( + collator_session_key: CollatorSessionKeys, + runtime_para_id: u32, + runtime_call_encode: Box) -> Vec>, + storage_constant_key_value: fn() -> (Vec, StorageConstantType), + new_storage_constant_value: fn(&StorageConstantType) -> StorageConstantType, +) where + Runtime: frame_system::Config + + pallet_balances::Config + + pallet_session::Config + + pallet_xcm::Config + + parachain_info::Config + + pallet_collator_selection::Config + + cumulus_pallet_parachain_system::Config, + ValidatorIdOf: From>, + StorageConstant: Get, + StorageConstantType: Encode + PartialEq + std::fmt::Debug, +{ + ExtBuilder::::default() + .with_collators(collator_session_key.collators()) + .with_session_keys(collator_session_key.session_keys()) + .with_para_id(runtime_para_id.into()) + .with_tracing() + .build() + .execute_with(|| { + let (storage_constant_key, storage_constant_init_value): ( + Vec, + StorageConstantType, + ) = storage_constant_key_value(); + + // check delivery reward constant before (not stored yet, just as default value is used) + assert_eq!(StorageConstant::get(), storage_constant_init_value); + assert_eq!(sp_io::storage::get(&storage_constant_key), None); + + let new_storage_constant_value = + new_storage_constant_value(&storage_constant_init_value); + assert_ne!(new_storage_constant_value, storage_constant_init_value); + + // encode `set_storage` call + let set_storage_call = + runtime_call_encode(frame_system::Call::::set_storage { + items: vec![( + storage_constant_key.clone(), + new_storage_constant_value.encode(), + )], + }); + + // estimate - storing just 1 value + use frame_system::WeightInfo; + let require_weight_at_most = + ::SystemWeightInfo::set_storage(1); + + // execute XCM with Transact to `set_storage` as governance does + assert_ok!(RuntimeHelper::::execute_as_governance( + set_storage_call, + require_weight_at_most + ) + .ensure_complete()); + + // check delivery reward constant after (stored) + assert_eq!(StorageConstant::get(), new_storage_constant_value); + assert_eq!( + sp_io::storage::get(&storage_constant_key), + Some(new_storage_constant_value.encode().into()) + ); + }) +} + +/// Test-case makes sure that `Runtime` can handle xcm `ExportMessage`: +/// Checks if received XCM messages is correctly added to the message outbound queue for delivery. +/// For SystemParachains we expect unpaid execution. +pub fn handle_export_message_from_system_parachain_to_outbound_queue_works< + Runtime, + XcmConfig, + MessagesPalletInstance, +>( + collator_session_key: CollatorSessionKeys, + runtime_para_id: u32, + sibling_parachain_id: u32, + unwrap_pallet_bridge_messages_event: Box< + dyn Fn(Vec) -> Option>, + >, + export_message_instruction: fn() -> Instruction, + expected_lane_id: LaneId, +) where + Runtime: frame_system::Config + + pallet_balances::Config + + pallet_session::Config + + pallet_xcm::Config + + parachain_info::Config + + pallet_collator_selection::Config + + cumulus_pallet_parachain_system::Config + + pallet_bridge_messages::Config, + XcmConfig: xcm_executor::Config, + MessagesPalletInstance: 'static, + ValidatorIdOf: From>, +{ + assert_ne!(runtime_para_id, sibling_parachain_id); + let sibling_parachain_location = MultiLocation::new(1, Parachain(sibling_parachain_id)); + + ExtBuilder::::default() + .with_collators(collator_session_key.collators()) + .with_session_keys(collator_session_key.session_keys()) + .with_para_id(runtime_para_id.into()) + .with_tracing() + .build() + .execute_with(|| { + // check queue before + assert_eq!( + pallet_bridge_messages::OutboundLanes::::try_get( + expected_lane_id + ), + Err(()) + ); + + // prepare `ExportMessage` + let xcm = Xcm(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + export_message_instruction(), + ]); + + // execute XCM + let hash = xcm.using_encoded(sp_io::hashing::blake2_256); + assert_ok!(XcmExecutor::::execute_xcm( + sibling_parachain_location, + xcm, + hash, + RuntimeHelper::::xcm_max_weight(XcmReceivedFrom::Sibling), + ) + .ensure_complete()); + + // check queue after + assert_eq!( + pallet_bridge_messages::OutboundLanes::::try_get( + expected_lane_id + ), + Ok(OutboundLaneData { + oldest_unpruned_nonce: 1, + latest_received_nonce: 0, + latest_generated_nonce: 1, + }) + ); + + // check events + let mut events = >::events() + .into_iter() + .filter_map(|e| unwrap_pallet_bridge_messages_event(e.event.encode())); + assert!( + events.any(|e| matches!(e, pallet_bridge_messages::Event::MessageAccepted { .. })) + ); + }) +} + +/// Test-case makes sure that Runtime can route XCM messages received in inbound queue, +/// We just test here `MessageDispatch` configuration. +/// We expect that runtime can route messages: +/// 1. to Parent (relay chain) +/// 2. to Sibling parachain +pub fn message_dispatch_routing_works< + Runtime, + XcmConfig, + HrmpChannelOpener, + MessagesPalletInstance, + RuntimeNetwork, + BridgedNetwork, +>( + collator_session_key: CollatorSessionKeys, + runtime_para_id: u32, + sibling_parachain_id: u32, + unwrap_cumulus_pallet_parachain_system_event: Box< + dyn Fn(Vec) -> Option>, + >, + unwrap_cumulus_pallet_xcmp_queue_event: Box< + dyn Fn(Vec) -> Option>, + >, + expected_lane_id: LaneId, +) where + Runtime: frame_system::Config + + pallet_balances::Config + + pallet_session::Config + + pallet_xcm::Config + + parachain_info::Config + + pallet_collator_selection::Config + + cumulus_pallet_parachain_system::Config + + cumulus_pallet_xcmp_queue::Config + + pallet_bridge_messages::Config, + XcmConfig: xcm_executor::Config, + MessagesPalletInstance: 'static, + ValidatorIdOf: From>, + HrmpChannelOpener: frame_support::inherent::ProvideInherent< + Call = cumulus_pallet_parachain_system::Call, + >, + // MessageDispatcher: MessageDispatch, DispatchLevelResult = XcmBlobMessageDispatchResult, DispatchPayload = XcmAsPlainPayload>, + RuntimeNetwork: Get, + BridgedNetwork: Get, +{ + assert_ne!(runtime_para_id, sibling_parachain_id); + + ExtBuilder::::default() + .with_collators(collator_session_key.collators()) + .with_session_keys(collator_session_key.session_keys()) + .with_safe_xcm_version(XCM_VERSION) + .with_para_id(runtime_para_id.into()) + .with_tracing() + .build() + .execute_with(|| { + // 1. this message is sent from other global consensus with destination of this Runtime relay chain (UMP) + let bridging_message = + test_data::simulate_message_exporter_on_bridged_chain::( + (RuntimeNetwork::get(), Here) + ); + let result = <>::MessageDispatch>::dispatch( + test_data::dispatch_message(expected_lane_id, 1, bridging_message) + ); + assert_eq!(format!("{:?}", result.dispatch_level_result), format!("{:?}", XcmBlobMessageDispatchResult::Dispatched)); + + // check events - UpwardMessageSent + let mut events = >::events() + .into_iter() + .filter_map(|e| unwrap_cumulus_pallet_parachain_system_event(e.event.encode())); + assert!( + events.any(|e| matches!(e, cumulus_pallet_parachain_system::Event::UpwardMessageSent { .. })) + ); + + // 2. this message is sent from other global consensus with destination of this Runtime sibling parachain (HRMP) + let bridging_message = + test_data::simulate_message_exporter_on_bridged_chain::( + (RuntimeNetwork::get(), X1(Parachain(sibling_parachain_id))), + ); + + // 2.1. WITHOUT opened hrmp channel -> RoutingError + let result = + <>::MessageDispatch>::dispatch( + DispatchMessage { + key: MessageKey { lane_id: expected_lane_id, nonce: 1 }, + data: DispatchMessageData { payload: Ok(bridging_message.clone()) }, + } + ); + assert_eq!(format!("{:?}", result.dispatch_level_result), format!("{:?}", XcmBlobMessageDispatchResult::NotDispatched(Some(DispatchBlobError::RoutingError)))); + + // check events - no XcmpMessageSent + assert_eq!(>::events() + .into_iter() + .filter_map(|e| unwrap_cumulus_pallet_xcmp_queue_event(e.event.encode())) + .count(), 0); + + // 2.1. WITH hrmp channel -> Ok + mock_open_hrmp_channel::(runtime_para_id.into(), sibling_parachain_id.into()); + let result = <>::MessageDispatch>::dispatch( + DispatchMessage { + key: MessageKey { lane_id: expected_lane_id, nonce: 1 }, + data: DispatchMessageData { payload: Ok(bridging_message) }, + } + ); + assert_eq!(format!("{:?}", result.dispatch_level_result), format!("{:?}", XcmBlobMessageDispatchResult::Dispatched)); + + // check events - XcmpMessageSent + let mut events = >::events() + .into_iter() + .filter_map(|e| unwrap_cumulus_pallet_xcmp_queue_event(e.event.encode())); + assert!( + events.any(|e| matches!(e, cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. })) + ); + }) +} + +/// Test-case makes sure that Runtime can dispatch XCM messages submitted by relayer, +/// with proofs (finality, para heads, message) independently submitted. +pub fn relayed_incoming_message_works( + collator_session_key: CollatorSessionKeys, + runtime_para_id: u32, + bridged_para_id: u32, + sibling_parachain_id: u32, + local_relay_chain_id: NetworkId, + lane_id: LaneId, +) where + Runtime: frame_system::Config + + pallet_balances::Config + + pallet_session::Config + + pallet_xcm::Config + + parachain_info::Config + + pallet_collator_selection::Config + + cumulus_pallet_parachain_system::Config + + cumulus_pallet_xcmp_queue::Config + + pallet_bridge_grandpa::Config + + pallet_bridge_parachains::Config + + pallet_bridge_messages::Config, + GPI: 'static, + PPI: 'static, + MPI: 'static, + MB: MessageBridge, + ::BridgedChain: Send + Sync + 'static, + UnderlyingChainOf>: bp_runtime::Chain + Parachain, + XcmConfig: xcm_executor::Config, + HrmpChannelOpener: frame_support::inherent::ProvideInherent< + Call = cumulus_pallet_parachain_system::Call, + >, + ValidatorIdOf: From>, + <>::SourceHeaderChain as SourceHeaderChain>::MessagesProof: From>, + <>::BridgedChain as bp_runtime::Chain>::Hash: From, + ParaHash: From<<>::BridgedChain as bp_runtime::Chain>::Hash>, + ::AccountId: + Into<<::RuntimeOrigin as OriginTrait>::AccountId>, + AccountIdOf: From, + >::InboundRelayer: From, +{ + assert_ne!(runtime_para_id, sibling_parachain_id); + assert_ne!(runtime_para_id, bridged_para_id); + + ExtBuilder::::default() + .with_collators(collator_session_key.collators()) + .with_session_keys(collator_session_key.session_keys()) + .with_safe_xcm_version(XCM_VERSION) + .with_para_id(runtime_para_id.into()) + .with_tracing() + .build() + .execute_with(|| { + mock_open_hrmp_channel::( + runtime_para_id.into(), + sibling_parachain_id.into(), + ); + + // start with bridged chain block#0 + let init_data = test_data::initialization_data::(0); + pallet_bridge_grandpa::Pallet::::initialize( + RuntimeHelper::::root_origin(), + init_data, + ) + .unwrap(); + + // set up relayer details and proofs + + let message_destination = + X2(GlobalConsensus(local_relay_chain_id), Parachain(sibling_parachain_id)); + // some random numbers (checked by test) + let message_nonce = 1; + let para_header_number = 5; + let relay_header_number = 1; + + let relayer_at_target = Bob; + let relayer_id_on_target: AccountIdOf = relayer_at_target.public().into(); + let relayer_at_source = Dave; + let relayer_id_on_source: AccountId32 = relayer_at_source.public().into(); + + let xcm = vec![xcm::v3::Instruction::<()>::ClearOrigin; 42]; + let expected_dispatch = xcm::latest::Xcm::<()>(xcm.clone()); + // generate bridged relay chain finality, parachain heads and message proofs, + // to be submitted by relayer to this chain. + let ( + relay_chain_header, + grandpa_justification, + bridged_para_head, + parachain_heads, + para_heads_proof, + message_proof, + ) = test_data::make_complex_relayer_proofs::, MB, ()>( + lane_id, + xcm.into(), + message_nonce, + message_destination, + para_header_number, + relay_header_number, + bridged_para_id, + ); + + // submit bridged relay chain finality proof + { + let result = pallet_bridge_grandpa::Pallet::::submit_finality_proof( + RuntimeHelper::::origin_of(relayer_id_on_target.clone()), + Box::new(relay_chain_header.clone()), + grandpa_justification, + ); + assert_ok!(result); + assert_eq!(result.unwrap().pays_fee, frame_support::dispatch::Pays::Yes); + } + + // verify finality proof correctly imported + assert_eq!( + pallet_bridge_grandpa::BestFinalized::::get().unwrap().1, + relay_chain_header.hash() + ); + assert!(pallet_bridge_grandpa::ImportedHeaders::::contains_key( + relay_chain_header.hash() + )); + + // submit parachain heads proof + { + let result = + pallet_bridge_parachains::Pallet::::submit_parachain_heads( + RuntimeHelper::::origin_of(relayer_id_on_target.clone()), + (relay_header_number, relay_chain_header.hash().into()), + parachain_heads, + para_heads_proof, + ); + assert_ok!(result); + assert_eq!(result.unwrap().pays_fee, frame_support::dispatch::Pays::Yes); + } + // verify parachain head proof correctly imported + assert_eq!( + pallet_bridge_parachains::ParasInfo::::get(ParaId(bridged_para_id)), + Some(ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: relay_header_number, + head_hash: bridged_para_head.hash() + }, + next_imported_hash_position: 1, + }) + ); + + // import message + assert!(RuntimeHelper::>::take_xcm( + sibling_parachain_id.into() + ) + .is_none()); + assert_eq!( + pallet_bridge_messages::InboundLanes::::get(lane_id) + .last_delivered_nonce(), + 0, + ); + // submit message proof + { + let result = pallet_bridge_messages::Pallet::::receive_messages_proof( + RuntimeHelper::::origin_of(relayer_id_on_target), + relayer_id_on_source.into(), + message_proof.into(), + 1, + Weight::MAX / 1000, + ); + assert_ok!(result); + assert_eq!(result.unwrap().pays_fee, frame_support::dispatch::Pays::Yes); + } + // verify message correctly imported and dispatched + assert_eq!( + pallet_bridge_messages::InboundLanes::::get(lane_id) + .last_delivered_nonce(), + 1, + ); + // verify relayed bridged XCM message is dispatched to destination sibling para + let dispatched = RuntimeHelper::>::take_xcm( + sibling_parachain_id.into(), + ) + .unwrap(); + let mut dispatched = xcm::latest::Xcm::<()>::try_from(dispatched).unwrap(); + // We use `WithUniqueTopic`, so expect a trailing `SetTopic`. + assert_matches!(dispatched.0.pop(), Some(SetTopic(..))); + assert_eq!(dispatched, expected_dispatch); + }) +} + +/// Test-case makes sure that Runtime can dispatch XCM messages submitted by relayer, +/// with proofs (finality, para heads, message) batched together in signed extrinsic. +/// Also verifies relayer transaction signed extensions work as intended. +pub fn complex_relay_extrinsic_works( + collator_session_key: CollatorSessionKeys, + runtime_para_id: u32, + bridged_para_id: u32, + sibling_parachain_id: u32, + bridged_chain_id: bp_runtime::ChainId, + local_relay_chain_id: NetworkId, + lane_id: LaneId, + existential_deposit: BalanceOf, + executive_init_block: fn(&::Header), + construct_and_apply_extrinsic: fn( + sp_keyring::AccountKeyring, + pallet_utility::Call:: + ) -> sp_runtime::DispatchOutcome, +) where + Runtime: frame_system::Config + + pallet_balances::Config + + pallet_utility::Config + + pallet_session::Config + + pallet_xcm::Config + + parachain_info::Config + + pallet_collator_selection::Config + + cumulus_pallet_parachain_system::Config + + cumulus_pallet_xcmp_queue::Config + + pallet_bridge_grandpa::Config + + pallet_bridge_parachains::Config + + pallet_bridge_messages::Config + + pallet_bridge_relayers::Config, + GPI: 'static, + PPI: 'static, + MPI: 'static, + MB: MessageBridge, + ::BridgedChain: Send + Sync + 'static, + UnderlyingChainOf>: bp_runtime::Chain + Parachain, + XcmConfig: xcm_executor::Config, + HrmpChannelOpener: frame_support::inherent::ProvideInherent< + Call = cumulus_pallet_parachain_system::Call, + >, + ValidatorIdOf: From>, + <>::SourceHeaderChain as SourceHeaderChain>::MessagesProof: From>, + <>::BridgedChain as bp_runtime::Chain>::Hash: From, + ParaHash: From<<>::BridgedChain as bp_runtime::Chain>::Hash>, + ::AccountId: + Into<<::RuntimeOrigin as OriginTrait>::AccountId>, + AccountIdOf: From, + >::InboundRelayer: From, + ::RuntimeCall: + From> + + From> + + From> +{ + assert_ne!(runtime_para_id, sibling_parachain_id); + assert_ne!(runtime_para_id, bridged_para_id); + + // Relayer account at local/this BH. + let relayer_at_target = Bob; + let relayer_id_on_target: AccountIdOf = relayer_at_target.public().into(); + let relayer_initial_balance = existential_deposit * 100000u32.into(); + // Relayer account at remote/bridged BH. + let relayer_at_source = Dave; + let relayer_id_on_source: AccountId32 = relayer_at_source.public().into(); + + ExtBuilder::::default() + .with_collators(collator_session_key.collators()) + .with_session_keys(collator_session_key.session_keys()) + .with_safe_xcm_version(XCM_VERSION) + .with_para_id(runtime_para_id.into()) + .with_balances(vec![(relayer_id_on_target.clone(), relayer_initial_balance)]) + .with_tracing() + .build() + .execute_with(|| { + let zero: ::BlockNumber = 0u32.into(); + let genesis_hash = frame_system::Pallet::::block_hash(zero); + let mut header: ::Header = + bp_test_utils::test_header(1u32.into()); + header.set_parent_hash(genesis_hash); + executive_init_block(&header); + + mock_open_hrmp_channel::( + runtime_para_id.into(), + sibling_parachain_id.into(), + ); + + // start with bridged chain block#0 + let init_data = test_data::initialization_data::(0); + pallet_bridge_grandpa::Pallet::::initialize( + RuntimeHelper::::root_origin(), + init_data, + ) + .unwrap(); + + // set up relayer details and proofs + + let message_destination = + X2(GlobalConsensus(local_relay_chain_id), Parachain(sibling_parachain_id)); + // some random numbers (checked by test) + let message_nonce = 1; + let para_header_number = 5; + let relay_header_number = 1; + + let xcm = vec![xcm::latest::Instruction::<()>::ClearOrigin; 42]; + let expected_dispatch = xcm::latest::Xcm::<()>(xcm.clone()); + // generate bridged relay chain finality, parachain heads and message proofs, + // to be submitted by relayer to this chain. + let ( + relay_chain_header, + grandpa_justification, + bridged_para_head, + parachain_heads, + para_heads_proof, + message_proof, + ) = test_data::make_complex_relayer_proofs::, MB, ()>( + lane_id, + xcm.into(), + message_nonce, + message_destination, + para_header_number, + relay_header_number, + bridged_para_id, + ); + + let submit_grandpa = + pallet_bridge_grandpa::Call::::submit_finality_proof { + finality_target: Box::new(relay_chain_header.clone()), + justification: grandpa_justification, + }; + let submit_para_head = + pallet_bridge_parachains::Call::::submit_parachain_heads { + at_relay_block: (relay_header_number, relay_chain_header.hash().into()), + parachains: parachain_heads, + parachain_heads_proof: para_heads_proof, + }; + let submit_message = + pallet_bridge_messages::Call::::receive_messages_proof { + relayer_id_at_bridged_chain: relayer_id_on_source.into(), + proof: message_proof.into(), + messages_count: 1, + dispatch_weight: Weight::from_parts(1000000000, 0), + }; + let batch = pallet_utility::Call::::batch_all { + calls: vec![submit_grandpa.into(), submit_para_head.into(), submit_message.into()], + }; + + // sanity checks - before relayer extrinsic + assert!(RuntimeHelper::>::take_xcm( + sibling_parachain_id.into() + ) + .is_none()); + assert_eq!( + pallet_bridge_messages::InboundLanes::::get(lane_id) + .last_delivered_nonce(), + 0, + ); + let msg_proofs_rewards_account = RewardsAccountParams::new( + lane_id, + bridged_chain_id, + RewardsAccountOwner::ThisChain, + ); + assert_eq!( + pallet_bridge_relayers::RelayerRewards::::get( + relayer_id_on_target.clone(), + msg_proofs_rewards_account + ), + None, + ); + + // construct and apply extrinsic containing batch calls: + // bridged relay chain finality proof + // + parachain heads proof + // + submit message proof + let dispatch_outcome = construct_and_apply_extrinsic(relayer_at_target, batch); + + // verify finality proof correctly imported + assert_ok!(dispatch_outcome); + assert_eq!( + >::get().unwrap().1, + relay_chain_header.hash() + ); + assert!(>::contains_key( + relay_chain_header.hash() + )); + // verify parachain head proof correctly imported + assert_eq!( + pallet_bridge_parachains::ParasInfo::::get(ParaId(bridged_para_id)), + Some(ParaInfo { + best_head_hash: BestParaHeadHash { + at_relay_block_number: relay_header_number, + head_hash: bridged_para_head.hash() + }, + next_imported_hash_position: 1, + }) + ); + // verify message correctly imported and dispatched + assert_eq!( + pallet_bridge_messages::InboundLanes::::get(lane_id) + .last_delivered_nonce(), + 1, + ); + // verify relayer is refunded + assert!(pallet_bridge_relayers::RelayerRewards::::get( + relayer_id_on_target, + msg_proofs_rewards_account + ) + .is_some()); + // verify relayed bridged XCM message is dispatched to destination sibling para + let dispatched = RuntimeHelper::>::take_xcm( + sibling_parachain_id.into(), + ) + .unwrap(); + let mut dispatched = xcm::latest::Xcm::<()>::try_from(dispatched).unwrap(); + // We use `WithUniqueTopic`, so expect a trailing `SetTopic`. + assert_matches!(dispatched.0.pop(), Some(SetTopic(..))); + assert_eq!(dispatched, expected_dispatch); + }) +} + +pub mod test_data { + use super::*; + use bp_header_chain::justification::GrandpaJustification; + use bp_messages::MessageNonce; + use bp_polkadot_core::parachains::{ParaHash, ParaHead, ParaHeadsProof, ParaId}; + use bp_runtime::BasicOperatingMode; + use bp_test_utils::authority_list; + use xcm_builder::{HaulBlob, HaulBlobError, HaulBlobExporter}; + use xcm_executor::traits::{validate_export, ExportXcm}; + + pub fn prepare_inbound_xcm( + xcm_message: Xcm, + destination: InteriorMultiLocation, + ) -> Vec { + let location = xcm::VersionedInteriorMultiLocation::V3(destination); + let xcm = xcm::VersionedXcm::::V3(xcm_message); + // this is the `BridgeMessage` from polkadot xcm builder, but it has no constructor + // or public fields, so just tuple + // (double encoding, because `.encode()` is called on original Xcm BLOB when it is pushed + // to the storage) + (location, xcm).encode().encode() + } + + pub fn make_complex_relayer_proofs( + lane_id: LaneId, + xcm_message: Xcm, + message_nonce: MessageNonce, + message_destination: Junctions, + para_header_number: u32, + relay_header_number: u32, + bridged_para_id: u32, + ) -> ( + BridgedRelayHeader, + GrandpaJustification, + ParaHead, + Vec<(ParaId, ParaHash)>, + ParaHeadsProof, + FromBridgedChainMessagesProof, + ) + where + BridgedRelayHeader: HeaderT, + ::Hash: From, + MB: MessageBridge, + ::BridgedChain: Send + Sync + 'static, + UnderlyingChainOf>: bp_runtime::Chain + Parachain, + { + let message_payload = prepare_inbound_xcm(xcm_message, message_destination); + let message_size = StorageProofSize::Minimal(message_payload.len() as u32); + // prepare para storage proof containing message + let (para_state_root, para_storage_proof) = prepare_messages_storage_proof::( + lane_id, + message_nonce..=message_nonce, + None, + message_size, + message_payload, + encode_all_messages, + encode_lane_data, + ); + + let bridged_para_head = ParaHead( + bp_test_utils::test_header_with_root::>( + para_header_number.into(), + para_state_root.into(), + ) + .encode(), + ); + let (relay_state_root, para_heads_proof, parachain_heads) = + prepare_parachain_heads_proof::>(vec![( + bridged_para_id, + bridged_para_head.clone(), + )]); + assert_eq!(bridged_para_head.hash(), parachain_heads[0].1); + + let message_proof = FromBridgedChainMessagesProof { + bridged_header_hash: bridged_para_head.hash(), + storage_proof: para_storage_proof, + lane: lane_id, + nonces_start: message_nonce, + nonces_end: message_nonce, + }; + + // import bridged relay chain block#1 with state root containing head#5 of bridged parachain + let relay_chain_header: BridgedRelayHeader = bp_test_utils::test_header_with_root( + relay_header_number.into(), + relay_state_root.into(), + ); + let justification = make_default_justification(&relay_chain_header); + ( + relay_chain_header, + justification, + bridged_para_head, + parachain_heads, + para_heads_proof, + message_proof, + ) + } + + /// Helper that creates InitializationData mock data, that can be used to initialize bridge GRANDPA pallet + pub fn initialization_data< + Runtime: pallet_bridge_grandpa::Config, + GrandpaPalletInstance: 'static, + >( + block_number: u32, + ) -> bp_header_chain::InitializationData> { + bp_header_chain::InitializationData { + header: Box::new(bp_test_utils::test_header(block_number.into())), + authority_list: authority_list(), + set_id: 1, + operating_mode: BasicOperatingMode::Normal, + } + } + + /// Dummy xcm + pub(crate) fn dummy_xcm() -> Xcm<()> { + vec![Trap(42)].into() + } + + pub(crate) fn dispatch_message( + lane_id: LaneId, + nonce: MessageNonce, + payload: Vec, + ) -> DispatchMessage> { + DispatchMessage { + key: MessageKey { lane_id, nonce }, + data: DispatchMessageData { payload: Ok(payload) }, + } + } + + /// Macro used for simulate_export_message and capturing bytes + macro_rules! grab_haul_blob ( + ($name:ident, $grabbed_payload:ident) => { + std::thread_local! { + static $grabbed_payload: std::cell::RefCell>> = std::cell::RefCell::new(None); + } + + struct $name; + impl HaulBlob for $name { + fn haul_blob(blob: Vec) -> Result<(), HaulBlobError>{ + $grabbed_payload.with(|rm| *rm.borrow_mut() = Some(blob)); + Ok(()) + } + } + } + ); + + /// Simulates `HaulBlobExporter` and all its wrapping and captures generated plain bytes, + /// which are transfered over bridge. + pub(crate) fn simulate_message_exporter_on_bridged_chain< + SourceNetwork: Get, + DestinationNetwork: Get, + >( + (destination_network, destination_junctions): (NetworkId, Junctions), + ) -> Vec { + grab_haul_blob!(GrabbingHaulBlob, GRABBED_HAUL_BLOB_PAYLOAD); + + // lets pretend that some parachain on bridged chain exported the message + let universal_source_on_bridged_chain = + X2(GlobalConsensus(SourceNetwork::get()), Parachain(5678)); + let channel = 1_u32; + + // simulate XCM message export + let (ticket, fee) = + validate_export::>( + destination_network, + channel, + universal_source_on_bridged_chain, + destination_junctions, + dummy_xcm(), + ) + .expect("validate_export to pass"); + log::info!( + target: "simulate_message_exporter_on_bridged_chain", + "HaulBlobExporter::validate fee: {:?}", + fee + ); + let xcm_hash = + HaulBlobExporter::::deliver(ticket) + .expect("deliver to pass"); + log::info!( + target: "simulate_message_exporter_on_bridged_chain", + "HaulBlobExporter::deliver xcm_hash: {:?}", + xcm_hash + ); + + GRABBED_HAUL_BLOB_PAYLOAD.with(|r| r.take().expect("Encoded message should be here")) + } +} diff --git a/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml b/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml index a2c2bf27620..8e7c24293a0 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml +++ b/parachains/runtimes/collectives/collectives-polkadot/Cargo.toml @@ -8,8 +8,8 @@ description = "Polkadot Collectives Parachain Runtime" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } hex-literal = { version = "0.4.1" } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } smallvec = "1.10.0" # Substrate diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/migration.rs b/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/migration.rs index 5056abb2e22..8ceb1c403b0 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/migration.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/migration.rs @@ -27,7 +27,7 @@ pub(crate) mod import_kusama_fellowship { #[cfg(feature = "try-runtime")] use sp_std::vec::Vec; - const TARGET: &'static str = "runtime::migration::import_fellowship"; + const TARGET: &str = "runtime::migration::import_fellowship"; parameter_types! { // The Fellowship addresses from Kusama state. @@ -90,11 +90,11 @@ pub(crate) mod import_kusama_fellowship { ::AccountId: From<[u8; 32]>, { #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { let onchain_version = RankedCollective::::on_chain_storage_version(); - assert_eq!(onchain_version, 0, "the storage version must be 0."); + ensure!(onchain_version == 0, "the storage version must be 0."); let member_count = MemberCount::::get(0); - assert_eq!(member_count, 0, "the collective must be uninitialized."); + ensure!(member_count == 0, "the collective must be uninitialized."); Ok(Vec::new()) } @@ -143,15 +143,15 @@ pub(crate) mod import_kusama_fellowship { } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), &'static str> { - assert_eq!(MemberCount::::get(0), 47, "invalid members count at rank 0."); - assert_eq!(MemberCount::::get(1), 47, "invalid members count at rank 1."); - assert_eq!(MemberCount::::get(2), 24, "invalid members count at rank 2."); - assert_eq!(MemberCount::::get(3), 17, "invalid members count at rank 3."); - assert_eq!(MemberCount::::get(4), 10, "invalid members count at rank 4."); - assert_eq!(MemberCount::::get(5), 7, "invalid members count at rank 5."); - assert_eq!(MemberCount::::get(6), 3, "invalid members count at rank 6."); - assert_eq!(MemberCount::::get(7), 0, "invalid members count at rank 7."); + fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + ensure!(MemberCount::::get(0) == 47, "invalid members count at rank 0."); + ensure!(MemberCount::::get(1) == 47, "invalid members count at rank 1."); + ensure!(MemberCount::::get(2) == 24, "invalid members count at rank 2."); + ensure!(MemberCount::::get(3) == 17, "invalid members count at rank 3."); + ensure!(MemberCount::::get(4) == 10, "invalid members count at rank 4."); + ensure!(MemberCount::::get(5) == 7, "invalid members count at rank 5."); + ensure!(MemberCount::::get(6) == 3, "invalid members count at rank 6."); + ensure!(MemberCount::::get(7) == 0, "invalid members count at rank 7."); Ok(()) } } @@ -250,7 +250,7 @@ pub mod tests { assert!(IdToIndex::::get(0, &who).is_some()); assert!(IdToIndex::::get(rank + 1, &who).is_none()); let index = IdToIndex::::get(rank, &who).unwrap(); - assert_eq!(IndexToId::::get(rank, &index).unwrap(), who); + assert_eq!(IndexToId::::get(rank, index).unwrap(), who); assert_eq!( Members::::get(&who).unwrap(), MemberRecord::new(rank) diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/tracks.rs b/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/tracks.rs index 5d75bde9e18..1f728279485 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/tracks.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/fellowship/tracks.rs @@ -54,7 +54,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -76,7 +76,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -98,7 +98,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -120,7 +120,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -142,7 +142,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -160,11 +160,11 @@ impl pallet_referenda::TracksInfo for TracksInfo { pallet_referenda::TrackInfo { name: "experts", max_deciding: 10, - decision_deposit: 1 * DOLLARS, + decision_deposit: DOLLARS, prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -182,11 +182,11 @@ impl pallet_referenda::TracksInfo for TracksInfo { pallet_referenda::TrackInfo { name: "senior experts", max_deciding: 10, - decision_deposit: 1 * DOLLARS, + decision_deposit: DOLLARS, prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -204,11 +204,11 @@ impl pallet_referenda::TracksInfo for TracksInfo { pallet_referenda::TrackInfo { name: "masters", max_deciding: 10, - decision_deposit: 1 * DOLLARS, + decision_deposit: DOLLARS, prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -226,11 +226,11 @@ impl pallet_referenda::TracksInfo for TracksInfo { pallet_referenda::TrackInfo { name: "senior masters", max_deciding: 10, - decision_deposit: 1 * DOLLARS, + decision_deposit: DOLLARS, prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), @@ -248,11 +248,11 @@ impl pallet_referenda::TracksInfo for TracksInfo { pallet_referenda::TrackInfo { name: "grand masters", max_deciding: 10, - decision_deposit: 1 * DOLLARS, + decision_deposit: DOLLARS, prepare_period: 30 * MINUTES, decision_period: 7 * DAYS, confirm_period: 30 * MINUTES, - min_enactment_period: 1 * MINUTES, + min_enactment_period: MINUTES, min_approval: pallet_referenda::Curve::LinearDecreasing { length: Perbill::from_percent(100), floor: Perbill::from_percent(50), diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs b/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs index f70fb30bff7..3b45d2824d9 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/impls.rs @@ -59,7 +59,7 @@ where let pallet_acc: AccountIdOf = PalletAccount::get(); let treasury_acc: AccountIdOf = TreasuryAccount::get(); - >::resolve_creating(&pallet_acc.clone(), amount); + >::resolve_creating(&pallet_acc, amount); let result = >::teleport_assets( <::RuntimeOrigin>::signed(pallet_acc.into()), @@ -73,10 +73,9 @@ where 0, ); - match result { - Err(err) => log::warn!("Failed to teleport slashed assets: {:?}", err), - _ => (), - }; + if let Err(err) = result { + log::warn!("Failed to teleport slashed assets: {:?}", err); + } } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs index da77aa573c8..b54f90f7f16 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/lib.rs @@ -110,10 +110,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("collectives"), impl_name: create_runtime_str!("collectives"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 4, + transaction_version: 5, state_version: 0, }; @@ -210,7 +210,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = weights::pallet_balances::WeightInfo; type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -218,7 +218,7 @@ impl pallet_balances::Config for Runtime { parameter_types! { /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 1 * MILLICENTS; + pub const TransactionByteFee: Balance = MILLICENTS; } impl pallet_transaction_payment::Config for Runtime { @@ -391,7 +391,7 @@ impl pallet_message_queue::Config for Runtime { >; #[cfg(not(feature = "runtime-benchmarks"))] type MessageProcessor = parachains_common::process_xcm_message::SplitMessages< - ProcessXcmMessage< + xcm_builder::ProcessXcmMessage< AggregateMessageOrigin, xcm_executor::XcmExecutor, RuntimeCall, @@ -418,7 +418,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type XcmpProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor; #[cfg(not(feature = "runtime-benchmarks"))] type XcmpProcessor = ProcessFromSibling< - ProcessXcmMessage< + xcm_builder::ProcessXcmMessage< AggregateMessageOrigin, xcm_executor::XcmExecutor, RuntimeCall, @@ -665,7 +665,12 @@ pub type UncheckedExtrinsic = pub type CheckedExtrinsic = generic::CheckedExtrinsic; // All migrations executed on runtime upgrade as a nested tuple of types implementing // `OnRuntimeUpgrade`. Included migrations must be idempotent. -type Migrations = import_kusama_fellowship::Migration; +type Migrations = ( + // v9420 + import_kusama_fellowship::Migration, + // unreleased + pallet_collator_selection::migration::v1::MigrateToV1, +); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -879,7 +884,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( @@ -935,7 +940,7 @@ impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { .create_inherent_data() .expect("Could not create the timestamp inherent data"); - inherent_data.check_extrinsics(&block) + inherent_data.check_extrinsics(block) } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs index 26e2ef7cc22..a8477008e6b 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/cumulus_pallet_xcmp_queue.rs @@ -31,7 +31,7 @@ // --pallet // cumulus_pallet_xcmp_queue // --extrinsic -// +// // --execution // native // --output @@ -44,9 +44,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `cumulus_pallet_xcmp_queue`. pub struct WeightInfo(PhantomData); diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/frame_system.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/frame_system.rs index 7bd018bd341..634757aa60b 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/frame_system.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/frame_system.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `frame_system` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `frame_system`. pub struct WeightInfo(PhantomData); @@ -52,22 +53,22 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_300_000 picoseconds. - Weight::from_parts(2_345_000, 0) + // Minimum execution time: 2_326_000 picoseconds. + Weight::from_parts(2_387_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(370, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(413, 0).saturating_mul(b.into())) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 8_053_000 picoseconds. - Weight::from_parts(8_155_000, 0) + // Minimum execution time: 7_797_000 picoseconds. + Weight::from_parts(7_933_000, 0) .saturating_add(Weight::from_parts(0, 0)) // Standard Error: 0 - .saturating_add(Weight::from_parts(1_414, 0).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(1_455, 0).saturating_mul(b.into())) } /// Storage: System Digest (r:1 w:1) /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) @@ -77,12 +78,15 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 4_456_000 picoseconds. - Weight::from_parts(4_609_000, 0) + // Minimum execution time: 4_428_000 picoseconds. + Weight::from_parts(4_614_000, 0) .saturating_add(Weight::from_parts(0, 1485)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } + fn set_code() -> Weight { + Weight::from_parts(1_000_000, 0) + } /// Storage: Skipped Metadata (r:0 w:0) /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `i` is `[0, 1000]`. @@ -90,11 +94,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_370_000 picoseconds. - Weight::from_parts(2_403_000, 0) + // Minimum execution time: 2_429_000 picoseconds. + Weight::from_parts(2_469_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1_643 - .saturating_add(Weight::from_parts(676_881, 0).saturating_mul(i.into())) + // Standard Error: 1_872 + .saturating_add(Weight::from_parts(671_478, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -104,11 +108,11 @@ impl frame_system::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_342_000 picoseconds. - Weight::from_parts(2_394_000, 0) + // Minimum execution time: 2_415_000 picoseconds. + Weight::from_parts(2_487_000, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 917 - .saturating_add(Weight::from_parts(502_661, 0).saturating_mul(i.into())) + // Standard Error: 923 + .saturating_add(Weight::from_parts(493_312, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } /// Storage: Skipped Metadata (r:0 w:0) @@ -116,13 +120,13 @@ impl frame_system::WeightInfo for WeightInfo { /// The range of component `p` is `[0, 1000]`. fn kill_prefix(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `68 + p * (69 ±0)` - // Estimated: `69 + p * (70 ±0)` - // Minimum execution time: 4_461_000 picoseconds. - Weight::from_parts(4_561_000, 0) - .saturating_add(Weight::from_parts(0, 69)) - // Standard Error: 1_428 - .saturating_add(Weight::from_parts(1_016_381, 0).saturating_mul(p.into())) + // Measured: `82 + p * (69 ±0)` + // Estimated: `77 + p * (70 ±0)` + // Minimum execution time: 4_228_000 picoseconds. + Weight::from_parts(4_297_000, 0) + .saturating_add(Weight::from_parts(0, 77)) + // Standard Error: 1_145 + .saturating_add(Weight::from_parts(1_022_122, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_alliance.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_alliance.rs index f8bf9ca73dd..4ee8738d5af 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_alliance.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_alliance.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_alliance` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_alliance`. pub struct WeightInfo(PhantomData); @@ -63,20 +64,20 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `439 + m * (32 ±0) + p * (36 ±0)` - // Estimated: `14703 + m * (128 ±0) + p * (144 ±0)` - // Minimum execution time: 29_793_000 picoseconds. - Weight::from_parts(31_622_009, 0) - .saturating_add(Weight::from_parts(0, 14703)) - // Standard Error: 59 - .saturating_add(Weight::from_parts(194, 0).saturating_mul(b.into())) - // Standard Error: 626 - .saturating_add(Weight::from_parts(16_277, 0).saturating_mul(m.into())) - // Standard Error: 618 - .saturating_add(Weight::from_parts(115_342, 0).saturating_mul(p.into())) + // Estimated: `6676 + m * (32 ±0) + p * (36 ±0)` + // Minimum execution time: 30_492_000 picoseconds. + Weight::from_parts(33_119_713, 0) + .saturating_add(Weight::from_parts(0, 6676)) + // Standard Error: 60 + .saturating_add(Weight::from_parts(285, 0).saturating_mul(b.into())) + // Standard Error: 632 + .saturating_add(Weight::from_parts(10_988, 0).saturating_mul(m.into())) + // Standard Error: 624 + .saturating_add(Weight::from_parts(140_169, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) - .saturating_add(Weight::from_parts(0, 128).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 144).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) @@ -86,12 +87,12 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn vote(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `868 + m * (64 ±0)` - // Estimated: `11008 + m * (64 ±0)` - // Minimum execution time: 24_860_000 picoseconds. - Weight::from_parts(25_540_583, 0) - .saturating_add(Weight::from_parts(0, 11008)) - // Standard Error: 1_049 - .saturating_add(Weight::from_parts(44_450, 0).saturating_mul(m.into())) + // Estimated: `6676 + m * (64 ±0)` + // Minimum execution time: 25_442_000 picoseconds. + Weight::from_parts(26_215_947, 0) + .saturating_add(Weight::from_parts(0, 6676)) + // Standard Error: 410 + .saturating_add(Weight::from_parts(43_449, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) @@ -111,18 +112,18 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn close_early_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `312 + m * (96 ±0) + p * (36 ±0)` - // Estimated: `14519 + m * (388 ±0) + p * (144 ±0)` - // Minimum execution time: 35_120_000 picoseconds. - Weight::from_parts(33_274_472, 0) - .saturating_add(Weight::from_parts(0, 14519)) - // Standard Error: 1_030 - .saturating_add(Weight::from_parts(41_853, 0).saturating_mul(m.into())) - // Standard Error: 1_004 - .saturating_add(Weight::from_parts(111_626, 0).saturating_mul(p.into())) + // Estimated: `6676 + m * (97 ±0) + p * (36 ±0)` + // Minimum execution time: 35_991_000 picoseconds. + Weight::from_parts(34_605_748, 0) + .saturating_add(Weight::from_parts(0, 6676)) + // Standard Error: 598 + .saturating_add(Weight::from_parts(38_227, 0).saturating_mul(m.into())) + // Standard Error: 583 + .saturating_add(Weight::from_parts(119_512, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 388).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 144).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 97).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) @@ -140,18 +141,18 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn close_early_approved(_b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `762 + m * (96 ±0) + p * (41 ±0)` - // Estimated: `19732 + m * (388 ±0) + p * (160 ±0)` - // Minimum execution time: 47_135_000 picoseconds. - Weight::from_parts(42_191_348, 0) - .saturating_add(Weight::from_parts(0, 19732)) - // Standard Error: 4_449 - .saturating_add(Weight::from_parts(76_548, 0).saturating_mul(m.into())) - // Standard Error: 4_337 - .saturating_add(Weight::from_parts(143_406, 0).saturating_mul(p.into())) + // Estimated: `6676 + m * (97 ±0) + p * (40 ±0)` + // Minimum execution time: 48_168_000 picoseconds. + Weight::from_parts(48_554_161, 0) + .saturating_add(Weight::from_parts(0, 6676)) + // Standard Error: 1_770 + .saturating_add(Weight::from_parts(47_441, 0).saturating_mul(m.into())) + // Standard Error: 1_725 + .saturating_add(Weight::from_parts(119_704, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 388).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 160).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 97).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 40).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) @@ -172,18 +173,18 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn close_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `518 + m * (96 ±0) + p * (41 ±0)` - // Estimated: `19135 + m * (509 ±0) + p * (203 ±0)` - // Minimum execution time: 45_329_000 picoseconds. - Weight::from_parts(46_859_108, 0) - .saturating_add(Weight::from_parts(0, 19135)) - // Standard Error: 3_831 - .saturating_add(Weight::from_parts(100_587, 0).saturating_mul(m.into())) - // Standard Error: 3_785 - .saturating_add(Weight::from_parts(134_469, 0).saturating_mul(p.into())) + // Estimated: `6676 + m * (109 ±0) + p * (43 ±0)` + // Minimum execution time: 47_356_000 picoseconds. + Weight::from_parts(48_308_769, 0) + .saturating_add(Weight::from_parts(0, 6676)) + // Standard Error: 3_712 + .saturating_add(Weight::from_parts(99_809, 0).saturating_mul(m.into())) + // Standard Error: 3_667 + .saturating_add(Weight::from_parts(136_999, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) - .saturating_add(Weight::from_parts(0, 509).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 203).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 109).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 43).saturating_mul(p.into())) } /// Storage: Alliance Members (r:1 w:0) /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) @@ -203,18 +204,18 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn close_approved(_b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `417 + m * (96 ±0) + p * (36 ±0)` - // Estimated: `16746 + m * (480 ±0) + p * (180 ±0)` - // Minimum execution time: 36_795_000 picoseconds. - Weight::from_parts(35_568_715, 0) - .saturating_add(Weight::from_parts(0, 16746)) - // Standard Error: 630 - .saturating_add(Weight::from_parts(42_253, 0).saturating_mul(m.into())) - // Standard Error: 607 - .saturating_add(Weight::from_parts(107_080, 0).saturating_mul(p.into())) + // Estimated: `6676 + m * (96 ±0) + p * (36 ±0)` + // Minimum execution time: 37_575_000 picoseconds. + Weight::from_parts(36_322_752, 0) + .saturating_add(Weight::from_parts(0, 6676)) + // Standard Error: 530 + .saturating_add(Weight::from_parts(38_879, 0).saturating_mul(m.into())) + // Standard Error: 511 + .saturating_add(Weight::from_parts(119_293, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 480).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 180).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 96).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } /// Storage: Alliance Members (r:2 w:2) /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) @@ -225,14 +226,14 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn init_members(m: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `12` - // Estimated: `13859` - // Minimum execution time: 30_057_000 picoseconds. - Weight::from_parts(19_584_887, 0) - .saturating_add(Weight::from_parts(0, 13859)) - // Standard Error: 657 - .saturating_add(Weight::from_parts(127_220, 0).saturating_mul(m.into())) - // Standard Error: 649 - .saturating_add(Weight::from_parts(111_719, 0).saturating_mul(z.into())) + // Estimated: `12362` + // Minimum execution time: 31_194_000 picoseconds. + Weight::from_parts(19_730_185, 0) + .saturating_add(Weight::from_parts(0, 12362)) + // Standard Error: 589 + .saturating_add(Weight::from_parts(141_552, 0).saturating_mul(m.into())) + // Standard Error: 582 + .saturating_add(Weight::from_parts(118_056, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -254,25 +255,25 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn disband(x: u32, y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + x * (52 ±0) + y * (53 ±0) + z * (250 ±0)` - // Estimated: `35354 + x * (2590 ±0) + y * (2590 ±0) + z * (3104 ±1)` - // Minimum execution time: 257_465_000 picoseconds. - Weight::from_parts(258_993_000, 0) - .saturating_add(Weight::from_parts(0, 35354)) - // Standard Error: 22_094 - .saturating_add(Weight::from_parts(469_539, 0).saturating_mul(x.into())) - // Standard Error: 21_987 - .saturating_add(Weight::from_parts(478_507, 0).saturating_mul(y.into())) - // Standard Error: 43_935 - .saturating_add(Weight::from_parts(10_541_803, 0).saturating_mul(z.into())) + // Estimated: `12362 + x * (2539 ±0) + y * (2539 ±0) + z * (2603 ±1)` + // Minimum execution time: 262_149_000 picoseconds. + Weight::from_parts(263_057_000, 0) + .saturating_add(Weight::from_parts(0, 12362)) + // Standard Error: 21_165 + .saturating_add(Weight::from_parts(497_129, 0).saturating_mul(x.into())) + // Standard Error: 21_063 + .saturating_add(Weight::from_parts(478_945, 0).saturating_mul(y.into())) + // Standard Error: 42_088 + .saturating_add(Weight::from_parts(14_786_304, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(z.into()))) - .saturating_add(Weight::from_parts(0, 2590).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 2590).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 3104).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(0, 2539).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2539).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(z.into())) } /// Storage: Alliance Rule (r:0 w:1) /// Proof: Alliance Rule (max_values: Some(1), max_size: Some(87), added: 582, mode: MaxEncodedLen) @@ -280,8 +281,8 @@ impl pallet_alliance::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_973_000 picoseconds. - Weight::from_parts(10_247_000, 0) + // Minimum execution time: 10_181_000 picoseconds. + Weight::from_parts(10_320_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -291,8 +292,8 @@ impl pallet_alliance::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `76` // Estimated: `10187` - // Minimum execution time: 12_510_000 picoseconds. - Weight::from_parts(12_659_000, 0) + // Minimum execution time: 12_958_000 picoseconds. + Weight::from_parts(13_130_000, 0) .saturating_add(Weight::from_parts(0, 10187)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -303,8 +304,8 @@ impl pallet_alliance::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `149` // Estimated: `10187` - // Minimum execution time: 13_365_000 picoseconds. - Weight::from_parts(13_575_000, 0) + // Minimum execution time: 13_987_000 picoseconds. + Weight::from_parts(14_205_000, 0) .saturating_add(Weight::from_parts(0, 10187)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -320,10 +321,10 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn join_alliance() -> Weight { // Proof Size summary in bytes: // Measured: `294` - // Estimated: `26328` - // Minimum execution time: 40_044_000 picoseconds. - Weight::from_parts(41_623_000, 0) - .saturating_add(Weight::from_parts(0, 26328)) + // Estimated: `18048` + // Minimum execution time: 44_585_000 picoseconds. + Weight::from_parts(45_153_000, 0) + .saturating_add(Weight::from_parts(0, 18048)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -334,10 +335,10 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn nominate_ally() -> Weight { // Proof Size summary in bytes: // Measured: `193` - // Estimated: `22735` - // Minimum execution time: 28_166_000 picoseconds. - Weight::from_parts(28_756_000, 0) - .saturating_add(Weight::from_parts(0, 22735)) + // Estimated: `18048` + // Minimum execution time: 28_059_000 picoseconds. + Weight::from_parts(28_305_000, 0) + .saturating_add(Weight::from_parts(0, 18048)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -352,10 +353,10 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn elevate_ally() -> Weight { // Proof Size summary in bytes: // Measured: `236` - // Estimated: `14555` - // Minimum execution time: 25_759_000 picoseconds. - Weight::from_parts(26_083_000, 0) - .saturating_add(Weight::from_parts(0, 14555)) + // Estimated: `12362` + // Minimum execution time: 26_197_000 picoseconds. + Weight::from_parts(26_655_000, 0) + .saturating_add(Weight::from_parts(0, 12362)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -372,10 +373,10 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn give_retirement_notice() -> Weight { // Proof Size summary in bytes: // Measured: `236` - // Estimated: `25927` - // Minimum execution time: 32_603_000 picoseconds. - Weight::from_parts(33_091_000, 0) - .saturating_add(Weight::from_parts(0, 25927)) + // Estimated: `23734` + // Minimum execution time: 33_606_000 picoseconds. + Weight::from_parts(33_898_000, 0) + .saturating_add(Weight::from_parts(0, 23734)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -390,10 +391,10 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn retire() -> Weight { // Proof Size summary in bytes: // Measured: `517` - // Estimated: `17315` - // Minimum execution time: 36_169_000 picoseconds. - Weight::from_parts(36_746_000, 0) - .saturating_add(Weight::from_parts(0, 17315)) + // Estimated: `6676` + // Minimum execution time: 39_968_000 picoseconds. + Weight::from_parts(40_586_000, 0) + .saturating_add(Weight::from_parts(0, 6676)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -423,11 +424,11 @@ impl pallet_alliance::WeightInfo for WeightInfo { /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn kick_member() -> Weight { // Proof Size summary in bytes: - // Measured: `622` - // Estimated: `45128` - // Minimum execution time: 127_845_000 picoseconds. - Weight::from_parts(129_248_000, 0) - .saturating_add(Weight::from_parts(0, 45128)) + // Measured: `643` + // Estimated: `18048` + // Minimum execution time: 145_826_000 picoseconds. + Weight::from_parts(149_620_000, 0) + .saturating_add(Weight::from_parts(0, 18048)) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(8)) } @@ -440,14 +441,14 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `76` - // Estimated: `31874` - // Minimum execution time: 8_183_000 picoseconds. - Weight::from_parts(8_256_000, 0) - .saturating_add(Weight::from_parts(0, 31874)) - // Standard Error: 2_929 - .saturating_add(Weight::from_parts(1_444_558, 0).saturating_mul(n.into())) - // Standard Error: 1_147 - .saturating_add(Weight::from_parts(68_146, 0).saturating_mul(l.into())) + // Estimated: `27187` + // Minimum execution time: 8_490_000 picoseconds. + Weight::from_parts(8_557_000, 0) + .saturating_add(Weight::from_parts(0, 27187)) + // Standard Error: 3_473 + .saturating_add(Weight::from_parts(1_473_071, 0).saturating_mul(n.into())) + // Standard Error: 1_360 + .saturating_add(Weight::from_parts(75_402, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -459,15 +460,15 @@ impl pallet_alliance::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + n * (289 ±0) + l * (100 ±0)` - // Estimated: `31874` - // Minimum execution time: 7_982_000 picoseconds. - Weight::from_parts(8_084_000, 0) - .saturating_add(Weight::from_parts(0, 31874)) - // Standard Error: 185_716 - .saturating_add(Weight::from_parts(16_937_748, 0).saturating_mul(n.into())) - // Standard Error: 72_734 - .saturating_add(Weight::from_parts(291_993, 0).saturating_mul(l.into())) + // Measured: `0 + l * (100 ±0) + n * (289 ±0)` + // Estimated: `27187` + // Minimum execution time: 8_394_000 picoseconds. + Weight::from_parts(8_467_000, 0) + .saturating_add(Weight::from_parts(0, 27187)) + // Standard Error: 199_845 + .saturating_add(Weight::from_parts(17_213_927, 0).saturating_mul(n.into())) + // Standard Error: 78_268 + .saturating_add(Weight::from_parts(427_473, 0).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -482,10 +483,10 @@ impl pallet_alliance::WeightInfo for WeightInfo { fn abdicate_fellow_status() -> Weight { // Proof Size summary in bytes: // Measured: `236` - // Estimated: `20241` - // Minimum execution time: 31_916_000 picoseconds. - Weight::from_parts(32_301_000, 0) - .saturating_add(Weight::from_parts(0, 20241)) + // Estimated: `18048` + // Minimum execution time: 32_255_000 picoseconds. + Weight::from_parts(32_787_000, 0) + .saturating_add(Weight::from_parts(0, 18048)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_balances.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_balances.rs index d36ba31bdb7..10b566b3f41 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_balances.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_balances.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_balances`. pub struct WeightInfo(PhantomData); @@ -53,8 +54,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 35_300_000 picoseconds. - Weight::from_parts(35_618_000, 0) + // Minimum execution time: 53_490_000 picoseconds. + Weight::from_parts(54_270_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -65,8 +66,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 26_091_000 picoseconds. - Weight::from_parts(26_666_000, 0) + // Minimum execution time: 40_895_000 picoseconds. + Weight::from_parts(41_541_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -77,8 +78,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 15_271_000 picoseconds. - Weight::from_parts(15_835_000, 0) + // Minimum execution time: 16_009_000 picoseconds. + Weight::from_parts(16_345_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -89,8 +90,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 18_684_000 picoseconds. - Weight::from_parts(19_146_000, 0) + // Minimum execution time: 22_757_000 picoseconds. + Weight::from_parts(23_225_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -101,8 +102,8 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `103` // Estimated: `6196` - // Minimum execution time: 36_588_000 picoseconds. - Weight::from_parts(37_315_000, 0) + // Minimum execution time: 55_122_000 picoseconds. + Weight::from_parts(55_729_000, 0) .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -113,25 +114,38 @@ impl pallet_balances::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 32_278_000 picoseconds. - Weight::from_parts(32_546_000, 0) + // Minimum execution time: 49_979_000 picoseconds. + Weight::from_parts(50_677_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn upgrade_accounts(_: u32) -> Weight { - Weight::from_parts(0, 0) - } fn force_unreserve() -> Weight { // Proof Size summary in bytes: // Measured: `103` // Estimated: `3593` - // Minimum execution time: 14_817_000 picoseconds. - Weight::from_parts(15_115_000, 0) + // Minimum execution time: 18_803_000 picoseconds. + Weight::from_parts(19_157_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + u * (136 ±0)` + // Estimated: `990 + u * (2603 ±0)` + // Minimum execution time: 18_508_000 picoseconds. + Weight::from_parts(18_773_000, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 9_864 + .saturating_add(Weight::from_parts(14_451_484, 0).saturating_mul(u.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collator_selection.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collator_selection.rs index fb14fb9f956..73961b722fa 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collator_selection.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collator_selection.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_collator_selection` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_collator_selection`. pub struct WeightInfo(PhantomData); @@ -56,11 +57,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `178 + b * (78 ±0)` // Estimated: `1168 + b * (2554 ±0)` - // Minimum execution time: 14_884_000 picoseconds. - Weight::from_parts(14_947_157, 0) + // Minimum execution time: 15_467_000 picoseconds. + Weight::from_parts(15_103_183, 0) .saturating_add(Weight::from_parts(0, 1168)) - // Standard Error: 4_169 - .saturating_add(Weight::from_parts(2_615_559, 0).saturating_mul(b.into())) + // Standard Error: 2_853 + .saturating_add(Weight::from_parts(2_584_332, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(Weight::from_parts(0, 2554).saturating_mul(b.into())) @@ -71,8 +72,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_057_000 picoseconds. - Weight::from_parts(7_226_000, 0) + // Minimum execution time: 7_562_000 picoseconds. + Weight::from_parts(7_765_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -82,8 +83,8 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_216_000 picoseconds. - Weight::from_parts(7_502_000, 0) + // Minimum execution time: 7_769_000 picoseconds. + Weight::from_parts(7_972_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -103,12 +104,12 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn register_as_candidate(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1108 + c * (48 ±0)` - // Estimated: `61671 + c * (49 ±0)` - // Minimum execution time: 38_806_000 picoseconds. - Weight::from_parts(31_477_823, 0) - .saturating_add(Weight::from_parts(0, 61671)) - // Standard Error: 1_220 - .saturating_add(Weight::from_parts(108_369, 0).saturating_mul(c.into())) + // Estimated: `49487 + c * (49 ±0)` + // Minimum execution time: 42_430_000 picoseconds. + Weight::from_parts(35_423_103, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 1_209 + .saturating_add(Weight::from_parts(114_362, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 49).saturating_mul(c.into())) @@ -122,11 +123,11 @@ impl pallet_collator_selection::WeightInfo for WeightIn // Proof Size summary in bytes: // Measured: `452 + c * (48 ±0)` // Estimated: `49487` - // Minimum execution time: 29_463_000 picoseconds. - Weight::from_parts(19_105_316, 0) + // Minimum execution time: 33_827_000 picoseconds. + Weight::from_parts(24_290_370, 0) .saturating_add(Weight::from_parts(0, 49487)) - // Standard Error: 1_307 - .saturating_add(Weight::from_parts(106_299, 0).saturating_mul(c.into())) + // Standard Error: 1_249 + .saturating_add(Weight::from_parts(109_487, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -139,13 +140,46 @@ impl pallet_collator_selection::WeightInfo for WeightIn fn note_author() -> Weight { // Proof Size summary in bytes: // Measured: `103` - // Estimated: `7729` - // Minimum execution time: 28_319_000 picoseconds. - Weight::from_parts(28_880_000, 0) - .saturating_add(Weight::from_parts(0, 7729)) + // Estimated: `6196` + // Minimum execution time: 43_086_000 picoseconds. + Weight::from_parts(43_643_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:0) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[1, 99]`. + fn add_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `581 + b * (37 ±0)` + // Estimated: `4687 + b * (37 ±0)` + // Minimum execution time: 269_126_000 picoseconds. + Weight::from_parts(286_711_880, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 22_887 + .saturating_add(Weight::from_parts(813_399, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(Weight::from_parts(0, 37).saturating_mul(b.into())) + } + /// Storage: CollatorSelection Invulnerables (r:1 w:1) + /// Proof: CollatorSelection Invulnerables (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// The range of component `b` is `[1, 100]`. + fn remove_invulnerable(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119 + b * (32 ±0)` + // Estimated: `4687` + // Minimum execution time: 183_054_000 picoseconds. + Weight::from_parts(197_205_427, 0) + .saturating_add(Weight::from_parts(0, 4687)) + // Standard Error: 13_533 + .saturating_add(Weight::from_parts(376_231, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: CollatorSelection Candidates (r:1 w:0) /// Proof: CollatorSelection Candidates (max_values: Some(1), max_size: Some(48002), added: 48497, mode: MaxEncodedLen) /// Storage: CollatorSelection LastAuthoredBlock (r:999 w:0) @@ -160,18 +194,18 @@ impl pallet_collator_selection::WeightInfo for WeightIn /// The range of component `c` is `[1, 1000]`. fn new_session(r: u32, c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `22721 + r * (116 ±0) + c * (97 ±0)` - // Estimated: `56697 + r * (2602 ±0) + c * (2520 ±0)` - // Minimum execution time: 17_111_000 picoseconds. - Weight::from_parts(17_332_000, 0) - .saturating_add(Weight::from_parts(0, 56697)) - // Standard Error: 800_597 - .saturating_add(Weight::from_parts(29_089_719, 0).saturating_mul(c.into())) + // Measured: `22721 + c * (97 ±0) + r * (116 ±0)` + // Estimated: `49487 + c * (2519 ±0) + r * (2602 ±0)` + // Minimum execution time: 17_338_000 picoseconds. + Weight::from_parts(17_589_000, 0) + .saturating_add(Weight::from_parts(0, 49487)) + // Standard Error: 906_988 + .saturating_add(Weight::from_parts(32_054_748, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2519).saturating_mul(c.into())) .saturating_add(Weight::from_parts(0, 2602).saturating_mul(r.into())) - .saturating_add(Weight::from_parts(0, 2520).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collective.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collective.rs index 5e7f67bea35..c4a71ec894a 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collective.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_collective.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_collective` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_collective`. pub struct WeightInfo(PhantomData); @@ -61,20 +62,20 @@ impl pallet_collective::WeightInfo for WeightInfo { fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `0 + m * (3232 ±0) + p * (3190 ±0)` - // Estimated: `18748 + m * (7799 ±23) + p * (10110 ±23)` - // Minimum execution time: 16_280_000 picoseconds. - Weight::from_parts(16_431_000, 0) - .saturating_add(Weight::from_parts(0, 18748)) - // Standard Error: 67_432 - .saturating_add(Weight::from_parts(5_382_109, 0).saturating_mul(m.into())) - // Standard Error: 67_432 - .saturating_add(Weight::from_parts(8_022_628, 0).saturating_mul(p.into())) + // Estimated: `15691 + m * (1967 ±23) + p * (4332 ±23)` + // Minimum execution time: 16_795_000 picoseconds. + Weight::from_parts(16_942_000, 0) + .saturating_add(Weight::from_parts(0, 15691)) + // Standard Error: 70_459 + .saturating_add(Weight::from_parts(5_607_397, 0).saturating_mul(m.into())) + // Standard Error: 70_459 + .saturating_add(Weight::from_parts(8_290_115, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) - .saturating_add(Weight::from_parts(0, 7799).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 10110).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 1967).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 4332).saturating_mul(p.into())) } /// Storage: AllianceMotion Members (r:1 w:0) /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) @@ -84,13 +85,13 @@ impl pallet_collective::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `32 + m * (32 ±0)` // Estimated: `1518 + m * (32 ±0)` - // Minimum execution time: 15_340_000 picoseconds. - Weight::from_parts(14_971_140, 0) + // Minimum execution time: 15_803_000 picoseconds. + Weight::from_parts(15_071_031, 0) .saturating_add(Weight::from_parts(0, 1518)) - // Standard Error: 24 - .saturating_add(Weight::from_parts(1_237, 0).saturating_mul(b.into())) - // Standard Error: 252 - .saturating_add(Weight::from_parts(13_257, 0).saturating_mul(m.into())) + // Standard Error: 21 + .saturating_add(Weight::from_parts(1_253, 0).saturating_mul(b.into())) + // Standard Error: 219 + .saturating_add(Weight::from_parts(13_241, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } @@ -103,16 +104,16 @@ impl pallet_collective::WeightInfo for WeightInfo { fn propose_execute(b: u32, m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `32 + m * (32 ±0)` - // Estimated: `5016 + m * (64 ±0)` - // Minimum execution time: 18_083_000 picoseconds. - Weight::from_parts(17_322_823, 0) - .saturating_add(Weight::from_parts(0, 5016)) - // Standard Error: 26 - .saturating_add(Weight::from_parts(1_248, 0).saturating_mul(b.into())) - // Standard Error: 272 - .saturating_add(Weight::from_parts(22_423, 0).saturating_mul(m.into())) + // Estimated: `3498 + m * (32 ±0)` + // Minimum execution time: 18_645_000 picoseconds. + Weight::from_parts(17_717_343, 0) + .saturating_add(Weight::from_parts(0, 3498)) + // Standard Error: 21 + .saturating_add(Weight::from_parts(1_471, 0).saturating_mul(b.into())) + // Standard Error: 218 + .saturating_add(Weight::from_parts(22_238, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 32).saturating_mul(m.into())) } /// Storage: AllianceMotion Members (r:1 w:0) /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) @@ -130,20 +131,20 @@ impl pallet_collective::WeightInfo for WeightInfo { fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `322 + m * (32 ±0) + p * (36 ±0)` - // Estimated: `9165 + m * (165 ±0) + p * (180 ±0)` - // Minimum execution time: 24_019_000 picoseconds. - Weight::from_parts(26_316_662, 0) - .saturating_add(Weight::from_parts(0, 9165)) - // Standard Error: 77 - .saturating_add(Weight::from_parts(2_166, 0).saturating_mul(b.into())) - // Standard Error: 810 - .saturating_add(Weight::from_parts(20_438, 0).saturating_mul(m.into())) - // Standard Error: 799 - .saturating_add(Weight::from_parts(122_504, 0).saturating_mul(p.into())) + // Estimated: `3714 + m * (33 ±0) + p * (36 ±0)` + // Minimum execution time: 24_537_000 picoseconds. + Weight::from_parts(26_471_602, 0) + .saturating_add(Weight::from_parts(0, 3714)) + // Standard Error: 79 + .saturating_add(Weight::from_parts(2_604, 0).saturating_mul(b.into())) + // Standard Error: 829 + .saturating_add(Weight::from_parts(20_480, 0).saturating_mul(m.into())) + // Standard Error: 818 + .saturating_add(Weight::from_parts(133_262, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) - .saturating_add(Weight::from_parts(0, 165).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 180).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 33).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } /// Storage: AllianceMotion Members (r:1 w:0) /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) @@ -153,15 +154,15 @@ impl pallet_collective::WeightInfo for WeightInfo { fn vote(m: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `771 + m * (64 ±0)` - // Estimated: `6490 + m * (128 ±0)` - // Minimum execution time: 22_516_000 picoseconds. - Weight::from_parts(23_803_657, 0) - .saturating_add(Weight::from_parts(0, 6490)) - // Standard Error: 1_968 - .saturating_add(Weight::from_parts(38_988, 0).saturating_mul(m.into())) + // Estimated: `4235 + m * (64 ±0)` + // Minimum execution time: 23_195_000 picoseconds. + Weight::from_parts(23_635_543, 0) + .saturating_add(Weight::from_parts(0, 4235)) + // Standard Error: 399 + .saturating_add(Weight::from_parts(45_089, 0).saturating_mul(m.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) - .saturating_add(Weight::from_parts(0, 128).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 64).saturating_mul(m.into())) } /// Storage: AllianceMotion Voting (r:1 w:1) /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) @@ -176,18 +177,18 @@ impl pallet_collective::WeightInfo for WeightInfo { fn close_early_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `360 + m * (64 ±0) + p * (36 ±0)` - // Estimated: `7795 + m * (260 ±0) + p * (144 ±0)` - // Minimum execution time: 26_841_000 picoseconds. - Weight::from_parts(28_166_692, 0) - .saturating_add(Weight::from_parts(0, 7795)) - // Standard Error: 657 - .saturating_add(Weight::from_parts(20_102, 0).saturating_mul(m.into())) - // Standard Error: 641 - .saturating_add(Weight::from_parts(113_841, 0).saturating_mul(p.into())) + // Estimated: `3805 + m * (65 ±0) + p * (36 ±0)` + // Minimum execution time: 27_925_000 picoseconds. + Weight::from_parts(29_021_838, 0) + .saturating_add(Weight::from_parts(0, 3805)) + // Standard Error: 582 + .saturating_add(Weight::from_parts(19_351, 0).saturating_mul(m.into())) + // Standard Error: 567 + .saturating_add(Weight::from_parts(120_374, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 260).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 144).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 65).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } /// Storage: AllianceMotion Voting (r:1 w:1) /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) @@ -203,21 +204,21 @@ impl pallet_collective::WeightInfo for WeightInfo { fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `662 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `11956 + b * (4 ±0) + m * (264 ±0) + p * (160 ±0)` - // Minimum execution time: 38_310_000 picoseconds. - Weight::from_parts(40_050_347, 0) - .saturating_add(Weight::from_parts(0, 11956)) - // Standard Error: 84 - .saturating_add(Weight::from_parts(1_379, 0).saturating_mul(b.into())) - // Standard Error: 892 - .saturating_add(Weight::from_parts(13_153, 0).saturating_mul(m.into())) - // Standard Error: 870 - .saturating_add(Weight::from_parts(132_394, 0).saturating_mul(p.into())) + // Estimated: `3979 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` + // Minimum execution time: 39_972_000 picoseconds. + Weight::from_parts(40_831_166, 0) + .saturating_add(Weight::from_parts(0, 3979)) + // Standard Error: 78 + .saturating_add(Weight::from_parts(1_568, 0).saturating_mul(b.into())) + // Standard Error: 825 + .saturating_add(Weight::from_parts(16_454, 0).saturating_mul(m.into())) + // Standard Error: 804 + .saturating_add(Weight::from_parts(132_248, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 4).saturating_mul(b.into())) - .saturating_add(Weight::from_parts(0, 264).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 160).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(0, 66).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 40).saturating_mul(p.into())) } /// Storage: AllianceMotion Voting (r:1 w:1) /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) @@ -234,18 +235,18 @@ impl pallet_collective::WeightInfo for WeightInfo { fn close_disapproved(m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `458 + m * (48 ±0) + p * (36 ±0)` - // Estimated: `10085 + m * (245 ±0) + p * (180 ±0)` - // Minimum execution time: 29_071_000 picoseconds. - Weight::from_parts(30_524_865, 0) - .saturating_add(Weight::from_parts(0, 10085)) - // Standard Error: 658 - .saturating_add(Weight::from_parts(18_125, 0).saturating_mul(m.into())) - // Standard Error: 641 - .saturating_add(Weight::from_parts(115_123, 0).saturating_mul(p.into())) + // Estimated: `3898 + m * (49 ±0) + p * (36 ±0)` + // Minimum execution time: 29_766_000 picoseconds. + Weight::from_parts(31_292_444, 0) + .saturating_add(Weight::from_parts(0, 3898)) + // Standard Error: 691 + .saturating_add(Weight::from_parts(19_285, 0).saturating_mul(m.into())) + // Standard Error: 674 + .saturating_add(Weight::from_parts(123_923, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 245).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 180).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 49).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 36).saturating_mul(p.into())) } /// Storage: AllianceMotion Voting (r:1 w:1) /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) @@ -263,21 +264,21 @@ impl pallet_collective::WeightInfo for WeightInfo { fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `682 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` - // Estimated: `14055 + b * (5 ±0) + m * (330 ±0) + p * (200 ±0)` - // Minimum execution time: 40_932_000 picoseconds. - Weight::from_parts(42_564_375, 0) - .saturating_add(Weight::from_parts(0, 14055)) - // Standard Error: 91 - .saturating_add(Weight::from_parts(1_354, 0).saturating_mul(b.into())) - // Standard Error: 962 - .saturating_add(Weight::from_parts(14_498, 0).saturating_mul(m.into())) - // Standard Error: 937 - .saturating_add(Weight::from_parts(133_672, 0).saturating_mul(p.into())) + // Estimated: `3999 + b * (1 ±0) + m * (66 ±0) + p * (40 ±0)` + // Minimum execution time: 42_588_000 picoseconds. + Weight::from_parts(43_162_079, 0) + .saturating_add(Weight::from_parts(0, 3999)) + // Standard Error: 86 + .saturating_add(Weight::from_parts(1_451, 0).saturating_mul(b.into())) + // Standard Error: 914 + .saturating_add(Weight::from_parts(18_855, 0).saturating_mul(m.into())) + // Standard Error: 891 + .saturating_add(Weight::from_parts(136_799, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 5).saturating_mul(b.into())) - .saturating_add(Weight::from_parts(0, 330).saturating_mul(m.into())) - .saturating_add(Weight::from_parts(0, 200).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into())) + .saturating_add(Weight::from_parts(0, 66).saturating_mul(m.into())) + .saturating_add(Weight::from_parts(0, 40).saturating_mul(p.into())) } /// Storage: AllianceMotion Proposals (r:1 w:1) /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) @@ -289,14 +290,14 @@ impl pallet_collective::WeightInfo for WeightInfo { fn disapprove_proposal(p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `189 + p * (32 ±0)` - // Estimated: `2052 + p * (96 ±0)` - // Minimum execution time: 14_577_000 picoseconds. - Weight::from_parts(17_078_204, 0) - .saturating_add(Weight::from_parts(0, 2052)) - // Standard Error: 1_851 - .saturating_add(Weight::from_parts(96_610, 0).saturating_mul(p.into())) + // Estimated: `1674 + p * (32 ±0)` + // Minimum execution time: 14_465_000 picoseconds. + Weight::from_parts(16_635_197, 0) + .saturating_add(Weight::from_parts(0, 1674)) + // Standard Error: 1_082 + .saturating_add(Weight::from_parts(117_250, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 96).saturating_mul(p.into())) + .saturating_add(Weight::from_parts(0, 32).saturating_mul(p.into())) } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_multisig.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_multisig.rs index 46e8b35ad17..92715ad62a9 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_multisig.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_multisig.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_multisig` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_multisig`. pub struct WeightInfo(PhantomData); @@ -52,11 +53,11 @@ impl pallet_multisig::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 11_874_000 picoseconds. - Weight::from_parts(12_338_482, 0) + // Minimum execution time: 12_207_000 picoseconds. + Weight::from_parts(12_624_117, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 1 - .saturating_add(Weight::from_parts(501, 0).saturating_mul(z.into())) + // Standard Error: 3 + .saturating_add(Weight::from_parts(596, 0).saturating_mul(z.into())) } /// Storage: Multisig Multisigs (r:1 w:1) /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) @@ -64,15 +65,15 @@ impl pallet_multisig::WeightInfo for WeightInfo { /// The range of component `z` is `[0, 10000]`. fn as_multi_create(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `262 + s * (2 ±0)` + // Measured: `295 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 37_113_000 picoseconds. - Weight::from_parts(31_650_752, 0) + // Minimum execution time: 41_674_000 picoseconds. + Weight::from_parts(35_138_837, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 685 - .saturating_add(Weight::from_parts(60_611, 0).saturating_mul(s.into())) - // Standard Error: 6 - .saturating_add(Weight::from_parts(1_223, 0).saturating_mul(z.into())) + // Standard Error: 426 + .saturating_add(Weight::from_parts(70_175, 0).saturating_mul(s.into())) + // Standard Error: 4 + .saturating_add(Weight::from_parts(1_321, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -82,15 +83,15 @@ impl pallet_multisig::WeightInfo for WeightInfo { /// The range of component `z` is `[0, 10000]`. fn as_multi_approve(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `282` + // Measured: `315` // Estimated: `6811` - // Minimum execution time: 27_063_000 picoseconds. - Weight::from_parts(21_745_286, 0) + // Minimum execution time: 28_196_000 picoseconds. + Weight::from_parts(22_060_677, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 540 - .saturating_add(Weight::from_parts(59_750, 0).saturating_mul(s.into())) - // Standard Error: 5 - .saturating_add(Weight::from_parts(1_199, 0).saturating_mul(z.into())) + // Standard Error: 378 + .saturating_add(Weight::from_parts(71_806, 0).saturating_mul(s.into())) + // Standard Error: 3 + .saturating_add(Weight::from_parts(1_256, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -102,15 +103,15 @@ impl pallet_multisig::WeightInfo for WeightInfo { /// The range of component `z` is `[0, 10000]`. fn as_multi_complete(s: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `385 + s * (33 ±0)` - // Estimated: `10404` - // Minimum execution time: 41_635_000 picoseconds. - Weight::from_parts(35_205_750, 0) - .saturating_add(Weight::from_parts(0, 10404)) - // Standard Error: 614 - .saturating_add(Weight::from_parts(77_394, 0).saturating_mul(s.into())) - // Standard Error: 6 - .saturating_add(Weight::from_parts(1_194, 0).saturating_mul(z.into())) + // Measured: `418 + s * (33 ±0)` + // Estimated: `6811` + // Minimum execution time: 47_099_000 picoseconds. + Weight::from_parts(38_806_484, 0) + .saturating_add(Weight::from_parts(0, 6811)) + // Standard Error: 540 + .saturating_add(Weight::from_parts(88_311, 0).saturating_mul(s.into())) + // Standard Error: 5 + .saturating_add(Weight::from_parts(1_354, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -119,13 +120,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { /// The range of component `s` is `[2, 100]`. fn approve_as_multi_create(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `263 + s * (2 ±0)` + // Measured: `296 + s * (2 ±0)` // Estimated: `6811` - // Minimum execution time: 28_179_000 picoseconds. - Weight::from_parts(29_964_208, 0) + // Minimum execution time: 31_899_000 picoseconds. + Weight::from_parts(33_492_356, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 692 - .saturating_add(Weight::from_parts(67_380, 0).saturating_mul(s.into())) + // Standard Error: 684 + .saturating_add(Weight::from_parts(79_819, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -134,13 +135,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { /// The range of component `s` is `[2, 100]`. fn approve_as_multi_approve(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `282` + // Measured: `315` // Estimated: `6811` - // Minimum execution time: 18_604_000 picoseconds. - Weight::from_parts(20_059_859, 0) + // Minimum execution time: 19_002_000 picoseconds. + Weight::from_parts(20_275_891, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 1_469 - .saturating_add(Weight::from_parts(65_134, 0).saturating_mul(s.into())) + // Standard Error: 482 + .saturating_add(Weight::from_parts(68_692, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -149,13 +150,13 @@ impl pallet_multisig::WeightInfo for WeightInfo { /// The range of component `s` is `[2, 100]`. fn cancel_as_multi(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `454 + s * (1 ±0)` + // Measured: `487 + s * (1 ±0)` // Estimated: `6811` - // Minimum execution time: 28_438_000 picoseconds. - Weight::from_parts(30_815_747, 0) + // Minimum execution time: 32_841_000 picoseconds. + Weight::from_parts(34_782_386, 0) .saturating_add(Weight::from_parts(0, 6811)) - // Standard Error: 774 - .saturating_add(Weight::from_parts(67_365, 0).saturating_mul(s.into())) + // Standard Error: 656 + .saturating_add(Weight::from_parts(73_853, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_preimage.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_preimage.rs index 706568a5ff6..7c8fab57ede 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_preimage.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_preimage.rs @@ -1,32 +1,49 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_preimage` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-06, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `cob`, CPU: `` -//! EXECUTION: Some(Native), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: -// ./target/debug/polkadot-parachain +// ./artifacts/polkadot-parachain // benchmark // pallet // --chain=collectives-polkadot-dev -// --steps=2 -// --repeat=1 +// --execution=wasm +// --wasm-execution=compiled // --pallet=pallet_preimage // --extrinsic=* -// --execution=native -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights +// --steps=50 +// --repeat=20 +// --json +// --header=./file_header.txt +// --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_preimage.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_preimage`. pub struct WeightInfo(PhantomData); @@ -36,13 +53,15 @@ impl pallet_preimage::WeightInfo for WeightInfo { /// Storage: Preimage PreimageFor (r:0 w:1) /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `s` is `[0, 4194304]`. - fn note_preimage(_s: u32, ) -> Weight { + fn note_preimage(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `175` + // Measured: `143` // Estimated: `3556` - // Minimum execution time: 316_000_000 picoseconds. - Weight::from_parts(152_722_000_000, 0) + // Minimum execution time: 31_179_000 picoseconds. + Weight::from_parts(31_555_000, 0) .saturating_add(Weight::from_parts(0, 3556)) + // Standard Error: 4 + .saturating_add(Weight::from_parts(2_116, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -51,13 +70,15 @@ impl pallet_preimage::WeightInfo for WeightInfo { /// Storage: Preimage PreimageFor (r:0 w:1) /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `s` is `[0, 4194304]`. - fn note_requested_preimage(_s: u32, ) -> Weight { + fn note_requested_preimage(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3556` - // Minimum execution time: 147_000_000 picoseconds. - Weight::from_parts(152_365_000_000, 0) + // Minimum execution time: 16_210_000 picoseconds. + Weight::from_parts(16_377_000, 0) .saturating_add(Weight::from_parts(0, 3556)) + // Standard Error: 3 + .saturating_add(Weight::from_parts(2_089, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -66,13 +87,15 @@ impl pallet_preimage::WeightInfo for WeightInfo { /// Storage: Preimage PreimageFor (r:0 w:1) /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `s` is `[0, 4194304]`. - fn note_no_deposit_preimage(_s: u32, ) -> Weight { + fn note_no_deposit_preimage(s: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3556` - // Minimum execution time: 145_000_000 picoseconds. - Weight::from_parts(152_298_000_000, 0) + // Minimum execution time: 15_441_000 picoseconds. + Weight::from_parts(15_607_000, 0) .saturating_add(Weight::from_parts(0, 3556)) + // Standard Error: 1 + .saturating_add(Weight::from_parts(2_072, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -82,10 +105,10 @@ impl pallet_preimage::WeightInfo for WeightInfo { /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) fn unnote_preimage() -> Weight { // Proof Size summary in bytes: - // Measured: `353` + // Measured: `289` // Estimated: `3556` - // Minimum execution time: 333_000_000 picoseconds. - Weight::from_parts(333_000_000, 0) + // Minimum execution time: 38_302_000 picoseconds. + Weight::from_parts(39_611_000, 0) .saturating_add(Weight::from_parts(0, 3556)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -98,8 +121,8 @@ impl pallet_preimage::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `144` // Estimated: `3556` - // Minimum execution time: 202_000_000 picoseconds. - Weight::from_parts(202_000_000, 0) + // Minimum execution time: 21_163_000 picoseconds. + Weight::from_parts(22_013_000, 0) .saturating_add(Weight::from_parts(0, 3556)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -108,10 +131,10 @@ impl pallet_preimage::WeightInfo for WeightInfo { /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn request_preimage() -> Weight { // Proof Size summary in bytes: - // Measured: `220` + // Measured: `188` // Estimated: `3556` - // Minimum execution time: 189_000_000 picoseconds. - Weight::from_parts(189_000_000, 0) + // Minimum execution time: 20_543_000 picoseconds. + Weight::from_parts(21_576_000, 0) .saturating_add(Weight::from_parts(0, 3556)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -122,8 +145,8 @@ impl pallet_preimage::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `144` // Estimated: `3556` - // Minimum execution time: 137_000_000 picoseconds. - Weight::from_parts(137_000_000, 0) + // Minimum execution time: 11_317_000 picoseconds. + Weight::from_parts(11_834_000, 0) .saturating_add(Weight::from_parts(0, 3556)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -134,8 +157,8 @@ impl pallet_preimage::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3556` - // Minimum execution time: 140_000_000 picoseconds. - Weight::from_parts(140_000_000, 0) + // Minimum execution time: 13_495_000 picoseconds. + Weight::from_parts(13_897_000, 0) .saturating_add(Weight::from_parts(0, 3556)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -146,8 +169,8 @@ impl pallet_preimage::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3556` - // Minimum execution time: 109_000_000 picoseconds. - Weight::from_parts(109_000_000, 0) + // Minimum execution time: 8_208_000 picoseconds. + Weight::from_parts(8_472_000, 0) .saturating_add(Weight::from_parts(0, 3556)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -160,8 +183,8 @@ impl pallet_preimage::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `144` // Estimated: `3556` - // Minimum execution time: 208_000_000 picoseconds. - Weight::from_parts(208_000_000, 0) + // Minimum execution time: 19_788_000 picoseconds. + Weight::from_parts(20_692_000, 0) .saturating_add(Weight::from_parts(0, 3556)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -172,8 +195,8 @@ impl pallet_preimage::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3556` - // Minimum execution time: 117_000_000 picoseconds. - Weight::from_parts(117_000_000, 0) + // Minimum execution time: 7_792_000 picoseconds. + Weight::from_parts(8_113_000, 0) .saturating_add(Weight::from_parts(0, 3556)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -184,8 +207,8 @@ impl pallet_preimage::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `106` // Estimated: `3556` - // Minimum execution time: 107_000_000 picoseconds. - Weight::from_parts(107_000_000, 0) + // Minimum execution time: 7_869_000 picoseconds. + Weight::from_parts(8_164_000, 0) .saturating_add(Weight::from_parts(0, 3556)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_proxy.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_proxy.rs index 5c168e89d47..c5cb4f2e713 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_proxy.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_proxy.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_proxy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_proxy`. pub struct WeightInfo(PhantomData); @@ -54,11 +55,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 16_370_000 picoseconds. - Weight::from_parts(17_099_234, 0) + // Minimum execution time: 16_925_000 picoseconds. + Weight::from_parts(17_434_407, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_021 - .saturating_add(Weight::from_parts(27_747, 0).saturating_mul(p.into())) + // Standard Error: 725 + .saturating_add(Weight::from_parts(35_067, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) } /// Storage: Proxy Proxies (r:1 w:0) @@ -72,14 +73,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn proxy_announced(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `454 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `13997` - // Minimum execution time: 34_655_000 picoseconds. - Weight::from_parts(35_088_843, 0) - .saturating_add(Weight::from_parts(0, 13997)) - // Standard Error: 1_939 - .saturating_add(Weight::from_parts(146_356, 0).saturating_mul(a.into())) - // Standard Error: 2_004 - .saturating_add(Weight::from_parts(38_363, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 38_996_000 picoseconds. + Weight::from_parts(38_697_326, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_269 + .saturating_add(Weight::from_parts(143_716, 0).saturating_mul(a.into())) + // Standard Error: 1_312 + .saturating_add(Weight::from_parts(36_502, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -92,14 +93,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn remove_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `369 + a * (68 ±0)` - // Estimated: `9291` - // Minimum execution time: 21_893_000 picoseconds. - Weight::from_parts(22_495_271, 0) - .saturating_add(Weight::from_parts(0, 9291)) - // Standard Error: 1_612 - .saturating_add(Weight::from_parts(149_480, 0).saturating_mul(a.into())) - // Standard Error: 1_665 - .saturating_add(Weight::from_parts(20_216, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 25_647_000 picoseconds. + Weight::from_parts(26_204_494, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_128 + .saturating_add(Weight::from_parts(137_913, 0).saturating_mul(a.into())) + // Standard Error: 1_166 + .saturating_add(Weight::from_parts(7_581, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -112,14 +113,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn reject_announcement(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `369 + a * (68 ±0)` - // Estimated: `9291` - // Minimum execution time: 22_129_000 picoseconds. - Weight::from_parts(22_971_862, 0) - .saturating_add(Weight::from_parts(0, 9291)) - // Standard Error: 1_324 - .saturating_add(Weight::from_parts(139_140, 0).saturating_mul(a.into())) - // Standard Error: 1_368 - .saturating_add(Weight::from_parts(9_720, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 25_508_000 picoseconds. + Weight::from_parts(26_110_626, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_155 + .saturating_add(Weight::from_parts(139_682, 0).saturating_mul(a.into())) + // Standard Error: 1_193 + .saturating_add(Weight::from_parts(8_390, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -134,14 +135,14 @@ impl pallet_proxy::WeightInfo for WeightInfo { fn announce(a: u32, p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `386 + a * (68 ±0) + p * (37 ±0)` - // Estimated: `13997` - // Minimum execution time: 30_496_000 picoseconds. - Weight::from_parts(31_777_493, 0) - .saturating_add(Weight::from_parts(0, 13997)) - // Standard Error: 2_153 - .saturating_add(Weight::from_parts(139_635, 0).saturating_mul(a.into())) - // Standard Error: 2_224 - .saturating_add(Weight::from_parts(36_392, 0).saturating_mul(p.into())) + // Estimated: `5698` + // Minimum execution time: 35_316_000 picoseconds. + Weight::from_parts(34_940_391, 0) + .saturating_add(Weight::from_parts(0, 5698)) + // Standard Error: 1_038 + .saturating_add(Weight::from_parts(143_848, 0).saturating_mul(a.into())) + // Standard Error: 1_072 + .saturating_add(Weight::from_parts(37_947, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -152,11 +153,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 23_465_000 picoseconds. - Weight::from_parts(24_342_756, 0) + // Minimum execution time: 26_890_000 picoseconds. + Weight::from_parts(27_454_486, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_559 - .saturating_add(Weight::from_parts(50_636, 0).saturating_mul(p.into())) + // Standard Error: 1_069 + .saturating_add(Weight::from_parts(50_270, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -167,11 +168,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 23_620_000 picoseconds. - Weight::from_parts(24_514_511, 0) + // Minimum execution time: 26_634_000 picoseconds. + Weight::from_parts(27_382_449, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_749 - .saturating_add(Weight::from_parts(47_870, 0).saturating_mul(p.into())) + // Standard Error: 1_573 + .saturating_add(Weight::from_parts(65_622, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -182,24 +183,26 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `127 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 18_506_000 picoseconds. - Weight::from_parts(19_463_396, 0) + // Minimum execution time: 23_582_000 picoseconds. + Weight::from_parts(23_977_985, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_241 - .saturating_add(Weight::from_parts(25_525, 0).saturating_mul(p.into())) + // Standard Error: 2_713 + .saturating_add(Weight::from_parts(44_551, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } /// Storage: Proxy Proxies (r:1 w:1) /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. - fn create_pure(_p: u32, ) -> Weight { + fn create_pure(p: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `139` // Estimated: `4706` - // Minimum execution time: 25_291_000 picoseconds. - Weight::from_parts(26_456_465, 0) + // Minimum execution time: 28_564_000 picoseconds. + Weight::from_parts(29_496_680, 0) .saturating_add(Weight::from_parts(0, 4706)) + // Standard Error: 5_045 + .saturating_add(Weight::from_parts(29_343, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -210,11 +213,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `164 + p * (37 ±0)` // Estimated: `4706` - // Minimum execution time: 19_931_000 picoseconds. - Weight::from_parts(20_842_319, 0) + // Minimum execution time: 24_932_000 picoseconds. + Weight::from_parts(25_952_091, 0) .saturating_add(Weight::from_parts(0, 4706)) - // Standard Error: 1_467 - .saturating_add(Weight::from_parts(26_062, 0).saturating_mul(p.into())) + // Standard Error: 5_615 + .saturating_add(Weight::from_parts(22_027, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_ranked_collective.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_ranked_collective.rs index 4be551d4bd5..aed4994c49b 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_ranked_collective.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_ranked_collective.rs @@ -1,32 +1,49 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_ranked_collective` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-06, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `cob`, CPU: `` -//! EXECUTION: Some(Native), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: -// ./target/debug/polkadot-parachain +// ./artifacts/polkadot-parachain // benchmark // pallet // --chain=collectives-polkadot-dev -// --steps=2 -// --repeat=1 +// --execution=wasm +// --wasm-execution=compiled // --pallet=pallet_ranked_collective // --extrinsic=* -// --execution=native -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights +// --steps=50 +// --repeat=20 +// --json +// --header=./file_header.txt +// --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_ranked_collective.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_ranked_collective`. pub struct WeightInfo(PhantomData); @@ -42,10 +59,10 @@ impl pallet_ranked_collective::WeightInfo for WeightInf fn add_member() -> Weight { // Proof Size summary in bytes: // Measured: `109` - // Estimated: `6986` - // Minimum execution time: 129_000_000 picoseconds. - Weight::from_parts(129_000_000, 0) - .saturating_add(Weight::from_parts(0, 6986)) + // Estimated: `3507` + // Minimum execution time: 16_966_000 picoseconds. + Weight::from_parts(17_355_000, 0) + .saturating_add(Weight::from_parts(0, 3507)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -58,15 +75,20 @@ impl pallet_ranked_collective::WeightInfo for WeightInf /// Storage: FellowshipCollective IndexToId (r:11 w:11) /// Proof: FellowshipCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// The range of component `r` is `[0, 10]`. - fn remove_member(_r: u32, ) -> Weight { + fn remove_member(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `575 + r * (281 ±0)` - // Estimated: `89494` - // Minimum execution time: 325_000_000 picoseconds. - Weight::from_parts(1_695_000_000, 0) - .saturating_add(Weight::from_parts(0, 89494)) - .saturating_add(T::DbWeight::get().reads(34)) - .saturating_add(T::DbWeight::get().writes(34)) + // Measured: `584 + r * (281 ±0)` + // Estimated: `3519 + r * (2529 ±0)` + // Minimum execution time: 28_160_000 picoseconds. + Weight::from_parts(30_609_588, 0) + .saturating_add(Weight::from_parts(0, 3519)) + // Standard Error: 25_389 + .saturating_add(Weight::from_parts(11_728_844, 0).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_parts(0, 2529).saturating_mul(r.into())) } /// Storage: FellowshipCollective Members (r:1 w:1) /// Proof: FellowshipCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) @@ -77,13 +99,15 @@ impl pallet_ranked_collective::WeightInfo for WeightInf /// Storage: FellowshipCollective IdToIndex (r:0 w:1) /// Proof: FellowshipCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// The range of component `r` is `[0, 10]`. - fn promote_member(_r: u32, ) -> Weight { + fn promote_member(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `277 + r * (17 ±0)` - // Estimated: `6986` - // Minimum execution time: 206_000_000 picoseconds. - Weight::from_parts(450_000_000, 0) - .saturating_add(Weight::from_parts(0, 6986)) + // Measured: `281 + r * (17 ±0)` + // Estimated: `3507` + // Minimum execution time: 20_058_000 picoseconds. + Weight::from_parts(20_751_832, 0) + .saturating_add(Weight::from_parts(0, 3507)) + // Standard Error: 3_745 + .saturating_add(Weight::from_parts(359_667, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -96,13 +120,15 @@ impl pallet_ranked_collective::WeightInfo for WeightInf /// Storage: FellowshipCollective IndexToId (r:1 w:1) /// Proof: FellowshipCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// The range of component `r` is `[0, 10]`. - fn demote_member(_r: u32, ) -> Weight { + fn demote_member(r: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `575 + r * (71 ±0)` - // Estimated: `14024` - // Minimum execution time: 309_000_000 picoseconds. - Weight::from_parts(449_000_000, 0) - .saturating_add(Weight::from_parts(0, 14024)) + // Measured: `599 + r * (72 ±0)` + // Estimated: `3519` + // Minimum execution time: 27_806_000 picoseconds. + Weight::from_parts(30_225_170, 0) + .saturating_add(Weight::from_parts(0, 3519)) + // Standard Error: 16_870 + .saturating_add(Weight::from_parts(608_652, 0).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -116,11 +142,11 @@ impl pallet_ranked_collective::WeightInfo for WeightInf /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn vote() -> Weight { // Proof Size summary in bytes: - // Measured: `665` - // Estimated: `328970` - // Minimum execution time: 536_000_000 picoseconds. - Weight::from_parts(536_000_000, 0) - .saturating_add(Weight::from_parts(0, 328970)) + // Measured: `633` + // Estimated: `317568` + // Minimum execution time: 48_000_000 picoseconds. + Weight::from_parts(48_520_000, 0) + .saturating_add(Weight::from_parts(0, 317568)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -131,14 +157,18 @@ impl pallet_ranked_collective::WeightInfo for WeightInf /// Storage: FellowshipCollective Voting (r:100 w:100) /// Proof: FellowshipCollective Voting (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) /// The range of component `n` is `[0, 100]`. - fn cleanup_poll(_n: u32, ) -> Weight { + fn cleanup_poll(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `308 + n * (52 ±0)` - // Estimated: `262934` - // Minimum execution time: 246_000_000 picoseconds. - Weight::from_parts(1_572_000_000, 0) - .saturating_add(Weight::from_parts(0, 262934)) - .saturating_add(T::DbWeight::get().reads(102)) - .saturating_add(T::DbWeight::get().writes(100)) + // Measured: `467 + n * (50 ±0)` + // Estimated: `4365 + n * (2540 ±0)` + // Minimum execution time: 15_426_000 picoseconds. + Weight::from_parts(19_278_701, 0) + .saturating_add(Weight::from_parts(0, 4365)) + // Standard Error: 1_274 + .saturating_add(Weight::from_parts(916_410, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_parts(0, 2540).saturating_mul(n.into())) } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_referenda.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_referenda.rs index 471aa55a767..b70c3017a38 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_referenda.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_referenda.rs @@ -1,32 +1,49 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_referenda` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-06, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `cob`, CPU: `` -//! EXECUTION: Some(Native), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: -// ./target/debug/polkadot-parachain +// ./artifacts/polkadot-parachain // benchmark // pallet // --chain=collectives-polkadot-dev -// --steps=2 -// --repeat=1 +// --execution=wasm +// --wasm-execution=compiled // --pallet=pallet_referenda // --extrinsic=* -// --execution=native -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights +// --steps=50 +// --repeat=20 +// --json +// --header=./file_header.txt +// --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_referenda.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_referenda`. pub struct WeightInfo(PhantomData); @@ -42,10 +59,10 @@ impl pallet_referenda::WeightInfo for WeightInfo { fn submit() -> Weight { // Proof Size summary in bytes: // Measured: `322` - // Estimated: `164275` - // Minimum execution time: 283_000_000 picoseconds. - Weight::from_parts(283_000_000, 0) - .saturating_add(Weight::from_parts(0, 164275)) + // Estimated: `159279` + // Minimum execution time: 29_980_000 picoseconds. + Weight::from_parts(30_415_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -55,11 +72,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn place_decision_deposit_preparing() -> Weight { // Proof Size summary in bytes: - // Measured: `430` - // Estimated: `321933` - // Minimum execution time: 472_000_000 picoseconds. - Weight::from_parts(472_000_000, 0) - .saturating_add(Weight::from_parts(0, 321933)) + // Measured: `366` + // Estimated: `317568` + // Minimum execution time: 54_782_000 picoseconds. + Weight::from_parts(55_250_000, 0) + .saturating_add(Weight::from_parts(0, 317568)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -71,11 +88,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: FellowshipReferenda TrackQueue (max_values: None, max_size: Some(812), added: 3287, mode: MaxEncodedLen) fn place_decision_deposit_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `1941` - // Estimated: `12121` - // Minimum execution time: 547_000_000 picoseconds. - Weight::from_parts(547_000_000, 0) - .saturating_add(Weight::from_parts(0, 12121)) + // Measured: `1845` + // Estimated: `4365` + // Minimum execution time: 68_580_000 picoseconds. + Weight::from_parts(69_745_000, 0) + .saturating_add(Weight::from_parts(0, 4365)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -87,11 +104,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: FellowshipReferenda TrackQueue (max_values: None, max_size: Some(812), added: 3287, mode: MaxEncodedLen) fn place_decision_deposit_not_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `1982` - // Estimated: `12121` - // Minimum execution time: 555_000_000 picoseconds. - Weight::from_parts(555_000_000, 0) - .saturating_add(Weight::from_parts(0, 12121)) + // Measured: `1886` + // Estimated: `4365` + // Minimum execution time: 66_900_000 picoseconds. + Weight::from_parts(69_144_000, 0) + .saturating_add(Weight::from_parts(0, 4365)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -105,11 +122,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn place_decision_deposit_passing() -> Weight { // Proof Size summary in bytes: - // Measured: `833` - // Estimated: `328891` - // Minimum execution time: 871_000_000 picoseconds. - Weight::from_parts(871_000_000, 0) - .saturating_add(Weight::from_parts(0, 328891)) + // Measured: `769` + // Estimated: `317568` + // Minimum execution time: 125_600_000 picoseconds. + Weight::from_parts(129_568_000, 0) + .saturating_add(Weight::from_parts(0, 317568)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -121,11 +138,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: FellowshipCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) fn place_decision_deposit_failing() -> Weight { // Proof Size summary in bytes: - // Measured: `643` - // Estimated: `11323` - // Minimum execution time: 460_000_000 picoseconds. - Weight::from_parts(460_000_000, 0) - .saturating_add(Weight::from_parts(0, 11323)) + // Measured: `579` + // Estimated: `4365` + // Minimum execution time: 47_058_000 picoseconds. + Weight::from_parts(47_629_000, 0) + .saturating_add(Weight::from_parts(0, 4365)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -133,10 +150,10 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: FellowshipReferenda ReferendumInfoFor (max_values: None, max_size: Some(900), added: 3375, mode: MaxEncodedLen) fn refund_decision_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `381` + // Measured: `317` // Estimated: `4365` - // Minimum execution time: 281_000_000 picoseconds. - Weight::from_parts(281_000_000, 0) + // Minimum execution time: 32_565_000 picoseconds. + Weight::from_parts(32_857_000, 0) .saturating_add(Weight::from_parts(0, 4365)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -145,10 +162,10 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: FellowshipReferenda ReferendumInfoFor (max_values: None, max_size: Some(900), added: 3375, mode: MaxEncodedLen) fn refund_submission_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `199` + // Measured: `167` // Estimated: `4365` - // Minimum execution time: 172_000_000 picoseconds. - Weight::from_parts(172_000_000, 0) + // Minimum execution time: 16_655_000 picoseconds. + Weight::from_parts(16_980_000, 0) .saturating_add(Weight::from_parts(0, 4365)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -159,11 +176,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn cancel() -> Weight { // Proof Size summary in bytes: - // Measured: `343` - // Estimated: `321933` - // Minimum execution time: 334_000_000 picoseconds. - Weight::from_parts(334_000_000, 0) - .saturating_add(Weight::from_parts(0, 321933)) + // Measured: `311` + // Estimated: `317568` + // Minimum execution time: 39_979_000 picoseconds. + Weight::from_parts(40_199_000, 0) + .saturating_add(Weight::from_parts(0, 317568)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -189,11 +206,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: FellowshipReferenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn kill() -> Weight { // Proof Size summary in bytes: - // Measured: `581` - // Estimated: `342842` - // Minimum execution time: 1_580_000_000 picoseconds. - Weight::from_parts(1_580_000_000, 0) - .saturating_add(Weight::from_parts(0, 342842)) + // Measured: `517` + // Estimated: `317568` + // Minimum execution time: 158_717_000 picoseconds. + Weight::from_parts(159_336_000, 0) + .saturating_add(Weight::from_parts(0, 317568)) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -204,10 +221,10 @@ impl pallet_referenda::WeightInfo for WeightInfo { fn one_fewer_deciding_queue_empty() -> Weight { // Proof Size summary in bytes: // Measured: `140` - // Estimated: `7756` - // Minimum execution time: 203_000_000 picoseconds. - Weight::from_parts(203_000_000, 0) - .saturating_add(Weight::from_parts(0, 7756)) + // Estimated: `4277` + // Minimum execution time: 11_107_000 picoseconds. + Weight::from_parts(11_302_000, 0) + .saturating_add(Weight::from_parts(0, 4277)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -221,11 +238,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn one_fewer_deciding_failing() -> Weight { // Proof Size summary in bytes: - // Measured: `3991` - // Estimated: `329689` - // Minimum execution time: 1_025_000_000 picoseconds. - Weight::from_parts(1_025_000_000, 0) - .saturating_add(Weight::from_parts(0, 329689)) + // Measured: `3896` + // Estimated: `317568` + // Minimum execution time: 237_949_000 picoseconds. + Weight::from_parts(240_956_000, 0) + .saturating_add(Weight::from_parts(0, 317568)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -239,11 +256,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn one_fewer_deciding_passing() -> Weight { // Proof Size summary in bytes: - // Measured: `3991` - // Estimated: `329689` - // Minimum execution time: 1_076_000_000 picoseconds. - Weight::from_parts(1_076_000_000, 0) - .saturating_add(Weight::from_parts(0, 329689)) + // Measured: `3896` + // Estimated: `317568` + // Minimum execution time: 240_708_000 picoseconds. + Weight::from_parts(242_646_000, 0) + .saturating_add(Weight::from_parts(0, 317568)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -255,11 +272,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_requeued_insertion() -> Weight { // Proof Size summary in bytes: - // Measured: `3589` - // Estimated: `167921` - // Minimum execution time: 621_000_000 picoseconds. - Weight::from_parts(621_000_000, 0) - .saturating_add(Weight::from_parts(0, 167921)) + // Measured: `3494` + // Estimated: `159279` + // Minimum execution time: 136_435_000 picoseconds. + Weight::from_parts(138_673_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -271,11 +288,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_requeued_slide() -> Weight { // Proof Size summary in bytes: - // Measured: `3542` - // Estimated: `167921` - // Minimum execution time: 643_000_000 picoseconds. - Weight::from_parts(643_000_000, 0) - .saturating_add(Weight::from_parts(0, 167921)) + // Measured: `3447` + // Estimated: `159279` + // Minimum execution time: 136_686_000 picoseconds. + Weight::from_parts(137_969_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -289,11 +306,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `3528` - // Estimated: `171400` - // Minimum execution time: 704_000_000 picoseconds. - Weight::from_parts(704_000_000, 0) - .saturating_add(Weight::from_parts(0, 171400)) + // Measured: `3433` + // Estimated: `159279` + // Minimum execution time: 139_598_000 picoseconds. + Weight::from_parts(140_713_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -307,11 +324,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_not_queued() -> Weight { // Proof Size summary in bytes: - // Measured: `3583` - // Estimated: `171400` - // Minimum execution time: 695_000_000 picoseconds. - Weight::from_parts(695_000_000, 0) - .saturating_add(Weight::from_parts(0, 171400)) + // Measured: `3488` + // Estimated: `159279` + // Minimum execution time: 139_149_000 picoseconds. + Weight::from_parts(140_033_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -321,11 +338,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_no_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `295` - // Estimated: `163644` - // Minimum execution time: 259_000_000 picoseconds. - Weight::from_parts(259_000_000, 0) - .saturating_add(Weight::from_parts(0, 163644)) + // Measured: `263` + // Estimated: `159279` + // Minimum execution time: 27_153_000 picoseconds. + Weight::from_parts(27_344_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -335,11 +352,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_preparing() -> Weight { // Proof Size summary in bytes: - // Measured: `343` - // Estimated: `163644` - // Minimum execution time: 260_000_000 picoseconds. - Weight::from_parts(260_000_000, 0) - .saturating_add(Weight::from_parts(0, 163644)) + // Measured: `311` + // Estimated: `159279` + // Minimum execution time: 27_327_000 picoseconds. + Weight::from_parts(27_886_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -347,10 +364,10 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: FellowshipReferenda ReferendumInfoFor (max_values: None, max_size: Some(900), added: 3375, mode: MaxEncodedLen) fn nudge_referendum_timed_out() -> Weight { // Proof Size summary in bytes: - // Measured: `240` + // Measured: `208` // Estimated: `4365` - // Minimum execution time: 184_000_000 picoseconds. - Weight::from_parts(184_000_000, 0) + // Minimum execution time: 19_314_000 picoseconds. + Weight::from_parts(19_667_000, 0) .saturating_add(Weight::from_parts(0, 4365)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -365,11 +382,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_begin_deciding_failing() -> Weight { // Proof Size summary in bytes: - // Measured: `611` - // Estimated: `170602` - // Minimum execution time: 445_000_000 picoseconds. - Weight::from_parts(445_000_000, 0) - .saturating_add(Weight::from_parts(0, 170602)) + // Measured: `579` + // Estimated: `159279` + // Minimum execution time: 39_377_000 picoseconds. + Weight::from_parts(39_742_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -383,11 +400,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_begin_deciding_passing() -> Weight { // Proof Size summary in bytes: - // Measured: `746` - // Estimated: `170602` - // Minimum execution time: 625_000_000 picoseconds. - Weight::from_parts(625_000_000, 0) - .saturating_add(Weight::from_parts(0, 170602)) + // Measured: `714` + // Estimated: `159279` + // Minimum execution time: 66_532_000 picoseconds. + Weight::from_parts(68_794_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -399,11 +416,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_begin_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `799` - // Estimated: `167123` - // Minimum execution time: 623_000_000 picoseconds. - Weight::from_parts(623_000_000, 0) - .saturating_add(Weight::from_parts(0, 167123)) + // Measured: `767` + // Estimated: `159279` + // Minimum execution time: 87_398_000 picoseconds. + Weight::from_parts(90_998_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -415,11 +432,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_end_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `782` - // Estimated: `167123` - // Minimum execution time: 580_000_000 picoseconds. - Weight::from_parts(580_000_000, 0) - .saturating_add(Weight::from_parts(0, 167123)) + // Measured: `750` + // Estimated: `159279` + // Minimum execution time: 87_401_000 picoseconds. + Weight::from_parts(90_985_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -431,11 +448,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_continue_not_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `799` - // Estimated: `167123` - // Minimum execution time: 595_000_000 picoseconds. - Weight::from_parts(595_000_000, 0) - .saturating_add(Weight::from_parts(0, 167123)) + // Measured: `767` + // Estimated: `159279` + // Minimum execution time: 82_591_000 picoseconds. + Weight::from_parts(86_670_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -447,11 +464,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_continue_confirming() -> Weight { // Proof Size summary in bytes: - // Measured: `803` - // Estimated: `167123` - // Minimum execution time: 556_000_000 picoseconds. - Weight::from_parts(556_000_000, 0) - .saturating_add(Weight::from_parts(0, 167123)) + // Measured: `771` + // Estimated: `159279` + // Minimum execution time: 55_759_000 picoseconds. + Weight::from_parts(58_177_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -465,11 +482,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn nudge_referendum_approved() -> Weight { // Proof Size summary in bytes: - // Measured: `803` - // Estimated: `328925` - // Minimum execution time: 704_000_000 picoseconds. - Weight::from_parts(704_000_000, 0) - .saturating_add(Weight::from_parts(0, 328925)) + // Measured: `771` + // Estimated: `317568` + // Minimum execution time: 99_521_000 picoseconds. + Weight::from_parts(106_553_000, 0) + .saturating_add(Weight::from_parts(0, 317568)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -481,11 +498,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: Scheduler Agenda (max_values: None, max_size: Some(155814), added: 158289, mode: MaxEncodedLen) fn nudge_referendum_rejected() -> Weight { // Proof Size summary in bytes: - // Measured: `799` - // Estimated: `167123` - // Minimum execution time: 615_000_000 picoseconds. - Weight::from_parts(615_000_000, 0) - .saturating_add(Weight::from_parts(0, 167123)) + // Measured: `767` + // Estimated: `159279` + // Minimum execution time: 87_381_000 picoseconds. + Weight::from_parts(91_501_000, 0) + .saturating_add(Weight::from_parts(0, 159279)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -497,11 +514,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: FellowshipReferenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn set_some_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `384` - // Estimated: `7921` - // Minimum execution time: 262_000_000 picoseconds. - Weight::from_parts(262_000_000, 0) - .saturating_add(Weight::from_parts(0, 7921)) + // Measured: `352` + // Estimated: `4365` + // Minimum execution time: 22_378_000 picoseconds. + Weight::from_parts(22_631_000, 0) + .saturating_add(Weight::from_parts(0, 4365)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -511,11 +528,11 @@ impl pallet_referenda::WeightInfo for WeightInfo { /// Proof: FellowshipReferenda MetadataOf (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `317` - // Estimated: `7882` - // Minimum execution time: 223_000_000 picoseconds. - Weight::from_parts(223_000_000, 0) - .saturating_add(Weight::from_parts(0, 7882)) + // Measured: `285` + // Estimated: `4365` + // Minimum execution time: 20_116_000 picoseconds. + Weight::from_parts(20_255_000, 0) + .saturating_add(Weight::from_parts(0, 4365)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_scheduler.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_scheduler.rs index 3c0a5f5f2f2..f6f6954aca3 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_scheduler.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_scheduler.rs @@ -1,32 +1,49 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . //! Autogenerated weights for `pallet_scheduler` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `cob`, CPU: `` -//! EXECUTION: Some(Native), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/polkadot-parachain +// ./artifacts/polkadot-parachain // benchmark // pallet // --chain=collectives-polkadot-dev -// --steps=50 -// --repeat=20 +// --execution=wasm +// --wasm-execution=compiled // --pallet=pallet_scheduler // --extrinsic=* -// --execution=native -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights +// --steps=50 +// --repeat=20 +// --json +// --header=./file_header.txt +// --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_scheduler.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_scheduler`. pub struct WeightInfo(PhantomData); @@ -37,8 +54,8 @@ impl pallet_scheduler::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `31` // Estimated: `1489` - // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(3_000_000, 0) + // Minimum execution time: 3_399_000 picoseconds. + Weight::from_parts(3_512_000, 0) .saturating_add(Weight::from_parts(0, 1489)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -48,13 +65,13 @@ impl pallet_scheduler::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 200]`. fn service_agenda_base(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `109 + s * (177 ±0)` + // Measured: `77 + s * (177 ±0)` // Estimated: `159279` - // Minimum execution time: 1_000_000 picoseconds. - Weight::from_parts(6_554_632, 0) + // Minimum execution time: 2_846_000 picoseconds. + Weight::from_parts(4_715_748, 0) .saturating_add(Weight::from_parts(0, 159279)) - // Standard Error: 3_795 - .saturating_add(Weight::from_parts(293_040, 0).saturating_mul(s.into())) + // Standard Error: 2_743 + .saturating_add(Weight::from_parts(971_622, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -62,8 +79,8 @@ impl pallet_scheduler::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(2_000_000, 0) + // Minimum execution time: 5_940_000 picoseconds. + Weight::from_parts(6_087_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// Storage: Preimage PreimageFor (r:1 w:1) @@ -73,13 +90,13 @@ impl pallet_scheduler::WeightInfo for WeightInfo { /// The range of component `s` is `[128, 4194304]`. fn service_task_fetched(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `211 + s * (1 ±0)` - // Estimated: `7232 + s * (1 ±0)` - // Minimum execution time: 12_000_000 picoseconds. - Weight::from_parts(13_000_000, 0) - .saturating_add(Weight::from_parts(0, 7232)) - // Standard Error: 2 - .saturating_add(Weight::from_parts(506, 0).saturating_mul(s.into())) + // Measured: `179 + s * (1 ±0)` + // Estimated: `3644 + s * (1 ±0)` + // Minimum execution time: 20_238_000 picoseconds. + Weight::from_parts(20_509_000, 0) + .saturating_add(Weight::from_parts(0, 3644)) + // Standard Error: 3 + .saturating_add(Weight::from_parts(1_271, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(s.into())) @@ -90,8 +107,8 @@ impl pallet_scheduler::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(3_000_000, 0) + // Minimum execution time: 7_274_000 picoseconds. + Weight::from_parts(7_466_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -99,24 +116,24 @@ impl pallet_scheduler::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_000_000 picoseconds. - Weight::from_parts(2_000_000, 0) + // Minimum execution time: 5_886_000 picoseconds. + Weight::from_parts(6_035_000, 0) .saturating_add(Weight::from_parts(0, 0)) } fn execute_dispatch_signed() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_000_000 picoseconds. - Weight::from_parts(1_000_000, 0) + // Minimum execution time: 2_994_000 picoseconds. + Weight::from_parts(3_101_000, 0) .saturating_add(Weight::from_parts(0, 0)) } fn execute_dispatch_unsigned() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_000_000 picoseconds. - Weight::from_parts(1_000_000, 0) + // Minimum execution time: 2_983_000 picoseconds. + Weight::from_parts(3_095_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// Storage: Scheduler Agenda (r:1 w:1) @@ -124,13 +141,13 @@ impl pallet_scheduler::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 199]`. fn schedule(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `109 + s * (177 ±0)` + // Measured: `77 + s * (177 ±0)` // Estimated: `159279` - // Minimum execution time: 6_000_000 picoseconds. - Weight::from_parts(10_397_360, 0) + // Minimum execution time: 12_851_000 picoseconds. + Weight::from_parts(14_995_788, 0) .saturating_add(Weight::from_parts(0, 159279)) - // Standard Error: 12_609 - .saturating_add(Weight::from_parts(342_422, 0).saturating_mul(s.into())) + // Standard Error: 3_056 + .saturating_add(Weight::from_parts(980_018, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -141,13 +158,13 @@ impl pallet_scheduler::WeightInfo for WeightInfo { /// The range of component `s` is `[1, 200]`. fn cancel(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `109 + s * (177 ±0)` + // Measured: `77 + s * (177 ±0)` // Estimated: `159279` - // Minimum execution time: 9_000_000 picoseconds. - Weight::from_parts(24_399_340, 0) + // Minimum execution time: 17_805_000 picoseconds. + Weight::from_parts(16_078_257, 0) .saturating_add(Weight::from_parts(0, 159279)) - // Standard Error: 17_555 - .saturating_add(Weight::from_parts(480_590, 0).saturating_mul(s.into())) + // Standard Error: 3_216 + .saturating_add(Weight::from_parts(1_767_117, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -158,13 +175,13 @@ impl pallet_scheduler::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 199]`. fn schedule_named(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `500 + s * (179 ±0)` - // Estimated: `162792` - // Minimum execution time: 7_000_000 picoseconds. - Weight::from_parts(9_819_325, 0) - .saturating_add(Weight::from_parts(0, 162792)) - // Standard Error: 9_309 - .saturating_add(Weight::from_parts(365_629, 0).saturating_mul(s.into())) + // Measured: `468 + s * (179 ±0)` + // Estimated: `159279` + // Minimum execution time: 16_210_000 picoseconds. + Weight::from_parts(20_557_445, 0) + .saturating_add(Weight::from_parts(0, 159279)) + // Standard Error: 3_292 + .saturating_add(Weight::from_parts(992_281, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -175,13 +192,13 @@ impl pallet_scheduler::WeightInfo for WeightInfo { /// The range of component `s` is `[1, 200]`. fn cancel_named(s: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `541 + s * (179 ±0)` - // Estimated: `162792` - // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(19_693_473, 0) - .saturating_add(Weight::from_parts(0, 162792)) - // Standard Error: 17_961 - .saturating_add(Weight::from_parts(559_993, 0).saturating_mul(s.into())) + // Measured: `509 + s * (179 ±0)` + // Estimated: `159279` + // Minimum execution time: 19_976_000 picoseconds. + Weight::from_parts(19_613_223, 0) + .saturating_add(Weight::from_parts(0, 159279)) + // Standard Error: 2_988 + .saturating_add(Weight::from_parts(1_765_202, 0).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_session.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_session.rs index 5c5f61d40b2..cb307d61e54 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_session.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_session.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_session` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_session`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn set_keys() -> Weight { // Proof Size summary in bytes: // Measured: `270` - // Estimated: `7470` - // Minimum execution time: 17_635_000 picoseconds. - Weight::from_parts(17_997_000, 0) - .saturating_add(Weight::from_parts(0, 7470)) + // Estimated: `3735` + // Minimum execution time: 17_505_000 picoseconds. + Weight::from_parts(17_789_000, 0) + .saturating_add(Weight::from_parts(0, 3735)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -68,10 +69,10 @@ impl pallet_session::WeightInfo for WeightInfo { fn purge_keys() -> Weight { // Proof Size summary in bytes: // Measured: `242` - // Estimated: `3949` - // Minimum execution time: 12_878_000 picoseconds. - Weight::from_parts(13_245_000, 0) - .saturating_add(Weight::from_parts(0, 3949)) + // Estimated: `3707` + // Minimum execution time: 12_686_000 picoseconds. + Weight::from_parts(12_960_000, 0) + .saturating_add(Weight::from_parts(0, 3707)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_timestamp.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_timestamp.rs index 5d0636e87d1..5b3bd10d3f1 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_timestamp.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_timestamp.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_timestamp`. pub struct WeightInfo(PhantomData); @@ -54,10 +55,10 @@ impl pallet_timestamp::WeightInfo for WeightInfo { fn set() -> Weight { // Proof Size summary in bytes: // Measured: `49` - // Estimated: `2986` - // Minimum execution time: 7_660_000 picoseconds. - Weight::from_parts(7_967_000, 0) - .saturating_add(Weight::from_parts(0, 2986)) + // Estimated: `1493` + // Minimum execution time: 8_048_000 picoseconds. + Weight::from_parts(8_313_000, 0) + .saturating_add(Weight::from_parts(0, 1493)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -65,8 +66,8 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `57` // Estimated: `0` - // Minimum execution time: 3_258_000 picoseconds. - Weight::from_parts(3_348_000, 0) + // Minimum execution time: 3_226_000 picoseconds. + Weight::from_parts(3_341_000, 0) .saturating_add(Weight::from_parts(0, 0)) } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_utility.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_utility.rs index 5ff7d46c142..6bec697194f 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_utility.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_utility.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_utility`. pub struct WeightInfo(PhantomData); @@ -52,18 +53,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_002_000 picoseconds. - Weight::from_parts(17_384_645, 0) + // Minimum execution time: 7_356_000 picoseconds. + Weight::from_parts(3_086_549, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_488 - .saturating_add(Weight::from_parts(4_736_077, 0).saturating_mul(c.into())) + // Standard Error: 3_625 + .saturating_add(Weight::from_parts(4_935_275, 0).saturating_mul(c.into())) } fn as_derivative() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_352_000 picoseconds. - Weight::from_parts(5_532_000, 0) + // Minimum execution time: 5_633_000 picoseconds. + Weight::from_parts(5_693_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -71,18 +72,18 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_030_000 picoseconds. - Weight::from_parts(18_968_785, 0) + // Minimum execution time: 7_312_000 picoseconds. + Weight::from_parts(3_780_731, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_112 - .saturating_add(Weight::from_parts(4_960_336, 0).saturating_mul(c.into())) + // Standard Error: 6_353 + .saturating_add(Weight::from_parts(5_289_295, 0).saturating_mul(c.into())) } fn dispatch_as() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_703_000 picoseconds. - Weight::from_parts(10_012_000, 0) + // Minimum execution time: 9_811_000 picoseconds. + Weight::from_parts(10_039_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// The range of component `c` is `[0, 1000]`. @@ -90,10 +91,10 @@ impl pallet_utility::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_029_000 picoseconds. - Weight::from_parts(13_505_714, 0) + // Minimum execution time: 7_419_000 picoseconds. + Weight::from_parts(4_232_933, 0) .saturating_add(Weight::from_parts(0, 0)) - // Standard Error: 3_032 - .saturating_add(Weight::from_parts(4_709_262, 0).saturating_mul(c.into())) + // Standard Error: 3_419 + .saturating_add(Weight::from_parts(4_950_293, 0).saturating_mul(c.into())) } } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_xcm.rs b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_xcm.rs index 43823d56560..ce00a1db94a 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_xcm.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_xcm.rs @@ -17,9 +17,9 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-05-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -40,9 +40,10 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions for `pallet_xcm`. pub struct WeightInfo(PhantomData); @@ -59,11 +60,11 @@ impl pallet_xcm::WeightInfo for WeightInfo { /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) fn send() -> Weight { // Proof Size summary in bytes: - // Measured: `38` - // Estimated: `9595` - // Minimum execution time: 25_963_000 picoseconds. - Weight::from_parts(26_569_000, 0) - .saturating_add(Weight::from_parts(0, 9595)) + // Measured: `111` + // Estimated: `3576` + // Minimum execution time: 30_061_000 picoseconds. + Weight::from_parts(30_674_000, 0) + .saturating_add(Weight::from_parts(0, 3576)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -73,8 +74,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `32` // Estimated: `1489` - // Minimum execution time: 26_187_000 picoseconds. - Weight::from_parts(26_643_000, 0) + // Minimum execution time: 30_473_000 picoseconds. + Weight::from_parts(30_869_000, 0) .saturating_add(Weight::from_parts(0, 1489)) .saturating_add(T::DbWeight::get().reads(1)) } @@ -104,8 +105,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_755_000 picoseconds. - Weight::from_parts(10_010_000, 0) + // Minimum execution time: 10_720_000 picoseconds. + Weight::from_parts(10_836_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -115,8 +116,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_994_000 picoseconds. - Weight::from_parts(3_125_000, 0) + // Minimum execution time: 3_284_000 picoseconds. + Weight::from_parts(3_349_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -138,11 +139,11 @@ impl pallet_xcm::WeightInfo for WeightInfo { /// Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) fn force_subscribe_version_notify() -> Weight { // Proof Size summary in bytes: - // Measured: `38` - // Estimated: `14659` - // Minimum execution time: 31_393_000 picoseconds. - Weight::from_parts(31_976_000, 0) - .saturating_add(Weight::from_parts(0, 14659)) + // Measured: `111` + // Estimated: `3576` + // Minimum execution time: 35_075_000 picoseconds. + Weight::from_parts(35_592_000, 0) + .saturating_add(Weight::from_parts(0, 3576)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -162,20 +163,22 @@ impl pallet_xcm::WeightInfo for WeightInfo { /// Proof Skipped: PolkadotXcm Queries (max_values: None, max_size: None, mode: Measured) fn force_unsubscribe_version_notify() -> Weight { // Proof Size summary in bytes: - // Measured: `220` - // Estimated: `14410` - // Minimum execution time: 34_048_000 picoseconds. - Weight::from_parts(35_696_000, 0) - .saturating_add(Weight::from_parts(0, 14410)) + // Measured: `294` + // Estimated: `3759` + // Minimum execution time: 35_814_000 picoseconds. + Weight::from_parts(36_242_000, 0) + .saturating_add(Weight::from_parts(0, 3759)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } + /// Storage: PolkadotXcm XcmExecutionSuspended (r:0 w:1) + /// Proof Skipped: PolkadotXcm XcmExecutionSuspended (max_values: Some(1), max_size: None, mode: Measured) fn force_suspension() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_994_000 picoseconds. - Weight::from_parts(3_125_000, 0) + // Minimum execution time: 3_199_000 picoseconds. + Weight::from_parts(3_444_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -183,11 +186,11 @@ impl pallet_xcm::WeightInfo for WeightInfo { /// Proof Skipped: PolkadotXcm SupportedVersion (max_values: None, max_size: None, mode: Measured) fn migrate_supported_version() -> Weight { // Proof Size summary in bytes: - // Measured: `95` - // Estimated: `10985` - // Minimum execution time: 16_432_000 picoseconds. - Weight::from_parts(16_898_000, 0) - .saturating_add(Weight::from_parts(0, 10985)) + // Measured: `129` + // Estimated: `11019` + // Minimum execution time: 16_207_000 picoseconds. + Weight::from_parts(16_419_000, 0) + .saturating_add(Weight::from_parts(0, 11019)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -195,11 +198,11 @@ impl pallet_xcm::WeightInfo for WeightInfo { /// Proof Skipped: PolkadotXcm VersionNotifiers (max_values: None, max_size: None, mode: Measured) fn migrate_version_notifiers() -> Weight { // Proof Size summary in bytes: - // Measured: `99` - // Estimated: `10989` - // Minimum execution time: 15_950_000 picoseconds. - Weight::from_parts(16_441_000, 0) - .saturating_add(Weight::from_parts(0, 10989)) + // Measured: `133` + // Estimated: `11023` + // Minimum execution time: 16_204_000 picoseconds. + Weight::from_parts(16_554_000, 0) + .saturating_add(Weight::from_parts(0, 11023)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -207,11 +210,11 @@ impl pallet_xcm::WeightInfo for WeightInfo { /// Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) fn already_notified_target() -> Weight { // Proof Size summary in bytes: - // Measured: `106` - // Estimated: `13471` - // Minimum execution time: 16_585_000 picoseconds. - Weight::from_parts(16_939_000, 0) - .saturating_add(Weight::from_parts(0, 13471)) + // Measured: `140` + // Estimated: `13505` + // Minimum execution time: 16_935_000 picoseconds. + Weight::from_parts(17_263_000, 0) + .saturating_add(Weight::from_parts(0, 13505)) .saturating_add(T::DbWeight::get().reads(5)) } /// Storage: PolkadotXcm VersionNotifyTargets (r:2 w:1) @@ -228,11 +231,11 @@ impl pallet_xcm::WeightInfo for WeightInfo { /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) fn notify_current_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `106` - // Estimated: `15981` - // Minimum execution time: 30_278_000 picoseconds. - Weight::from_parts(30_676_000, 0) - .saturating_add(Weight::from_parts(0, 15981)) + // Measured: `178` + // Estimated: `6118` + // Minimum execution time: 31_462_000 picoseconds. + Weight::from_parts(32_095_000, 0) + .saturating_add(Weight::from_parts(0, 6118)) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -240,22 +243,22 @@ impl pallet_xcm::WeightInfo for WeightInfo { /// Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) fn notify_target_migration_fail() -> Weight { // Proof Size summary in bytes: - // Measured: `136` - // Estimated: `8551` - // Minimum execution time: 8_923_000 picoseconds. - Weight::from_parts(9_257_000, 0) - .saturating_add(Weight::from_parts(0, 8551)) + // Measured: `172` + // Estimated: `8587` + // Minimum execution time: 8_664_000 picoseconds. + Weight::from_parts(8_835_000, 0) + .saturating_add(Weight::from_parts(0, 8587)) .saturating_add(T::DbWeight::get().reads(3)) } /// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2) /// Proof Skipped: PolkadotXcm VersionNotifyTargets (max_values: None, max_size: None, mode: Measured) fn migrate_version_notify_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `106` - // Estimated: `10996` - // Minimum execution time: 16_897_000 picoseconds. - Weight::from_parts(17_998_000, 0) - .saturating_add(Weight::from_parts(0, 10996)) + // Measured: `140` + // Estimated: `11030` + // Minimum execution time: 15_999_000 picoseconds. + Weight::from_parts(16_305_000, 0) + .saturating_add(Weight::from_parts(0, 11030)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -273,11 +276,11 @@ impl pallet_xcm::WeightInfo for WeightInfo { /// Proof Skipped: ParachainSystem PendingUpwardMessages (max_values: Some(1), max_size: None, mode: Measured) fn migrate_and_notify_old_targets() -> Weight { // Proof Size summary in bytes: - // Measured: `112` - // Estimated: `20967` - // Minimum execution time: 40_145_000 picoseconds. - Weight::from_parts(41_423_000, 0) - .saturating_add(Weight::from_parts(0, 20967)) + // Measured: `182` + // Estimated: `11072` + // Minimum execution time: 37_949_000 picoseconds. + Weight::from_parts(38_524_000, 0) + .saturating_add(Weight::from_parts(0, 11072)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(4)) } diff --git a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs index fe227ef9353..b32caf6ee5a 100644 --- a/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs +++ b/parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs @@ -24,19 +24,17 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::XcmPassthrough; -use parachains_common::{ - impls::ToStakingPot, - xcm_config::{ConcreteNativeAssetFrom, DenyReserveTransferToRelayChain, DenyThenTry}, -}; +use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - FixedWeightBounds, IsConcrete, OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, - RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WithComputedOrigin, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, + DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, + OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + WithComputedOrigin, }; use xcm_executor::{traits::WithOriginFilter, XcmExecutor}; @@ -101,8 +99,11 @@ pub type XcmOriginToTransactDispatchOrigin = ( ); 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); + /// The amount of weight an XCM operation takes. This is a safe overestimate. + pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 1024); + /// A temporary weight value for each XCM instruction. + /// NOTE: This should be removed after we account for PoV weights. + pub const TempFixedXcmWeight: Weight = Weight::from_parts(1_000_000_000, 0); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; // Fellows pluralistic body. @@ -137,57 +138,56 @@ impl Contains for SafeCallFilter { } } - match call { + matches!( + call, RuntimeCall::System( frame_system::Call::set_heap_pages { .. } | - frame_system::Call::set_code { .. } | - frame_system::Call::set_code_without_checks { .. } | - frame_system::Call::kill_prefix { .. }, - ) | - RuntimeCall::ParachainSystem(..) | - RuntimeCall::Timestamp(..) | - RuntimeCall::Balances(..) | - RuntimeCall::CollatorSelection( - pallet_collator_selection::Call::set_desired_candidates { .. } | - pallet_collator_selection::Call::set_candidacy_bond { .. } | - pallet_collator_selection::Call::register_as_candidate { .. } | - pallet_collator_selection::Call::leave_intent { .. }, - ) | - RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | - RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | - RuntimeCall::XcmpQueue(..) | - RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | - RuntimeCall::Alliance( - // `init_members` accepts unbounded vecs as arguments, - // but the call can be initiated only by root origin. - pallet_alliance::Call::init_members { .. } | - pallet_alliance::Call::vote { .. } | - pallet_alliance::Call::disband { .. } | - pallet_alliance::Call::set_rule { .. } | - pallet_alliance::Call::announce { .. } | - pallet_alliance::Call::remove_announcement { .. } | - pallet_alliance::Call::join_alliance { .. } | - pallet_alliance::Call::nominate_ally { .. } | - pallet_alliance::Call::elevate_ally { .. } | - pallet_alliance::Call::give_retirement_notice { .. } | - pallet_alliance::Call::retire { .. } | - pallet_alliance::Call::kick_member { .. } | - pallet_alliance::Call::close { .. } | - pallet_alliance::Call::abdicate_fellow_status { .. }, - ) | - RuntimeCall::AllianceMotion( + frame_system::Call::set_code { .. } | + frame_system::Call::set_code_without_checks { .. } | + frame_system::Call::kill_prefix { .. }, + ) | RuntimeCall::ParachainSystem(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Balances(..) | + RuntimeCall::CollatorSelection( + pallet_collator_selection::Call::set_desired_candidates { .. } | + pallet_collator_selection::Call::set_candidacy_bond { .. } | + pallet_collator_selection::Call::register_as_candidate { .. } | + pallet_collator_selection::Call::leave_intent { .. } | + pallet_collator_selection::Call::set_invulnerables { .. } | + pallet_collator_selection::Call::add_invulnerable { .. } | + pallet_collator_selection::Call::remove_invulnerable { .. }, + ) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) | + RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) | + RuntimeCall::XcmpQueue(..) | + RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) | + RuntimeCall::Alliance( + // `init_members` accepts unbounded vecs as arguments, + // but the call can be initiated only by root origin. + pallet_alliance::Call::init_members { .. } | + pallet_alliance::Call::vote { .. } | + pallet_alliance::Call::disband { .. } | + pallet_alliance::Call::set_rule { .. } | + pallet_alliance::Call::announce { .. } | + pallet_alliance::Call::remove_announcement { .. } | + pallet_alliance::Call::join_alliance { .. } | + pallet_alliance::Call::nominate_ally { .. } | + pallet_alliance::Call::elevate_ally { .. } | + pallet_alliance::Call::give_retirement_notice { .. } | + pallet_alliance::Call::retire { .. } | + pallet_alliance::Call::kick_member { .. } | + pallet_alliance::Call::close { .. } | + pallet_alliance::Call::abdicate_fellow_status { .. }, + ) | RuntimeCall::AllianceMotion( pallet_collective::Call::vote { .. } | - pallet_collective::Call::disapprove_proposal { .. } | - pallet_collective::Call::close { .. }, - ) | - RuntimeCall::FellowshipCollective( + pallet_collective::Call::disapprove_proposal { .. } | + pallet_collective::Call::close { .. }, + ) | RuntimeCall::FellowshipCollective( pallet_ranked_collective::Call::add_member { .. } | - pallet_ranked_collective::Call::promote_member { .. } | - pallet_ranked_collective::Call::demote_member { .. } | - pallet_ranked_collective::Call::remove_member { .. }, - ) => true, - _ => false, - } + pallet_ranked_collective::Call::promote_member { .. } | + pallet_ranked_collective::Call::demote_member { .. } | + pallet_ranked_collective::Call::remove_member { .. }, + ) + ) } } @@ -227,7 +227,7 @@ impl xcm_executor::Config for XcmConfig { type IsTeleporter = ConcreteNativeAssetFrom; type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type Trader = UsingComponents>; type ResponseHandler = PolkadotXcm; @@ -278,7 +278,7 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Nothing; // This parachain is not meant as a reserve location. - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; @@ -293,6 +293,8 @@ impl pallet_xcm::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/parachains/runtimes/contracts/contracts-rococo/Cargo.toml b/parachains/runtimes/contracts/contracts-rococo/Cargo.toml index 5c75038da39..0f84b4f8d34 100644 --- a/parachains/runtimes/contracts/contracts-rococo/Cargo.toml +++ b/parachains/runtimes/contracts/contracts-rococo/Cargo.toml @@ -13,8 +13,8 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } hex-literal = { version = "0.4.1", optional = true } -log = { version = "0.4.17", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } smallvec = "1.10.0" # Substrate @@ -144,6 +144,7 @@ runtime-benchmarks = [ "pallet-contracts/runtime-benchmarks", "pallet-message-queue/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", diff --git a/parachains/runtimes/contracts/contracts-rococo/README.md b/parachains/runtimes/contracts/contracts-rococo/README.md index 973d84a14b8..e4f15ccf92d 100644 --- a/parachains/runtimes/contracts/contracts-rococo/README.md +++ b/parachains/runtimes/contracts/contracts-rococo/README.md @@ -45,7 +45,7 @@ To run a Contracts node that connects to Rococo you will need to compile the `polkadot-parachain` binary: ```bash -cargo build --release --locked -p polkadot-parachain +cargo build --release --locked --bin polkadot-parachain ``` Once the executable is built, launch the parachain node via: @@ -54,7 +54,7 @@ Once the executable is built, launch the parachain node via: ./target/release/polkadot-parachain --chain contracts-rococo ``` -Refer to the [setup instructions below](#local-setup) to run a local network for development. +Refer to the [setup instructions](https://github.com/paritytech/cumulus#manual-setup) to run a local network for development. ### Rococo Deployment @@ -70,8 +70,8 @@ Due to this you'll need `ROC` in order to deploy contracts on this parachain. As a first step, you should create an account. See [here](https://wiki.polkadot.network/docs/learn-account-generation) for a detailed guide. -As a second step, you have to get `ROC` testnet tokens through the [Rococo Faucet](https://wiki.polkadot.network/docs/learn-DOT#getting-rococo-tokens). -This is a chat room in which you need to write: +As a second step, you have to get `ROC` testnet tokens through the [Rococo Faucet](https://wiki.polkadot.network/docs/learn-DOT#obtaining-testnet-tokens). +This is a chat room in which you'd need to post the following message: ```bash !drip YOUR_SS_58_ADDRESS:1002 @@ -84,5 +84,5 @@ If everything worked out, the teleported `ROC` tokens will show up under [the "Accounts" tab](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-contracts-rpc.polkadot.io#/accounts). Once you have `ROC` you can deploy a contract as you would normally. -If you're unsure about this, our [guided tutorial](https://docs.substrate.io/tutorials/v3/ink-workshop/pt1/) +If you're unsure about this, our [guided tutorial](https://use.ink/getting-started/deploy-your-contract) will clarify that for you in no time. diff --git a/parachains/runtimes/contracts/contracts-rococo/src/constants.rs b/parachains/runtimes/contracts/contracts-rococo/src/constants.rs index 4598ddaa264..1147b935aa3 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/constants.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/constants.rs @@ -76,7 +76,7 @@ pub mod fee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { // in Kusama, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: - // in Statemine, we map to 1/10 of that, or 1/100 CENT + // in Rococo Contracts, we map to 1/10 of that, or 1/100 CENT let p = super::currency::CENTS; let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); diff --git a/parachains/runtimes/contracts/contracts-rococo/src/contracts.rs b/parachains/runtimes/contracts/contracts-rococo/src/contracts.rs index f184dfd4ff8..8577dd64703 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/contracts.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/contracts.rs @@ -7,13 +7,13 @@ use frame_support::{ traits::{ConstBool, ConstU32, Nothing}, }; use pallet_contracts::{ - weights::SubstrateWeight, Config, DefaultAddressGenerator, Frame, Schedule, + weights::SubstrateWeight, Config, DebugInfo, DefaultAddressGenerator, Frame, Schedule, }; pub use parachains_common::AVERAGE_ON_INITIALIZE_RATIO; // Prints debug output of the `contracts` pallet to stdout if the node is // started with `-lruntime::contracts=debug`. -pub const CONTRACTS_DEBUG_OUTPUT: bool = true; +pub const CONTRACTS_DEBUG_OUTPUT: DebugInfo = DebugInfo::UnsafeDebug; parameter_types! { pub const DepositPerItem: Balance = deposit(1, 0); diff --git a/parachains/runtimes/contracts/contracts-rococo/src/lib.rs b/parachains/runtimes/contracts/contracts-rococo/src/lib.rs index b0356e871e5..8baae9e3e94 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/lib.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/lib.rs @@ -94,10 +94,16 @@ pub type SignedExtra = ( /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; -pub type Migrations = (pallet_contracts::Migration,); +pub type Migrations = ( + pallet_contracts::Migration, + pallet_collator_selection::migration::v1::MigrateToV1, +); + +type EventRecord = frame_system::EventRecord< + ::RuntimeEvent, + ::Hash, +>; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -120,7 +126,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("contracts-rococo"), impl_name: create_runtime_str!("contracts-rococo"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 6, @@ -210,7 +216,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -287,7 +293,7 @@ impl pallet_message_queue::Config for Runtime { >; #[cfg(not(feature = "runtime-benchmarks"))] type MessageProcessor = parachains_common::process_xcm_message::SplitMessages< - parachains_common::process_xcm_message::ProcessXcmMessage< + xcm_builder::ProcessXcmMessage< cumulus_primitives_core::AggregateMessageOrigin, xcm_executor::XcmExecutor, RuntimeCall, @@ -351,6 +357,7 @@ impl pallet_collator_selection::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_sudo::weights::SubstrateWeight; } // Create the runtime by composing the FRAME pallets that were previously configured. @@ -407,6 +414,7 @@ mod benches { [pallet_multisig, Multisig] [pallet_session, SessionBench::] [pallet_utility, Utility] + [pallet_sudo, Sudo] [pallet_timestamp, Timestamp] [pallet_collator_selection, CollatorSelection] [pallet_contracts, Contracts] @@ -558,7 +566,7 @@ impl_runtime_apis! { } } - impl pallet_contracts::ContractsApi for Runtime { + impl pallet_contracts::ContractsApi for Runtime { fn call( origin: AccountId, dest: AccountId, @@ -566,7 +574,7 @@ impl_runtime_apis! { gas_limit: Option, storage_deposit_limit: Option, input_data: Vec, - ) -> pallet_contracts_primitives::ContractExecResult { + ) -> pallet_contracts_primitives::ContractExecResult { let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block); Contracts::bare_call( origin, @@ -576,6 +584,7 @@ impl_runtime_apis! { storage_deposit_limit, input_data, contracts::CONTRACTS_DEBUG_OUTPUT, + pallet_contracts::CollectEvents::UnsafeCollect, pallet_contracts::Determinism::Enforced, ) } @@ -588,7 +597,7 @@ impl_runtime_apis! { code: pallet_contracts_primitives::Code, data: Vec, salt: Vec, - ) -> pallet_contracts_primitives::ContractInstantiateResult { + ) -> pallet_contracts_primitives::ContractInstantiateResult { let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block); Contracts::bare_instantiate( origin, @@ -599,6 +608,7 @@ impl_runtime_apis! { data, salt, contracts::CONTRACTS_DEBUG_OUTPUT, + pallet_contracts::CollectEvents::UnsafeCollect, ) } @@ -658,7 +668,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( diff --git a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index fa8094f9851..6262795d312 100644 --- a/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -25,19 +25,17 @@ use frame_support::{ }; use frame_system::EnsureRoot; use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough}; -use parachains_common::{ - process_xcm_message::{ParaIdToSibling, ProcessFromSibling, ProcessXcmMessage}, - xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry}, -}; +use parachains_common::process_xcm_message::{ParaIdToSibling, ProcessFromSibling}; use polkadot_parachain::primitives::Sibling; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - FixedWeightBounds, IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset, - RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WithComputedOrigin, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter, + DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, FixedWeightBounds, IsConcrete, + NativeAsset, ParentAsSuperuser, ParentIsPreset, ProcessXcmMessage, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, + UsingComponents, WithComputedOrigin, WithUniqueTopic, }; use xcm_executor::XcmExecutor; @@ -122,26 +120,28 @@ match_types! { }; } -pub type Barrier = DenyThenTry< - DenyReserveTransferToRelayChain, - ( - TakeWeightCredit, - // Expected responses are OK. - AllowKnownQueryResponses, - // Allow XCMs with some computed origins to pass through. - WithComputedOrigin< - ( - // If the message is one that immediately attemps to pay for execution, then allow it. - AllowTopLevelPaidExecutionFrom, - // Parent and its pluralities (i.e. governance bodies) get free execution. - AllowExplicitUnpaidExecutionFrom, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, - ), - UniversalLocation, - ConstU32<8>, - >, - ), +pub type Barrier = TrailingSetTopicAsId< + DenyThenTry< + DenyReserveTransferToRelayChain, + ( + TakeWeightCredit, + // Expected responses are OK. + AllowKnownQueryResponses, + // Allow XCMs with some computed origins to pass through. + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Parent and its pluralities (i.e. governance bodies) get free execution. + AllowExplicitUnpaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, + ), + >, >; pub struct XcmConfig; @@ -177,12 +177,12 @@ pub type LocalOriginToLocation = SignedToAccountId32, // ..and XCMP to communicate with the sibling chains. XcmpQueue, -); +)>; #[cfg(feature = "runtime-benchmarks")] parameter_types! { @@ -217,6 +217,8 @@ impl pallet_xcm::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/parachains/runtimes/glutton/glutton-kusama/Cargo.toml b/parachains/runtimes/glutton/glutton-kusama/Cargo.toml new file mode 100644 index 00000000000..bc502c116f3 --- /dev/null +++ b/parachains/runtimes/glutton/glutton-kusama/Cargo.toml @@ -0,0 +1,88 @@ +[package] +name = "glutton-runtime" +version = "1.0.0" +authors = ["Parity Technologies "] +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } + +# Substrate +frame-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "master" } +frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "master" } +frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "master" } +pallet-glutton = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "master" } +pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "master" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-block-builder = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-inherents = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-offchain = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } + +# Polkadot +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } + +# Cumulus +cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false } +cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false } +cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false } +parachain-info = { path = "../../../pallets/parachain-info", default-features = false } +parachains-common = { path = "../../../common", default-features = false } + +[build-dependencies] +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } + +[features] +default = [ "std" ] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-glutton/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", +] +std = [ + "codec/std", + "scale-info/std", + "frame-executive/std", + "frame-support/std", + "frame-system/std", + "pallet-glutton/std", + "pallet-sudo/std", + "sp-api/std", + "sp-block-builder/std", + "sp-core/std", + "sp-inherents/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-std/std", + "sp-transaction-pool/std", + "sp-version/std", + "xcm-builder/std", + "xcm-executor/std", + "xcm/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm/std", + "cumulus-primitives-core/std", + "parachain-info/std", + "parachains-common/std", +] +try-runtime = [ + "frame-executive/try-runtime", + "frame-try-runtime/try-runtime", + "pallet-glutton/try-runtime", + "pallet-sudo/try-runtime", +] diff --git a/parachains/runtimes/glutton/glutton-kusama/build.rs b/parachains/runtimes/glutton/glutton-kusama/build.rs new file mode 100644 index 00000000000..9b53d2457df --- /dev/null +++ b/parachains/runtimes/glutton/glutton-kusama/build.rs @@ -0,0 +1,9 @@ +use substrate_wasm_builder::WasmBuilder; + +fn main() { + WasmBuilder::new() + .with_current_project() + .export_heap_base() + .import_memory() + .build() +} diff --git a/parachains/runtimes/glutton/glutton-kusama/src/lib.rs b/parachains/runtimes/glutton/glutton-kusama/src/lib.rs new file mode 100644 index 00000000000..50fd6383857 --- /dev/null +++ b/parachains/runtimes/glutton/glutton-kusama/src/lib.rs @@ -0,0 +1,407 @@ +// Copyright (C) 2023 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! # Glutton Runtime +//! +//! The purpose of the Glutton parachain is to do stress testing on the Kusama +//! network. +//! +//! There may be multiple instances of the Glutton parachain deployed and +//! connected to Kusama. +//! +//! These parachains are not holding any real value. Their purpose is to stress +//! test the network. +//! +//! ### Governance +//! +//! Glutton defers its governance (namely, its `Root` origin), to its Relay +//! Chain parent, Kusama. +//! +//! ### XCM +//! +//! Since the main goal of Glutton is solely stress testing, the parachain will +//! only be able receive XCM messages from Kusama via DMP. This way the Glutton +//! parachains will be able to listen for upgrades that are coming from the +//! Relay chain. + +#![cfg_attr(not(feature = "std"), no_std)] +#![recursion_limit = "256"] + +// Make the WASM binary available. +#[cfg(feature = "std")] +include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); + +pub mod weights; +pub mod xcm_config; + +use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; +use sp_api::impl_runtime_apis; +use sp_core::OpaqueMetadata; +use sp_runtime::{ + create_runtime_str, generic, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT}, + transaction_validity::{TransactionSource, TransactionValidity}, + ApplyExtrinsicResult, +}; +use sp_std::prelude::*; +#[cfg(feature = "std")] +use sp_version::NativeVersion; +use sp_version::RuntimeVersion; + +pub use frame_support::{ + construct_runtime, + dispatch::DispatchClass, + parameter_types, + traits::{Everything, IsInVec, Randomness}, + weights::{ + constants::{ + BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, + }, + IdentityFee, Weight, + }, + StorageValue, +}; +use frame_system::{ + limits::{BlockLength, BlockWeights}, + EnsureRoot, +}; +use parachains_common::{AccountId, Signature}; +#[cfg(any(feature = "std", test))] +pub use sp_runtime::BuildStorage; +pub use sp_runtime::{Perbill, Permill}; + +#[sp_version::runtime_version] +pub const VERSION: RuntimeVersion = RuntimeVersion { + spec_name: create_runtime_str!("glutton"), + impl_name: create_runtime_str!("glutton"), + authoring_version: 1, + spec_version: 9430, + impl_version: 0, + apis: RUNTIME_API_VERSIONS, + transaction_version: 1, + state_version: 1, +}; + +/// The version information used to identify this runtime when compiled natively. +#[cfg(feature = "std")] +pub fn native_version() -> NativeVersion { + NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } +} + +/// We assume that ~10% of the block weight is consumed by `on_initialize` handlers. +/// This is used to limit the maximal weight of a single extrinsic. +const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); +/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used +/// by Operational extrinsics. +const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +/// We allow for .5 seconds of compute with a 12 second average block time. +const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( + WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64, +); + +parameter_types! { + pub const BlockHashCount: BlockNumber = 4096; + pub const Version: RuntimeVersion = VERSION; + pub RuntimeBlockLength: BlockLength = + BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); + pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder() + .base_block(BlockExecutionWeight::get()) + .for_class(DispatchClass::all(), |weights| { + weights.base_extrinsic = ExtrinsicBaseWeight::get(); + }) + .for_class(DispatchClass::Normal, |weights| { + weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); + }) + .for_class(DispatchClass::Operational, |weights| { + weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); + // Operational transactions have some extra reserved space, so that they + // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. + weights.reserved = Some( + MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT + ); + }) + .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) + .build_or_panic(); + pub const SS58Prefix: u8 = 2; +} + +impl frame_system::Config for Runtime { + type AccountId = AccountId; + type RuntimeCall = RuntimeCall; + type Lookup = AccountIdLookup; + type Index = Index; + type BlockNumber = BlockNumber; + type Hash = Hash; + type Hashing = BlakeTwo256; + type Header = generic::Header; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type BlockHashCount = BlockHashCount; + type Version = Version; + type PalletInfo = PalletInfo; + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); + type DbWeight = (); + type BaseCallFilter = frame_support::traits::Everything; + type SystemWeightInfo = (); + type BlockWeights = RuntimeBlockWeights; + type BlockLength = RuntimeBlockLength; + type SS58Prefix = SS58Prefix; + type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +parameter_types! { + // We do anything the parent chain tells us in this runtime. + pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(2); +} + +impl cumulus_pallet_parachain_system::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OnSystemEvent = (); + type SelfParaId = parachain_info::Pallet; + type OutboundXcmpMessageSource = (); + type ReservedDmpWeight = ReservedDmpWeight; + type XcmpMessageHandler = (); + type ReservedXcmpWeight = (); + type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; + type WeightInfo = (); + type DmpQueue = (); +} + +impl parachain_info::Config for Runtime {} + +impl pallet_glutton::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_glutton::WeightInfo; + type AdminOrigin = EnsureRoot; +} + +impl pallet_sudo::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type WeightInfo = (); +} + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = generic::Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, + ParachainSystem: cumulus_pallet_parachain_system::{ + Pallet, Call, Config, Storage, Inherent, Event, ValidateUnsigned, + } = 1, + ParachainInfo: parachain_info::{Pallet, Storage, Config} = 2, + + // DMP handler. + CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Storage, Event, Origin} = 10, + + // The main stage. + Glutton: pallet_glutton::{Pallet, Call, Storage, Event, Config} = 20, + + // Sudo. + Sudo: pallet_sudo::{Pallet, Call, Storage, Event, Config} = 255, + } +} + +/// Index of a transaction in the chain. +pub type Index = u32; +/// A hash of some data used by the chain. +pub type Hash = sp_core::H256; +/// An index to a block. +pub type BlockNumber = u32; +/// The address format for describing accounts. +pub type Address = sp_runtime::MultiAddress; +/// Block header type as expected by this runtime. +pub type Header = generic::Header; +/// Block type as expected by this runtime. +pub type Block = generic::Block; +/// A Block signed with a Justification +pub type SignedBlock = generic::SignedBlock; +/// BlockId type as expected by this runtime. +pub type BlockId = generic::BlockId; +/// The SignedExtension to the basic transaction logic. +pub type SignedExtra = ( + pallet_sudo::CheckOnlySudoAccount, + frame_system::CheckNonZeroSender, + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, +); +/// Unchecked extrinsic type as expected by this runtime. +pub type UncheckedExtrinsic = + generic::UncheckedExtrinsic; +/// Extrinsic type that has already been checked. +pub type CheckedExtrinsic = generic::CheckedExtrinsic; +/// Executive: handles dispatch to the various modules. +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, +>; + +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + [frame_system, SystemBench::] + [pallet_glutton, Glutton] + ); +} + +impl_runtime_apis! { + impl sp_api::Core for Runtime { + fn version() -> RuntimeVersion { + VERSION + } + + fn execute_block(block: Block) { + Executive::execute_block(block) + } + + fn initialize_block(header: &::Header) { + Executive::initialize_block(header) + } + } + + impl sp_api::Metadata for Runtime { + fn metadata() -> OpaqueMetadata { + OpaqueMetadata::new(Runtime::metadata().into()) + } + + fn metadata_at_version(version: u32) -> Option { + Runtime::metadata_at_version(version) + } + + fn metadata_versions() -> sp_std::vec::Vec { + Runtime::metadata_versions() + } + } + + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic( + extrinsic: ::Extrinsic, + ) -> ApplyExtrinsicResult { + Executive::apply_extrinsic(extrinsic) + } + + fn finalize_block() -> ::Header { + Executive::finalize_block() + } + + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { + data.create_extrinsics() + } + + fn check_inherents(block: Block, data: sp_inherents::InherentData) -> sp_inherents::CheckInherentsResult { + data.check_extrinsics(&block) + } + } + + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { + fn validate_transaction( + source: TransactionSource, + tx: ::Extrinsic, + block_hash: ::Hash, + ) -> TransactionValidity { + Executive::validate_transaction(source, tx, block_hash) + } + } + + impl sp_offchain::OffchainWorkerApi for Runtime { + fn offchain_worker(header: &::Header) { + Executive::offchain_worker(header) + } + } + + impl sp_session::SessionKeys for Runtime { + fn decode_session_keys(_: Vec) -> Option, sp_core::crypto::KeyTypeId)>> { + Some(Vec::new()) + } + + fn generate_session_keys(_: Option>) -> Vec { + Vec::new() + } + } + + impl cumulus_primitives_core::CollectCollationInfo for Runtime { + fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { + ParachainSystem::collect_collation_info(header) + } + } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { + use frame_benchmarking::{Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + use frame_system_benchmarking::Pallet as SystemBench; + + let mut list = Vec::::new(); + list_benchmarks!(list, extra); + + let storage_info = AllPalletsWithSystem::storage_info(); + + (list, storage_info) + } + + fn dispatch_benchmark( + config: frame_benchmarking::BenchmarkConfig + ) -> Result, sp_runtime::RuntimeString> { + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; + use frame_system_benchmarking::Pallet as SystemBench; + impl frame_system_benchmarking::Config for Runtime {} + + use frame_support::traits::WhitelistedStorageKeys; + let whitelist: Vec = AllPalletsWithSystem::whitelisted_storage_keys(); + + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + add_benchmarks!(params, batches); + Ok(batches) + } + } +} + +struct CheckInherents; + +impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { + fn check_inherents( + _: &Block, + _: &cumulus_pallet_parachain_system::RelayChainStateProof, + ) -> sp_inherents::CheckInherentsResult { + sp_inherents::CheckInherentsResult::new() + } +} + +cumulus_pallet_parachain_system::register_validate_block! { + Runtime = Runtime, + BlockExecutor = Executive, + CheckInherents = CheckInherents, +} diff --git a/parachains/runtimes/glutton/glutton-kusama/src/weights/mod.rs b/parachains/runtimes/glutton/glutton-kusama/src/weights/mod.rs new file mode 100644 index 00000000000..234ce34bf42 --- /dev/null +++ b/parachains/runtimes/glutton/glutton-kusama/src/weights/mod.rs @@ -0,0 +1 @@ +pub mod pallet_glutton; diff --git a/parachains/runtimes/glutton/glutton-kusama/src/weights/pallet_glutton.rs b/parachains/runtimes/glutton/glutton-kusama/src/weights/pallet_glutton.rs new file mode 100644 index 00000000000..991ec6f5336 --- /dev/null +++ b/parachains/runtimes/glutton/glutton-kusama/src/weights/pallet_glutton.rs @@ -0,0 +1,175 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Autogenerated weights for `pallet_glutton` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-05-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("glutton-kusama-dev-1300"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot-parachain +// benchmark +// pallet +// --steps=50 +// --repeat=20 +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json +// --pallet=pallet_glutton +// --chain=glutton-kusama-dev-1300 +// --header=./file_header.txt +// --output=./parachains/runtimes/glutton/glutton-kusama/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_glutton`. +pub struct WeightInfo(PhantomData); +impl pallet_glutton::WeightInfo for WeightInfo { + /// Storage: Glutton TrashDataCount (r:1 w:1) + /// Proof: Glutton TrashDataCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Glutton TrashData (r:0 w:1000) + /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 1000]`. + fn initialize_pallet_grow(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `6` + // Estimated: `1489` + // Minimum execution time: 7_874_000 picoseconds. + Weight::from_parts(7_943_000, 0) + .saturating_add(Weight::from_parts(0, 1489)) + // Standard Error: 1_822 + .saturating_add(Weight::from_parts(1_461_713, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + } + /// Storage: Glutton TrashDataCount (r:1 w:1) + /// Proof: Glutton TrashDataCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Glutton TrashData (r:0 w:1000) + /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 1000]`. + fn initialize_pallet_shrink(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `66` + // Estimated: `1489` + // Minimum execution time: 8_562_000 picoseconds. + Weight::from_parts(8_684_000, 0) + .saturating_add(Weight::from_parts(0, 1489)) + // Standard Error: 1_058 + .saturating_add(Weight::from_parts(951_263, 0).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + } + /// The range of component `i` is `[0, 100000]`. + fn waste_ref_time_iter(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 632_000 picoseconds. + Weight::from_parts(648_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 20 + .saturating_add(Weight::from_parts(95_703, 0).saturating_mul(i.into())) + } + /// Storage: Glutton TrashData (r:5000 w:0) + /// Proof: Glutton TrashData (max_values: Some(65000), max_size: Some(1036), added: 3016, mode: MaxEncodedLen) + /// The range of component `i` is `[0, 5000]`. + fn waste_proof_size_some(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `119037 + i * (1022 ±0)` + // Estimated: `990 + i * (3016 ±0)` + // Minimum execution time: 508_000 picoseconds. + Weight::from_parts(20_794_033, 0) + .saturating_add(Weight::from_parts(0, 990)) + // Standard Error: 2_740 + .saturating_add(Weight::from_parts(5_120_718, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_parts(0, 3016).saturating_mul(i.into())) + } + /// Storage: Glutton Storage (r:1 w:0) + /// Proof: Glutton Storage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Glutton Compute (r:1 w:0) + /// Proof: Glutton Compute (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn on_idle_high_proof_waste() -> Weight { + // Proof Size summary in bytes: + // Measured: `89` + // Estimated: `1489` + // Minimum execution time: 92_266_435_000 picoseconds. + Weight::from_parts(92_887_511_000, 0) + .saturating_add(Weight::from_parts(0, 1489)) + .saturating_add(T::DbWeight::get().reads(2)) + } + /// Storage: Glutton Storage (r:1 w:0) + /// Proof: Glutton Storage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Glutton Compute (r:1 w:0) + /// Proof: Glutton Compute (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn on_idle_low_proof_waste() -> Weight { + // Proof Size summary in bytes: + // Measured: `89` + // Estimated: `1489` + // Minimum execution time: 92_086_821_000 picoseconds. + Weight::from_parts(92_651_037_000, 0) + .saturating_add(Weight::from_parts(0, 1489)) + .saturating_add(T::DbWeight::get().reads(2)) + } + /// Storage: Glutton Storage (r:1 w:0) + /// Proof: Glutton Storage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Glutton Compute (r:1 w:0) + /// Proof: Glutton Compute (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn empty_on_idle() -> Weight { + // Proof Size summary in bytes: + // Measured: `6` + // Estimated: `1489` + // Minimum execution time: 3_161_000 picoseconds. + Weight::from_parts(3_222_000, 0) + .saturating_add(Weight::from_parts(0, 1489)) + .saturating_add(T::DbWeight::get().reads(2)) + } + /// Storage: Glutton Compute (r:0 w:1) + /// Proof: Glutton Compute (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn set_compute() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_464_000 picoseconds. + Weight::from_parts(6_617_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Glutton Storage (r:0 w:1) + /// Proof: Glutton Storage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn set_storage() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_510_000 picoseconds. + Weight::from_parts(6_641_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/parachains/runtimes/glutton/glutton-kusama/src/xcm_config.rs b/parachains/runtimes/glutton/glutton-kusama/src/xcm_config.rs new file mode 100644 index 00000000000..083ca592491 --- /dev/null +++ b/parachains/runtimes/glutton/glutton-kusama/src/xcm_config.rs @@ -0,0 +1,91 @@ +// Copyright (C) 2023 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::{ + AccountId, AllPalletsWithSystem, ParachainInfo, Runtime, RuntimeCall, RuntimeEvent, + RuntimeOrigin, +}; +use frame_support::{ + match_types, parameter_types, + traits::{Everything, Nothing}, + weights::Weight, +}; +use xcm::latest::prelude::*; +use xcm_builder::{ + AllowExplicitUnpaidExecutionFrom, FixedWeightBounds, ParentAsSuperuser, ParentIsPreset, + SovereignSignedViaLocation, +}; + +parameter_types! { + pub const KusamaLocation: MultiLocation = MultiLocation::parent(); + pub const KusamaNetwork: Option = Some(NetworkId::Kusama); + pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into())); +} + +/// 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 + // foreign chains who want to have a local sovereign account on this chain which they control. + SovereignSignedViaLocation, RuntimeOrigin>, + // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a + // transaction from the Root origin. + ParentAsSuperuser, +); + +match_types! { + pub type JustTheParent: impl Contains = { MultiLocation { parents:1, interior: Here } }; +} + +parameter_types! { + // One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate. + pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); + pub const MaxInstructions: u32 = 100; + pub const MaxAssetsIntoHolding: u32 = 64; +} + +pub struct XcmConfig; +impl xcm_executor::Config for XcmConfig { + type RuntimeCall = RuntimeCall; + type XcmSender = (); // sending XCM not supported + type AssetTransactor = (); // balances not supported + type OriginConverter = XcmOriginToTransactDispatchOrigin; + type IsReserve = (); // balances not supported + type IsTeleporter = (); // balances not supported + type UniversalLocation = UniversalLocation; + type Barrier = AllowExplicitUnpaidExecutionFrom; + type Weigher = FixedWeightBounds; // balances not supported + type Trader = (); // balances not supported + type ResponseHandler = (); // Don't handle responses for now. + type AssetTrap = (); // don't trap for now + type AssetClaims = (); // don't claim for now + type SubscriptionService = (); // don't handle subscriptions for now + type PalletInstancesInfo = AllPalletsWithSystem; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type AssetLocker = (); + type AssetExchanger = (); + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; +} + +impl cumulus_pallet_xcm::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = xcm_executor::XcmExecutor; +} diff --git a/parachains/runtimes/starters/seedling/Cargo.toml b/parachains/runtimes/starters/seedling/Cargo.toml index 96ec9544009..ac81003f36f 100644 --- a/parachains/runtimes/starters/seedling/Cargo.toml +++ b/parachains/runtimes/starters/seedling/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } # Substrate frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/parachains/runtimes/starters/seedling/src/lib.rs b/parachains/runtimes/starters/seedling/src/lib.rs index 453d3a0a119..7841f8cff1b 100644 --- a/parachains/runtimes/starters/seedling/src/lib.rs +++ b/parachains/runtimes/starters/seedling/src/lib.rs @@ -67,7 +67,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("seedling"), impl_name: create_runtime_str!("seedling"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -160,6 +160,7 @@ impl frame_system::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_sudo::weights::SubstrateWeight; } impl cumulus_pallet_solo_to_para::Config for Runtime { @@ -226,8 +227,6 @@ pub type SignedExtra = ( /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< diff --git a/parachains/runtimes/starters/shell/Cargo.toml b/parachains/runtimes/starters/shell/Cargo.toml index a176e73906a..670578b506a 100644 --- a/parachains/runtimes/starters/shell/Cargo.toml +++ b/parachains/runtimes/starters/shell/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } # Substrate frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/parachains/runtimes/starters/shell/src/lib.rs b/parachains/runtimes/starters/shell/src/lib.rs index 28824384da3..a7e90de4516 100644 --- a/parachains/runtimes/starters/shell/src/lib.rs +++ b/parachains/runtimes/starters/shell/src/lib.rs @@ -223,7 +223,7 @@ impl sp_runtime::traits::SignedExtension for DisallowSigned { info: &DispatchInfoOf, len: usize, ) -> Result { - Ok(self.validate(who, call, info, len).map(|_| ())?) + self.validate(who, call, info, len).map(|_| ()) } fn validate( &self, @@ -258,8 +258,6 @@ pub type SignedExtra = DisallowSigned; /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, diff --git a/parachains/runtimes/test-utils/Cargo.toml b/parachains/runtimes/test-utils/Cargo.toml new file mode 100644 index 00000000000..2de9b298b2d --- /dev/null +++ b/parachains/runtimes/test-utils/Cargo.toml @@ -0,0 +1,72 @@ +[package] +name = "parachains-runtimes-test-utils" +version = "1.0.0" +authors = ["Parity Technologies "] +edition = "2021" +description = "Utils for Runtimes testing" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } + +# Substrate +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-assets = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-consensus-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } + +# Cumulus +cumulus-pallet-parachain-system = { path = "../../../pallets/parachain-system", default-features = false } +cumulus-pallet-xcmp-queue = { path = "../../../pallets/xcmp-queue", default-features = false } +pallet-collator-selection = { path = "../../../pallets/collator-selection", default-features = false } +parachains-common = { path = "../../common", default-features = false } +assets-common = { path = "../assets/common", default-features = false } +cumulus-primitives-core = { path = "../../../primitives/core", default-features = false } +cumulus-primitives-parachain-inherent = { path = "../../../primitives/parachain-inherent", default-features = false } +cumulus-test-relay-sproof-builder = { path = "../../../test/relay-sproof-builder", default-features = false } +parachain-info = { path = "../../../parachains/pallets/parachain-info", default-features = false } + +# Polkadot +xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } +polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } + +[dev-dependencies] +hex-literal = "0.3.4" + +[build-dependencies] +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" } + +[features] +default = [ "std" ] +std = [ + "cumulus-pallet-parachain-system/std", + "cumulus-primitives-core/std", + "cumulus-test-relay-sproof-builder/std", + "cumulus-primitives-parachain-inherent/std", + "frame-support/std", + "frame-system/std", + "pallet-assets/std", + "pallet-balances/std", + "cumulus-pallet-parachain-system/std", + "pallet-collator-selection/std", + "pallet-session/std", + "assets-common/std", + "parachains-common/std", + "parachain-info/std", + "polkadot-parachain/std", + "sp-consensus-aura/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "xcm/std", + "xcm-executor/std", + "pallet-xcm/std", + "cumulus-pallet-xcmp-queue/std", +] diff --git a/parachains/runtimes/test-utils/src/lib.rs b/parachains/runtimes/test-utils/src/lib.rs new file mode 100644 index 00000000000..b39a3df9e7e --- /dev/null +++ b/parachains/runtimes/test-utils/src/lib.rs @@ -0,0 +1,479 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use sp_std::marker::PhantomData; + +use codec::DecodeLimit; +use cumulus_primitives_core::{AbridgedHrmpChannel, ParaId, PersistedValidationData}; +use cumulus_primitives_parachain_inherent::ParachainInherentData; +use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; +use frame_support::{ + dispatch::{DispatchResult, RawOrigin, UnfilteredDispatchable}, + inherent::{InherentData, ProvideInherent}, + traits::{GenesisBuild, OriginTrait}, + weights::Weight, +}; +use parachains_common::AccountId; +use polkadot_parachain::primitives::{HrmpChannelId, RelayChainBlockNumber, XcmpMessageFormat}; +use sp_consensus_aura::AURA_ENGINE_ID; +use sp_core::Encode; +use sp_runtime::{Digest, DigestItem}; +use xcm::{ + latest::{MultiAsset, MultiLocation, XcmContext, XcmHash}, + prelude::*, + VersionedXcm, MAX_XCM_DECODE_DEPTH, +}; +use xcm_executor::{traits::TransactAsset, Assets}; + +pub type BalanceOf = ::Balance; +pub type AccountIdOf = ::AccountId; +pub type ValidatorIdOf = ::ValidatorId; +pub type SessionKeysOf = ::Keys; + +pub struct CollatorSessionKeys< + Runtime: frame_system::Config + pallet_balances::Config + pallet_session::Config, +> { + collator: AccountIdOf, + validator: ValidatorIdOf, + key: SessionKeysOf, +} + +impl + CollatorSessionKeys +{ + pub fn new( + collator: AccountIdOf, + validator: ValidatorIdOf, + key: SessionKeysOf, + ) -> Self { + Self { collator, validator, key } + } + pub fn collators(&self) -> Vec> { + vec![self.collator.clone()] + } + + pub fn session_keys( + &self, + ) -> Vec<(AccountIdOf, ValidatorIdOf, SessionKeysOf)> { + vec![(self.collator.clone(), self.validator.clone(), self.key.clone())] + } +} + +// Basic builder based on balances, collators and pallet_sessopm +pub struct ExtBuilder< + Runtime: frame_system::Config + + pallet_balances::Config + + pallet_session::Config + + pallet_xcm::Config + + parachain_info::Config, +> { + // endowed accounts with balances + balances: Vec<(AccountIdOf, BalanceOf)>, + // collators to test block prod + collators: Vec>, + // keys added to pallet session + keys: Vec<(AccountIdOf, ValidatorIdOf, SessionKeysOf)>, + // safe xcm version for pallet_xcm + safe_xcm_version: Option, + // para id + para_id: Option, + _runtime: PhantomData, +} + +impl< + Runtime: frame_system::Config + + pallet_balances::Config + + pallet_session::Config + + pallet_xcm::Config + + parachain_info::Config, + > Default for ExtBuilder +{ + fn default() -> ExtBuilder { + ExtBuilder { + balances: vec![], + collators: vec![], + keys: vec![], + safe_xcm_version: None, + para_id: None, + _runtime: PhantomData, + } + } +} + +impl< + Runtime: frame_system::Config + + pallet_balances::Config + + pallet_session::Config + + pallet_xcm::Config + + parachain_info::Config, + > ExtBuilder +{ + pub fn with_balances( + mut self, + balances: Vec<(AccountIdOf, BalanceOf)>, + ) -> Self { + self.balances = balances; + self + } + pub fn with_collators(mut self, collators: Vec>) -> Self { + self.collators = collators; + self + } + + pub fn with_session_keys( + mut self, + keys: Vec<(AccountIdOf, ValidatorIdOf, SessionKeysOf)>, + ) -> Self { + self.keys = keys; + self + } + + pub fn with_tracing(self) -> Self { + frame_support::sp_tracing::try_init_simple(); + self + } + + pub fn with_safe_xcm_version(mut self, safe_xcm_version: XcmVersion) -> Self { + self.safe_xcm_version = Some(safe_xcm_version); + self + } + + pub fn with_para_id(mut self, para_id: ParaId) -> Self { + self.para_id = Some(para_id); + self + } + + pub fn build(self) -> sp_io::TestExternalities + where + Runtime: + pallet_collator_selection::Config + pallet_balances::Config + pallet_session::Config, + ValidatorIdOf: From>, + { + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + + >::assimilate_storage( + &pallet_xcm::GenesisConfig { safe_xcm_version: self.safe_xcm_version }, + &mut t, + ) + .unwrap(); + + if let Some(para_id) = self.para_id { + >::assimilate_storage( + ¶chain_info::GenesisConfig { parachain_id: para_id }, + &mut t, + ) + .unwrap(); + } + + pallet_balances::GenesisConfig:: { balances: self.balances } + .assimilate_storage(&mut t) + .unwrap(); + + pallet_collator_selection::GenesisConfig:: { + invulnerables: self.collators.clone(), + candidacy_bond: Default::default(), + desired_candidates: Default::default(), + } + .assimilate_storage(&mut t) + .unwrap(); + + pallet_session::GenesisConfig:: { keys: self.keys } + .assimilate_storage(&mut t) + .unwrap(); + + let mut ext = sp_io::TestExternalities::new(t); + + ext.execute_with(|| { + frame_system::Pallet::::set_block_number(1u32.into()); + }); + + ext + } +} + +pub struct RuntimeHelper(PhantomData); +/// Utility function that advances the chain to the desired block number. +/// If an author is provided, that author information is injected to all the blocks in the meantime. +impl RuntimeHelper +where + AccountIdOf: + Into<<::RuntimeOrigin as OriginTrait>::AccountId>, +{ + pub fn run_to_block(n: u32, author: Option) { + while frame_system::Pallet::::block_number() < n.into() { + // Set the new block number and author + match author { + Some(ref author) => { + let pre_digest = Digest { + logs: vec![DigestItem::PreRuntime(AURA_ENGINE_ID, author.encode())], + }; + frame_system::Pallet::::reset_events(); + frame_system::Pallet::::initialize( + &(frame_system::Pallet::::block_number() + 1u32.into()), + &frame_system::Pallet::::parent_hash(), + &pre_digest, + ); + }, + None => { + frame_system::Pallet::::set_block_number( + frame_system::Pallet::::block_number() + 1u32.into(), + ); + }, + } + } + } + + pub fn root_origin() -> ::RuntimeOrigin { + ::RuntimeOrigin::root() + } + + pub fn origin_of( + account_id: AccountIdOf, + ) -> ::RuntimeOrigin { + ::RuntimeOrigin::signed(account_id.into()) + } +} + +impl RuntimeHelper { + pub fn do_transfer( + from: MultiLocation, + to: MultiLocation, + (asset, amount): (MultiLocation, u128), + ) -> Result { + ::transfer_asset( + &MultiAsset { id: Concrete(asset), fun: Fungible(amount) }, + &from, + &to, + // We aren't able to track the XCM that initiated the fee deposit, so we create a + // fake message hash here + &XcmContext::with_message_id([0; 32]), + ) + } +} + +impl RuntimeHelper { + pub fn do_teleport_assets( + origin: ::RuntimeOrigin, + dest: MultiLocation, + beneficiary: MultiLocation, + (asset, amount): (MultiLocation, u128), + open_hrmp_channel: Option<(u32, u32)>, + ) -> DispatchResult + where + HrmpChannelOpener: frame_support::inherent::ProvideInherent< + Call = cumulus_pallet_parachain_system::Call, + >, + { + // open hrmp (if needed) + if let Some((source_para_id, target_para_id)) = open_hrmp_channel { + mock_open_hrmp_channel::( + source_para_id.into(), + target_para_id.into(), + ); + } + + // do teleport + >::teleport_assets( + origin, + Box::new(dest.into()), + Box::new(beneficiary.into()), + Box::new((Concrete(asset), amount).into()), + 0, + ) + } +} + +impl RuntimeHelper { + pub fn execute_as_governance(call: Vec, require_weight_at_most: Weight) -> Outcome { + // prepare xcm as governance will do + let xcm = Xcm::<::RuntimeCall>(vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + Transact { + origin_kind: OriginKind::Superuser, + require_weight_at_most, + call: call.into(), + }, + ]); + + // execute xcm as parent origin + let hash = xcm.using_encoded(sp_io::hashing::blake2_256); + // TODO: is this correct, or should I have enqueued the message for later processing? + <::XcmExecutor>::execute_xcm( + MultiLocation::parent(), + xcm, + hash, + Self::xcm_max_weight(XcmReceivedFrom::Parent), + ) + } +} + +pub enum XcmReceivedFrom { + Parent, + Sibling, +} + +impl RuntimeHelper { + pub fn xcm_max_weight(from: XcmReceivedFrom) -> Weight { + use frame_support::traits::Get; + match from { + XcmReceivedFrom::Parent => ParachainSystem::ReservedDmpWeight::get(), + XcmReceivedFrom::Sibling => ParachainSystem::ReservedXcmpWeight::get(), + } + } +} + +impl RuntimeHelper { + pub fn assert_pallet_xcm_event_outcome( + unwrap_pallet_xcm_event: &Box) -> Option>>, + assert_outcome: fn(Outcome), + ) { + let outcome = >::events() + .into_iter() + .filter_map(|e| unwrap_pallet_xcm_event(e.event.encode())) + .find_map(|e| match e { + pallet_xcm::Event::Attempted { outcome } => Some(outcome), + _ => None, + }) + .expect("No `pallet_xcm::Event::Attempted(outcome)` event found!"); + + assert_outcome(outcome); + } +} + +impl RuntimeHelper { + pub fn xcmp_queue_message_sent( + unwrap_xcmp_queue_event: Box< + dyn Fn(Vec) -> Option>, + >, + ) -> Option { + >::events() + .into_iter() + .filter_map(|e| unwrap_xcmp_queue_event(e.event.encode())) + .find_map(|e| match e { + cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { message_hash } => + Some(message_hash), + _ => None, + }) + } +} + +pub fn assert_metadata( + asset_id: impl Into + Copy, + expected_name: &str, + expected_symbol: &str, + expected_decimals: u8, +) where + Fungibles: frame_support::traits::tokens::fungibles::metadata::Inspect + + frame_support::traits::tokens::fungibles::Inspect, +{ + assert_eq!(Fungibles::name(asset_id.into()), Vec::from(expected_name),); + assert_eq!(Fungibles::symbol(asset_id.into()), Vec::from(expected_symbol),); + assert_eq!(Fungibles::decimals(asset_id.into()), expected_decimals); +} + +pub fn assert_total( + asset_id: impl Into + Copy, + expected_total_issuance: impl Into, + expected_active_issuance: impl Into, +) where + Fungibles: frame_support::traits::tokens::fungibles::metadata::Inspect + + frame_support::traits::tokens::fungibles::Inspect, +{ + assert_eq!(Fungibles::total_issuance(asset_id.into()), expected_total_issuance.into()); + assert_eq!(Fungibles::active_issuance(asset_id.into()), expected_active_issuance.into()); +} + +/// Helper function which emulates opening HRMP channel which is needed for `XcmpQueue` to pass +pub fn mock_open_hrmp_channel< + C: cumulus_pallet_parachain_system::Config, + T: ProvideInherent>, +>( + sender: ParaId, + recipient: ParaId, +) { + let n = 1_u32; + let mut sproof_builder = RelayStateSproofBuilder { + para_id: sender, + hrmp_egress_channel_index: Some(vec![recipient]), + ..Default::default() + }; + sproof_builder.hrmp_channels.insert( + HrmpChannelId { sender, recipient }, + AbridgedHrmpChannel { + max_capacity: 10, + max_total_size: 10_000_000_u32, + max_message_size: 10_000_000_u32, + msg_count: 0, + total_size: 0_u32, + mqc_head: None, + }, + ); + + let (relay_parent_storage_root, relay_chain_state) = sproof_builder.into_state_root_and_proof(); + let vfp = PersistedValidationData { + relay_parent_number: n as RelayChainBlockNumber, + relay_parent_storage_root, + ..Default::default() + }; + // It is insufficient to push the validation function params + // to storage; they must also be included in the inherent data. + let inherent_data = { + let mut inherent_data = InherentData::default(); + let system_inherent_data = ParachainInherentData { + validation_data: vfp, + relay_chain_state, + downward_messages: Default::default(), + horizontal_messages: Default::default(), + }; + inherent_data + .put_data( + cumulus_primitives_parachain_inherent::INHERENT_IDENTIFIER, + &system_inherent_data, + ) + .expect("failed to put VFP inherent"); + inherent_data + }; + + // execute the block + T::create_inherent(&inherent_data) + .expect("got an inherent") + .dispatch_bypass_filter(RawOrigin::None.into()) + .expect("dispatch succeeded"); +} + +impl + RuntimeHelper +{ + pub fn take_xcm(sent_to_para_id: ParaId) -> Option> { + match HrmpChannelSource::take_outbound_messages(10)[..] { + [(para_id, ref mut xcm_message_data)] if para_id.eq(&sent_to_para_id.into()) => { + let mut xcm_message_data = &xcm_message_data[..]; + // decode + let _ = XcmpMessageFormat::decode_with_depth_limit( + MAX_XCM_DECODE_DEPTH, + &mut xcm_message_data, + ) + .expect("valid format"); + VersionedXcm::<()>::decode_with_depth_limit( + MAX_XCM_DECODE_DEPTH, + &mut xcm_message_data, + ) + .map(|x| Some(x)) + .expect("result with xcm") + }, + _ => return None, + } + } +} diff --git a/parachains/runtimes/testing/penpal/Cargo.toml b/parachains/runtimes/testing/penpal/Cargo.toml index 8ca7797bf5d..2dc60b6fb26 100644 --- a/parachains/runtimes/testing/penpal/Cargo.toml +++ b/parachains/runtimes/testing/penpal/Cargo.toml @@ -17,8 +17,8 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } hex-literal = { version = "0.4.1", optional = true } -log = { version = "0.4.16", default-features = false } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +log = { version = "0.4.18", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } smallvec = "1.10.0" # Substrate @@ -137,6 +137,7 @@ runtime-benchmarks = [ "pallet-assets/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "sp-runtime/runtime-benchmarks", diff --git a/parachains/runtimes/testing/penpal/src/lib.rs b/parachains/runtimes/testing/penpal/src/lib.rs index 7074e3788bd..4f830c07604 100644 --- a/parachains/runtimes/testing/penpal/src/lib.rs +++ b/parachains/runtimes/testing/penpal/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2019-2022 Parity Technologies (UK) Ltd. +// Copyright 2019-2023 Parity Technologies (UK) Ltd. // This file is part of Cumulus. // Cumulus is free software: you can redistribute it and/or modify @@ -14,11 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . -//! The Penpal runtime is designed as a test runtime that can be created using an arbitrary parachain id. -//! (and as such multiple parachains can be on the same relay node - though make sure you have enough relay -//! nodes running to support this or you will get the not scheduled on a core error message.) +//! The PenPal runtime is designed as a test runtime that can be created with an arbitrary `ParaId`, +//! such that multiple instances of the parachain can be on the same parent relay. Ensure that you +//! have enough nodes running to support this or you will get scheduling errors. //! -//! The penpal runtime's primary use is as a partner when testing statemine/t with reserve asset transfers. +//! The PenPal runtime's primary use is for testing interactions between System parachains and +//! other chains that are not trusted teleporters. + #![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] @@ -48,9 +50,7 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, }; -use parachains_common::process_xcm_message::{ - ParaIdToSibling, ProcessFromSibling, ProcessXcmMessage, -}; +use parachains_common::process_xcm_message::{ParaIdToSibling, ProcessFromSibling}; use smallvec::smallvec; use sp_api::impl_runtime_apis; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -126,11 +126,10 @@ pub type SignedExtra = ( pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; - -pub type Migrations = - (pallet_balances::migration::MigrateToTrackInactive,); +pub type Migrations = ( + pallet_balances::migration::MigrateToTrackInactive, + pallet_collator_selection::migration::v1::MigrateToV1, +); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -227,7 +226,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("penpal-parachain"), impl_name: create_runtime_str!("penpal-parachain"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -390,7 +389,7 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -480,7 +479,7 @@ impl pallet_message_queue::Config for Runtime { >; #[cfg(not(feature = "runtime-benchmarks"))] type MessageProcessor = parachains_common::process_xcm_message::SplitMessages< - ProcessXcmMessage< + xcm_builder::ProcessXcmMessage< AggregateMessageOrigin, xcm_executor::XcmExecutor, RuntimeCall, @@ -507,7 +506,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type XcmpProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor; #[cfg(not(feature = "runtime-benchmarks"))] type XcmpProcessor = ProcessFromSibling< - ProcessXcmMessage< + xcm_builder::ProcessXcmMessage< AggregateMessageOrigin, xcm_executor::XcmExecutor, RuntimeCall, @@ -585,6 +584,7 @@ impl pallet_asset_tx_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type WeightInfo = pallet_sudo::weights::SubstrateWeight; } // Create the runtime by composing the FRAME pallets that were previously configured. @@ -634,6 +634,7 @@ mod benches { [pallet_balances, Balances] [pallet_message_queue, MessageQueue] [pallet_session, SessionBench::] + [pallet_sudo, Sudo] [pallet_timestamp, Timestamp] [pallet_collator_selection, CollatorSelection] [cumulus_pallet_parachain_system, ParachainSystem] @@ -819,7 +820,7 @@ impl_runtime_apis! { list_benchmarks!(list, extra); let storage_info = AllPalletsWithSystem::storage_info(); - return (list, storage_info) + (list, storage_info) } fn dispatch_benchmark( diff --git a/parachains/runtimes/testing/penpal/src/xcm_config.rs b/parachains/runtimes/testing/penpal/src/xcm_config.rs index 89cfc2ced65..da1904c16c2 100644 --- a/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -19,8 +19,8 @@ //! This configuration dictates how the Penpal chain will communicate with other chains. //! //! One of the main uses of the penpal chain will be to be a benefactor of reserve asset transfers -//! with statemine as the reserve. At present no derivative tokens are minted on receipt of a -//! ReserveAssetTransferDeposited message but that will but the intension will be to support this soon. +//! with Asset Hub as the reserve. At present no derivative tokens are minted on receipt of a +//! `ReserveAssetTransferDeposited` message but that will but the intension will be to support this soon. use super::{ AccountId, AllPalletsWithSystem, AssetId as AssetIdPalletAssets, Assets, Balance, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, @@ -38,7 +38,6 @@ use frame_support::{ use frame_system::EnsureRoot; use pallet_asset_tx_payment::HandleCredit; use pallet_xcm::XcmPassthrough; -use parachains_common::xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry}; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; use sp_runtime::traits::Zero; @@ -46,11 +45,11 @@ use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, - ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, - IsConcrete, LocalMint, NativeAsset, ParentIsPreset, RelayChainAsNative, - SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, - WithComputedOrigin, + ConvertedConcreteId, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry, + EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, + ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic, }; use xcm_executor::{traits::JustTry, XcmExecutor}; @@ -95,7 +94,7 @@ pub type FungiblesTransactor = FungiblesAdapter< ConvertedConcreteId< AssetIdPalletAssets, Balance, - AsPrefixedGeneralIndex, + AsPrefixedGeneralIndex, JustTry, >, // Convert an XCM MultiLocation into a local account id: @@ -120,7 +119,7 @@ pub type XcmOriginToTransactDispatchOrigin = ( // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for // foreign chains who want to have a local sovereign account on this chain which they control. SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when + // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when // recognized. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when @@ -150,29 +149,31 @@ match_types! { }; } -pub type Barrier = DenyThenTry< - DenyReserveTransferToRelayChain, - ( - TakeWeightCredit, - // Expected responses are OK. - AllowKnownQueryResponses, - // Allow XCMs with some computed origins to pass through. - WithComputedOrigin< - ( - // If the message is one that immediately attemps to pay for execution, then allow it. - AllowTopLevelPaidExecutionFrom, - // Common Good Assets parachain, parent and its exec plurality get free execution - AllowExplicitUnpaidExecutionFrom<( - CommonGoodAssetsParachain, - ParentOrParentsExecutivePlurality, - )>, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, - ), - UniversalLocation, - ConstU32<8>, - >, - ), +pub type Barrier = TrailingSetTopicAsId< + DenyThenTry< + DenyReserveTransferToRelayChain, + ( + TakeWeightCredit, + // Expected responses are OK. + AllowKnownQueryResponses, + // Allow XCMs with some computed origins to pass through. + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Common Good Assets parachain, parent and its exec plurality get free execution + AllowExplicitUnpaidExecutionFrom<( + CommonGoodAssetsParachain, + ParentOrParentsExecutivePlurality, + )>, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, + ), + >, >; /// Type alias to conveniently refer to `frame_system`'s `Config::AccountId`. @@ -197,7 +198,7 @@ where Assets: fungibles::Inspect, { fn contains(id: &>::AssetId) -> bool { - !Assets::total_issuance(*id).is_zero() + !Assets::total_issuance(id.clone()).is_zero() } } @@ -225,12 +226,12 @@ pub trait Reserve { // Takes the chain part of a MultiAsset impl Reserve for MultiAsset { fn reserve(&self) -> Option { - if let AssetId::Concrete(location) = self.id.clone() { + if let AssetId::Concrete(location) = self.id { let first_interior = location.first_interior(); let parents = location.parent_count(); - match (parents, first_interior.clone()) { - (0, Some(Parachain(id))) => Some(MultiLocation::new(0, X1(Parachain(id.clone())))), - (1, Some(Parachain(id))) => Some(MultiLocation::new(1, X1(Parachain(id.clone())))), + match (parents, first_interior) { + (0, Some(Parachain(id))) => Some(MultiLocation::new(0, X1(Parachain(*id)))), + (1, Some(Parachain(id))) => Some(MultiLocation::new(1, X1(Parachain(*id)))), (1, _) => Some(MultiLocation::parent()), _ => None, } @@ -255,15 +256,16 @@ impl ContainsPair for MultiNativeAsset { } parameter_types! { - pub CommonGoodAssetsLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(1000))); + /// The location that this chain recognizes as the Relay network's Asset Hub. + pub SystemAssetHubLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(1000))); // ALWAYS ensure that the index in PalletInstance stays up-to-date with - // Statemint's Assets pallet index - pub CommonGoodAssetsPalletLocation: MultiLocation = + // the Relay Chain's Asset Hub's Assets pallet index + pub SystemAssetHubAssetsPalletLocation: MultiLocation = MultiLocation::new(1, X2(Parachain(1000), PalletInstance(50))); pub CheckingAccount: AccountId = PolkadotXcm::check_account(); } -pub type Reserves = (NativeAsset, AssetsFrom); +pub type Reserves = (NativeAsset, AssetsFrom); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -299,12 +301,12 @@ pub type LocalOriginToLocation = SignedToAccountId32, // ..and XCMP to communicate with the sibling chains. XcmpQueue, -); +)>; #[cfg(feature = "runtime-benchmarks")] parameter_types! { @@ -339,6 +341,8 @@ impl pallet_xcm::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/parachains/runtimes/testing/rococo-parachain/Cargo.toml b/parachains/runtimes/testing/rococo-parachain/Cargo.toml index 0a68f60639b..ec905e49966 100644 --- a/parachains/runtimes/testing/rococo-parachain/Cargo.toml +++ b/parachains/runtimes/testing/rococo-parachain/Cargo.toml @@ -7,7 +7,7 @@ description = "Simple runtime used by the rococo parachain(s)" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } # Substrate frame-benchmarking = { git = "https://github.com/paritytech/substrate", optional = true, default-features = false, branch = "master" } diff --git a/parachains/runtimes/testing/rococo-parachain/src/lib.rs b/parachains/runtimes/testing/rococo-parachain/src/lib.rs index 3d2f9270c95..82165208240 100644 --- a/parachains/runtimes/testing/rococo-parachain/src/lib.rs +++ b/parachains/runtimes/testing/rococo-parachain/src/lib.rs @@ -68,12 +68,12 @@ use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use frame_support::traits::TransformOrigin; use parachains_common::{ impls::{AssetsFrom, NonZeroIssuance}, - process_xcm_message::{ParaIdToSibling, ProcessFromSibling, ProcessXcmMessage}, + process_xcm_message::{ParaIdToSibling, ProcessFromSibling}, AccountId, AssetIdForTrustBackedAssets, Signature, }; use xcm_builder::{ AllowKnownQueryResponses, AllowSubscriptionsFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, - FungiblesAdapter, LocalMint, + FungiblesAdapter, LocalMint, ProcessXcmMessage, }; use xcm_executor::traits::JustTry; @@ -104,7 +104,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("test-parachain"), impl_name: create_runtime_str!("test-parachain"), authoring_version: 1, - spec_version: 9400, + spec_version: 9420, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 6, @@ -222,10 +222,10 @@ impl pallet_timestamp::Config for Runtime { } parameter_types! { - pub const ExistentialDeposit: u128 = 1 * MILLIROC; - pub const TransferFee: u128 = 1 * MILLIROC; - pub const CreationFee: u128 = 1 * MILLIROC; - pub const TransactionByteFee: u128 = 1 * MICROROC; + pub const ExistentialDeposit: u128 = MILLIROC; + pub const TransferFee: u128 = MILLIROC; + pub const CreationFee: u128 = MILLIROC; + pub const TransactionByteFee: u128 = MICROROC; } impl pallet_balances::Config for Runtime { @@ -240,7 +240,7 @@ impl pallet_balances::Config for Runtime { type MaxLocks = ConstU32<50>; type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -258,6 +258,7 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_sudo::weights::SubstrateWeight; } parameter_types! { @@ -352,7 +353,11 @@ pub type FungiblesTransactor = FungiblesAdapter< ConvertedConcreteId< AssetIdForTrustBackedAssets, u64, - AsPrefixedGeneralIndex, + AsPrefixedGeneralIndex< + SystemAssetHubAssetsPalletLocation, + AssetIdForTrustBackedAssets, + JustTry, + >, JustTry, >, // Convert an XCM MultiLocation into a local account id: @@ -376,7 +381,7 @@ pub type XcmOriginToTransactDispatchOrigin = ( // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for // foreign chains who want to have a local sovereign account on this chain which they control. SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when + // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when // recognised. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when @@ -401,11 +406,13 @@ parameter_types! { } match_types! { + // The parent or the parent's unit plurality. pub type ParentOrParentsUnitPlurality: impl Contains = { MultiLocation { parents: 1, interior: Here } | MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) } }; - pub type Statemint: impl Contains = { + // The location recognized as the Relay network's Asset Hub. + pub type AssetHub: impl Contains = { MultiLocation { parents: 1, interior: X1(Parachain(1000)) } }; } @@ -413,9 +420,10 @@ match_types! { pub type Barrier = ( TakeWeightCredit, AllowTopLevelPaidExecutionFrom, + // Parent & its unit plurality gets free execution. AllowExplicitUnpaidExecutionFrom, - // ^^^ Parent & its unit plurality gets free execution - AllowExplicitUnpaidExecutionFrom, + // The network's Asset Hub gets free execution. + AllowExplicitUnpaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, // Subscriptions for version tracking are OK. @@ -424,14 +432,14 @@ pub type Barrier = ( parameter_types! { pub MaxAssetsIntoHolding: u32 = 64; - pub StatemintLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(1000))); + pub SystemAssetHubLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(1000))); // ALWAYS ensure that the index in PalletInstance stays up-to-date with - // Statemint's Assets pallet index - pub StatemintAssetsPalletLocation: MultiLocation = + // the Relay Chain's Asset Hub's Assets pallet index + pub SystemAssetHubAssetsPalletLocation: MultiLocation = MultiLocation::new(1, X2(Parachain(1000), PalletInstance(50))); } -pub type Reserves = (NativeAsset, AssetsFrom); +pub type Reserves = (NativeAsset, AssetsFrom); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -502,6 +510,8 @@ impl pallet_xcm::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type ReachableDest = ReachableDest; type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { @@ -541,11 +551,11 @@ impl cumulus_ping::Config for Runtime { } parameter_types! { - pub const AssetDeposit: Balance = 1 * ROC; - pub const AssetAccountDeposit: Balance = 1 * ROC; + pub const AssetDeposit: Balance = ROC; + pub const AssetAccountDeposit: Balance = ROC; pub const ApprovalDeposit: Balance = 100 * MILLIROC; pub const AssetsStringLimit: u32 = 50; - pub const MetadataDepositBase: Balance = 1 * ROC; + pub const MetadataDepositBase: Balance = ROC; pub const MetadataDepositPerByte: Balance = 10 * MILLIROC; pub const UnitBody: BodyId = BodyId::Unit; } @@ -648,8 +658,6 @@ pub type SignedExtra = ( /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, diff --git a/polkadot-parachain/Cargo.toml b/polkadot-parachain/Cargo.toml index fafae12aedb..9ee20c8beb5 100644 --- a/polkadot-parachain/Cargo.toml +++ b/polkadot-parachain/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-parachain-bin" -version = "0.9.400" +version = "0.9.420" authors = ["Parity Technologies "] build = "build.rs" edition = "2021" @@ -12,20 +12,22 @@ path = "src/main.rs" [dependencies] async-trait = "0.1.68" -clap = { version = "4.2.3", features = ["derive"] } +clap = { version = "4.3.1", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0" } futures = "0.3.28" hex-literal = "0.4.1" -log = "0.4.17" -serde = { version = "1.0.160", features = ["derive"] } +log = "0.4.18" +serde = { version = "1.0.163", features = ["derive"] } +serde_json = "1.0.96" # Local rococo-parachain-runtime = { path = "../parachains/runtimes/testing/rococo-parachain" } shell-runtime = { path = "../parachains/runtimes/starters/shell" } +glutton-runtime = { path = "../parachains/runtimes/glutton/glutton-kusama" } seedling-runtime = { path = "../parachains/runtimes/starters/seedling" } -statemint-runtime = { path = "../parachains/runtimes/assets/statemint" } -statemine-runtime = { path = "../parachains/runtimes/assets/statemine" } -westmint-runtime = { path = "../parachains/runtimes/assets/westmint" } +asset-hub-polkadot-runtime = { path = "../parachains/runtimes/assets/asset-hub-polkadot" } +asset-hub-kusama-runtime = { path = "../parachains/runtimes/assets/asset-hub-kusama" } +asset-hub-westend-runtime = { path = "../parachains/runtimes/assets/asset-hub-westend" } collectives-polkadot-runtime = { path = "../parachains/runtimes/collectives/collectives-polkadot" } contracts-rococo-runtime = { path = "../parachains/runtimes/contracts/contracts-rococo" } bridge-hub-rococo-runtime = { path = "../parachains/runtimes/bridge-hubs/bridge-hub-rococo" } @@ -64,7 +66,6 @@ sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "maste sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" } -sp-serializer = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" } try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" } @@ -96,7 +97,7 @@ substrate-build-script-utils = { git = "https://github.com/paritytech/substrate" assert_cmd = "2.0" nix = { version = "0.26.1", features = ["signal"] } tempfile = "3.5.0" -tokio = { version = "1.27.0", features = ["macros", "time", "parking_lot"] } +tokio = { version = "1.28.2", features = ["macros", "time", "parking_lot"] } wait-timeout = "0.2" # purge_chain_works works with rococo-local and needs to allow this polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master", features = ["rococo-native"] } @@ -105,9 +106,9 @@ polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "maste default = [] runtime-benchmarks = [ "polkadot-service/runtime-benchmarks", - "statemint-runtime/runtime-benchmarks", - "statemine-runtime/runtime-benchmarks", - "westmint-runtime/runtime-benchmarks", + "asset-hub-polkadot-runtime/runtime-benchmarks", + "asset-hub-kusama-runtime/runtime-benchmarks", + "asset-hub-westend-runtime/runtime-benchmarks", "bridge-hub-rococo-runtime/runtime-benchmarks", "bridge-hub-kusama-runtime/runtime-benchmarks", "bridge-hub-polkadot-runtime/runtime-benchmarks", @@ -118,9 +119,9 @@ runtime-benchmarks = [ "penpal-runtime/runtime-benchmarks", ] try-runtime = [ - "statemint-runtime/try-runtime", - "statemine-runtime/try-runtime", - "westmint-runtime/try-runtime", + "asset-hub-polkadot-runtime/try-runtime", + "asset-hub-kusama-runtime/try-runtime", + "asset-hub-westend-runtime/try-runtime", "shell-runtime/try-runtime", "try-runtime-cli/try-runtime", ] diff --git a/polkadot-parachain/src/chain_spec/statemint.rs b/polkadot-parachain/src/chain_spec/asset_hubs.rs similarity index 71% rename from polkadot-parachain/src/chain_spec/statemint.rs rename to polkadot-parachain/src/chain_spec/asset_hubs.rs index e12a5d12e17..9188431bdf5 100644 --- a/polkadot-parachain/src/chain_spec/statemint.rs +++ b/polkadot-parachain/src/chain_spec/asset_hubs.rs @@ -19,61 +19,66 @@ use crate::chain_spec::{ }; use cumulus_primitives_core::ParaId; use hex_literal::hex; -use parachains_common::{AccountId, AuraId, Balance as StatemintBalance, StatemintAuraId}; +use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance as AssetHubBalance}; use sc_service::ChainType; use sp_core::{crypto::UncheckedInto, sr25519}; /// Specialized `ChainSpec` for the normal parachain runtime. -pub type StatemintChainSpec = - sc_service::GenericChainSpec; -pub type StatemineChainSpec = - sc_service::GenericChainSpec; -pub type WestmintChainSpec = - sc_service::GenericChainSpec; +pub type AssetHubPolkadotChainSpec = + sc_service::GenericChainSpec; +pub type AssetHubKusamaChainSpec = + sc_service::GenericChainSpec; +pub type AssetHubWestendChainSpec = + sc_service::GenericChainSpec; -const STATEMINT_ED: StatemintBalance = statemint_runtime::constants::currency::EXISTENTIAL_DEPOSIT; -const STATEMINE_ED: StatemintBalance = statemine_runtime::constants::currency::EXISTENTIAL_DEPOSIT; -const WESTMINT_ED: StatemintBalance = westmint_runtime::constants::currency::EXISTENTIAL_DEPOSIT; +const ASSET_HUB_POLKADOT_ED: AssetHubBalance = + asset_hub_polkadot_runtime::constants::currency::EXISTENTIAL_DEPOSIT; +const ASSET_HUB_KUSAMA_ED: AssetHubBalance = + asset_hub_kusama_runtime::constants::currency::EXISTENTIAL_DEPOSIT; +const ASSET_HUB_WESTEND_ED: AssetHubBalance = + asset_hub_westend_runtime::constants::currency::EXISTENTIAL_DEPOSIT; /// Generate the session keys from individual elements. /// /// The input must be a tuple of individual keys (a single arg for now since we have just one key). -pub fn statemint_session_keys(keys: StatemintAuraId) -> statemint_runtime::SessionKeys { - statemint_runtime::SessionKeys { aura: keys } +pub fn asset_hub_polkadot_session_keys( + keys: AssetHubPolkadotAuraId, +) -> asset_hub_polkadot_runtime::SessionKeys { + asset_hub_polkadot_runtime::SessionKeys { aura: keys } } /// Generate the session keys from individual elements. /// /// The input must be a tuple of individual keys (a single arg for now since we have just one key). -pub fn statemine_session_keys(keys: AuraId) -> statemine_runtime::SessionKeys { - statemine_runtime::SessionKeys { aura: keys } +pub fn asset_hub_kusama_session_keys(keys: AuraId) -> asset_hub_kusama_runtime::SessionKeys { + asset_hub_kusama_runtime::SessionKeys { aura: keys } } /// Generate the session keys from individual elements. /// /// The input must be a tuple of individual keys (a single arg for now since we have just one key). -pub fn westmint_session_keys(keys: AuraId) -> westmint_runtime::SessionKeys { - westmint_runtime::SessionKeys { aura: keys } +pub fn asset_hub_westend_session_keys(keys: AuraId) -> asset_hub_westend_runtime::SessionKeys { + asset_hub_westend_runtime::SessionKeys { aura: keys } } -pub fn statemint_development_config() -> StatemintChainSpec { +pub fn asset_hub_polkadot_development_config() -> AssetHubPolkadotChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("ss58Format".into(), 0.into()); properties.insert("tokenSymbol".into(), "DOT".into()); properties.insert("tokenDecimals".into(), 10.into()); - StatemintChainSpec::from_genesis( + AssetHubPolkadotChainSpec::from_genesis( // Name - "Statemint Development", + "Polkadot Asset Hub Development", // ID - "statemint_dev", + "asset-hub-polkadot-dev", ChainType::Local, move || { - statemint_genesis( + asset_hub_polkadot_genesis( // initial collators. vec![( get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed::("Alice"), + get_collator_keys_from_seed::("Alice"), )], vec![ get_account_id_from_seed::("Alice"), @@ -93,29 +98,29 @@ pub fn statemint_development_config() -> StatemintChainSpec { ) } -pub fn statemint_local_config() -> StatemintChainSpec { +pub fn asset_hub_polkadot_local_config() -> AssetHubPolkadotChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("ss58Format".into(), 0.into()); properties.insert("tokenSymbol".into(), "DOT".into()); properties.insert("tokenDecimals".into(), 10.into()); - StatemintChainSpec::from_genesis( + AssetHubPolkadotChainSpec::from_genesis( // Name - "Statemint Local", + "Polkadot Asset Hub Local", // ID - "statemint_local", + "asset-hub-polkadot-local", ChainType::Local, move || { - statemint_genesis( + asset_hub_polkadot_genesis( // initial collators. vec![ ( get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed::("Alice"), + get_collator_keys_from_seed::("Alice"), ), ( get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed::("Bob"), + get_collator_keys_from_seed::("Bob"), ), ], vec![ @@ -145,20 +150,20 @@ pub fn statemint_local_config() -> StatemintChainSpec { } // Not used for syncing, but just to determine the genesis values set for the upgrade from shell. -pub fn statemint_config() -> StatemintChainSpec { +pub fn asset_hub_polkadot_config() -> AssetHubPolkadotChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("ss58Format".into(), 0.into()); properties.insert("tokenSymbol".into(), "DOT".into()); properties.insert("tokenDecimals".into(), 10.into()); - StatemintChainSpec::from_genesis( + AssetHubPolkadotChainSpec::from_genesis( // Name - "Statemint", + "Polkadot Asset Hub", // ID - "statemint", + "asset-hub-polkadot", ChainType::Live, move || { - statemint_genesis( + asset_hub_polkadot_genesis( // initial collators. vec![ ( @@ -204,34 +209,38 @@ pub fn statemint_config() -> StatemintChainSpec { ) } -fn statemint_genesis( - invulnerables: Vec<(AccountId, StatemintAuraId)>, +fn asset_hub_polkadot_genesis( + invulnerables: Vec<(AccountId, AssetHubPolkadotAuraId)>, endowed_accounts: Vec, id: ParaId, -) -> statemint_runtime::GenesisConfig { - statemint_runtime::GenesisConfig { - system: statemint_runtime::SystemConfig { - code: statemint_runtime::WASM_BINARY +) -> asset_hub_polkadot_runtime::GenesisConfig { + asset_hub_polkadot_runtime::GenesisConfig { + system: asset_hub_polkadot_runtime::SystemConfig { + code: asset_hub_polkadot_runtime::WASM_BINARY .expect("WASM binary was not build, please build it!") .to_vec(), }, - balances: statemint_runtime::BalancesConfig { - balances: endowed_accounts.iter().cloned().map(|k| (k, STATEMINT_ED * 4096)).collect(), + balances: asset_hub_polkadot_runtime::BalancesConfig { + balances: endowed_accounts + .iter() + .cloned() + .map(|k| (k, ASSET_HUB_POLKADOT_ED * 4096)) + .collect(), }, - parachain_info: statemint_runtime::ParachainInfoConfig { parachain_id: id }, - collator_selection: statemint_runtime::CollatorSelectionConfig { + parachain_info: asset_hub_polkadot_runtime::ParachainInfoConfig { parachain_id: id }, + collator_selection: asset_hub_polkadot_runtime::CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), - candidacy_bond: STATEMINT_ED * 16, + candidacy_bond: ASSET_HUB_POLKADOT_ED * 16, ..Default::default() }, - session: statemint_runtime::SessionConfig { + session: asset_hub_polkadot_runtime::SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - statemint_session_keys(aura), // session keys + acc.clone(), // account id + acc, // validator id + asset_hub_polkadot_session_keys(aura), // session keys ) }) .collect(), @@ -241,26 +250,26 @@ fn statemint_genesis( aura: Default::default(), aura_ext: Default::default(), parachain_system: Default::default(), - polkadot_xcm: statemint_runtime::PolkadotXcmConfig { + polkadot_xcm: asset_hub_polkadot_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), }, } } -pub fn statemine_development_config() -> StatemineChainSpec { +pub fn asset_hub_kusama_development_config() -> AssetHubKusamaChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("ss58Format".into(), 2.into()); properties.insert("tokenSymbol".into(), "KSM".into()); properties.insert("tokenDecimals".into(), 12.into()); - StatemineChainSpec::from_genesis( + AssetHubKusamaChainSpec::from_genesis( // Name - "Statemine Development", + "Kusama Asset Hub Development", // ID - "statemine_dev", + "asset-hub-kusama-dev", ChainType::Local, move || { - statemine_genesis( + asset_hub_kusama_genesis( // initial collators. vec![( get_account_id_from_seed::("Alice"), @@ -284,20 +293,20 @@ pub fn statemine_development_config() -> StatemineChainSpec { ) } -pub fn statemine_local_config() -> StatemineChainSpec { +pub fn asset_hub_kusama_local_config() -> AssetHubKusamaChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("ss58Format".into(), 2.into()); properties.insert("tokenSymbol".into(), "KSM".into()); properties.insert("tokenDecimals".into(), 12.into()); - StatemineChainSpec::from_genesis( + AssetHubKusamaChainSpec::from_genesis( // Name - "Statemine Local", + "Kusama Asset Hub Local", // ID - "statemine_local", + "asset-hub-kusama-local", ChainType::Local, move || { - statemine_genesis( + asset_hub_kusama_genesis( // initial collators. vec![ ( @@ -335,20 +344,20 @@ pub fn statemine_local_config() -> StatemineChainSpec { ) } -pub fn statemine_config() -> StatemineChainSpec { +pub fn asset_hub_kusama_config() -> AssetHubKusamaChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("ss58Format".into(), 2.into()); properties.insert("tokenSymbol".into(), "KSM".into()); properties.insert("tokenDecimals".into(), 12.into()); - StatemineChainSpec::from_genesis( + AssetHubKusamaChainSpec::from_genesis( // Name - "Statemine", + "Kusama Asset Hub", // ID - "statemine", + "asset-hub-kusama", ChainType::Live, move || { - statemine_genesis( + asset_hub_kusama_genesis( // initial collators. vec![ ( @@ -389,38 +398,38 @@ pub fn statemine_config() -> StatemineChainSpec { ) } -fn statemine_genesis( +fn asset_hub_kusama_genesis( invulnerables: Vec<(AccountId, AuraId)>, endowed_accounts: Vec, id: ParaId, -) -> statemine_runtime::GenesisConfig { - statemine_runtime::GenesisConfig { - system: statemine_runtime::SystemConfig { - code: statemine_runtime::WASM_BINARY +) -> asset_hub_kusama_runtime::GenesisConfig { + asset_hub_kusama_runtime::GenesisConfig { + system: asset_hub_kusama_runtime::SystemConfig { + code: asset_hub_kusama_runtime::WASM_BINARY .expect("WASM binary was not build, please build it!") .to_vec(), }, - balances: statemine_runtime::BalancesConfig { + balances: asset_hub_kusama_runtime::BalancesConfig { balances: endowed_accounts .iter() .cloned() - .map(|k| (k, STATEMINE_ED * 524_288)) + .map(|k| (k, ASSET_HUB_KUSAMA_ED * 524_288)) .collect(), }, - parachain_info: statemine_runtime::ParachainInfoConfig { parachain_id: id }, - collator_selection: statemine_runtime::CollatorSelectionConfig { + parachain_info: asset_hub_kusama_runtime::ParachainInfoConfig { parachain_id: id }, + collator_selection: asset_hub_kusama_runtime::CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), - candidacy_bond: STATEMINE_ED * 16, + candidacy_bond: ASSET_HUB_KUSAMA_ED * 16, ..Default::default() }, - session: statemine_runtime::SessionConfig { + session: asset_hub_kusama_runtime::SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - statemine_session_keys(aura), // session keys + acc.clone(), // account id + acc, // validator id + asset_hub_kusama_session_keys(aura), // session keys ) }) .collect(), @@ -428,25 +437,25 @@ fn statemine_genesis( aura: Default::default(), aura_ext: Default::default(), parachain_system: Default::default(), - polkadot_xcm: statemine_runtime::PolkadotXcmConfig { + polkadot_xcm: asset_hub_kusama_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), }, } } -pub fn westmint_development_config() -> WestmintChainSpec { +pub fn asset_hub_westend_development_config() -> AssetHubWestendChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("tokenSymbol".into(), "WND".into()); properties.insert("tokenDecimals".into(), 12.into()); - WestmintChainSpec::from_genesis( + AssetHubWestendChainSpec::from_genesis( // Name - "Westmint Development", + "Westend Asset Hub Development", // ID - "westmint_dev", + "asset-hub-westend-dev", ChainType::Local, move || { - westmint_genesis( + asset_hub_westend_genesis( // initial collators. vec![( get_account_id_from_seed::("Alice"), @@ -470,19 +479,19 @@ pub fn westmint_development_config() -> WestmintChainSpec { ) } -pub fn westmint_local_config() -> WestmintChainSpec { +pub fn asset_hub_westend_local_config() -> AssetHubWestendChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("tokenSymbol".into(), "WND".into()); properties.insert("tokenDecimals".into(), 12.into()); - WestmintChainSpec::from_genesis( + AssetHubWestendChainSpec::from_genesis( // Name - "Westmint Local", + "Westend Asset Hub Local", // ID - "westmint_local", + "asset-hub-westend-local", ChainType::Local, move || { - westmint_genesis( + asset_hub_westend_genesis( // initial collators. vec![ ( @@ -520,19 +529,19 @@ pub fn westmint_local_config() -> WestmintChainSpec { ) } -pub fn westmint_config() -> WestmintChainSpec { +pub fn asset_hub_westend_config() -> AssetHubWestendChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("tokenSymbol".into(), "WND".into()); properties.insert("tokenDecimals".into(), 12.into()); - WestmintChainSpec::from_genesis( + AssetHubWestendChainSpec::from_genesis( // Name - "Westmint", + "Westend Asset Hub", // ID - "westmint", + "asset-hub-westend", ChainType::Live, move || { - westmint_genesis( + asset_hub_westend_genesis( // initial collators. vec![ ( @@ -573,34 +582,38 @@ pub fn westmint_config() -> WestmintChainSpec { ) } -fn westmint_genesis( +fn asset_hub_westend_genesis( invulnerables: Vec<(AccountId, AuraId)>, endowed_accounts: Vec, id: ParaId, -) -> westmint_runtime::GenesisConfig { - westmint_runtime::GenesisConfig { - system: westmint_runtime::SystemConfig { - code: westmint_runtime::WASM_BINARY +) -> asset_hub_westend_runtime::GenesisConfig { + asset_hub_westend_runtime::GenesisConfig { + system: asset_hub_westend_runtime::SystemConfig { + code: asset_hub_westend_runtime::WASM_BINARY .expect("WASM binary was not build, please build it!") .to_vec(), }, - balances: westmint_runtime::BalancesConfig { - balances: endowed_accounts.iter().cloned().map(|k| (k, WESTMINT_ED * 4096)).collect(), + balances: asset_hub_westend_runtime::BalancesConfig { + balances: endowed_accounts + .iter() + .cloned() + .map(|k| (k, ASSET_HUB_WESTEND_ED * 4096)) + .collect(), }, - parachain_info: westmint_runtime::ParachainInfoConfig { parachain_id: id }, - collator_selection: westmint_runtime::CollatorSelectionConfig { + parachain_info: asset_hub_westend_runtime::ParachainInfoConfig { parachain_id: id }, + collator_selection: asset_hub_westend_runtime::CollatorSelectionConfig { invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), - candidacy_bond: WESTMINT_ED * 16, + candidacy_bond: ASSET_HUB_WESTEND_ED * 16, ..Default::default() }, - session: westmint_runtime::SessionConfig { + session: asset_hub_westend_runtime::SessionConfig { keys: invulnerables .into_iter() .map(|(acc, aura)| { ( - acc.clone(), // account id - acc, // validator id - westmint_session_keys(aura), // session keys + acc.clone(), // account id + acc, // validator id + asset_hub_westend_session_keys(aura), // session keys ) }) .collect(), @@ -610,7 +623,7 @@ fn westmint_genesis( aura: Default::default(), aura_ext: Default::default(), parachain_system: Default::default(), - polkadot_xcm: westmint_runtime::PolkadotXcmConfig { + polkadot_xcm: asset_hub_westend_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), }, } diff --git a/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/polkadot-parachain/src/chain_spec/bridge_hubs.rs index ab3e44220cc..e8f7d9d065d 100644 --- a/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -1,4 +1,4 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// Copyright 2022 Parity Technologies (UK) Ltd. // This file is part of Cumulus. // Cumulus is free software: you can redistribute it and/or modify @@ -14,10 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . +use crate::chain_spec::{get_account_id_from_seed, get_collator_keys_from_seed}; use cumulus_primitives_core::ParaId; use parachains_common::Balance as BridgeHubBalance; use sc_chain_spec::ChainSpec; use sc_cli::RuntimeVersion; +use sp_core::sr25519; use std::{path::PathBuf, str::FromStr}; /// Collects all supported BridgeHub configurations @@ -139,6 +141,7 @@ impl BridgeHubRuntimeType { "Rococo BridgeHub Local", "rococo-local", ParaId::new(1013), + Some("Bob".to_string()), |_| (), ))), BridgeHubRuntimeType::RococoDevelopment => Ok(Box::new(rococo::local_config( @@ -146,6 +149,7 @@ impl BridgeHubRuntimeType { "Rococo BridgeHub Development", "rococo-dev", ParaId::new(1013), + Some("Bob".to_string()), |_| (), ))), BridgeHubRuntimeType::Wococo => @@ -157,6 +161,7 @@ impl BridgeHubRuntimeType { "Wococo BridgeHub Local", "wococo-local", ParaId::new(1014), + Some("Bob".to_string()), ))), } } @@ -197,13 +202,12 @@ fn ensure_id(id: &str) -> Result<&str, String> { /// Sub-module for Rococo setup pub mod rococo { - use super::{BridgeHubBalance, ParaId}; - use crate::chain_spec::{ - get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION, - }; + use super::{get_account_id_from_seed, get_collator_keys_from_seed, sr25519, ParaId}; + use crate::chain_spec::{Extensions, SAFE_XCM_VERSION}; use parachains_common::{AccountId, AuraId}; use sc_chain_spec::ChainType; - use sp_core::sr25519; + + use super::BridgeHubBalance; pub(crate) const BRIDGE_HUB_ROCOCO: &str = "bridge-hub-rococo"; pub(crate) const BRIDGE_HUB_ROCOCO_LOCAL: &str = "bridge-hub-rococo-local"; @@ -222,6 +226,7 @@ pub mod rococo { chain_name: &str, relay_chain: &str, para_id: ParaId, + bridges_pallet_owner_seed: Option, modify_props: ModifyProperties, ) -> BridgeHubChainSpec { // Rococo defaults @@ -265,6 +270,9 @@ pub mod rococo { get_account_id_from_seed::("Ferdie//stash"), ], para_id, + bridges_pallet_owner_seed + .as_ref() + .map(|seed| get_account_id_from_seed::(seed)), ) }, Vec::new(), @@ -280,6 +288,7 @@ pub mod rococo { invulnerables: Vec<(AccountId, AuraId)>, endowed_accounts: Vec, id: ParaId, + bridges_pallet_owner: Option, ) -> bridge_hub_rococo_runtime::GenesisConfig { bridge_hub_rococo_runtime::GenesisConfig { system: bridge_hub_rococo_runtime::SystemConfig { @@ -314,6 +323,22 @@ pub mod rococo { polkadot_xcm: bridge_hub_rococo_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), }, + bridge_wococo_grandpa: bridge_hub_rococo_runtime::BridgeWococoGrandpaConfig { + owner: bridges_pallet_owner.clone(), + ..Default::default() + }, + bridge_rococo_grandpa: bridge_hub_rococo_runtime::BridgeRococoGrandpaConfig { + owner: bridges_pallet_owner.clone(), + ..Default::default() + }, + bridge_rococo_messages: bridge_hub_rococo_runtime::BridgeRococoMessagesConfig { + owner: bridges_pallet_owner.clone(), + ..Default::default() + }, + bridge_wococo_messages: bridge_hub_rococo_runtime::BridgeWococoMessagesConfig { + owner: bridges_pallet_owner, + ..Default::default() + }, } } } @@ -334,10 +359,18 @@ pub mod wococo { chain_name: &str, relay_chain: &str, para_id: ParaId, + bridges_pallet_owner_seed: Option, ) -> BridgeHubChainSpec { - rococo::local_config(id, chain_name, relay_chain, para_id, |properties| { - properties.insert("tokenSymbol".into(), "WOOK".into()); - }) + rococo::local_config( + id, + chain_name, + relay_chain, + para_id, + bridges_pallet_owner_seed, + |properties| { + properties.insert("tokenSymbol".into(), "WOOK".into()); + }, + ) } } diff --git a/polkadot-parachain/src/chain_spec/glutton.rs b/polkadot-parachain/src/chain_spec/glutton.rs new file mode 100644 index 00000000000..d975a0d7d87 --- /dev/null +++ b/polkadot-parachain/src/chain_spec/glutton.rs @@ -0,0 +1,99 @@ +// Copyright Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +use crate::chain_spec::{get_account_id_from_seed, Extensions}; +use cumulus_primitives_core::ParaId; +use sc_service::ChainType; +use sp_core::sr25519; + +/// Specialized `ChainSpec` for the Glutton parachain runtime. +pub type GluttonChainSpec = + sc_service::GenericChainSpec; + +pub fn glutton_development_config(para_id: ParaId) -> GluttonChainSpec { + GluttonChainSpec::from_genesis( + // Name + "Glutton Development", + // ID + "glutton_dev", + ChainType::Local, + move || glutton_genesis(para_id), + Vec::new(), + None, + None, + None, + None, + Extensions { relay_chain: "kusama-dev".into(), para_id: para_id.into() }, + ) +} + +pub fn glutton_local_config(para_id: ParaId) -> GluttonChainSpec { + GluttonChainSpec::from_genesis( + // Name + "Glutton Local", + // ID + "glutton_local", + ChainType::Local, + move || glutton_genesis(para_id), + Vec::new(), + None, + None, + None, + None, + Extensions { relay_chain: "kusama-local".into(), para_id: para_id.into() }, + ) +} + +pub fn glutton_config(para_id: ParaId) -> GluttonChainSpec { + let mut properties = sc_chain_spec::Properties::new(); + properties.insert("ss58Format".into(), 2.into()); + + GluttonChainSpec::from_genesis( + // Name + format!("Glutton {}", para_id).as_str(), + // ID + format!("glutton-kusama-{}", para_id).as_str(), + ChainType::Live, + move || glutton_genesis(para_id), + Vec::new(), + None, + // Protocol ID + Some(format!("glutton-kusama-{}", para_id).as_str()), + None, + Some(properties), + Extensions { relay_chain: "kusama".into(), para_id: para_id.into() }, + ) +} + +fn glutton_genesis(parachain_id: ParaId) -> glutton_runtime::GenesisConfig { + glutton_runtime::GenesisConfig { + system: glutton_runtime::SystemConfig { + code: glutton_runtime::WASM_BINARY + .expect("WASM binary was not build, please build it!") + .to_vec(), + }, + parachain_info: glutton_runtime::ParachainInfoConfig { parachain_id }, + parachain_system: Default::default(), + glutton: glutton_runtime::GluttonConfig { + compute: Default::default(), + storage: Default::default(), + trash_data_count: Default::default(), + }, + sudo: glutton_runtime::SudoConfig { + key: Some(get_account_id_from_seed::("Alice")), + }, + } +} diff --git a/polkadot-parachain/src/chain_spec/mod.rs b/polkadot-parachain/src/chain_spec/mod.rs index 3637e915406..d7014a9f43c 100644 --- a/polkadot-parachain/src/chain_spec/mod.rs +++ b/polkadot-parachain/src/chain_spec/mod.rs @@ -20,14 +20,15 @@ use serde::{Deserialize, Serialize}; use sp_core::{Pair, Public}; use sp_runtime::traits::{IdentifyAccount, Verify}; +pub mod asset_hubs; pub mod bridge_hubs; pub mod collectives; pub mod contracts; +pub mod glutton; pub mod penpal; pub mod rococo_parachain; pub mod seedling; pub mod shell; -pub mod statemint; /// The default XCM version to set in genesis config. const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION; diff --git a/polkadot-parachain/src/cli.rs b/polkadot-parachain/src/cli.rs index 682911abf75..7be61810a7d 100644 --- a/polkadot-parachain/src/cli.rs +++ b/polkadot-parachain/src/cli.rs @@ -66,10 +66,10 @@ pub enum Subcommand { const AFTER_HELP_EXAMPLE: &str = color_print::cstr!( r#"Examples: - polkadot-parachain --chain statemint --sync warp -- --chain polkadot --sync warp - Launch a warp-syncing full node of the statemint parachain on the polkadot relay chain. - polkadot-parachain --chain statemint --sync warp --relay-chain-rpc-url ws://rpc.example.com -- --chain polkadot - Launch a warp-syncing full node of the statemint parachain on the polkadot relay chain. + polkadot-parachain --chain asset-hub-polkadot --sync warp -- --chain polkadot --sync warp + Launch a warp-syncing full node of the Asset Hub parachain on the Polkadot Relay Chain. + polkadot-parachain --chain asset-hub-polkadot --sync warp --relay-chain-rpc-url ws://rpc.example.com -- --chain polkadot + Launch a warp-syncing full node of the Asset Hub parachain on the Polkadot Relay Chain. Uses ws://rpc.example.com as remote relay chain node. "# ); @@ -122,7 +122,11 @@ impl RelayChainCli { ) -> Self { let extension = crate::chain_spec::Extensions::try_get(&*para_config.chain_spec); let chain_id = extension.map(|e| e.relay_chain.clone()); - let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot")); - Self { base_path, chain_id, base: clap::Parser::parse_from(relay_chain_args) } + let base_path = para_config.base_path.path().join("polkadot"); + Self { + base_path: Some(base_path), + chain_id, + base: clap::Parser::parse_from(relay_chain_args), + } } } diff --git a/polkadot-parachain/src/command.rs b/polkadot-parachain/src/command.rs index 4270677e0bf..f59a58aa367 100644 --- a/polkadot-parachain/src/command.rs +++ b/polkadot-parachain/src/command.rs @@ -18,9 +18,10 @@ use crate::{ chain_spec, cli::{Cli, RelayChainCli, Subcommand}, service::{ - new_partial, Block, BridgeHubKusamaRuntimeExecutor, BridgeHubPolkadotRuntimeExecutor, - BridgeHubRococoRuntimeExecutor, CollectivesPolkadotRuntimeExecutor, - StatemineRuntimeExecutor, StatemintRuntimeExecutor, WestmintRuntimeExecutor, + new_partial, AssetHubKusamaExecutor, AssetHubPolkadotRuntimeExecutor, + AssetHubWestendExecutor, Block, BridgeHubKusamaRuntimeExecutor, + BridgeHubPolkadotRuntimeExecutor, BridgeHubRococoRuntimeExecutor, + CollectivesPolkadotRuntimeExecutor, GluttonRuntimeExecutor, }, }; use codec::Encode; @@ -28,7 +29,7 @@ use cumulus_client_cli::generate_genesis_block; use cumulus_primitives_core::ParaId; use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; use log::{info, warn}; -use parachains_common::{AuraId, StatemintAuraId}; +use parachains_common::{AssetHubPolkadotAuraId, AuraId}; use sc_cli::{ ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, @@ -47,13 +48,14 @@ enum Runtime { Default, Shell, Seedling, - Statemint, - Statemine, - Westmint, + AssetHubPolkadot, + AssetHubKusama, + AssetHubWestend, Penpal(ParaId), ContractsRococo, CollectivesPolkadot, CollectivesWestend, + Glutton, BridgeHub(chain_spec::bridge_hubs::BridgeHubRuntimeType), } @@ -77,7 +79,7 @@ impl RuntimeResolver for PathBuf { let file = std::fs::File::open(self).expect("Failed to open file"); let reader = std::io::BufReader::new(file); - let chain_spec: EmptyChainSpecWithId = sp_serializer::from_reader(reader) + let chain_spec: EmptyChainSpecWithId = serde_json::from_reader(reader) .expect("Failed to read 'json' file with ChainSpec configuration"); runtime(&chain_spec.id) @@ -85,19 +87,19 @@ impl RuntimeResolver for PathBuf { } fn runtime(id: &str) -> Runtime { - let id = id.replace("_", "-"); + let id = id.replace('_', "-"); let (_, id, para_id) = extract_parachain_id(&id); if id.starts_with("shell") { Runtime::Shell } else if id.starts_with("seedling") { Runtime::Seedling - } else if id.starts_with("statemint") { - Runtime::Statemint - } else if id.starts_with("statemine") { - Runtime::Statemine - } else if id.starts_with("westmint") { - Runtime::Westmint + } else if id.starts_with("asset-hub-polkadot") | id.starts_with("statemint") { + Runtime::AssetHubPolkadot + } else if id.starts_with("asset-hub-kusama") | id.starts_with("statemine") { + Runtime::AssetHubKusama + } else if id.starts_with("asset-hub-westend") | id.starts_with("westmint") { + Runtime::AssetHubWestend } else if id.starts_with("penpal") { Runtime::Penpal(para_id.unwrap_or(ParaId::new(0))) } else if id.starts_with("contracts-rococo") { @@ -111,6 +113,8 @@ fn runtime(id: &str) -> Runtime { id.parse::() .expect("Invalid value"), ) + } else if id.starts_with("glutton") { + Runtime::Glutton } else { log::warn!("No specific runtime was recognized for ChainSpec's id: '{}', so Runtime::default() will be used", id); Runtime::default() @@ -140,35 +144,47 @@ fn load_spec(id: &str) -> std::result::Result, String> { "shell" => Box::new(chain_spec::shell::get_shell_chain_spec()), "seedling" => Box::new(chain_spec::seedling::get_seedling_chain_spec()), - // -- Statemint - "statemint-dev" => Box::new(chain_spec::statemint::statemint_development_config()), - "statemint-local" => Box::new(chain_spec::statemint::statemint_local_config()), + // -- Asset Hub Polkadot + "asset-hub-polkadot-dev" | "statemint-dev" => + Box::new(chain_spec::asset_hubs::asset_hub_polkadot_development_config()), + "asset-hub-polkadot-local" | "statemint-local" => + Box::new(chain_spec::asset_hubs::asset_hub_polkadot_local_config()), // the chain spec as used for generating the upgrade genesis values - "statemint-genesis" => Box::new(chain_spec::statemint::statemint_config()), + "asset-hub-polkadot-genesis" | "statemint-genesis" => + Box::new(chain_spec::asset_hubs::asset_hub_polkadot_config()), // the shell-based chain spec as used for syncing - "statemint" => Box::new(chain_spec::statemint::StatemintChainSpec::from_json_bytes( - &include_bytes!("../../parachains/chain-specs/statemint.json")[..], - )?), + "asset-hub-polkadot" | "statemint" => + Box::new(chain_spec::asset_hubs::AssetHubPolkadotChainSpec::from_json_bytes( + &include_bytes!("../../parachains/chain-specs/asset-hub-polkadot.json")[..], + )?), - // -- Statemine - "statemine-dev" => Box::new(chain_spec::statemint::statemine_development_config()), - "statemine-local" => Box::new(chain_spec::statemint::statemine_local_config()), + // -- Asset Hub Kusama + "asset-hub-kusama-dev" | "statemine-dev" => + Box::new(chain_spec::asset_hubs::asset_hub_kusama_development_config()), + "asset-hub-kusama-local" | "statemine-local" => + Box::new(chain_spec::asset_hubs::asset_hub_kusama_local_config()), // the chain spec as used for generating the upgrade genesis values - "statemine-genesis" => Box::new(chain_spec::statemint::statemine_config()), + "asset-hub-kusama-genesis" | "statemine-genesis" => + Box::new(chain_spec::asset_hubs::asset_hub_kusama_config()), // the shell-based chain spec as used for syncing - "statemine" => Box::new(chain_spec::statemint::StatemineChainSpec::from_json_bytes( - &include_bytes!("../../parachains/chain-specs/statemine.json")[..], - )?), + "asset-hub-kusama" | "statemine" => + Box::new(chain_spec::asset_hubs::AssetHubKusamaChainSpec::from_json_bytes( + &include_bytes!("../../parachains/chain-specs/asset-hub-kusama.json")[..], + )?), - // -- Westmint - "westmint-dev" => Box::new(chain_spec::statemint::westmint_development_config()), - "westmint-local" => Box::new(chain_spec::statemint::westmint_local_config()), + // -- Asset Hub Westend + "asset-hub-westend-dev" | "westmint-dev" => + Box::new(chain_spec::asset_hubs::asset_hub_westend_development_config()), + "asset-hub-westend-local" | "westmint-local" => + Box::new(chain_spec::asset_hubs::asset_hub_westend_local_config()), // the chain spec as used for generating the upgrade genesis values - "westmint-genesis" => Box::new(chain_spec::statemint::westmint_config()), + "asset-hub-westend-genesis" | "westmint-genesis" => + Box::new(chain_spec::asset_hubs::asset_hub_westend_config()), // the shell-based chain spec as used for syncing - "westmint" => Box::new(chain_spec::statemint::WestmintChainSpec::from_json_bytes( - &include_bytes!("../../parachains/chain-specs/westmint.json")[..], - )?), + "asset-hub-westend" | "westmint" => + Box::new(chain_spec::asset_hubs::AssetHubWestendChainSpec::from_json_bytes( + &include_bytes!("../../parachains/chain-specs/asset-hub-westend.json")[..], + )?), // -- Polkadot Collectives "collectives-polkadot-dev" => @@ -214,6 +230,18 @@ fn load_spec(id: &str) -> std::result::Result, String> { "polkadot-local", )), + // -- Glutton + "glutton-kusama-dev" => Box::new(chain_spec::glutton::glutton_development_config( + para_id.expect("Must specify parachain id"), + )), + "glutton-kusama-local" => Box::new(chain_spec::glutton::glutton_local_config( + para_id.expect("Must specify parachain id"), + )), + // the chain spec as used for generating the upgrade genesis values + "glutton-kusama-genesis" => Box::new(chain_spec::glutton::glutton_config( + para_id.expect("Must specify parachain id"), + )), + // -- Fallback (generic chainspec) "" => { log::warn!("No ChainSpec.id specified, so using default one, based on rococo-parachain runtime"); @@ -224,12 +252,14 @@ fn load_spec(id: &str) -> std::result::Result, String> { path => { let path: PathBuf = path.into(); match path.runtime() { - Runtime::Statemint => - Box::new(chain_spec::statemint::StatemintChainSpec::from_json_file(path)?), - Runtime::Statemine => - Box::new(chain_spec::statemint::StatemineChainSpec::from_json_file(path)?), - Runtime::Westmint => - Box::new(chain_spec::statemint::WestmintChainSpec::from_json_file(path)?), + Runtime::AssetHubPolkadot => Box::new( + chain_spec::asset_hubs::AssetHubPolkadotChainSpec::from_json_file(path)?, + ), + Runtime::AssetHubKusama => + Box::new(chain_spec::asset_hubs::AssetHubKusamaChainSpec::from_json_file(path)?), + Runtime::AssetHubWestend => Box::new( + chain_spec::asset_hubs::AssetHubWestendChainSpec::from_json_file(path)?, + ), Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => Box::new( chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_file(path)?, ), @@ -240,9 +270,11 @@ fn load_spec(id: &str) -> std::result::Result, String> { Runtime::ContractsRococo => Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path)?), Runtime::BridgeHub(bridge_hub_runtime_type) => - bridge_hub_runtime_type.chain_spec_from_json_file(path.into())?, + bridge_hub_runtime_type.chain_spec_from_json_file(path)?, Runtime::Penpal(_para_id) => Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?), + Runtime::Glutton => + Box::new(chain_spec::glutton::GluttonChainSpec::from_json_file(path)?), Runtime::Default => Box::new( chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_file(path)?, ), @@ -258,14 +290,25 @@ fn extract_parachain_id(id: &str) -> (&str, &str, Option) { const KUSAMA_TEST_PARA_PREFIX: &str = "penpal-kusama-"; const POLKADOT_TEST_PARA_PREFIX: &str = "penpal-polkadot-"; - let (norm_id, orig_id, para) = if id.starts_with(KUSAMA_TEST_PARA_PREFIX) { - let suffix = &id[KUSAMA_TEST_PARA_PREFIX.len()..]; + const GLUTTON_PARA_DEV_PREFIX: &str = "glutton-kusama-dev-"; + const GLUTTON_PARA_LOCAL_PREFIX: &str = "glutton-kusama-local-"; + const GLUTTON_PARA_GENESIS_PREFIX: &str = "glutton-kusama-genesis-"; + + let (norm_id, orig_id, para) = if let Some(suffix) = id.strip_prefix(KUSAMA_TEST_PARA_PREFIX) { let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix"); (&id[..KUSAMA_TEST_PARA_PREFIX.len() - 1], id, Some(para_id)) - } else if id.starts_with(POLKADOT_TEST_PARA_PREFIX) { - let suffix = &id[POLKADOT_TEST_PARA_PREFIX.len()..]; + } else if let Some(suffix) = id.strip_prefix(POLKADOT_TEST_PARA_PREFIX) { let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix"); (&id[..POLKADOT_TEST_PARA_PREFIX.len() - 1], id, Some(para_id)) + } else if let Some(suffix) = id.strip_prefix(GLUTTON_PARA_DEV_PREFIX) { + let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix"); + (&id[..GLUTTON_PARA_DEV_PREFIX.len() - 1], id, Some(para_id)) + } else if let Some(suffix) = id.strip_prefix(GLUTTON_PARA_LOCAL_PREFIX) { + let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix"); + (&id[..GLUTTON_PARA_LOCAL_PREFIX.len() - 1], id, Some(para_id)) + } else if let Some(suffix) = id.strip_prefix(GLUTTON_PARA_GENESIS_PREFIX) { + let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix"); + (&id[..GLUTTON_PARA_GENESIS_PREFIX.len() - 1], id, Some(para_id)) } else { (id, id, None) }; @@ -310,9 +353,9 @@ impl SubstrateCli for Cli { fn native_runtime_version(chain_spec: &Box) -> &'static RuntimeVersion { match chain_spec.runtime() { - Runtime::Statemint => &statemint_runtime::VERSION, - Runtime::Statemine => &statemine_runtime::VERSION, - Runtime::Westmint => &westmint_runtime::VERSION, + Runtime::AssetHubPolkadot => &asset_hub_polkadot_runtime::VERSION, + Runtime::AssetHubKusama => &asset_hub_kusama_runtime::VERSION, + Runtime::AssetHubWestend => &asset_hub_westend_runtime::VERSION, Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => &collectives_polkadot_runtime::VERSION, Runtime::Shell => &shell_runtime::VERSION, @@ -321,6 +364,7 @@ impl SubstrateCli for Cli { Runtime::BridgeHub(bridge_hub_runtime_type) => bridge_hub_runtime_type.runtime_version(), Runtime::Penpal(_) => &penpal_runtime::VERSION, + Runtime::Glutton => &glutton_runtime::VERSION, Runtime::Default => &rococo_parachain_runtime::VERSION, } } @@ -370,24 +414,24 @@ impl SubstrateCli for RelayChainCli { macro_rules! construct_benchmark_partials { ($config:expr, |$partials:ident| $code:expr) => { match $config.chain_spec.runtime() { - Runtime::Statemine => { - let $partials = new_partial::( + Runtime::AssetHubKusama => { + let $partials = new_partial::( &$config, crate::service::aura_build_import_queue::<_, AuraId>, )?; $code }, - Runtime::Westmint => { - let $partials = new_partial::( + Runtime::AssetHubWestend => { + let $partials = new_partial::( &$config, crate::service::aura_build_import_queue::<_, AuraId>, )?; $code }, - Runtime::Statemint => { - let $partials = new_partial::( + Runtime::AssetHubPolkadot => { + let $partials = new_partial::( &$config, - crate::service::aura_build_import_queue::<_, StatemintAuraId>, + crate::service::aura_build_import_queue::<_, AssetHubPolkadotAuraId>, )?; $code }, @@ -407,9 +451,9 @@ macro_rules! construct_async_run { (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{ let runner = $cli.create_runner($cmd)?; match runner.config().chain_spec.runtime() { - Runtime::Westmint => { + Runtime::AssetHubWestend => { runner.async_run(|$config| { - let $components = new_partial::( + let $components = new_partial::( &$config, crate::service::aura_build_import_queue::<_, AuraId>, )?; @@ -417,9 +461,9 @@ macro_rules! construct_async_run { { $( $code )* }.map(|v| (v, task_manager)) }) }, - Runtime::Statemine => { + Runtime::AssetHubKusama => { runner.async_run(|$config| { - let $components = new_partial::( + let $components = new_partial::( &$config, crate::service::aura_build_import_queue::<_, AuraId>, )?; @@ -427,11 +471,11 @@ macro_rules! construct_async_run { { $( $code )* }.map(|v| (v, task_manager)) }) }, - Runtime::Statemint => { + Runtime::AssetHubPolkadot => { runner.async_run(|$config| { - let $components = new_partial::( + let $components = new_partial::( &$config, - crate::service::aura_build_import_queue::<_, StatemintAuraId>, + crate::service::aura_build_import_queue::<_, AssetHubPolkadotAuraId>, )?; let task_manager = $components.task_manager; { $( $code )* }.map(|v| (v, task_manager)) @@ -555,6 +599,16 @@ macro_rules! construct_async_run { let task_manager = $components.task_manager; { $( $code )* }.map(|v| (v, task_manager)) }) + }, + Runtime::Glutton => { + runner.async_run(|$config| { + let $components = new_partial::( + &$config, + crate::service::shell_build_import_queue, + )?; + let task_manager = $components.task_manager; + { $( $code )* }.map(|v| (v, task_manager)) + }) } } }} @@ -635,11 +689,11 @@ pub fn run() -> Result<()> { if cfg!(feature = "runtime-benchmarks") { runner.sync_run(|config| { match config.chain_spec.runtime() { - Runtime::Statemine => - cmd.run::(config), - Runtime::Westmint => cmd.run::(config), - Runtime::Statemint => - cmd.run::(config), + Runtime::AssetHubKusama => + cmd.run::(config), + Runtime::AssetHubWestend => cmd.run::(config), + Runtime::AssetHubPolkadot => + cmd.run::(config), Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => cmd.run::(config), Runtime::BridgeHub(bridge_hub_runtime_type) => match bridge_hub_runtime_type { @@ -661,7 +715,9 @@ pub fn run() -> Result<()> { bridge_hub_runtime_type ) .into()), - } + }, + Runtime::Glutton => + cmd.run::(config), _ => Err(format!( "Chain '{:?}' doesn't support benchmarking", config.chain_spec.runtime() @@ -721,25 +777,25 @@ pub fn run() -> Result<()> { let info_provider = timestamp_with_aura_info(6000); match runner.config().chain_spec.runtime() { - Runtime::Statemine => runner.async_run(|_| { + Runtime::AssetHubKusama => runner.async_run(|_| { Ok(( - cmd.run::, _>(Some( + cmd.run::, _>(Some( info_provider, )), task_manager, )) }), - Runtime::Westmint => runner.async_run(|_| { + Runtime::AssetHubWestend => runner.async_run(|_| { Ok(( - cmd.run::, _>(Some( + cmd.run::, _>(Some( info_provider, )), task_manager, )) }), - Runtime::Statemint => runner.async_run(|_| { + Runtime::AssetHubPolkadot => runner.async_run(|_| { Ok(( - cmd.run::, _>(Some( + cmd.run::, _>(Some( info_provider, )), task_manager, @@ -798,6 +854,12 @@ pub fn run() -> Result<()> { task_manager, )) }), + Runtime::Glutton => runner.async_run(|_| { + Ok(( + cmd.run::, _>(Some(info_provider)), + task_manager, + )) + }), _ => Err("Chain doesn't support try-runtime".into()), } }, @@ -811,15 +873,47 @@ pub fn run() -> Result<()> { let collator_options = cli.run.collator_options(); runner.run_node_until_exit(|config| async move { + // If Statemint (Statemine, Westmint, Rockmine) DB exists and we're using the + // asset-hub chain spec, then rename the base path to the new chain ID. In the case + // that both file paths exist, the node will exit, as the user must decide (by + // deleting one path) the information that they want to use as their DB. + let old_name = match config.chain_spec.id() { + "asset-hub-polkadot" => Some("statemint"), + "asset-hub-kusama" => Some("statemine"), + "asset-hub-westend" => Some("westmint"), + "asset-hub-rococo" => Some("rockmine"), + _ => None, + }; + + if let Some(old_name) = old_name { + let new_path = config.base_path.config_dir(config.chain_spec.id()); + let old_path = config.base_path.config_dir(old_name); + + if old_path.exists() && new_path.exists() { + return Err(format!( + "Found legacy {} path {} and new asset-hub path {}. Delete one path such that only one exists.", + old_name, old_path.display(), new_path.display() + ).into()) + } + + if old_path.exists() { + std::fs::rename(old_path.clone(), new_path.clone())?; + info!( + "Statemint renamed to Asset Hub. The filepath with associated data on disk has been renamed from {} to {}.", + old_path.display(), new_path.display() + ); + } + } + let hwbench = (!cli.no_hardware_benchmarks).then_some( config.database.path().map(|database_path| { - let _ = std::fs::create_dir_all(&database_path); + let _ = std::fs::create_dir_all(database_path); sc_sysinfo::gather_hwbench(Some(database_path)) })).flatten(); let para_id = chain_spec::Extensions::try_get(&*config.chain_spec) .map(|e| e.para_id) - .ok_or_else(|| "Could not find parachain extension in chain-spec.")?; + .ok_or("Could not find parachain extension in chain-spec.")?; let polkadot_cli = RelayChainCli::new( &config, @@ -848,27 +942,27 @@ pub fn run() -> Result<()> { info!("Parachain genesis state: {}", genesis_state); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); - if !collator_options.relay_chain_rpc_urls.is_empty() && cli.relaychain_args.len() > 0 { + if !collator_options.relay_chain_rpc_urls.is_empty() && !cli.relaychain_args.is_empty() { warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options."); } match config.chain_spec.runtime() { - Runtime::Statemint => crate::service::start_generic_aura_node::< - statemint_runtime::RuntimeApi, - StatemintAuraId, + Runtime::AssetHubPolkadot => crate::service::start_generic_aura_node::< + asset_hub_polkadot_runtime::RuntimeApi, + AssetHubPolkadotAuraId, >(config, polkadot_config, collator_options, id, hwbench) .await .map(|r| r.0) .map_err(Into::into), - Runtime::Statemine => crate::service::start_generic_aura_node::< - statemine_runtime::RuntimeApi, + Runtime::AssetHubKusama => crate::service::start_generic_aura_node::< + asset_hub_kusama_runtime::RuntimeApi, AuraId, >(config, polkadot_config, collator_options, id, hwbench) .await .map(|r| r.0) .map_err(Into::into), - Runtime::Westmint => crate::service::start_generic_aura_node::< - westmint_runtime::RuntimeApi, + Runtime::AssetHubWestend => crate::service::start_generic_aura_node::< + asset_hub_westend_runtime::RuntimeApi, AuraId, >(config, polkadot_config, collator_options, id, hwbench) .await @@ -965,6 +1059,17 @@ pub fn run() -> Result<()> { .await .map(|r| r.0) .map_err(Into::into), + Runtime::Glutton => + crate::service::start_shell_node::( + config, + polkadot_config, + collator_options, + id, + hwbench, + ) + .await + .map(|r| r.0) + .map_err(Into::into), } }) }, @@ -976,14 +1081,10 @@ impl DefaultConfigurationValues for RelayChainCli { 30334 } - fn rpc_ws_listen_port() -> u16 { + fn rpc_listen_port() -> u16 { 9945 } - fn rpc_http_listen_port() -> u16 { - 9934 - } - fn prometheus_listen_port() -> u16 { 9616 } @@ -1013,16 +1114,8 @@ impl CliConfiguration for RelayChainCli { .or_else(|| self.base_path.clone().map(Into::into))) } - fn rpc_http(&self, default_listen_port: u16) -> Result> { - self.base.base.rpc_http(default_listen_port) - } - - fn rpc_ipc(&self) -> Result> { - self.base.base.rpc_ipc() - } - - fn rpc_ws(&self, default_listen_port: u16) -> Result> { - self.base.base.rpc_ws(default_listen_port) + fn rpc_addr(&self, default_listen_port: u16) -> Result> { + self.base.base.rpc_addr(default_listen_port) } fn prometheus_config( @@ -1068,8 +1161,8 @@ impl CliConfiguration for RelayChainCli { self.base.base.rpc_methods() } - fn rpc_ws_max_connections(&self) -> Result> { - self.base.base.rpc_ws_max_connections() + fn rpc_max_connections(&self) -> Result { + self.base.base.rpc_max_connections() } fn rpc_cors(&self, is_dev: bool) -> Result>> { @@ -1211,9 +1304,9 @@ mod tests { let path = store_configuration( &temp_dir, - Box::new(crate::chain_spec::statemint::statemine_local_config()), + Box::new(crate::chain_spec::asset_hubs::asset_hub_kusama_local_config()), ); - assert_eq!(Runtime::Statemine, path.runtime()); + assert_eq!(Runtime::AssetHubKusama, path.runtime()); let path = store_configuration( &temp_dir, diff --git a/polkadot-parachain/src/rpc.rs b/polkadot-parachain/src/rpc.rs index 43752fd8d12..c2eeaf38608 100644 --- a/polkadot-parachain/src/rpc.rs +++ b/polkadot-parachain/src/rpc.rs @@ -70,7 +70,7 @@ where module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?; - module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; + module.merge(StateMigration::new(client, backend, deny_unsafe).into_rpc())?; Ok(module) } diff --git a/polkadot-parachain/src/service.rs b/polkadot-parachain/src/service.rs index 803d0987844..b493f3589ed 100644 --- a/polkadot-parachain/src/service.rs +++ b/polkadot-parachain/src/service.rs @@ -43,7 +43,7 @@ use sc_consensus::{ BlockImportParams, ImportQueue, }; use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY}; -use sc_network::NetworkBlock; +use sc_network::{config::FullNetworkConfiguration, NetworkBlock}; use sc_network_sync::SyncingService; use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; @@ -86,52 +86,52 @@ impl sc_executor::NativeExecutionDispatch for ShellRuntimeExecutor { } } -// Native Statemint executor instance. -pub struct StatemintRuntimeExecutor; +/// Native Asset Hub Polkadot (Statemint) executor instance. +pub struct AssetHubPolkadotRuntimeExecutor; -impl sc_executor::NativeExecutionDispatch for StatemintRuntimeExecutor { +impl sc_executor::NativeExecutionDispatch for AssetHubPolkadotRuntimeExecutor { type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; fn dispatch(method: &str, data: &[u8]) -> Option> { - statemint_runtime::api::dispatch(method, data) + asset_hub_polkadot_runtime::api::dispatch(method, data) } fn native_version() -> sc_executor::NativeVersion { - statemint_runtime::native_version() + asset_hub_polkadot_runtime::native_version() } } -/// Native Statemine executor instance. -pub struct StatemineRuntimeExecutor; +/// Native Asset Hub Kusama (Statemine) executor instance. +pub struct AssetHubKusamaExecutor; -impl sc_executor::NativeExecutionDispatch for StatemineRuntimeExecutor { +impl sc_executor::NativeExecutionDispatch for AssetHubKusamaExecutor { type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; fn dispatch(method: &str, data: &[u8]) -> Option> { - statemine_runtime::api::dispatch(method, data) + asset_hub_kusama_runtime::api::dispatch(method, data) } fn native_version() -> sc_executor::NativeVersion { - statemine_runtime::native_version() + asset_hub_kusama_runtime::native_version() } } -/// Native Westmint executor instance. -pub struct WestmintRuntimeExecutor; +/// Native Asset Hub Westend (Westmint) executor instance. +pub struct AssetHubWestendExecutor; -impl sc_executor::NativeExecutionDispatch for WestmintRuntimeExecutor { +impl sc_executor::NativeExecutionDispatch for AssetHubWestendExecutor { type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; fn dispatch(method: &str, data: &[u8]) -> Option> { - westmint_runtime::api::dispatch(method, data) + asset_hub_westend_runtime::api::dispatch(method, data) } fn native_version() -> sc_executor::NativeVersion { - westmint_runtime::native_version() + asset_hub_westend_runtime::native_version() } } -// Native Polkadot Collectives executor instance. +/// Native Polkadot Collectives executor instance. pub struct CollectivesPolkadotRuntimeExecutor; impl sc_executor::NativeExecutionDispatch for CollectivesPolkadotRuntimeExecutor { @@ -146,7 +146,7 @@ impl sc_executor::NativeExecutionDispatch for CollectivesPolkadotRuntimeExecutor } } -// Native BridgeHubPolkadot executor instance. +/// Native BridgeHubPolkadot executor instance. pub struct BridgeHubPolkadotRuntimeExecutor; impl sc_executor::NativeExecutionDispatch for BridgeHubPolkadotRuntimeExecutor { @@ -161,7 +161,7 @@ impl sc_executor::NativeExecutionDispatch for BridgeHubPolkadotRuntimeExecutor { } } -// Native BridgeHubKusama executor instance. +/// Native BridgeHubKusama executor instance. pub struct BridgeHubKusamaRuntimeExecutor; impl sc_executor::NativeExecutionDispatch for BridgeHubKusamaRuntimeExecutor { @@ -176,7 +176,7 @@ impl sc_executor::NativeExecutionDispatch for BridgeHubKusamaRuntimeExecutor { } } -// Native BridgeHubRococo executor instance. +/// Native BridgeHubRococo executor instance. pub struct BridgeHubRococoRuntimeExecutor; impl sc_executor::NativeExecutionDispatch for BridgeHubRococoRuntimeExecutor { @@ -191,7 +191,7 @@ impl sc_executor::NativeExecutionDispatch for BridgeHubRococoRuntimeExecutor { } } -// Native contracts executor instance. +/// Native contracts executor instance. pub struct ContractsRococoRuntimeExecutor; impl sc_executor::NativeExecutionDispatch for ContractsRococoRuntimeExecutor { @@ -206,6 +206,21 @@ impl sc_executor::NativeExecutionDispatch for ContractsRococoRuntimeExecutor { } } +/// Native Glutton executor instance. +pub struct GluttonRuntimeExecutor; + +impl sc_executor::NativeExecutionDispatch for GluttonRuntimeExecutor { + type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; + + fn dispatch(method: &str, data: &[u8]) -> Option> { + shell_runtime::api::dispatch(method, data) + } + + fn native_version() -> sc_executor::NativeVersion { + shell_runtime::native_version() + } +} + /// Starts a `ServiceBuilder` for a full service. /// /// Use this macro if you don't actually need the full service, but just the builder in order to @@ -393,10 +408,12 @@ where let prometheus_registry = parachain_config.prometheus_registry().cloned(); let transaction_pool = params.transaction_pool.clone(); let import_queue_service = params.import_queue.service(); + let net_config = FullNetworkConfiguration::new(¶chain_config.network); let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = build_network(BuildNetworkParams { parachain_config: ¶chain_config, + net_config, client: client.clone(), transaction_pool: transaction_pool.clone(), para_id, @@ -582,10 +599,12 @@ where let prometheus_registry = parachain_config.prometheus_registry().cloned(); let transaction_pool = params.transaction_pool.clone(); let import_queue_service = params.import_queue.service(); + let net_config = FullNetworkConfiguration::new(¶chain_config.network); let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = build_network(BuildNetworkParams { parachain_config: ¶chain_config, + net_config, client: client.clone(), transaction_pool: transaction_pool.clone(), para_id, @@ -858,7 +877,7 @@ where sc_client_api::StateBackendFor: sp_api::StateBackend, { cumulus_client_consensus_relay_chain::import_queue( - client.clone(), + client, block_import, |_, _| async { Ok(()) }, &task_manager.spawn_essential_handle(), @@ -1049,7 +1068,7 @@ where } } -/// Build the import queue for Statemint and other Aura-based runtimes. +/// Build the import queue for Aura-based runtimes. pub fn aura_build_import_queue( client: Arc>, block_import: ParachainBlockImport, @@ -1103,7 +1122,7 @@ where Box::new(RelayChainVerifier::new(client.clone(), |_, _| async { Ok(()) })) as Box<_>; let verifier = Verifier { - client: client.clone(), + client, relay_chain_verifier, aura_verifier: BuildOnAccess::Uninitialized(Some(Box::new(aura_verifier))), _phantom: PhantomData, @@ -1115,8 +1134,7 @@ where Ok(BasicQueue::new(verifier, Box::new(block_import), None, &spawner, registry)) } -/// Start an aura powered parachain node. -/// (collective-polkadot and statemine/t use this) +/// Start an aura powered parachain node. Asset Hub and Collectives use this. pub async fn start_generic_aura_node( parachain_config: Configuration, polkadot_config: Configuration, @@ -1355,10 +1373,12 @@ where let prometheus_registry = parachain_config.prometheus_registry().cloned(); let transaction_pool = params.transaction_pool.clone(); let import_queue_service = params.import_queue.service(); + let net_config = FullNetworkConfiguration::new(¶chain_config.network); let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = build_network(BuildNetworkParams { parachain_config: ¶chain_config, + net_config, client: client.clone(), transaction_pool: transaction_pool.clone(), para_id, diff --git a/polkadot-parachain/tests/benchmark_storage_works.rs b/polkadot-parachain/tests/benchmark_storage_works.rs index 916d65c0a1b..df3078b4dab 100644 --- a/polkadot-parachain/tests/benchmark_storage_works.rs +++ b/polkadot-parachain/tests/benchmark_storage_works.rs @@ -8,7 +8,7 @@ use std::{ use tempfile::tempdir; /// The runtimes that this command supports. -static RUNTIMES: [&'static str; 3] = ["westmint", "statemine", "statemint"]; +static RUNTIMES: [&str; 3] = ["asset-hub-westend", "asset-hub-kusama", "asset-hub-polkadot"]; /// The `benchmark storage` command works for the dev runtimes. #[test] @@ -31,7 +31,7 @@ fn benchmark_storage_works() { /// Invoke the `benchmark storage` sub-command for the given database and runtime. fn benchmark_storage(db: &str, runtime: &str, base_path: &Path) -> ExitStatus { Command::new(cargo_bin("polkadot-parachain")) - .args(&["benchmark", "storage", "--chain", runtime]) + .args(["benchmark", "storage", "--chain", runtime]) .arg("--db") .arg(db) .arg("--weight-path") diff --git a/polkadot-parachain/tests/common.rs b/polkadot-parachain/tests/common.rs index 1d3d710c83d..d8ecfe9bcbe 100644 --- a/polkadot-parachain/tests/common.rs +++ b/polkadot-parachain/tests/common.rs @@ -103,7 +103,7 @@ impl DerefMut for KillChildOnDrop { } } -/// Read the WS address from the output. +/// Read the RPC server address from the output. /// /// This is hack to get the actual bound sockaddr because /// substrate assigns a random port if the specified port was already bound. @@ -117,19 +117,19 @@ pub fn find_ws_url_from_output(read: impl Read + Send) -> (String, String) { line.expect("failed to obtain next line from stdout for WS address discovery"); data.push_str(&line); - data.push_str("\n"); + data.push('\n'); // does the line contain our port (we expect this specific output from substrate). - let sock_addr = match line.split_once("Running JSON-RPC WS server: addr=") { + let sock_addr = match line.split_once("Running JSON-RPC server: addr=") { None => return None, - Some((_, after)) => after.split_once(",").unwrap().0, + Some((_, after)) => after.split_once(',').unwrap().0, }; Some(format!("ws://{}", sock_addr)) }) .unwrap_or_else(|| { eprintln!("Output:\n{}", data); - panic!("We should get a WebSocket address") + panic!("We should get an address") }); (ws_url, data) diff --git a/polkadot-parachain/tests/purge_chain_works.rs b/polkadot-parachain/tests/purge_chain_works.rs index 34a51dcff84..2f4609273da 100644 --- a/polkadot-parachain/tests/purge_chain_works.rs +++ b/polkadot-parachain/tests/purge_chain_works.rs @@ -38,7 +38,7 @@ async fn purge_chain_works() { assert!(base_dir.path().join("polkadot/chains/dev/db/full").exists()); let status = Command::new(cargo_bin("polkadot-parachain")) - .args(&["purge-chain", "-d"]) + .args(["purge-chain", "-d"]) .arg(base_dir.path()) .arg("-y") .status() diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index 6f3c7fcf239..04525360dab 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ "derive" ] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } # Substrate sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/primitives/core/src/lib.rs b/primitives/core/src/lib.rs index b08d65db467..22155e2ef86 100644 --- a/primitives/core/src/lib.rs +++ b/primitives/core/src/lib.rs @@ -21,7 +21,7 @@ use codec::{Decode, Encode, MaxEncodedLen}; use polkadot_parachain::primitives::HeadData; use scale_info::TypeInfo; -use sp_runtime::{traits::Block as BlockT, RuntimeDebug}; +use sp_runtime::RuntimeDebug; use sp_std::prelude::*; pub use polkadot_core_primitives::InboundDownwardMessage; @@ -32,6 +32,12 @@ pub use polkadot_primitives::{ AbridgedHostConfiguration, AbridgedHrmpChannel, PersistedValidationData, }; +pub use sp_runtime::{ + generic::{Digest, DigestItem}, + traits::Block as BlockT, + ConsensusEngineId, +}; + pub use xcm::latest::prelude::*; /// A module that re-exports relevant relay chain definitions. @@ -233,6 +239,88 @@ impl ParachainBlockData { } } +/// A consensus engine ID indicating that this is a Cumulus Parachain. +pub const CUMULUS_CONSENSUS_ID: ConsensusEngineId = *b"CMLS"; + +/// Consensus header digests for Cumulus parachains. +#[derive(Clone, RuntimeDebug, Decode, Encode, PartialEq)] +pub enum CumulusDigestItem { + /// A digest item indicating the relay-parent a parachain block was built against. + #[codec(index = 0)] + RelayParent(relay_chain::Hash), +} + +impl CumulusDigestItem { + /// Encode this as a Substrate [`DigestItem`]. + pub fn to_digest_item(&self) -> DigestItem { + DigestItem::Consensus(CUMULUS_CONSENSUS_ID, self.encode()) + } +} + +/// Extract the relay-parent from the provided header digest. Returns `None` if none were found. +/// +/// If there are multiple valid digests, this returns the value of the first one, although +/// well-behaving runtimes should not produce headers with more than one. +pub fn extract_relay_parent(digest: &Digest) -> Option { + digest.convert_first(|d| match d { + DigestItem::Consensus(id, val) if id == &CUMULUS_CONSENSUS_ID => + match CumulusDigestItem::decode(&mut &val[..]) { + Ok(CumulusDigestItem::RelayParent(hash)) => Some(hash), + _ => None, + }, + _ => None, + }) +} + +/// Utilities for handling the relay-parent storage root as a digest item. +/// +/// This is not intended to be part of the public API, as it is a workaround for +/// via +/// . +/// +/// Runtimes using the parachain-system pallet are expected to produce this digest item, +/// but will stop as soon as they are able to provide the relay-parent hash directly. +/// +/// The relay-chain storage root is, in practice, a unique identifier of a block +/// in the absence of equivocations (which are slashable). This assumes that the relay chain +/// uses BABE or SASSAFRAS, because the slot and the author's VRF randomness are both included +/// in the relay-chain storage root in both cases. +/// +/// Therefore, the relay-parent storage root is a suitable identifier of unique relay chain +/// blocks in low-value scenarios such as performance optimizations. +#[doc(hidden)] +pub mod rpsr_digest { + use super::{relay_chain, ConsensusEngineId, Decode, Digest, DigestItem, Encode}; + use codec::Compact; + + /// A consensus engine ID for relay-parent storage root digests. + pub const RPSR_CONSENSUS_ID: ConsensusEngineId = *b"RPSR"; + + /// Construct a digest item for relay-parent storage roots. + pub fn relay_parent_storage_root_item( + storage_root: relay_chain::Hash, + number: impl Into>, + ) -> DigestItem { + DigestItem::Consensus(RPSR_CONSENSUS_ID, (storage_root, number.into()).encode()) + } + + /// Extract the relay-parent storage root and number from the provided header digest. Returns `None` + /// if none were found. + pub fn extract_relay_parent_storage_root( + digest: &Digest, + ) -> Option<(relay_chain::Hash, relay_chain::BlockNumber)> { + digest.convert_first(|d| match d { + DigestItem::Consensus(id, val) if id == &RPSR_CONSENSUS_ID => { + let (h, n): (relay_chain::Hash, Compact) = + Decode::decode(&mut &val[..]).ok()?; + + Some((h, n.0)) + }, + _ => None, + }) + } +} + /// Information about a collation. /// /// This was used in version 1 of the [`CollectCollationInfo`] runtime api. diff --git a/primitives/parachain-inherent/Cargo.toml b/primitives/parachain-inherent/Cargo.toml index 2135802592b..5c1730e35e0 100644 --- a/primitives/parachain-inherent/Cargo.toml +++ b/primitives/parachain-inherent/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] async-trait = { version = "0.1.68", optional = true } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ "derive" ] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } tracing = { version = "0.1.37", optional = true } # Substrate diff --git a/primitives/parachain-inherent/src/client_side.rs b/primitives/parachain-inherent/src/client_side.rs index 6f2cd5eb504..03ca3203dc0 100644 --- a/primitives/parachain-inherent/src/client_side.rs +++ b/primitives/parachain-inherent/src/client_side.rs @@ -92,18 +92,23 @@ async fn collect_relay_storage_proof( .ok()? .unwrap_or_default(); - let mut relevant_keys = Vec::new(); - relevant_keys.push(relay_well_known_keys::CURRENT_BLOCK_RANDOMNESS.to_vec()); - relevant_keys.push(relay_well_known_keys::ONE_EPOCH_AGO_RANDOMNESS.to_vec()); - relevant_keys.push(relay_well_known_keys::TWO_EPOCHS_AGO_RANDOMNESS.to_vec()); - relevant_keys.push(relay_well_known_keys::CURRENT_SLOT.to_vec()); - relevant_keys.push(relay_well_known_keys::ACTIVE_CONFIG.to_vec()); - relevant_keys.push(relay_well_known_keys::dmq_mqc_head(para_id)); - relevant_keys.push(relay_well_known_keys::relay_dispatch_queue_size(para_id)); - relevant_keys.push(relay_well_known_keys::hrmp_ingress_channel_index(para_id)); - relevant_keys.push(relay_well_known_keys::hrmp_egress_channel_index(para_id)); - relevant_keys.push(relay_well_known_keys::upgrade_go_ahead_signal(para_id)); - relevant_keys.push(relay_well_known_keys::upgrade_restriction_signal(para_id)); + let mut relevant_keys = vec![ + relay_well_known_keys::CURRENT_BLOCK_RANDOMNESS.to_vec(), + relay_well_known_keys::ONE_EPOCH_AGO_RANDOMNESS.to_vec(), + relay_well_known_keys::TWO_EPOCHS_AGO_RANDOMNESS.to_vec(), + relay_well_known_keys::CURRENT_SLOT.to_vec(), + relay_well_known_keys::ACTIVE_CONFIG.to_vec(), + relay_well_known_keys::dmq_mqc_head(para_id), + // TODO paritytech/polkadot#6283: Remove all usages of `relay_dispatch_queue_size` + // We need to keep this here until all parachains have migrated to `relay_dispatch_queue_remaining_capacity`. + #[allow(deprecated)] + relay_well_known_keys::relay_dispatch_queue_size(para_id), + relay_well_known_keys::relay_dispatch_queue_remaining_capacity(para_id).key, + relay_well_known_keys::hrmp_ingress_channel_index(para_id), + relay_well_known_keys::hrmp_egress_channel_index(para_id), + relay_well_known_keys::upgrade_go_ahead_signal(para_id), + relay_well_known_keys::upgrade_restriction_signal(para_id), + ]; relevant_keys.extend(ingress_channels.into_iter().map(|sender| { relay_well_known_keys::hrmp_channels(HrmpChannelId { sender, recipient: para_id }) })); diff --git a/primitives/parachain-inherent/src/mock.rs b/primitives/parachain-inherent/src/mock.rs index a26ee114ef7..00dff40800f 100644 --- a/primitives/parachain-inherent/src/mock.rs +++ b/primitives/parachain-inherent/src/mock.rs @@ -160,8 +160,8 @@ impl> InherentDataProvider self.relay_offset + self.relay_blocks_per_para_block * self.current_para_block; // Use the "sproof" (spoof proof) builder to build valid mock state root and proof. - let mut sproof_builder = RelayStateSproofBuilder::default(); - sproof_builder.para_id = self.xcm_config.para_id; + let mut sproof_builder = + RelayStateSproofBuilder { para_id: self.xcm_config.para_id, ..Default::default() }; // Process the downward messages and set up the correct head let mut downward_messages = Vec::new(); diff --git a/primitives/timestamp/src/lib.rs b/primitives/timestamp/src/lib.rs index ddc2fe340dd..932656d9b0f 100644 --- a/primitives/timestamp/src/lib.rs +++ b/primitives/timestamp/src/lib.rs @@ -99,7 +99,7 @@ mod tests { relay_parent_number: 1, relay_parent_storage_root, }, - &WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"), + WASM_BINARY.expect("You need to build the WASM binaries to run the tests!"), ) .map(|v| Header::decode(&mut &v.head_data.0[..]).expect("Decodes `Header`.")) } @@ -175,7 +175,7 @@ mod tests { (slot_timestamp * 10, false), ] { let output = Command::new(env::current_exe().unwrap()) - .args(&["check_timestamp_inherent_works", "--", "--nocapture"]) + .args(["check_timestamp_inherent_works", "--", "--nocapture"]) .env("RUN_TEST", "1") .env("TIMESTAMP", timestamp.to_string()) .output() diff --git a/primitives/utility/Cargo.toml b/primitives/utility/Cargo.toml index 58d5ee23c8e..00a634fa438 100644 --- a/primitives/utility/Cargo.toml +++ b/primitives/utility/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ "derive" ] } -log = { version = "0.4.17", default-features = false } +log = { version = "0.4.18", default-features = false } # Substrate frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/primitives/utility/src/lib.rs b/primitives/utility/src/lib.rs index d3a7c77aed2..f2488b83a51 100644 --- a/primitives/utility/src/lib.rs +++ b/primitives/utility/src/lib.rs @@ -163,25 +163,26 @@ impl< // Get the local asset id in which we can pay for fees let (local_asset_id, _) = - Matcher::matches_fungibles(&first).map_err(|_| XcmError::AssetNotFound)?; + Matcher::matches_fungibles(first).map_err(|_| XcmError::AssetNotFound)?; // Calculate how much we should charge in the asset_id for such amount of weight // Require at least a payment of minimum_balance // Necessary for fully collateral-backed assets - let asset_balance: u128 = FeeCharger::charge_weight_in_fungibles(local_asset_id, weight) - .map(|amount| { - let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id); - if amount < minimum_balance { - minimum_balance - } else { - amount - } - })? - .try_into() - .map_err(|_| XcmError::Overflow)?; + let asset_balance: u128 = + FeeCharger::charge_weight_in_fungibles(local_asset_id.clone(), weight) + .map(|amount| { + let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id); + if amount < minimum_balance { + minimum_balance + } else { + amount + } + })? + .try_into() + .map_err(|_| XcmError::Overflow)?; // Convert to the same kind of multiasset, with the required fungible balance - let required = first.id.clone().into_multiasset(asset_balance.into()); + let required = first.id.into_multiasset(asset_balance.into()); // Substract payment let unused = payment.checked_sub(required.clone()).map_err(|_| XcmError::TooExpensive)?; @@ -204,9 +205,9 @@ impl< { // Get the local asset id in which we can refund fees let (local_asset_id, outstanding_balance) = - Matcher::matches_fungibles(&(id.clone(), fun).into()).ok()?; + Matcher::matches_fungibles(&(id, fun).into()).ok()?; - let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id); + let minimum_balance = ConcreteAssets::minimum_balance(local_asset_id.clone()); // Calculate asset_balance // This read should have already be cached in buy_weight @@ -233,8 +234,7 @@ impl< let asset_balance: u128 = asset_balance.saturated_into(); // Construct outstanding_concrete_asset with the same location id and substracted balance - let outstanding_concrete_asset: MultiAsset = - (id.clone(), outstanding_minus_substracted).into(); + let outstanding_concrete_asset: MultiAsset = (id, outstanding_minus_substracted).into(); // Substract from existing weight and balance weight_outstanding = weight_outstanding.saturating_sub(weight); @@ -288,7 +288,7 @@ impl< &(X1(AccountId32 { network: None, id: receiver.into() }).into()), // We aren't able to track the XCM that initiated the fee deposit, so we create a // fake message hash here - &XcmContext::with_message_hash([0; 32]), + &XcmContext::with_message_id([0; 32]), ) .is_ok(); @@ -365,7 +365,7 @@ mod tests { // ParentAsUmp - check dest is really not applicable let dest = (Parent, Parent, Parent); - let mut dest_wrapper = Some(dest.clone().into()); + let mut dest_wrapper = Some(dest.into()); let mut msg_wrapper = Some(message.clone()); assert_eq!( Err(SendError::NotApplicable), @@ -373,7 +373,7 @@ mod tests { ); // check wrapper were not consumed - assert_eq!(Some(dest.clone().into()), dest_wrapper.take()); + assert_eq!(Some(dest.into()), dest_wrapper.take()); assert_eq!(Some(message.clone()), msg_wrapper.take()); // another try with router chain with asserting sender @@ -393,7 +393,7 @@ mod tests { // ParentAsUmp - check dest/msg is valid let dest = (Parent, Here); - let mut dest_wrapper = Some(dest.clone().into()); + let mut dest_wrapper = Some(dest.into()); let mut msg_wrapper = Some(message.clone()); assert!( as SendXcm>::validate( &mut dest_wrapper, @@ -529,16 +529,13 @@ mod tests { // prepare test data let asset: MultiAsset = (Here, AMOUNT).into(); - let payment = Assets::from(asset.clone()); + let payment = Assets::from(asset); let weight_to_buy = Weight::from_parts(1_000, 1_000); // lets do first call (success) assert_ok!(trader.buy_weight(weight_to_buy, payment.clone())); // lets do second call (error) - assert_eq!( - trader.buy_weight(weight_to_buy, payment.clone()), - Err(XcmError::NotWithdrawable) - ); + assert_eq!(trader.buy_weight(weight_to_buy, payment), Err(XcmError::NotWithdrawable)); } } diff --git a/scripts/benchmarks-ci.sh b/scripts/benchmarks-ci.sh index 4b465400198..fcf0cc61984 100755 --- a/scripts/benchmarks-ci.sh +++ b/scripts/benchmarks-ci.sh @@ -9,6 +9,10 @@ repeat=${5:-20} benchmarkOutput=./parachains/runtimes/$category/$runtimeName/src/weights benchmarkRuntimeName="$runtimeName-dev" +if [ $category = "glutton" ]; then + benchmarkRuntimeName="$runtimeName-dev-1300" +fi + # Load all pallet names in an array. pallets=($( ${artifactsDir}/polkadot-parachain benchmark pallet --list --chain="${benchmarkRuntimeName}" |\ diff --git a/scripts/benchmarks.sh b/scripts/benchmarks.sh index 0db74102f24..29d06905925 100755 --- a/scripts/benchmarks.sh +++ b/scripts/benchmarks.sh @@ -8,10 +8,12 @@ __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ${__dir}/benchmarks-ci.sh collectives collectives-polkadot target/$target $steps $repeat -${__dir}/benchmarks-ci.sh assets statemine target/$target $steps $repeat -${__dir}/benchmarks-ci.sh assets statemint target/$target $steps $repeat -${__dir}/benchmarks-ci.sh assets westmint target/$target $steps $repeat +${__dir}/benchmarks-ci.sh assets asset-hub-kusama target/$target $steps $repeat +${__dir}/benchmarks-ci.sh assets asset-hub-polkadot target/$target $steps $repeat +${__dir}/benchmarks-ci.sh assets asset-hub-westend target/$target $steps $repeat ${__dir}/benchmarks-ci.sh bridge-hubs bridge-hub-polkadot target/$target $steps $repeat ${__dir}/benchmarks-ci.sh bridge-hubs bridge-hub-kusama target/$target $steps $repeat ${__dir}/benchmarks-ci.sh bridge-hubs bridge-hub-rococo target/$target $steps $repeat + +${__dir}/benchmarks-ci.sh glutton glutton-kusama target/$target $steps $repeat diff --git a/scripts/bridges_rococo_wococo.sh b/scripts/bridges_rococo_wococo.sh new file mode 100755 index 00000000000..1117ed68109 --- /dev/null +++ b/scripts/bridges_rococo_wococo.sh @@ -0,0 +1,695 @@ +#!/bin/bash + +# Address: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY +# AccountId: [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] +ASSET_HUB_KUSAMA_ACCOUNT_SEED_FOR_LOCAL="//Alice" +# Address: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY +# AccountId: [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125] +ASSET_HUB_WOCOCO_ACCOUNT_SEED_FOR_LOCAL="5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" + +# SovereignAccount for `MultiLocation { parents: 2, interior: X2(GlobalConsensus(Rococo), Parachain(1000)) }` => 5CfNu7eH3SJvqqPt3aJh38T8dcFvhGzEohp9tsd41ANhXDnQ +# +# use sp_core::crypto::Ss58Codec; +# println!("{}", +# frame_support::sp_runtime::AccountId32::new( +# GlobalConsensusParachainConvertsFor::::convert_ref( +# MultiLocation { parents: 2, interior: X2(GlobalConsensus(Kusama), Parachain(1000)) }).unwrap() +# ).to_ss58check_with_version(42_u16.into()) +# ); +ASSET_HUB_ROCOCO_1000_SOVEREIGN_ACCOUNT="5CfNu7eH3SJvqqPt3aJh38T8dcFvhGzEohp9tsd41ANhXDnQ" + +# Address: GegTpZJMyzkntLN7NJhRfHDk4GWukLbGSsag6PHrLSrCK4h +ASSET_HUB2_ROCOCO_1000_SOVEREIGN_ACCOUNT="scatter feed race company oxygen trip extra elbow slot bundle auto canoe" + +# Adress: 5Ge7YcbctWCP1CccugzxWDn9hFnTxvTh3bL6PNy4ubNJmp7Y / H9jCvwVWsDJkrS4gPp1QB99qr4hmbGsVyAqn3F2PPaoWyU3 +# AccountId: [202, 107, 198, 135, 15, 25, 193, 165, 172, 73, 137, 218, 115, 177, 204, 0, 5, 155, 215, 86, 208, 51, 50, 130, 190, 110, 184, 143, 124, 50, 160, 20] +ASSET_HUB_WOCOCO_ACCOUNT_ADDRESS_FOR_ROCOCO="5Ge7YcbctWCP1CccugzxWDn9hFnTxvTh3bL6PNy4ubNJmp7Y" +ASSET_HUB_WOCOCO_ACCOUNT_SEED_FOR_WOCOCO="tone spirit magnet sunset cannon poverty forget lock river east blouse random" + +function address_to_account_id_bytes() { + local address=$1 + local output=$2 + echo "address_to_account_id_bytes - address: $address, output: $output" + if [ $address == "$ASSET_HUB_WOCOCO_ACCOUNT_SEED_FOR_LOCAL" ]; then + jq --null-input '[212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125]' > $output + elif [ $address == "$ASSET_HUB_WOCOCO_ACCOUNT_ADDRESS_FOR_ROCOCO" ]; then + jq --null-input '[202, 107, 198, 135, 15, 25, 193, 165, 172, 73, 137, 218, 115, 177, 204, 0, 5, 155, 215, 86, 208, 51, 50, 130, 190, 110, 184, 143, 124, 50, 160, 20]' > $output + else + echo -n "Sorry, unknown address: $address - please, add bytes here or function for that!" + exit 1 + fi +} + +function ensure_binaries() { + if [[ ! -f ~/local_bridge_testing/bin/polkadot ]]; then + echo " Required polkadot binary '~/local_bridge_testing/bin/polkadot' does not exist!" + echo " You need to build it and copy to this location!" + echo " Please, check ./parachains/runtimes/bridge-hubs/README.md (Prepare/Build/Deploy)" + exit 1 + fi + if [[ ! -f ~/local_bridge_testing/bin/polkadot-parachain ]]; then + echo " Required polkadot-parachain binary '~/local_bridge_testing/bin/polkadot-parachain' does not exist!" + echo " You need to build it and copy to this location!" + echo " Please, check ./parachains/runtimes/bridge-hubs/README.md (Prepare/Build/Deploy)" + exit 1 + fi +} + +function ensure_relayer() { + if [[ ! -f ~/local_bridge_testing/bin/substrate-relay ]]; then + echo " Required substrate-relay binary '~/local_bridge_testing/bin/substrate-relay' does not exist!" + echo " You need to build it and copy to this location!" + echo " Please, check ./parachains/runtimes/bridge-hubs/README.md (Prepare/Build/Deploy)" + exit 1 + fi +} + +function ensure_polkadot_js_api() { + if ! which polkadot-js-api &> /dev/null; then + echo '' + echo 'Required command `polkadot-js-api` not in PATH, please, install, e.g.:' + echo "npm install -g @polkadot/api-cli@beta" + echo " or" + echo "yarn global add @polkadot/api-cli" + echo '' + exit 1 + fi + if ! which jq &> /dev/null; then + echo '' + echo 'Required command `jq` not in PATH, please, install, e.g.:' + echo "apt install -y jq" + echo '' + exit 1 + fi + generate_hex_encoded_call_data "check" "--" + local retVal=$? + if [ $retVal -ne 0 ]; then + echo "" + echo "" + echo "-------------------" + echo "Installing (nodejs) sub module: ./scripts/generate_hex_encoded_call" + pushd ./scripts/generate_hex_encoded_call + npm install + popd + fi +} + +function generate_hex_encoded_call_data() { + local type=$1 + local endpoint=$2 + local output=$3 + shift + shift + shift + echo "Input params: $@" + + node ./scripts/generate_hex_encoded_call "$type" "$endpoint" "$output" "$@" + local retVal=$? + + if [ $type != "check" ]; then + local hex_encoded_data=$(cat $output) + echo "Generated hex-encoded bytes to file '$output': $hex_encoded_data" + fi + + return $retVal +} + +function transfer_balance() { + local runtime_para_endpoint=$1 + local seed=$2 + local target_account=$3 + local amount=$4 + echo " calling transfer_balance:" + echo " runtime_para_endpoint: ${runtime_para_endpoint}" + echo " seed: ${seed}" + echo " target_account: ${target_account}" + echo " amount: ${amount}" + echo "--------------------------------------------------" + + polkadot-js-api \ + --ws "${runtime_para_endpoint}" \ + --seed "${seed?}" \ + tx.balances.transfer \ + "${target_account}" \ + "${amount}" +} + +function send_governance_transact() { + local relay_url=$1 + local relay_chain_seed=$2 + local para_id=$3 + local hex_encoded_data=$4 + local require_weight_at_most_ref_time=$5 + local require_weight_at_most_proof_size=$6 + echo " calling send_governance_transact:" + echo " relay_url: ${relay_url}" + echo " relay_chain_seed: ${relay_chain_seed}" + echo " para_id: ${para_id}" + echo " hex_encoded_data: ${hex_encoded_data}" + echo " require_weight_at_most_ref_time: ${require_weight_at_most_ref_time}" + echo " require_weight_at_most_proof_size: ${require_weight_at_most_proof_size}" + echo " params:" + + local dest=$(jq --null-input \ + --arg para_id "$para_id" \ + '{ "V3": { "parents": 0, "interior": { "X1": { "Parachain": $para_id } } } }') + + local message=$(jq --null-input \ + --argjson hex_encoded_data $hex_encoded_data \ + --arg require_weight_at_most_ref_time "$require_weight_at_most_ref_time" \ + --arg require_weight_at_most_proof_size "$require_weight_at_most_proof_size" \ + ' + { + "V3": [ + { + "UnpaidExecution": { + "weight_limit": "Unlimited" + } + }, + { + "Transact": { + "origin_kind": "Superuser", + "require_weight_at_most": { + "ref_time": $require_weight_at_most_ref_time, + "proof_size": $require_weight_at_most_proof_size, + }, + "call": { + "encoded": $hex_encoded_data + } + } + } + ] + } + ') + + echo "" + echo " dest:" + echo "${dest}" + echo "" + echo " message:" + echo "${message}" + echo "" + echo "--------------------------------------------------" + + polkadot-js-api \ + --ws "${relay_url?}" \ + --seed "${relay_chain_seed?}" \ + --sudo \ + tx.xcmPallet.send \ + "${dest}" \ + "${message}" +} + +function allow_assets_transfer_send() { + local relay_url=$1 + local relay_chain_seed=$2 + local runtime_para_id=$3 + local runtime_para_endpoint=$4 + local bridge_hub_para_id=$5 + local bridged_para_network=$6 + local bridged_para_para_id=$7 + echo " calling allow_assets_transfer_send:" + echo " relay_url: ${relay_url}" + echo " relay_chain_seed: ${relay_chain_seed}" + echo " runtime_para_id: ${runtime_para_id}" + echo " runtime_para_endpoint: ${runtime_para_endpoint}" + echo " bridge_hub_para_id: ${bridge_hub_para_id}" + echo " bridged_para_network: ${bridged_para_network}" + echo " bridged_para_para_id: ${bridged_para_para_id}" + echo " params:" + + # 1. generate data for Transact (add_exporter_config) + local bridge_config=$(jq --null-input \ + --arg bridge_hub_para_id "$bridge_hub_para_id" \ + --arg bridged_para_network "$bridged_para_network" \ + --arg bridged_para_para_id "$bridged_para_para_id" \ + ' + { + "bridgeLocation": { + "parents": 1, + "interior": { + "X1": { "Parachain": $bridge_hub_para_id } + } + }, + "allowedTargetLocation": { + "parents": 2, + "interior": { + "X2": [ + { + "GlobalConsensus": $bridged_para_network, + }, + { + "Parachain": $bridged_para_para_id + } + ] + } + }, + "maxTargetLocationFee": { + "id": { + "Concrete": { + "parents": 1, + "interior": "Here" + } + }, + "fun": { + "Fungible": 50000000000 + } + } + } + ' + ) + local tmp_output_file=$(mktemp) + generate_hex_encoded_call_data "add-exporter-config" "${runtime_para_endpoint}" "${tmp_output_file}" $bridged_para_network "$bridge_config" + local hex_encoded_data=$(cat $tmp_output_file) + + send_governance_transact "${relay_url}" "${relay_chain_seed}" "${runtime_para_id}" "${hex_encoded_data}" 200000000 12000 +} + +function force_create_foreign_asset() { + local relay_url=$1 + local relay_chain_seed=$2 + local runtime_para_id=$3 + local runtime_para_endpoint=$4 + local global_consensus=$5 + local asset_owner_account_id=$6 + echo " calling force_create_foreign_asset:" + echo " relay_url: ${relay_url}" + echo " relay_chain_seed: ${relay_chain_seed}" + echo " runtime_para_id: ${runtime_para_id}" + echo " runtime_para_endpoint: ${runtime_para_endpoint}" + echo " global_consensus: ${global_consensus}" + echo " asset_owner_account_id: ${asset_owner_account_id}" + echo " params:" + + # 1. generate data for Transact (ForeignAssets::force_create) + local asset_id=$(jq --null-input \ + --arg global_consensus "$global_consensus" \ + ' + { + "parents": 2, + "interior": { + "X1": { + "GlobalConsensus": $global_consensus, + } + } + } + ' + ) + local tmp_output_file=$(mktemp) + generate_hex_encoded_call_data "force-create-asset" "${runtime_para_endpoint}" "${tmp_output_file}" "$asset_id" "$asset_owner_account_id" false "1000" + local hex_encoded_data=$(cat $tmp_output_file) + + send_governance_transact "${relay_url}" "${relay_chain_seed}" "${runtime_para_id}" "${hex_encoded_data}" 200000000 12000 +} + +function allow_assets_transfer_receive() { + local relay_url=$1 + local relay_chain_seed=$2 + local runtime_para_id=$3 + local runtime_para_endpoint=$4 + local bridge_hub_para_id=$5 + local bridged_network=$6 + local bridged_para_id=$7 + echo " calling allow_assets_transfer_receive:" + echo " relay_url: ${relay_url}" + echo " relay_chain_seed: ${relay_chain_seed}" + echo " runtime_para_id: ${runtime_para_id}" + echo " runtime_para_endpoint: ${runtime_para_endpoint}" + echo " bridge_hub_para_id: ${bridge_hub_para_id}" + echo " bridged_network: ${bridged_network}" + echo " bridged_para_id: ${bridged_para_id}" + echo " params:" + + # 1. generate data for Transact (add_universal_alias) + local location=$(jq --null-input \ + --arg bridge_hub_para_id "$bridge_hub_para_id" \ + '{ "V3": { "parents": 1, "interior": { "X1": { "Parachain": $bridge_hub_para_id } } } }') + + local junction=$(jq --null-input \ + --arg bridged_network "$bridged_network" \ + '{ "GlobalConsensus": $bridged_network } ') + + local tmp_output_file=$(mktemp) + generate_hex_encoded_call_data "add-universal-alias" "${runtime_para_endpoint}" "${tmp_output_file}" "$location" "$junction" + local hex_encoded_data=$(cat $tmp_output_file) + + send_governance_transact "${relay_url}" "${relay_chain_seed}" "${runtime_para_id}" "${hex_encoded_data}" 200000000 12000 + + # 2. generate data for Transact (add_reserve_location) + local reserve_location=$(jq --null-input \ + --arg bridged_network "$bridged_network" \ + --arg bridged_para_id "$bridged_para_id" \ + '{ "V3": { + "parents": 2, + "interior": { + "X2": [ + { + "GlobalConsensus": $bridged_network, + }, + { + "Parachain": $bridged_para_id + } + ] + } + } }') + + local tmp_output_file=$(mktemp) + generate_hex_encoded_call_data "add-reserve-location" "${runtime_para_endpoint}" "${tmp_output_file}" "$reserve_location" + local hex_encoded_data=$(cat $tmp_output_file) + + send_governance_transact "${relay_url}" "${relay_chain_seed}" "${runtime_para_id}" "${hex_encoded_data}" 200000000 12000 +} + +function remove_assets_transfer_send() { + local relay_url=$1 + local relay_chain_seed=$2 + local runtime_para_id=$3 + local runtime_para_endpoint=$4 + local bridged_network=$5 + echo " calling remove_assets_transfer_send:" + echo " relay_url: ${relay_url}" + echo " relay_chain_seed: ${relay_chain_seed}" + echo " runtime_para_id: ${runtime_para_id}" + echo " runtime_para_endpoint: ${runtime_para_endpoint}" + echo " bridged_network: ${bridged_network}" + echo " params:" + + local tmp_output_file=$(mktemp) + generate_hex_encoded_call_data "remove-exporter-config" "${runtime_para_endpoint}" "${tmp_output_file}" $bridged_network + local hex_encoded_data=$(cat $tmp_output_file) + + send_governance_transact "${relay_url}" "${relay_chain_seed}" "${runtime_para_id}" "${hex_encoded_data}" 200000000 12000 +} + +# TODO: we need to fill sovereign account for bridge-hub, because, small ammouts does not match ExistentialDeposit, so no reserve pass +# SA for BH: MultiLocation { parents: 1, interior: X1(Parachain(1013)) } - 5Eg2fntRRwLinojmk3sh5xscp7F3S6Zzm5oDVtoLTALKiypR on Kusama Asset Hub + +function transfer_asset_via_bridge() { + local url=$1 + local seed=$2 + local target_account=$3 + local target_global_consensus=$4 + echo " calling transfer_asset_via_bridge:" + echo " url: ${url}" + echo " seed: ${seed}" + echo " target_account: ${target_account}" + echo " target_global_consensus: ${target_global_consensus}" + echo " params:" + + local assets=$(jq --null-input \ + ' + { + "V3": [ + { + "id": { + "Concrete": { + "parents": 1, + "interior": "Here" + } + }, + "fun": { + "Fungible": 100000000 + } + } + ] + } + ' + ) + + local tmp_output_file=$(mktemp) + address_to_account_id_bytes "$target_account" "${tmp_output_file}" + local hex_encoded_data=$(cat $tmp_output_file) + + local destination=$(jq --null-input \ + --arg target_global_consensus "$target_global_consensus" \ + --argjson hex_encoded_data "$hex_encoded_data" \ + ' + { + "V3": { + "parents": 2, + "interior": { + "X3": [ + { + "GlobalConsensus": $target_global_consensus + }, + { + "Parachain": 1000 + }, + { + "AccountId32": { + "id": $hex_encoded_data + } + } + ] + } + } + } + ' + ) + + echo "" + echo " assets:" + echo "${assets}" + echo "" + echo " destination:" + echo "${destination}" + echo "" + echo "--------------------------------------------------" + + polkadot-js-api \ + --ws "${url?}" \ + --seed "${seed?}" \ + tx.bridgeTransfer.transferAssetViaBridge \ + "${assets}" \ + "${destination}" +} + +function ping_via_bridge() { + local url=$1 + local seed=$2 + local target_account=$3 + local target_global_consensus=$4 + echo " calling ping_via_bridge:" + echo " url: ${url}" + echo " seed: ${seed}" + echo " target_account: ${target_account}" + echo " target_global_consensus: ${target_global_consensus}" + echo " params:" + + local tmp_output_file=$(mktemp) + address_to_account_id_bytes "$target_account" "${tmp_output_file}" + local hex_encoded_data=$(cat $tmp_output_file) + + local destination=$(jq --null-input \ + --arg target_global_consensus "$target_global_consensus" \ + --argjson hex_encoded_data "$hex_encoded_data" \ + ' + { + "V3": { + "parents": 2, + "interior": { + "X3": [ + { + "GlobalConsensus": $target_global_consensus + }, + { + "Parachain": 1000 + }, + { + "AccountId32": { + "id": $hex_encoded_data + } + } + ] + } + } + } + ' + ) + + echo "" + echo " destination:" + echo "${destination}" + echo "" + echo "--------------------------------------------------" + + polkadot-js-api \ + --ws "${url?}" \ + --seed "${seed?}" \ + tx.bridgeTransfer.pingViaBridge \ + "${destination}" +} + +function init_ro_wo() { + ensure_relayer + + RUST_LOG=runtime=trace,rpc=trace,bridge=trace \ + ~/local_bridge_testing/bin/substrate-relay init-bridge rococo-to-bridge-hub-wococo \ + --source-host localhost \ + --source-port 9942 \ + --source-version-mode Auto \ + --target-host localhost \ + --target-port 8945 \ + --target-version-mode Auto \ + --target-signer //Bob +} + +function init_wo_ro() { + ensure_relayer + + RUST_LOG=runtime=trace,rpc=trace,bridge=trace \ + ~/local_bridge_testing/bin/substrate-relay init-bridge wococo-to-bridge-hub-rococo \ + --source-host localhost \ + --source-port 9945 \ + --source-version-mode Auto \ + --target-host localhost \ + --target-port 8943 \ + --target-version-mode Auto \ + --target-signer //Bob +} + +function run_relay() { + ensure_relayer + + RUST_LOG=runtime=trace,rpc=trace,bridge=trace \ + ~/local_bridge_testing/bin/substrate-relay relay-headers-and-messages bridge-hub-rococo-bridge-hub-wococo \ + --rococo-host localhost \ + --rococo-port 9942 \ + --rococo-version-mode Auto \ + --bridge-hub-rococo-host localhost \ + --bridge-hub-rococo-port 8943 \ + --bridge-hub-rococo-version-mode Auto \ + --bridge-hub-rococo-signer //Charlie \ + --wococo-headers-to-bridge-hub-rococo-signer //Bob \ + --wococo-parachains-to-bridge-hub-rococo-signer //Bob \ + --bridge-hub-rococo-transactions-mortality 4 \ + --wococo-host localhost \ + --wococo-port 9945 \ + --wococo-version-mode Auto \ + --bridge-hub-wococo-host localhost \ + --bridge-hub-wococo-port 8945 \ + --bridge-hub-wococo-version-mode Auto \ + --bridge-hub-wococo-signer //Charlie \ + --rococo-headers-to-bridge-hub-wococo-signer //Bob \ + --rococo-parachains-to-bridge-hub-wococo-signer //Bob \ + --bridge-hub-wococo-transactions-mortality 4 \ + --lane 00000001 +} + +case "$1" in + run-relay) + init_ro_wo + init_wo_ro + run_relay + ;; + allow-transfers-local) + # this allows send transfers on asset hub kusama local (by governance-like) + ./$0 "allow-transfer-on-asset-hub-kusama-local" + # this allows receive transfers on asset hub westend local (by governance-like) + ./$0 "allow-transfer-on-asset-hub-westend-local" + ;; + allow-transfer-on-asset-hub-kusama-local) + ensure_polkadot_js_api + allow_assets_transfer_send \ + "ws://127.0.0.1:9942" \ + "//Alice" \ + 1000 \ + "ws://127.0.0.1:9910" \ + 1013 \ + "Wococo" 1000 + ;; + allow-transfer-on-asset-hub-westend-local) + ensure_polkadot_js_api + allow_assets_transfer_receive \ + "ws://127.0.0.1:9945" \ + "//Alice" \ + 1000 \ + "ws://127.0.0.1:9010" \ + 1014 \ + "Rococo" \ + 1000 + transfer_balance \ + "ws://127.0.0.1:9010" \ + "//Alice" \ + "$ASSET_HUB_ROCOCO_1000_SOVEREIGN_ACCOUNT" \ + $((1000000000 + 50000000000 * 20)) # ExistentialDeposit + maxTargetLocationFee * 20 + # create foreign assets for native Kusama token (yes, Kusama, because we are using Kusama Asset Hub runtime on rococo) + force_create_foreign_asset \ + "ws://127.0.0.1:9945" \ + "//Alice" \ + 1000 \ + "ws://127.0.0.1:9010" \ + "Kusama" \ + "$ASSET_HUB_ROCOCO_1000_SOVEREIGN_ACCOUNT" + ;; + remove-assets-transfer-from-asset-hub-kusama-local) + ensure_polkadot_js_api + remove_assets_transfer_send \ + "ws://127.0.0.1:9942" \ + "//Alice" \ + 1000 \ + "ws://127.0.0.1:9910" \ + "Wococo" + ;; + transfer-asset-from-asset-hub-kusama-local) + ensure_polkadot_js_api + transfer_asset_via_bridge \ + "ws://127.0.0.1:9910" \ + "$ASSET_HUB_KUSAMA_ACCOUNT_SEED_FOR_LOCAL" \ + "$ASSET_HUB_WOCOCO_ACCOUNT_SEED_FOR_LOCAL" \ + "Wococo" + ;; + ping-via-bridge-from-asset-hub-kusama-local) + ensure_polkadot_js_api + ping_via_bridge \ + "ws://127.0.0.1:9910" \ + "$ASSET_HUB_KUSAMA_ACCOUNT_SEED_FOR_LOCAL" \ + "$ASSET_HUB_WOCOCO_ACCOUNT_SEED_FOR_LOCAL" \ + "Wococo" + ;; + transfer-asset-from-asset-hub-rococo) + ensure_polkadot_js_api + transfer_asset_via_bridge \ + "wss://ws-rococo-rockmine2-collator-node-0.parity-testnet.parity.io" \ + "$ASSET_HUB2_ROCOCO_1000_SOVEREIGN_ACCOUNT" \ + "$ASSET_HUB_WOCOCO_ACCOUNT_ADDRESS_FOR_ROCOCO" \ + "Wococo" + ;; + ping-via-bridge-from-asset-hub-rococo) + ensure_polkadot_js_api + ping_via_bridge \ + "wss://ws-rococo-rockmine2-collator-node-0.parity-testnet.parity.io" \ + "${ASSET_HUB2_ROCOCO_1000_SOVEREIGN_ACCOUNT}" \ + "$ASSET_HUB_WOCOCO_ACCOUNT_ADDRESS_FOR_ROCOCO" \ + "Wococo" + ;; + drip) + transfer_balance \ + "ws://127.0.0.1:9010" \ + "//Alice" \ + "$ASSET_HUB_ROCOCO_1000_SOVEREIGN_ACCOUNT" \ + $((1000000000 + 50000000000 * 20)) + ;; + stop) + pkill -f polkadot + pkill -f parachain + ;; + import) + # to avoid trigger anything here + ;; + *) + echo "A command is require. Supported commands for: + Local (zombienet) run: + - run-relay + - allow-transfers-local + - allow-transfer-on-asset-hub-kusama-local + - allow-transfer-on-asset-hub-westend-local + - remove-assets-transfer-from-asset-hub-kusama-local + - transfer-asset-from-asset-hub-kusama-local + - ping-via-bridge-from-asset-hub-kusama-local + Live Rococo/Wococo run: + - transfer-asset-from-asset-hub-rococo + - ping-via-bridge-from-asset-hub-rococo"; + exit 1 + ;; +esac diff --git a/scripts/bridges_update_subtree.sh b/scripts/bridges_update_subtree.sh new file mode 100755 index 00000000000..3928dc23213 --- /dev/null +++ b/scripts/bridges_update_subtree.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +# A script to udpate bridges repo as subtree to Cumulus +# Usage: +# ./scripts/bridges_update_subtree.sh fetch +# ./scripts/bridges_update_subtree.sh patch +# ./scripts/bridges_update_subtree.sh merge + +set -e + +BRIDGES_BRANCH="${BRANCH:-master}" +BRIDGES_TARGET_DIR="${TARGET_DIR:-bridges}" + +function fetch() { + # the script is able to work only on clean git copy + [[ -z "$(git status --porcelain)" ]] || { + echo >&2 "The git copy must be clean (stash all your changes):"; + git status --porcelain + exit 1; + } + + local bridges_remote=$(git remote -v | grep "parity-bridges-common.git (fetch)" | head -n1 | awk '{print $1;}') + if [ -z "$bridges_remote" ]; then + echo "" + echo "Adding new remote: 'bridges' repo..." + echo "" + echo "... check your YubiKey ..." + git remote add -f bridges git@github.com:paritytech/parity-bridges-common.git + bridges_remote="bridges" + else + echo "" + echo "Fetching remote: '${bridges_remote}' repo..." + echo "" + echo "... check your YubiKey ..." + git fetch ${bridges_remote} --prune + fi + + echo "" + echo "Syncing/updating subtree with remote branch '${bridges_remote}/$BRIDGES_BRANCH' to target directory: '$BRIDGES_TARGET_DIR'" + echo "" + echo "... check your YubiKey ..." + git subtree pull --prefix=$BRIDGES_TARGET_DIR ${bridges_remote} $BRIDGES_BRANCH --squash +} + +function patch() { + echo "" + echo "Patching/removing unneeded stuff from subtree in target directory: '$BRIDGES_TARGET_DIR'" + $BRIDGES_TARGET_DIR/scripts/verify-pallets-build.sh --ignore-git-state --no-revert +} + +function merge() { + echo "" + echo "Merging stuff from subtree in target directory: '$BRIDGES_TARGET_DIR'" + + # stage all removed by patch: DU, MD, D, AD - only from subtree directory + git status -s | awk '$1 == "DU" || $1 == "D" || $1 == "MD" || $1 == "AD" {print $2}' | grep "^$BRIDGES_TARGET_DIR/" | xargs git rm -q --ignore-unmatch + + echo "" + echo "When all conflicts are resolved, do 'git merge --continue'" +} + +function amend() { + echo "" + echo "Amend stuff from subtree in target directory: '$BRIDGES_TARGET_DIR'" + git commit --amend -S -m "updating bridges subtree + remove extra folders" +} + +case "$1" in + fetch) + fetch + ;; + patch) + patch + ;; + merge) + merge + ;; + amend) + amend + ;; + all) + fetch + patch + ;; +esac diff --git a/scripts/ci/gitlab/pipeline/benchmarks.yml b/scripts/ci/gitlab/pipeline/benchmarks.yml index d1fdd64c341..011e750a735 100644 --- a/scripts/ci/gitlab/pipeline/benchmarks.yml +++ b/scripts/ci/gitlab/pipeline/benchmarks.yml @@ -22,13 +22,13 @@ benchmarks-assets: before_script: - !reference [.docker-env, before_script] script: - - ./scripts/benchmarks-ci.sh assets statemine ./artifacts - - ./scripts/benchmarks-ci.sh assets statemint ./artifacts - - ./scripts/benchmarks-ci.sh assets westmint ./artifacts + - ./scripts/benchmarks-ci.sh assets asset-hub-kusama ./artifacts + - ./scripts/benchmarks-ci.sh assets asset-hub-polkadot ./artifacts + - ./scripts/benchmarks-ci.sh assets asset-hub-westend ./artifacts - export CURRENT_TIME=$(date '+%s') - - export BRANCHNAME="weights-statemint-${CI_COMMIT_BRANCH}-${CURRENT_TIME}" + - export BRANCHNAME="weights-asset-hub-polkadot-${CI_COMMIT_BRANCH}-${CURRENT_TIME}" - !reference [.git-commit-push, script] - - ./scripts/ci/create-benchmark-pr.sh "[benchmarks] Update weights for statemine/t" "$BRANCHNAME" + - ./scripts/ci/create-benchmark-pr.sh "[benchmarks] Update weights for asset-hub-kusama/t" "$BRANCHNAME" - rm -f ./artifacts/polkadot-parachain - rm -f ./artifacts/test-parachain after_script: diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index 0ef51ae2e6d..a67c15eec6b 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -97,3 +97,11 @@ cargo-check-benches: artifacts: false script: - time cargo check --all --benches + +cargo-clippy: + stage: test + extends: + - .docker-env + - .common-refs + script: + - SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo clippy --locked --all-targets diff --git a/scripts/ci/gitlab/pipeline/zombienet.yml b/scripts/ci/gitlab/pipeline/zombienet.yml index d76531b19e7..d5ab3e13d42 100644 --- a/scripts/ci/gitlab/pipeline/zombienet.yml +++ b/scripts/ci/gitlab/pipeline/zombienet.yml @@ -35,7 +35,7 @@ expire_in: 2 days paths: - ./zombienet-logs - allow_failure: true + allow_failure: false retry: 2 tags: - zombienet-polkadot-integration-test diff --git a/scripts/create_glutton_spec.sh b/scripts/create_glutton_spec.sh new file mode 100755 index 00000000000..571a84b57a0 --- /dev/null +++ b/scripts/create_glutton_spec.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# Example usage to: +# +# - Use the `polkadot-parachain` binary; +# - Use `rococo` as the parent Relay Chain; +# - Generate `ParaId`s from 1,300 to 1,370, inclusive; +# - Set the Sudo key to `G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR`; +# - Set `compute`, `storage`, and `trash_data_count` set to 50%, 50%, and 5,120, respectively; +# - And save the results in `output-dir`. +# +# ./scripts/create_glutton_spec.sh ./target/release/polkadot-parachain rococo 1300 1370 G7Z5mTmTQsjEGBVqVGDZyR9m7RoHNZJk6JeykyfKQ3vmBiR 500000000 500000000 5120 output-dir + +usage() { + echo Usage: + echo "$0 " + exit 1 +} + +set -e + +if ! command -v jq >/dev/null 2>&1; then + echo "'jq' is not installed, please install. Exiting..." + exit 1 +fi + +binary_path=$1 +relay_chain=$2 +from_para_id=$3 +to_para_id=$4 +sudo=$5 +compute=$6 +storage=$7 +trash_data_count=$8 +output_dir=$9 + +[ -z "$binary_path" ] && usage +[ -z "$relay_chain" ] && usage +[ -z "$from_para_id" ] && usage +[ -z "$to_para_id" ] && usage +[ -z "$sudo" ] && usage +[ -z "$compute" ] && usage +[ -z "$storage" ] && usage +[ -z "$trash_data_count" ] && usage +[ -z "$output_dir" ] && usage + + +for (( para_id=$from_para_id; para_id<=$to_para_id; para_id++ )); do + echo "Building chain specs for parachain $para_id" + + # create dir to store parachain generated files + output_para_dir="$output_dir/glutton-$relay_chain-$para_id" + if [ ! -d "$output_para_dir" ]; then + mkdir $output_para_dir + fi + + # build the chain spec we'll manipulate + $binary_path build-spec --disable-default-bootnode --chain "glutton-kusama-genesis-$para_id" > "$output_para_dir/plain-glutton-$relay_chain-$para_id-spec.json" + + id="glutton-$relay_chain-$para_id" + protocol_id="glutton-$relay_chain-$para_id" + + # replace the runtime in the spec with the given runtime and set some values to production + cat "$output_para_dir/plain-glutton-$relay_chain-$para_id-spec.json" \ + | jq --arg id $id '.id = $id' \ + | jq --arg protocol_id $protocol_id '.protocolId = $protocol_id' \ + | jq --arg relay_chain $relay_chain '.relay_chain = $relay_chain' \ + | jq --argjson para_id $para_id '.para_id = $para_id' \ + | jq --arg sudo $sudo '.genesis.runtime.sudo.key = $sudo' \ + | jq --argjson para_id $para_id '.genesis.runtime.parachainInfo.parachainId = $para_id' \ + | jq --argjson compute $compute '.genesis.runtime.glutton.compute = $compute' \ + | jq --argjson storage $storage '.genesis.runtime.glutton.storage = $storage' \ + | jq --argjson trash_data_count $trash_data_count '.genesis.runtime.glutton.trashDataCount = $trash_data_count' \ + > $output_para_dir/glutton-$relay_chain-$para_id-spec.json + + # build a raw spec + $binary_path build-spec --disable-default-bootnode --chain "$output_para_dir/glutton-$relay_chain-$para_id-spec.json" --raw > "$output_para_dir/glutton-$relay_chain-$para_id-raw-spec.json" + + # build genesis data + $binary_path export-genesis-state --chain "$output_para_dir/glutton-$relay_chain-$para_id-raw-spec.json" > "$output_para_dir/glutton-$relay_chain-$para_id-head-data" + + # build genesis wasm + $binary_path export-genesis-wasm --chain "$output_para_dir/glutton-$relay_chain-$para_id-raw-spec.json" > "$output_para_dir/glutton-$relay_chain-$para_id-validation-code" + + rm "$output_para_dir/plain-glutton-$relay_chain-$para_id-spec.json" +done diff --git a/scripts/generate_genesis_value.sh b/scripts/generate_genesis_value.sh index 07e9fca59d7..178e15fb8a9 100755 --- a/scripts/generate_genesis_value.sh +++ b/scripts/generate_genesis_value.sh @@ -58,7 +58,7 @@ if [[ "$rpc_endpoint" =~ "localhost" ]]; then check_collator echo -e "Make sure you have a collator running with the correct version at $rpc_endpoint." echo -e "If you don't, NOW is the time to start it with:" - echo -e "target/release/polkadot-parachain --chain parachains/chain-specs/shell-statemint.json --tmp\n" + echo -e "target/release/polkadot-parachain --chain parachains/chain-specs/shell.json --tmp\n" read -p "You can abort with CTRL+C if this is not correct, otherwise press ENTER " fi diff --git a/scripts/generate_hex_encoded_call/index.js b/scripts/generate_hex_encoded_call/index.js new file mode 100644 index 00000000000..25e094df905 --- /dev/null +++ b/scripts/generate_hex_encoded_call/index.js @@ -0,0 +1,148 @@ +const fs = require("fs"); +const { exit } = require("process"); +const { WsProvider, ApiPromise } = require("@polkadot/api"); +const util = require("@polkadot/util"); + +// connect to a substrate chain and return the api object +async function connect(endpoint, types = {}) { + const provider = new WsProvider(endpoint); + const api = await ApiPromise.create({ + provider, + types, + throwOnConnect: false, + }); + return api; +} + +function writeHexEncodedBytesToOutput(method, outputFile) { + console.log("Payload (hex): ", method.toHex()); + console.log("Payload (bytes): ", Array.from(method.toU8a())); + console.log("Payload (plain): ", JSON.stringify(method)); + fs.writeFileSync(outputFile, JSON.stringify(Array.from(method.toU8a()))); +} + +function remarkWithEvent(endpoint, outputFile) { + console.log(`Generating remarkWithEvent from RPC endpoint: ${endpoint} to outputFile: ${outputFile}`); + connect(endpoint) + .then((api) => { + const call = api.tx.system.remarkWithEvent("Hello"); + writeHexEncodedBytesToOutput(call.method, outputFile); + exit(0); + }) + .catch((e) => { + console.error(e); + exit(1); + }); +} + +function addExporterConfig(endpoint, outputFile, bridgedNetwork, bridgeConfig) { + console.log(`Generating addExporterConfig from RPC endpoint: ${endpoint} to outputFile: ${outputFile} based on bridgedNetwork: ${bridgedNetwork}, bridgeConfig: ${bridgeConfig}`); + connect(endpoint) + .then((api) => { + const call = api.tx.bridgeTransfer.addExporterConfig(bridgedNetwork, JSON.parse(bridgeConfig)); + writeHexEncodedBytesToOutput(call.method, outputFile); + exit(0); + }) + .catch((e) => { + console.error(e); + exit(1); + }); +} + +function addUniversalAlias(endpoint, outputFile, location, junction) { + console.log(`Generating addUniversalAlias from RPC endpoint: ${endpoint} to outputFile: ${outputFile} based on location: ${location}, junction: ${junction}`); + connect(endpoint) + .then((api) => { + const call = api.tx.bridgeTransfer.addUniversalAlias(JSON.parse(location), JSON.parse(junction)); + writeHexEncodedBytesToOutput(call.method, outputFile); + exit(0); + }) + .catch((e) => { + console.error(e); + exit(1); + }); +} + +function addReserveLocation(endpoint, outputFile, reserve_location) { + console.log(`Generating addReserveLocation from RPC endpoint: ${endpoint} to outputFile: ${outputFile} based on reserve_location: ${reserve_location}`); + connect(endpoint) + .then((api) => { + const call = api.tx.bridgeTransfer.addReserveLocation(JSON.parse(reserve_location)); + writeHexEncodedBytesToOutput(call.method, outputFile); + exit(0); + }) + .catch((e) => { + console.error(e); + exit(1); + }); +} + +function removeExporterConfig(endpoint, outputFile, bridgedNetwork) { + console.log(`Generating removeExporterConfig from RPC endpoint: ${endpoint} to outputFile: ${outputFile} based on bridgedNetwork: ${bridgedNetwork}`); + connect(endpoint) + .then((api) => { + const call = api.tx.bridgeTransfer.removeExporterConfig(bridgedNetwork); + writeHexEncodedBytesToOutput(call.method, outputFile); + exit(0); + }) + .catch((e) => { + console.error(e); + exit(1); + }); +} + +function forceCreateAsset(endpoint, outputFile, assetId, assetOwnerAccountId, isSufficient, minBalance) { + var isSufficient = isSufficient == "true" ? true : false; + console.log(`Generating forceCreateAsset from RPC endpoint: ${endpoint} to outputFile: ${outputFile} based on assetId: ${assetId}, assetOwnerAccountId: ${assetOwnerAccountId}, isSufficient: ${isSufficient}, minBalance: ${minBalance}`); + connect(endpoint) + .then((api) => { + const call = api.tx.foreignAssets.forceCreate(JSON.parse(assetId), assetOwnerAccountId, isSufficient, minBalance); + writeHexEncodedBytesToOutput(call.method, outputFile); + exit(0); + }) + .catch((e) => { + console.error(e); + exit(1); + }); +} + +if (!process.argv[2] || !process.argv[3]) { + console.log("usage: node ./script/generate_hex_encoded_call "); + exit(1); +} + +const type = process.argv[2]; +const rpcEnpoint = process.argv[3]; +const output = process.argv[4]; +const inputArgs = process.argv.slice(5, process.argv.length); +console.log(`Generating hex-encoded call data for:`); +console.log(` type: ${type}`); +console.log(` rpcEnpoint: ${rpcEnpoint}`); +console.log(` output: ${output}`); +console.log(` inputArgs: ${inputArgs}`); + +switch (type) { + case 'remark-with-event': + remarkWithEvent(rpcEnpoint, output); + break; + case 'add-exporter-config': + addExporterConfig(rpcEnpoint, output, inputArgs[0], inputArgs[1]); + break; + case 'remove-exporter-config': + removeExporterConfig(rpcEnpoint, output, inputArgs[0], inputArgs[1]); + break; + case 'add-universal-alias': + addUniversalAlias(rpcEnpoint, output, inputArgs[0], inputArgs[1]); + break; + case 'add-reserve-location': + addReserveLocation(rpcEnpoint, output, inputArgs[0]); + break; + case 'force-create-asset': + forceCreateAsset(rpcEnpoint, output, inputArgs[0], inputArgs[1], inputArgs[2], inputArgs[3]); + break; + case 'check': + console.log(`Checking nodejs installation, if you see this everything is ready!`); + break; + default: + console.log(`Sorry, we are out of ${type} - not yet supported!`); +} diff --git a/scripts/generate_hex_encoded_call/package-lock.json b/scripts/generate_hex_encoded_call/package-lock.json new file mode 100644 index 00000000000..3383265e779 --- /dev/null +++ b/scripts/generate_hex_encoded_call/package-lock.json @@ -0,0 +1,1213 @@ +{ + "name": "y", + "version": "y", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "y", + "version": "y", + "license": "MIT", + "dependencies": { + "@polkadot/api": "^6.5.2", + "@polkadot/util": "^7.6.1" + } + }, + "node_modules/@babel/runtime": { + "version": "7.20.13", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.13.tgz", + "integrity": "sha512-gt3PKXs0DBoL9xCvOIIZ2NEqAGZqHjAnmVbfQtB620V0uReIQutpel14KcneZuer7UioY8ALKZ7iocavvzTNFA==", + "dependencies": { + "regenerator-runtime": "^0.13.11" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@noble/hashes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.0.0.tgz", + "integrity": "sha512-DZVbtY62kc3kkBtMHqwCOfXrT/hnoORy5BJ4+HU1IR59X0KWAOqsfzQPcUl/lQLlG7qXbe/fZ3r/emxtAl+sqg==" + }, + "node_modules/@noble/secp256k1": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.5.5.tgz", + "integrity": "sha512-sZ1W6gQzYnu45wPrWx8D3kwI2/U29VYTx9OjbDAd7jwRItJ0cSTMPRL/C8AWZFn9kWFLQGqEXVEE86w4Z8LpIQ==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ] + }, + "node_modules/@polkadot/api": { + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/@polkadot/api/-/api-6.12.1.tgz", + "integrity": "sha512-RVdTiA2WaEvproM3i6E9TKS1bfXpPd9Ly9lUG/kVLaspjKoIot9DJUDTl97TJ+7xr8LXGbXqm448Ud0hsEBV8Q==", + "dependencies": { + "@babel/runtime": "^7.16.3", + "@polkadot/api-derive": "6.12.1", + "@polkadot/keyring": "^8.1.2", + "@polkadot/rpc-core": "6.12.1", + "@polkadot/rpc-provider": "6.12.1", + "@polkadot/types": "6.12.1", + "@polkadot/types-known": "6.12.1", + "@polkadot/util": "^8.1.2", + "@polkadot/util-crypto": "^8.1.2", + "eventemitter3": "^4.0.7", + "rxjs": "^7.4.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/api-derive": { + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/@polkadot/api-derive/-/api-derive-6.12.1.tgz", + "integrity": "sha512-5LOVlG5EBCT+ytY6aHmQ4RdEWZovZQqRoc6DLd5BLhkR7BFTHKSkLQW+89so8jd0zEtmSXBVPPnsrXS8joM35Q==", + "dependencies": { + "@babel/runtime": "^7.16.3", + "@polkadot/api": "6.12.1", + "@polkadot/rpc-core": "6.12.1", + "@polkadot/types": "6.12.1", + "@polkadot/util": "^8.1.2", + "@polkadot/util-crypto": "^8.1.2", + "rxjs": "^7.4.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/api-derive/node_modules/@polkadot/util": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-8.7.1.tgz", + "integrity": "sha512-XjY1bTo7V6OvOCe4yn8H2vifeuBciCy0gq0k5P1tlGUQLI/Yt0hvDmxcA0FEPtqg8CL+rYRG7WXGPVNjkrNvyQ==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-bigint": "8.7.1", + "@polkadot/x-global": "8.7.1", + "@polkadot/x-textdecoder": "8.7.1", + "@polkadot/x-textencoder": "8.7.1", + "@types/bn.js": "^5.1.0", + "bn.js": "^5.2.0", + "ip-regex": "^4.3.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/api-derive/node_modules/@polkadot/x-textdecoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-8.7.1.tgz", + "integrity": "sha512-ia0Ie2zi4VdQdNVD2GE2FZzBMfX//hEL4w546RMJfZM2LqDS674LofHmcyrsv5zscLnnRyCxZC1+J2dt+6MDIA==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/api-derive/node_modules/@polkadot/x-textencoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-8.7.1.tgz", + "integrity": "sha512-XDO0A27Xy+eJCKSxENroB8Dcnl+UclGG4ZBei+P/BqZ9rsjskUyd2Vsl6peMXAcsxwOE7g0uTvujoGM8jpKOXw==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/api-derive/node_modules/@types/bn.js": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", + "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@polkadot/api-derive/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@polkadot/api/node_modules/@polkadot/util": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-8.7.1.tgz", + "integrity": "sha512-XjY1bTo7V6OvOCe4yn8H2vifeuBciCy0gq0k5P1tlGUQLI/Yt0hvDmxcA0FEPtqg8CL+rYRG7WXGPVNjkrNvyQ==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-bigint": "8.7.1", + "@polkadot/x-global": "8.7.1", + "@polkadot/x-textdecoder": "8.7.1", + "@polkadot/x-textencoder": "8.7.1", + "@types/bn.js": "^5.1.0", + "bn.js": "^5.2.0", + "ip-regex": "^4.3.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/api/node_modules/@polkadot/x-textdecoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-8.7.1.tgz", + "integrity": "sha512-ia0Ie2zi4VdQdNVD2GE2FZzBMfX//hEL4w546RMJfZM2LqDS674LofHmcyrsv5zscLnnRyCxZC1+J2dt+6MDIA==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/api/node_modules/@polkadot/x-textencoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-8.7.1.tgz", + "integrity": "sha512-XDO0A27Xy+eJCKSxENroB8Dcnl+UclGG4ZBei+P/BqZ9rsjskUyd2Vsl6peMXAcsxwOE7g0uTvujoGM8jpKOXw==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/api/node_modules/@types/bn.js": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", + "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@polkadot/api/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@polkadot/keyring": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/keyring/-/keyring-8.7.1.tgz", + "integrity": "sha512-t6ZgQVC+nQT7XwbWtEhkDpiAzxKVJw8Xd/gWdww6xIrawHu7jo3SGB4QNdPgkf8TvDHYAAJiupzVQYAlOIq3GA==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/util": "8.7.1", + "@polkadot/util-crypto": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "@polkadot/util": "8.7.1", + "@polkadot/util-crypto": "8.7.1" + } + }, + "node_modules/@polkadot/keyring/node_modules/@polkadot/util": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-8.7.1.tgz", + "integrity": "sha512-XjY1bTo7V6OvOCe4yn8H2vifeuBciCy0gq0k5P1tlGUQLI/Yt0hvDmxcA0FEPtqg8CL+rYRG7WXGPVNjkrNvyQ==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-bigint": "8.7.1", + "@polkadot/x-global": "8.7.1", + "@polkadot/x-textdecoder": "8.7.1", + "@polkadot/x-textencoder": "8.7.1", + "@types/bn.js": "^5.1.0", + "bn.js": "^5.2.0", + "ip-regex": "^4.3.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/keyring/node_modules/@polkadot/x-textdecoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-8.7.1.tgz", + "integrity": "sha512-ia0Ie2zi4VdQdNVD2GE2FZzBMfX//hEL4w546RMJfZM2LqDS674LofHmcyrsv5zscLnnRyCxZC1+J2dt+6MDIA==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/keyring/node_modules/@polkadot/x-textencoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-8.7.1.tgz", + "integrity": "sha512-XDO0A27Xy+eJCKSxENroB8Dcnl+UclGG4ZBei+P/BqZ9rsjskUyd2Vsl6peMXAcsxwOE7g0uTvujoGM8jpKOXw==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/keyring/node_modules/@types/bn.js": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", + "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@polkadot/keyring/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@polkadot/networks": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/networks/-/networks-8.7.1.tgz", + "integrity": "sha512-8xAmhDW0ry5EKcEjp6VTuwoTm0DdDo/zHsmx88P6sVL87gupuFsL+B6TrsYLl8GcaqxujwrOlKB+CKTUg7qFKg==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/util": "8.7.1", + "@substrate/ss58-registry": "^1.17.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/networks/node_modules/@polkadot/util": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-8.7.1.tgz", + "integrity": "sha512-XjY1bTo7V6OvOCe4yn8H2vifeuBciCy0gq0k5P1tlGUQLI/Yt0hvDmxcA0FEPtqg8CL+rYRG7WXGPVNjkrNvyQ==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-bigint": "8.7.1", + "@polkadot/x-global": "8.7.1", + "@polkadot/x-textdecoder": "8.7.1", + "@polkadot/x-textencoder": "8.7.1", + "@types/bn.js": "^5.1.0", + "bn.js": "^5.2.0", + "ip-regex": "^4.3.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/networks/node_modules/@polkadot/x-textdecoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-8.7.1.tgz", + "integrity": "sha512-ia0Ie2zi4VdQdNVD2GE2FZzBMfX//hEL4w546RMJfZM2LqDS674LofHmcyrsv5zscLnnRyCxZC1+J2dt+6MDIA==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/networks/node_modules/@polkadot/x-textencoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-8.7.1.tgz", + "integrity": "sha512-XDO0A27Xy+eJCKSxENroB8Dcnl+UclGG4ZBei+P/BqZ9rsjskUyd2Vsl6peMXAcsxwOE7g0uTvujoGM8jpKOXw==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/networks/node_modules/@types/bn.js": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", + "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@polkadot/networks/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@polkadot/rpc-core": { + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/@polkadot/rpc-core/-/rpc-core-6.12.1.tgz", + "integrity": "sha512-Hb08D9zho3SB1UNlUCmG5q0gdgbOx25JKGLDfSYpD/wtD0Y1Sf2X5cfgtMoSYE3USWiRdCu4BxQkXTiRjPjzJg==", + "dependencies": { + "@babel/runtime": "^7.16.3", + "@polkadot/rpc-provider": "6.12.1", + "@polkadot/types": "6.12.1", + "@polkadot/util": "^8.1.2", + "rxjs": "^7.4.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/rpc-core/node_modules/@polkadot/util": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-8.7.1.tgz", + "integrity": "sha512-XjY1bTo7V6OvOCe4yn8H2vifeuBciCy0gq0k5P1tlGUQLI/Yt0hvDmxcA0FEPtqg8CL+rYRG7WXGPVNjkrNvyQ==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-bigint": "8.7.1", + "@polkadot/x-global": "8.7.1", + "@polkadot/x-textdecoder": "8.7.1", + "@polkadot/x-textencoder": "8.7.1", + "@types/bn.js": "^5.1.0", + "bn.js": "^5.2.0", + "ip-regex": "^4.3.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/rpc-core/node_modules/@polkadot/x-textdecoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-8.7.1.tgz", + "integrity": "sha512-ia0Ie2zi4VdQdNVD2GE2FZzBMfX//hEL4w546RMJfZM2LqDS674LofHmcyrsv5zscLnnRyCxZC1+J2dt+6MDIA==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/rpc-core/node_modules/@polkadot/x-textencoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-8.7.1.tgz", + "integrity": "sha512-XDO0A27Xy+eJCKSxENroB8Dcnl+UclGG4ZBei+P/BqZ9rsjskUyd2Vsl6peMXAcsxwOE7g0uTvujoGM8jpKOXw==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/rpc-core/node_modules/@types/bn.js": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", + "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@polkadot/rpc-core/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@polkadot/rpc-provider": { + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/@polkadot/rpc-provider/-/rpc-provider-6.12.1.tgz", + "integrity": "sha512-uUHD3fLTOeZYWJoc6DQlhz+MJR33rVelasV+OxFY2nSD9MSNXRwQh+9UKDQBnyxw5B4BZ2QaEGfucDeavXmVDw==", + "dependencies": { + "@babel/runtime": "^7.16.3", + "@polkadot/types": "6.12.1", + "@polkadot/util": "^8.1.2", + "@polkadot/util-crypto": "^8.1.2", + "@polkadot/x-fetch": "^8.1.2", + "@polkadot/x-global": "^8.1.2", + "@polkadot/x-ws": "^8.1.2", + "eventemitter3": "^4.0.7" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/rpc-provider/node_modules/@polkadot/util": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-8.7.1.tgz", + "integrity": "sha512-XjY1bTo7V6OvOCe4yn8H2vifeuBciCy0gq0k5P1tlGUQLI/Yt0hvDmxcA0FEPtqg8CL+rYRG7WXGPVNjkrNvyQ==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-bigint": "8.7.1", + "@polkadot/x-global": "8.7.1", + "@polkadot/x-textdecoder": "8.7.1", + "@polkadot/x-textencoder": "8.7.1", + "@types/bn.js": "^5.1.0", + "bn.js": "^5.2.0", + "ip-regex": "^4.3.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/rpc-provider/node_modules/@polkadot/x-textdecoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-8.7.1.tgz", + "integrity": "sha512-ia0Ie2zi4VdQdNVD2GE2FZzBMfX//hEL4w546RMJfZM2LqDS674LofHmcyrsv5zscLnnRyCxZC1+J2dt+6MDIA==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/rpc-provider/node_modules/@polkadot/x-textencoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-8.7.1.tgz", + "integrity": "sha512-XDO0A27Xy+eJCKSxENroB8Dcnl+UclGG4ZBei+P/BqZ9rsjskUyd2Vsl6peMXAcsxwOE7g0uTvujoGM8jpKOXw==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/rpc-provider/node_modules/@types/bn.js": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", + "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@polkadot/rpc-provider/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@polkadot/types": { + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/@polkadot/types/-/types-6.12.1.tgz", + "integrity": "sha512-O37cAGUL0xiXTuO3ySweVh0OuFUD6asrd0TfuzGsEp3jAISWdElEHV5QDiftWq8J9Vf8BMgTcP2QLFbmSusxqA==", + "dependencies": { + "@babel/runtime": "^7.16.3", + "@polkadot/types-known": "6.12.1", + "@polkadot/util": "^8.1.2", + "@polkadot/util-crypto": "^8.1.2", + "rxjs": "^7.4.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/types-known": { + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/@polkadot/types-known/-/types-known-6.12.1.tgz", + "integrity": "sha512-Z8bHpPQy+mqUm0uR1tai6ra0bQIoPmgRcGFYUM+rJtW1kx/6kZLh10HAICjLpPeA1cwLRzaxHRDqH5MCU6OgXw==", + "dependencies": { + "@babel/runtime": "^7.16.3", + "@polkadot/networks": "^8.1.2", + "@polkadot/types": "6.12.1", + "@polkadot/util": "^8.1.2" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/types-known/node_modules/@polkadot/util": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-8.7.1.tgz", + "integrity": "sha512-XjY1bTo7V6OvOCe4yn8H2vifeuBciCy0gq0k5P1tlGUQLI/Yt0hvDmxcA0FEPtqg8CL+rYRG7WXGPVNjkrNvyQ==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-bigint": "8.7.1", + "@polkadot/x-global": "8.7.1", + "@polkadot/x-textdecoder": "8.7.1", + "@polkadot/x-textencoder": "8.7.1", + "@types/bn.js": "^5.1.0", + "bn.js": "^5.2.0", + "ip-regex": "^4.3.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/types-known/node_modules/@polkadot/x-textdecoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-8.7.1.tgz", + "integrity": "sha512-ia0Ie2zi4VdQdNVD2GE2FZzBMfX//hEL4w546RMJfZM2LqDS674LofHmcyrsv5zscLnnRyCxZC1+J2dt+6MDIA==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/types-known/node_modules/@polkadot/x-textencoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-8.7.1.tgz", + "integrity": "sha512-XDO0A27Xy+eJCKSxENroB8Dcnl+UclGG4ZBei+P/BqZ9rsjskUyd2Vsl6peMXAcsxwOE7g0uTvujoGM8jpKOXw==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/types-known/node_modules/@types/bn.js": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", + "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@polkadot/types-known/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@polkadot/types/node_modules/@polkadot/util": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-8.7.1.tgz", + "integrity": "sha512-XjY1bTo7V6OvOCe4yn8H2vifeuBciCy0gq0k5P1tlGUQLI/Yt0hvDmxcA0FEPtqg8CL+rYRG7WXGPVNjkrNvyQ==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-bigint": "8.7.1", + "@polkadot/x-global": "8.7.1", + "@polkadot/x-textdecoder": "8.7.1", + "@polkadot/x-textencoder": "8.7.1", + "@types/bn.js": "^5.1.0", + "bn.js": "^5.2.0", + "ip-regex": "^4.3.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/types/node_modules/@polkadot/x-textdecoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-8.7.1.tgz", + "integrity": "sha512-ia0Ie2zi4VdQdNVD2GE2FZzBMfX//hEL4w546RMJfZM2LqDS674LofHmcyrsv5zscLnnRyCxZC1+J2dt+6MDIA==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/types/node_modules/@polkadot/x-textencoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-8.7.1.tgz", + "integrity": "sha512-XDO0A27Xy+eJCKSxENroB8Dcnl+UclGG4ZBei+P/BqZ9rsjskUyd2Vsl6peMXAcsxwOE7g0uTvujoGM8jpKOXw==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/types/node_modules/@types/bn.js": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", + "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@polkadot/types/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@polkadot/util": { + "version": "7.9.2", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-7.9.2.tgz", + "integrity": "sha512-6ABY6ErgkCsM4C6+X+AJSY4pBGwbKlHZmUtHftaiTvbaj4XuA4nTo3GU28jw8wY0Jh2cJZJvt6/BJ5GVkm5tBA==", + "dependencies": { + "@babel/runtime": "^7.16.3", + "@polkadot/x-textdecoder": "7.9.2", + "@polkadot/x-textencoder": "7.9.2", + "@types/bn.js": "^4.11.6", + "bn.js": "^4.12.0", + "camelcase": "^6.2.1", + "ip-regex": "^4.3.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/util-crypto": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-8.7.1.tgz", + "integrity": "sha512-TaSuJ2aNrB5sYK7YXszkEv24nYJKRFqjF2OrggoMg6uYxUAECvTkldFnhtgeizMweRMxJIBu6bMHlSIutbWgjw==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@noble/hashes": "1.0.0", + "@noble/secp256k1": "1.5.5", + "@polkadot/networks": "8.7.1", + "@polkadot/util": "8.7.1", + "@polkadot/wasm-crypto": "^5.1.1", + "@polkadot/x-bigint": "8.7.1", + "@polkadot/x-randomvalues": "8.7.1", + "@scure/base": "1.0.0", + "ed2curve": "^0.3.0", + "tweetnacl": "^1.0.3" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "@polkadot/util": "8.7.1" + } + }, + "node_modules/@polkadot/util-crypto/node_modules/@polkadot/util": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/util/-/util-8.7.1.tgz", + "integrity": "sha512-XjY1bTo7V6OvOCe4yn8H2vifeuBciCy0gq0k5P1tlGUQLI/Yt0hvDmxcA0FEPtqg8CL+rYRG7WXGPVNjkrNvyQ==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-bigint": "8.7.1", + "@polkadot/x-global": "8.7.1", + "@polkadot/x-textdecoder": "8.7.1", + "@polkadot/x-textencoder": "8.7.1", + "@types/bn.js": "^5.1.0", + "bn.js": "^5.2.0", + "ip-regex": "^4.3.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/util-crypto/node_modules/@polkadot/x-textdecoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-8.7.1.tgz", + "integrity": "sha512-ia0Ie2zi4VdQdNVD2GE2FZzBMfX//hEL4w546RMJfZM2LqDS674LofHmcyrsv5zscLnnRyCxZC1+J2dt+6MDIA==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/util-crypto/node_modules/@polkadot/x-textencoder": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-8.7.1.tgz", + "integrity": "sha512-XDO0A27Xy+eJCKSxENroB8Dcnl+UclGG4ZBei+P/BqZ9rsjskUyd2Vsl6peMXAcsxwOE7g0uTvujoGM8jpKOXw==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/util-crypto/node_modules/@types/bn.js": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", + "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@polkadot/util-crypto/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@polkadot/wasm-crypto": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@polkadot/wasm-crypto/-/wasm-crypto-5.1.1.tgz", + "integrity": "sha512-JCcAVfH8DhYuEyd4oX1ouByxhou0TvpErKn8kHjtzt7+tRoFi0nzWlmK4z49vszsV3JJgXxV81i10C0BYlwTcQ==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/wasm-crypto-asmjs": "^5.1.1", + "@polkadot/wasm-crypto-wasm": "^5.1.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "@polkadot/util": "*", + "@polkadot/x-randomvalues": "*" + } + }, + "node_modules/@polkadot/wasm-crypto-asmjs": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@polkadot/wasm-crypto-asmjs/-/wasm-crypto-asmjs-5.1.1.tgz", + "integrity": "sha512-1WBwc2G3pZMKW1T01uXzKE30Sg22MXmF3RbbZiWWk3H2d/Er4jZQRpjumxO5YGWan+xOb7HQQdwnrUnrPgbDhg==", + "dependencies": { + "@babel/runtime": "^7.17.8" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "@polkadot/util": "*" + } + }, + "node_modules/@polkadot/wasm-crypto-wasm": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@polkadot/wasm-crypto-wasm/-/wasm-crypto-wasm-5.1.1.tgz", + "integrity": "sha512-F9PZ30J2S8vUNl2oY7Myow5Xsx5z5uNVpnNlJwlmY8IXBvyucvyQ4HSdhJsrbs4W1BfFc0mHghxgp0FbBCnf/Q==", + "dependencies": { + "@babel/runtime": "^7.17.8" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "@polkadot/util": "*" + } + }, + "node_modules/@polkadot/x-bigint": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-bigint/-/x-bigint-8.7.1.tgz", + "integrity": "sha512-ClkhgdB/KqcAKk3zA6Qw8wBL6Wz67pYTPkrAtImpvoPJmR+l4RARauv+MH34JXMUNlNb3aUwqN6lq2Z1zN+mJg==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/x-fetch": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-fetch/-/x-fetch-8.7.1.tgz", + "integrity": "sha512-ygNparcalYFGbspXtdtZOHvNXZBkNgmNO+um9C0JYq74K5OY9/be93uyfJKJ8JcRJtOqBfVDsJpbiRkuJ1PRfg==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1", + "@types/node-fetch": "^2.6.1", + "node-fetch": "^2.6.7" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/x-global": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-global/-/x-global-8.7.1.tgz", + "integrity": "sha512-WOgUor16IihgNVdiTVGAWksYLUAlqjmODmIK1cuWrLOZtV1VBomWcb3obkO9sh5P6iWziAvCB/i+L0vnTN9ZCA==", + "dependencies": { + "@babel/runtime": "^7.17.8" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/x-randomvalues": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-randomvalues/-/x-randomvalues-8.7.1.tgz", + "integrity": "sha512-njt17MlfN6yNyNEti7fL12lr5qM6A1aSGkWKVuqzc7XwSBesifJuW4km5u6r2gwhXjH2eHDv9SoQ7WXu8vrrkg==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/x-textdecoder": { + "version": "7.9.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-7.9.2.tgz", + "integrity": "sha512-wfwbSHXPhrOAl12QvlIOGNkMH/N/h8PId2ytIjvM/8zPPFB5Il6DWSFLtVapOGEpIFjEWbd5t8Td4pHBVXIEbg==", + "dependencies": { + "@babel/runtime": "^7.16.3", + "@polkadot/x-global": "7.9.2" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/x-textdecoder/node_modules/@polkadot/x-global": { + "version": "7.9.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-global/-/x-global-7.9.2.tgz", + "integrity": "sha512-JX5CrGWckHf1P9xKXq4vQCAuMUbL81l2hOWX7xeP8nv4caHEpmf5T1wD1iMdQBL5PFifo6Pg0V6/oZBB+bts7A==", + "dependencies": { + "@babel/runtime": "^7.16.3" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/x-textencoder": { + "version": "7.9.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-7.9.2.tgz", + "integrity": "sha512-A19wwYINuZwU2dUyQ/mMzB0ISjyfc4cISfL4zCMUAVgj7xVoXMYV2GfjNdMpA8Wsjch3su6pxLbtJ2wU03sRTQ==", + "dependencies": { + "@babel/runtime": "^7.16.3", + "@polkadot/x-global": "7.9.2" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/x-textencoder/node_modules/@polkadot/x-global": { + "version": "7.9.2", + "resolved": "https://registry.npmjs.org/@polkadot/x-global/-/x-global-7.9.2.tgz", + "integrity": "sha512-JX5CrGWckHf1P9xKXq4vQCAuMUbL81l2hOWX7xeP8nv4caHEpmf5T1wD1iMdQBL5PFifo6Pg0V6/oZBB+bts7A==", + "dependencies": { + "@babel/runtime": "^7.16.3" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@polkadot/x-ws": { + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/@polkadot/x-ws/-/x-ws-8.7.1.tgz", + "integrity": "sha512-Mt0tcNzGXyKnN3DQ06alkv+JLtTfXWu6zSypFrrKHSQe3u79xMQ1nSicmpT3gWLhIa8YF+8CYJXMrqaXgCnDhw==", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@polkadot/x-global": "8.7.1", + "@types/websocket": "^1.0.5", + "websocket": "^1.0.34" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@scure/base": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.0.0.tgz", + "integrity": "sha512-gIVaYhUsy+9s58m/ETjSJVKHhKTBMmcRb9cEV5/5dwvfDlfORjKrFsDeDHWRrm6RjcPvCLZFwGJjAjLj1gg4HA==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ] + }, + "node_modules/@substrate/ss58-registry": { + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/@substrate/ss58-registry/-/ss58-registry-1.38.0.tgz", + "integrity": "sha512-sHiVRWekGMRZAjPukN9/W166NM6D5wtHcK6RVyLy66kg3CHNZ1BXfpXcjOiXSwhbd7guQFDEwnOVaDrbk1XL1g==" + }, + "node_modules/@types/bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "18.11.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", + "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==" + }, + "node_modules/@types/node-fetch": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.2.tgz", + "integrity": "sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==", + "dependencies": { + "@types/node": "*", + "form-data": "^3.0.0" + } + }, + "node_modules/@types/websocket": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/websocket/-/websocket-1.0.5.tgz", + "integrity": "sha512-NbsqiNX9CnEfC1Z0Vf4mE1SgAJ07JnRYcNex7AJ9zAVzmiGHmjKFEk7O4TJIsgv2B1sLEb6owKFZrACwdYngsQ==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, + "node_modules/bufferutil": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", + "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", + "hasInstallScript": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/d": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "dependencies": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ed2curve": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/ed2curve/-/ed2curve-0.3.0.tgz", + "integrity": "sha512-8w2fmmq3hv9rCrcI7g9hms2pMunQr1JINfcjwR9tAyZqhtyaMN991lF/ZfHfr5tzZQ8c7y7aBgZbjfbd0fjFwQ==", + "dependencies": { + "tweetnacl": "1.x.x" + } + }, + "node_modules/es5-ext": { + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", + "hasInstallScript": true, + "dependencies": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", + "dependencies": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "node_modules/es6-symbol": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "dependencies": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "node_modules/eventemitter3": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", + "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==" + }, + "node_modules/ext": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", + "dependencies": { + "type": "^2.7.2" + } + }, + "node_modules/ext/node_modules/type": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==" + }, + "node_modules/form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/ip-regex": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-4.3.0.tgz", + "integrity": "sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/next-tick": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, + "node_modules/node-fetch": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-gyp-build": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz", + "integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==", + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" + }, + "node_modules/rxjs": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.0.tgz", + "integrity": "sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" + }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" + }, + "node_modules/type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, + "node_modules/typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dependencies": { + "is-typedarray": "^1.0.0" + } + }, + "node_modules/utf-8-validate": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", + "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", + "hasInstallScript": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/websocket": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz", + "integrity": "sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==", + "dependencies": { + "bufferutil": "^4.0.1", + "debug": "^2.2.0", + "es5-ext": "^0.10.50", + "typedarray-to-buffer": "^3.1.5", + "utf-8-validate": "^5.0.2", + "yaeti": "^0.0.6" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/yaeti": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", + "integrity": "sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug==", + "engines": { + "node": ">=0.10.32" + } + } + } +} diff --git a/scripts/generate_hex_encoded_call/package.json b/scripts/generate_hex_encoded_call/package.json new file mode 100644 index 00000000000..1c68924db24 --- /dev/null +++ b/scripts/generate_hex_encoded_call/package.json @@ -0,0 +1,11 @@ +{ + "name": "y", + "version": "y", + "description": "create a scale hex-encoded call values from given message", + "main": "index.js", + "license": "MIT", + "dependencies": { + "@polkadot/api": "^6.5.2", + "@polkadot/util": "^7.6.1" + } +} diff --git a/scripts/parachains_integration_tests.sh b/scripts/parachains_integration_tests.sh index ed920f430fc..2a06b930e22 100755 --- a/scripts/parachains_integration_tests.sh +++ b/scripts/parachains_integration_tests.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash tests=( - statemine - statemint + asset-hub-kusama + asset-hub-polkadot ) rm -R logs &> /dev/null diff --git a/test/client/src/block_builder.rs b/test/client/src/block_builder.rs index 13b20df6be6..0c0c5c4e9c7 100644 --- a/test/client/src/block_builder.rs +++ b/test/client/src/block_builder.rs @@ -64,13 +64,13 @@ pub trait InitBlockBuilder { ) -> sc_block_builder::BlockBuilder; } -fn init_block_builder<'a>( - client: &'a Client, +fn init_block_builder( + client: &Client, at: Hash, validation_data: Option>, relay_sproof_builder: RelayStateSproofBuilder, timestamp: u64, -) -> BlockBuilder<'a, Block, Client, Backend> { +) -> BlockBuilder<'_, Block, Client, Backend> { let mut block_builder = client .new_block_at(at, Default::default(), true) .expect("Creates new block builder for test runtime"); diff --git a/test/client/src/lib.rs b/test/client/src/lib.rs index 4008dca350d..cbf0459b816 100644 --- a/test/client/src/lib.rs +++ b/test/client/src/lib.rs @@ -183,7 +183,7 @@ pub fn validate_block( let heap_pages = HeapAllocStrategy::Static { extra_pages: 1024 }; let executor = WasmExecutor::::builder() - .with_execution_method(WasmExecutionMethod::Interpreted) + .with_execution_method(WasmExecutionMethod::default()) .with_max_runtime_instances(1) .with_runtime_cache_size(2) .with_onchain_heap_alloc_strategy(heap_pages) @@ -199,5 +199,4 @@ pub fn validate_block( &validation_params.encode(), ) .map(|v| ValidationResult::decode(&mut &v[..]).expect("Decode `ValidationResult`.")) - .map_err(|err| err.into()) } diff --git a/test/relay-sproof-builder/src/lib.rs b/test/relay-sproof-builder/src/lib.rs index decc6ee3aa0..fd98899ed3b 100644 --- a/test/relay-sproof-builder/src/lib.rs +++ b/test/relay-sproof-builder/src/lib.rs @@ -38,7 +38,7 @@ pub struct RelayStateSproofBuilder { pub host_config: AbridgedHostConfiguration, pub dmq_mqc_head: Option, pub upgrade_go_ahead: Option, - pub relay_dispatch_queue_size: Option<(u32, u32)>, + pub relay_dispatch_queue_remaining_capacity: Option<(u32, u32)>, pub hrmp_ingress_channel_index: Option>, pub hrmp_egress_channel_index: Option>, pub hrmp_channels: BTreeMap, @@ -65,7 +65,7 @@ impl Default for RelayStateSproofBuilder { }, dmq_mqc_head: None, upgrade_go_ahead: None, - relay_dispatch_queue_size: None, + relay_dispatch_queue_remaining_capacity: None, hrmp_ingress_channel_index: None, hrmp_egress_channel_index: None, hrmp_channels: BTreeMap::new(), @@ -124,9 +124,12 @@ impl RelayStateSproofBuilder { dmq_mqc_head.encode(), ); } - if let Some(relay_dispatch_queue_size) = self.relay_dispatch_queue_size { + if let Some(relay_dispatch_queue_size) = self.relay_dispatch_queue_remaining_capacity { insert( - relay_chain::well_known_keys::relay_dispatch_queue_size(self.para_id), + relay_chain::well_known_keys::relay_dispatch_queue_remaining_capacity( + self.para_id, + ) + .key, relay_dispatch_queue_size.encode(), ); } @@ -171,7 +174,7 @@ impl RelayStateSproofBuilder { } } - let root = backend.root().clone(); + let root = *backend.root(); let proof = sp_state_machine::prove_read(backend, relevant_keys).expect("prove read"); (root, proof) } diff --git a/test/relay-validation-worker-provider/Cargo.toml b/test/relay-validation-worker-provider/Cargo.toml index e8cc1f16b9f..ea4587b2c7c 100644 --- a/test/relay-validation-worker-provider/Cargo.toml +++ b/test/relay-validation-worker-provider/Cargo.toml @@ -8,7 +8,7 @@ build = "build.rs" [dependencies] # Polkadot -polkadot-node-core-pvf-worker = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-node-core-pvf = { git = "https://github.com/paritytech/polkadot", branch = "master" } [build-dependencies] -toml = "0.7.3" +toml = "0.7.4" diff --git a/test/relay-validation-worker-provider/build.rs b/test/relay-validation-worker-provider/build.rs index d2c894ac89d..9b5247bcbe5 100644 --- a/test/relay-validation-worker-provider/build.rs +++ b/test/relay-validation-worker-provider/build.rs @@ -97,7 +97,7 @@ fn create_project(out_dir: &Path) -> PathBuf { fs::write( project_dir.join("src").join("main.rs"), r#" - cumulus_test_relay_validation_worker_provider::polkadot_node_core_pvf_worker::decl_puppet_worker_main!(); + cumulus_test_relay_validation_worker_provider::polkadot_node_core_pvf::decl_puppet_worker_main!(); "#, ) .expect("Writes `main.rs`"); diff --git a/test/relay-validation-worker-provider/src/lib.rs b/test/relay-validation-worker-provider/src/lib.rs index ccb896a276e..840214eb3c0 100644 --- a/test/relay-validation-worker-provider/src/lib.rs +++ b/test/relay-validation-worker-provider/src/lib.rs @@ -21,7 +21,7 @@ //! //! !!This should only be used for tests!! -pub use polkadot_node_core_pvf_worker; +pub use polkadot_node_core_pvf; /// The path to the validation worker. pub const VALIDATION_WORKER: &str = concat!(env!("OUT_DIR"), "/validation-worker"); diff --git a/test/runtime/Cargo.toml b/test/runtime/Cargo.toml index 5115b1cc6aa..dc4492b64dc 100644 --- a/test/runtime/Cargo.toml +++ b/test/runtime/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } # Substrate frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } diff --git a/test/runtime/src/lib.rs b/test/runtime/src/lib.rs index ed9725bf8d0..da17ce93c37 100644 --- a/test/runtime/src/lib.rs +++ b/test/runtime/src/lib.rs @@ -244,7 +244,7 @@ impl pallet_balances::Config for Runtime { type MaxLocks = (); type MaxReserves = MaxReserves; type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); + type RuntimeHoldReason = RuntimeHoldReason; type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; type MaxFreezes = ConstU32<0>; @@ -262,6 +262,7 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_sudo::weights::SubstrateWeight; } impl cumulus_pallet_parachain_system::Config for Runtime { diff --git a/test/service/Cargo.toml b/test/service/Cargo.toml index f04632b3c20..b0141ec96cc 100644 --- a/test/service/Cargo.toml +++ b/test/service/Cargo.toml @@ -10,13 +10,13 @@ path = "src/main.rs" [dependencies] async-trait = "0.1.68" -clap = { version = "4.2.3", features = ["derive"] } +clap = { version = "4.3.1", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0" } -criterion = { version = "0.4.0", features = [ "async_tokio" ] } +criterion = { version = "0.5.1", features = [ "async_tokio" ] } jsonrpsee = { version = "0.16.2", features = ["server"] } rand = "0.8.5" -serde = { version = "1.0.160", features = ["derive"] } -tokio = { version = "1.27.0", features = ["macros"] } +serde = { version = "1.0.163", features = ["derive"] } +tokio = { version = "1.28.2", features = ["macros"] } tracing = "0.1.37" url = "2.3.1" diff --git a/test/service/benches/transaction_throughput.rs b/test/service/benches/transaction_throughput.rs index 1c3f841fe23..48bf49487e6 100644 --- a/test/service/benches/transaction_throughput.rs +++ b/test/service/benches/transaction_throughput.rs @@ -46,7 +46,7 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec accounts .iter() .enumerate() - .map(|(i, a)| { + .flat_map(|(i, a)| { vec![ // Reset the nonce by removing any funds construct_extrinsic( @@ -54,7 +54,7 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec SudoCall::sudo { call: Box::new( BalancesCall::force_set_balance { - who: AccountId::from(a.public()).into(), + who: AccountId::from(a.public()), new_free: 0, } .into(), @@ -69,7 +69,7 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec SudoCall::sudo { call: Box::new( BalancesCall::force_set_balance { - who: AccountId::from(a.public()).into(), + who: AccountId::from(a.public()), new_free: 1_000_000_000_000 * ExistentialDeposit::get(), } .into(), @@ -80,7 +80,6 @@ fn create_account_extrinsics(client: &Client, accounts: &[sr25519::Pair]) -> Vec ), ] }) - .flatten() .map(OpaqueExtrinsic::from) .collect() } @@ -92,20 +91,19 @@ fn create_benchmark_extrinsics( ) -> Vec { accounts .iter() - .map(|account| { + .flat_map(|account| { (0..extrinsics_per_account).map(move |nonce| { construct_extrinsic( client, BalancesCall::transfer_allow_death { - dest: Bob.to_account_id().into(), - value: 1 * ExistentialDeposit::get(), + dest: Bob.to_account_id(), + value: ExistentialDeposit::get(), }, account.clone(), Some(nonce as u32), ) }) }) - .flatten() .map(OpaqueExtrinsic::from) .collect() } @@ -208,27 +206,27 @@ fn transaction_throughput_benchmarks(c: &mut Criterion) { |b| { b.iter_batched( || { - let prepare_extrinsics = create_account_extrinsics(&*dave.client, &accounts); + let prepare_extrinsics = create_account_extrinsics(&dave.client, &accounts); benchmark_handle.block_on(future::join_all( prepare_extrinsics.into_iter().map(|tx| { submit_tx_and_wait_for_inclusion( &dave.transaction_pool, tx, - &*dave.client, + &dave.client, true, ) }), )); - create_benchmark_extrinsics(&*dave.client, &accounts, extrinsics_per_account) + create_benchmark_extrinsics(&dave.client, &accounts, extrinsics_per_account) }, |extrinsics| { benchmark_handle.block_on(future::join_all(extrinsics.into_iter().map(|tx| { submit_tx_and_wait_for_inclusion( &dave.transaction_pool, tx, - &*dave.client, + &dave.client, false, ) }))); diff --git a/test/service/src/chain_spec.rs b/test/service/src/chain_spec.rs index e1399e97a36..5ae77084b6c 100644 --- a/test/service/src/chain_spec.rs +++ b/test/service/src/chain_spec.rs @@ -39,7 +39,7 @@ pub struct GenesisExt { impl sp_runtime::BuildStorage for GenesisExt { fn assimilate_storage(&self, storage: &mut sp_core::storage::Storage) -> Result<(), String> { sp_state_machine::BasicExternalities::execute_with_storage(storage, || { - sp_io::storage::set(cumulus_test_runtime::TEST_RUNTIME_UPGRADE_KEY, &vec![1, 2, 3, 4]); + sp_io::storage::set(cumulus_test_runtime::TEST_RUNTIME_UPGRADE_KEY, &[1, 2, 3, 4]); cumulus_test_runtime::ParachainId::set(&self.para_id); }); @@ -125,7 +125,6 @@ fn testnet_genesis( code: cumulus_test_runtime::WASM_BINARY .expect("WASM binary was not build, please build it!") .to_vec(), - ..Default::default() }, parachain_system: Default::default(), balances: cumulus_test_runtime::BalancesConfig { diff --git a/test/service/src/cli.rs b/test/service/src/cli.rs index 3cf99496576..0b7084e1abd 100644 --- a/test/service/src/cli.rs +++ b/test/service/src/cli.rs @@ -117,8 +117,12 @@ impl RelayChainCli { para_config: &sc_service::Configuration, relay_chain_args: impl Iterator, ) -> Self { - let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot")); - Self { base_path, chain_id: None, base: clap::Parser::parse_from(relay_chain_args) } + let base_path = para_config.base_path.path().join("polkadot"); + Self { + base_path: Some(base_path), + chain_id: None, + base: clap::Parser::parse_from(relay_chain_args), + } } } @@ -146,16 +150,8 @@ impl CliConfiguration for RelayChainCli { .or_else(|| self.base_path.clone().map(Into::into))) } - fn rpc_http(&self, default_listen_port: u16) -> CliResult> { - self.base.base.rpc_http(default_listen_port) - } - - fn rpc_ipc(&self) -> CliResult> { - self.base.base.rpc_ipc() - } - - fn rpc_ws(&self, default_listen_port: u16) -> CliResult> { - self.base.base.rpc_ws(default_listen_port) + fn rpc_addr(&self, default_listen_port: u16) -> CliResult> { + self.base.base.rpc_addr(default_listen_port) } fn prometheus_config( @@ -204,8 +200,8 @@ impl CliConfiguration for RelayChainCli { self.base.base.rpc_methods() } - fn rpc_ws_max_connections(&self) -> CliResult> { - self.base.base.rpc_ws_max_connections() + fn rpc_max_connections(&self) -> CliResult { + self.base.base.rpc_max_connections() } fn rpc_cors(&self, is_dev: bool) -> CliResult>> { @@ -249,14 +245,10 @@ impl DefaultConfigurationValues for RelayChainCli { 30334 } - fn rpc_ws_listen_port() -> u16 { + fn rpc_listen_port() -> u16 { 9945 } - fn rpc_http_listen_port() -> u16 { - 9934 - } - fn prometheus_listen_port() -> u16 { 9616 } diff --git a/test/service/src/lib.rs b/test/service/src/lib.rs index 84d5636f9b1..c97339f7fe9 100644 --- a/test/service/src/lib.rs +++ b/test/service/src/lib.rs @@ -54,7 +54,8 @@ use polkadot_service::ProvideRuntimeApi; use sc_client_api::execution_extensions::ExecutionStrategies; use sc_consensus::ImportQueue; use sc_network::{ - config::TransportConfig, multiaddr, NetworkBlock, NetworkService, NetworkStateInfo, + config::{FullNetworkConfiguration, TransportConfig}, + multiaddr, NetworkBlock, NetworkService, NetworkStateInfo, }; use sc_service::{ config::{ @@ -323,9 +324,12 @@ where .map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?; let import_queue_service = params.import_queue.service(); + let net_config = FullNetworkConfiguration::new(¶chain_config.network); + let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = build_network(BuildNetworkParams { parachain_config: ¶chain_config, + net_config, client: client.clone(), transaction_pool: transaction_pool.clone(), para_id, @@ -630,7 +634,7 @@ impl TestNodeBuilder { let parachain_config = node_config( self.storage_update_func_parachain.unwrap_or_else(|| Box::new(|| ())), self.tokio_handle.clone(), - self.key.clone(), + self.key, self.parachain_nodes, self.parachain_nodes_exclusive, self.para_id, @@ -667,7 +671,7 @@ impl TestNodeBuilder { .await .expect("could not create Cumulus test service"); - let peer_id = network.local_peer_id().clone(); + let peer_id = network.local_peer_id(); let addr = MultiaddrWithPeerId { multiaddr, peer_id }; TestNode { task_manager, client, network, addr, rpc_handlers, transaction_pool } @@ -690,7 +694,7 @@ pub fn node_config( is_collator: bool, ) -> Result { let base_path = BasePath::new_temp_dir()?; - let root = base_path.path().join(format!("cumulus_test_service_{}", key.to_string())); + let root = base_path.path().join(format!("cumulus_test_service_{}", key)); let role = if is_collator { Role::Authority } else { Role::Full }; let key_seed = key.to_seed(); let mut spec = Box::new(chain_spec::get_chain_spec(para_id)); @@ -736,7 +740,7 @@ pub fn node_config( state_pruning: Some(PruningMode::ArchiveAll), blocks_pruning: BlocksPruning::KeepAll, chain_spec: spec, - wasm_method: WasmExecutionMethod::Interpreted, + wasm_method: WasmExecutionMethod::default(), // NOTE: we enforce the use of the native runtime to make the errors more debuggable execution_strategies: ExecutionStrategies { syncing: sc_client_api::ExecutionStrategy::NativeWhenPossible, @@ -745,18 +749,15 @@ pub fn node_config( offchain_worker: sc_client_api::ExecutionStrategy::NativeWhenPossible, other: sc_client_api::ExecutionStrategy::NativeWhenPossible, }, - rpc_http: None, - rpc_ws: None, - rpc_ipc: None, - rpc_ws_max_connections: None, + rpc_addr: None, + rpc_max_connections: Default::default(), rpc_cors: None, rpc_methods: Default::default(), - rpc_max_payload: None, - rpc_max_request_size: None, - rpc_max_response_size: None, + rpc_max_request_size: Default::default(), + rpc_max_response_size: Default::default(), rpc_id_provider: None, - rpc_max_subs_per_conn: None, - ws_max_out_buffer_capacity: None, + rpc_max_subs_per_conn: Default::default(), + rpc_port: 9945, prometheus_config: None, telemetry_endpoints: None, default_heap_pages: None, @@ -768,7 +769,8 @@ pub fn node_config( tracing_receiver: Default::default(), max_runtime_instances: 8, announce_block: true, - base_path: Some(base_path), + data_path: root, + base_path, informant_output_format: Default::default(), wasm_runtime_overrides: None, runtime_cache_size: 2, @@ -789,7 +791,7 @@ impl TestNode { function: impl Into, caller: Sr25519Keyring, ) -> Result { - let extrinsic = construct_extrinsic(&*self.client, function, caller.pair(), Some(0)); + let extrinsic = construct_extrinsic(&self.client, function, caller.pair(), Some(0)); self.rpc_handlers.send_transaction(extrinsic.into()).await } @@ -871,7 +873,7 @@ pub fn run_relay_chain_validator_node( key: Sr25519Keyring, storage_update_func: impl Fn(), boot_nodes: Vec, - websocket_port: Option, + port: Option, ) -> polkadot_test_service::PolkadotTestNode { let mut config = polkadot_test_service::node_config( storage_update_func, @@ -881,8 +883,8 @@ pub fn run_relay_chain_validator_node( true, ); - if let Some(port) = websocket_port { - config.rpc_ws = Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), port)); + if let Some(port) = port { + config.rpc_addr = Some(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), port)); } polkadot_test_service::run_validator_node( diff --git a/xcm/xcm-emulator/Cargo.toml b/xcm/xcm-emulator/Cargo.toml new file mode 100644 index 00000000000..e7cf3adac19 --- /dev/null +++ b/xcm/xcm-emulator/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "xcm-emulator" +description = "Test kit to emulate XCM program execution." +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0" } +paste = "1.0.5" +quote = "1.0.28" +casey = "0.4.0" +log = { version = "0.4.18", default-features = false } + +frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" } +pallet-message-queue = { git = "https://github.com/paritytech/substrate", branch = "master" } + +cumulus-primitives-core = { path = "../../primitives/core"} +cumulus-pallet-xcmp-queue = { path = "../../pallets/xcmp-queue" } +cumulus-pallet-parachain-system = { path = "../../pallets/parachain-system" } +cumulus-test-service = { path = "../../test/service" } +parachain-info = { path = "../../parachains/pallets/parachain-info" } +cumulus-primitives-parachain-inherent = { path = "../../primitives/parachain-inherent" } +cumulus-test-relay-sproof-builder = { path = "../../test/relay-sproof-builder" } +parachains-common = { path = "../../parachains/common" } + +xcm = { git = "https://github.com/paritytech/polkadot", branch = "master" } +xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } +polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "master" } diff --git a/xcm/xcm-emulator/README.md b/xcm/xcm-emulator/README.md new file mode 100644 index 00000000000..d188c99eecf --- /dev/null +++ b/xcm/xcm-emulator/README.md @@ -0,0 +1,23 @@ +# xcm-emulator + +XCM-Emulator is a tool to emulate XCM program execution using +pre-configured runtimes, including those used to run on live +networks, such as Kusama, Polkadot, Asset Hubs, et cetera. +This allows for testing cross-chain message passing and verifying +outcomes, weights, and side-effects. It is faster than spinning up +a zombienet and as all the chains are in one process debugging using Clion is easy. + +## Limitations + +As the messages do not physically go through the same messaging infrastructure +there is some code that is not being tested compared to using slower E2E tests. +In future it may be possible to run these XCM emulated tests as E2E tests (without changes). + +As well as the XCM message transport being mocked out, so too are areas around consensus, +in particular things like disputes, staking and iamonline events can't be tested. + +## Alternatives + +If you just wish to test execution of various XCM instructions +against the XCM VM then the `xcm-simulator` (in the polkadot +repo) is the perfect tool for this. diff --git a/xcm/xcm-emulator/src/lib.rs b/xcm/xcm-emulator/src/lib.rs new file mode 100644 index 00000000000..655ec3f929c --- /dev/null +++ b/xcm/xcm-emulator/src/lib.rs @@ -0,0 +1,956 @@ +// Copyright 2023 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . + +pub use casey::pascal; +pub use codec::Encode; +pub use cumulus_pallet_parachain_system; +pub use cumulus_pallet_xcmp_queue; +pub use cumulus_primitives_core::{ + self, relay_chain::BlockNumber as RelayBlockNumber, + AggregateMessageOrigin as CumulusAggregateMessageOrigin, ParaId, PersistedValidationData, + XcmpMessageHandler, +}; +pub use cumulus_primitives_parachain_inherent::ParachainInherentData; +pub use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; +pub use cumulus_test_service::get_account_id_from_seed; +pub use frame_support::{ + sp_runtime::BuildStorage, + traits::{EnqueueMessage, Get, Hooks, ProcessMessage, ProcessMessageError, ServiceQueues}, + weights::{Weight, WeightMeter}, + BoundedSlice, +}; +pub use frame_system::AccountInfo; +pub use log; +pub use pallet_balances::AccountData; +pub use pallet_message_queue; +pub use parachain_info; +pub use parachains_common::{AccountId, BlockNumber}; +pub use paste; +pub use sp_arithmetic::traits::Bounded; +pub use sp_core::storage::Storage; +pub use sp_io; +pub use sp_std::{cell::RefCell, collections::vec_deque::VecDeque, marker::PhantomData}; +pub use sp_trie::StorageProof; + +pub use polkadot_primitives; +pub use polkadot_runtime_parachains::{ + dmp, + inclusion::{AggregateMessageOrigin, UmpQueueId}, +}; +pub use std::{collections::HashMap, thread::LocalKey}; +pub use xcm::{v3::prelude::*, VersionedXcm}; +pub use xcm_executor::XcmExecutor; + +thread_local! { + /// Downward messages, each message is: `(to_para_id, [(relay_block_number, msg)])` + #[allow(clippy::type_complexity)] + pub static DOWNWARD_MESSAGES: RefCell)>)>>> + = RefCell::new(HashMap::new()); + /// Downward messages that already processed by parachains, each message is: `(to_para_id, relay_block_number, Vec)` + #[allow(clippy::type_complexity)] + pub static DMP_DONE: RefCell)>>> + = RefCell::new(HashMap::new()); + /// Horizontal messages, each message is: `(to_para_id, [(from_para_id, relay_block_number, msg)])` + #[allow(clippy::type_complexity)] + pub static HORIZONTAL_MESSAGES: RefCell)>)>>> + = RefCell::new(HashMap::new()); + /// Upward messages, each message is: `(from_para_id, msg) + pub static UPWARD_MESSAGES: RefCell)>>> = RefCell::new(HashMap::new()); + /// Global incremental relay chain block number + pub static RELAY_BLOCK_NUMBER: RefCell> = RefCell::new(HashMap::new()); + /// Parachains Ids a the Network + pub static PARA_IDS: RefCell>> = RefCell::new(HashMap::new()); + /// Flag indicating if global variables have been initialized for a certain Network + pub static INITIALIZED: RefCell> = RefCell::new(HashMap::new()); +} + +pub trait TestExt { + fn build_new_ext(storage: Storage) -> sp_io::TestExternalities; + fn new_ext() -> sp_io::TestExternalities; + fn reset_ext(); + fn execute_with(execute: impl FnOnce() -> R) -> R; + fn ext_wrapper(func: impl FnOnce() -> R) -> R; +} + +pub trait Network { + fn _init(); + fn _para_ids() -> Vec; + fn _relay_block_number() -> u32; + fn _set_relay_block_number(block_number: u32); + fn _process_messages(); + fn _has_unprocessed_messages() -> bool; + fn _process_downward_messages(); + fn _process_horizontal_messages(); + fn _process_upward_messages(); + fn _hrmp_channel_parachain_inherent_data( + para_id: u32, + relay_parent_number: u32, + ) -> ParachainInherentData; +} + +pub trait NetworkComponent { + fn network_name() -> &'static str; + + fn init() { + N::_init(); + } + + fn relay_block_number() -> u32 { + N::_relay_block_number() + } + + fn set_relay_block_number(block_number: u32) { + N::_set_relay_block_number(block_number); + } + + fn para_ids() -> Vec { + N::_para_ids() + } + + fn send_horizontal_messages)>>( + to_para_id: u32, + iter: I, + ) { + HORIZONTAL_MESSAGES.with(|b| { + b.borrow_mut() + .get_mut(Self::network_name()) + .unwrap() + .push_back((to_para_id, iter.collect())) + }); + } + + fn send_upward_message(from_para_id: u32, msg: Vec) { + UPWARD_MESSAGES.with(|b| { + b.borrow_mut() + .get_mut(Self::network_name()) + .unwrap() + .push_back((from_para_id, msg)) + }); + } + + fn send_downward_messages( + to_para_id: u32, + iter: impl Iterator)>, + ) { + DOWNWARD_MESSAGES.with(|b| { + b.borrow_mut() + .get_mut(Self::network_name()) + .unwrap() + .push_back((to_para_id, iter.collect())) + }); + } + + fn hrmp_channel_parachain_inherent_data( + para_id: u32, + relay_parent_number: u32, + ) -> ParachainInherentData { + N::_hrmp_channel_parachain_inherent_data(para_id, relay_parent_number) + } + + fn process_messages() { + N::_process_messages(); + } +} + +pub trait RelayChain: ProcessMessage { + type Runtime; + type RuntimeOrigin; + type RuntimeCall; + type RuntimeEvent; + type XcmConfig; + type SovereignAccountOf; + type System; + type Balances; +} + +pub trait Parachain: XcmpMessageHandler { + type Runtime; + type RuntimeOrigin; + type RuntimeCall; + type RuntimeEvent; + type XcmpMessageHandler; + type LocationToAccountId; + type System; + type Balances; + type ParachainSystem; + type ParachainInfo; +} + +// Relay Chain Implementation +#[macro_export] +macro_rules! decl_test_relay_chains { + ( + $( + #[api_version($api_version:tt)] + pub struct $name:ident { + genesis = $genesis:expr, + on_init = $on_init:expr, + runtime = { + Runtime: $runtime:path, + RuntimeOrigin: $runtime_origin:path, + RuntimeCall: $runtime_call:path, + RuntimeEvent: $runtime_event:path, + MessageQueue: $mq:path, + XcmConfig: $xcm_config:path, + SovereignAccountOf: $sovereign_acc_of:path, + System: $system:path, + Balances: $balances:path, + }, + pallets_extra = { + $($pallet_name:ident: $pallet_path:path,)* + } + } + ), + + + ) => { + $( + pub struct $name; + + impl RelayChain for $name { + type Runtime = $runtime; + type RuntimeOrigin = $runtime_origin; + type RuntimeCall = $runtime_call; + type RuntimeEvent = $runtime_event; + type XcmConfig = $xcm_config; + type SovereignAccountOf = $sovereign_acc_of; + type System = $system; + type Balances = $balances; + } + + $crate::paste::paste! { + pub trait [<$name Pallet>] { + $( + type $pallet_name; + )? + } + + impl [<$name Pallet>] for $name { + $( + type $pallet_name = $pallet_path; + )? + } + } + + impl $crate::ProcessMessage for $name { + type Origin = $crate::ParaId; + + fn process_message( + msg: &[u8], + para: Self::Origin, + meter: &mut $crate::WeightMeter, + _id: &mut XcmHash + ) -> Result { + use $crate::{Weight, AggregateMessageOrigin, UmpQueueId, ServiceQueues, EnqueueMessage}; + use $mq as message_queue; + use $runtime_event as runtime_event; + + Self::execute_with(|| { + <$mq as EnqueueMessage>::enqueue_message( + msg.try_into().expect("Message too long"), + AggregateMessageOrigin::Ump(UmpQueueId::Para(para.clone())) + ); + + <$system>::reset_events(); + <$mq as ServiceQueues>::service_queues(Weight::MAX); + let events = <$system>::events(); + let event = events.last().expect("There must be at least one event"); + + match &event.event { + runtime_event::MessageQueue( + $crate::pallet_message_queue::Event::Processed {origin, ..}) => { + assert_eq!(origin, &AggregateMessageOrigin::Ump(UmpQueueId::Para(para))); + }, + event => panic!("Unexpected event: {:#?}", event), + } + Ok(true) + }) + } + } + + $crate::__impl_test_ext_for_relay_chain!($name, $genesis, $on_init, $api_version); + )+ + }; +} + +#[macro_export] +macro_rules! __impl_test_ext_for_relay_chain { + // entry point: generate ext name + ($name:ident, $genesis:expr, $on_init:expr, $api_version:tt) => { + $crate::paste::paste! { + $crate::__impl_test_ext_for_relay_chain!(@impl $name, $genesis, $on_init, [], []); + } + }; + // impl + (@impl $name:ident, $genesis:expr, $on_init:expr, $api_version:ident, $ext_name:ident) => { + thread_local! { + pub static $ext_name: $crate::RefCell<$crate::sp_io::TestExternalities> + = $crate::RefCell::new(<$name>::build_new_ext($genesis)); + } + + impl TestExt for $name { + fn build_new_ext(storage: $crate::Storage) -> $crate::sp_io::TestExternalities { + let mut ext = sp_io::TestExternalities::new(storage); + ext.execute_with(|| { + #[allow(clippy::no_effect)] + $on_init; + sp_tracing::try_init_simple(); + ::System::set_block_number(1); + }); + ext + } + + fn new_ext() -> $crate::sp_io::TestExternalities { + <$name>::build_new_ext($genesis) + } + + fn reset_ext() { + $ext_name.with(|v| *v.borrow_mut() = <$name>::build_new_ext($genesis)); + } + + fn execute_with(execute: impl FnOnce() -> R) -> R { + use $crate::{NetworkComponent}; + // Make sure the Network is initialized + <$name>::init(); + + let r = $ext_name.with(|v| v.borrow_mut().execute_with(execute)); + + // send messages if needed + $ext_name.with(|v| { + v.borrow_mut().execute_with(|| { + use $crate::polkadot_primitives::runtime_api::runtime_decl_for_parachain_host::$api_version; + + //TODO: mark sent count & filter out sent msg + for para_id in <$name>::para_ids() { + // downward messages + let downward_messages = ::Runtime::dmq_contents(para_id.into()) + .into_iter() + .map(|inbound| (inbound.sent_at, inbound.msg)); + if downward_messages.len() == 0 { + continue; + } + <$name>::send_downward_messages(para_id, downward_messages.into_iter()); + + // Note: no need to handle horizontal messages, as the + // simulator directly sends them to dest (not relayed). + } + }) + }); + + <$name>::process_messages(); + + r + } + + fn ext_wrapper(func: impl FnOnce() -> R) -> R { + $ext_name.with(|v| { + v.borrow_mut().execute_with(|| { + func() + }) + }) + } + } + }; +} + +#[macro_export] +macro_rules! __impl_relay { + ($network_name:ident, $relay_chain:ty) => { + impl $crate::NetworkComponent<$network_name> for $relay_chain { + fn network_name() -> &'static str { + stringify!($network_name) + } + } + + impl $relay_chain { + pub fn child_location_of(id: $crate::ParaId) -> MultiLocation { + (Ancestor(0), Parachain(id.into())).into() + } + + pub fn account_id_of(seed: &str) -> $crate::AccountId { + $crate::get_account_id_from_seed::(seed) + } + + pub fn account_data_of(account: AccountId) -> $crate::AccountData { + Self::ext_wrapper(|| ::System::account(account).data) + } + + pub fn sovereign_account_id_of(location: $crate::MultiLocation) -> $crate::AccountId { + ::SovereignAccountOf::convert(location.into()).unwrap() + } + + pub fn fund_accounts(accounts: Vec<(AccountId, Balance)>) { + Self::ext_wrapper(|| { + for account in accounts { + let _ = ::Balances::force_set_balance( + ::RuntimeOrigin::root(), + account.0.into(), + account.1.into(), + ); + } + }); + } + + pub fn events() -> Vec<::RuntimeEvent> { + ::System::events() + .iter() + .map(|record| record.event.clone()) + .collect() + } + } + }; +} + +// Parachain Implementation +#[macro_export] +macro_rules! decl_test_parachains { + ( + $( + pub struct $name:ident { + genesis = $genesis:expr, + on_init = $on_init:expr, + runtime = { + Runtime: $runtime:path, + RuntimeOrigin: $runtime_origin:path, + RuntimeCall: $runtime_call:path, + RuntimeEvent: $runtime_event:path, + XcmpMessageHandler: $xcmp_message_handler:path, + LocationToAccountId: $location_to_account:path, + System: $system:path, + Balances: $balances_pallet:path, + ParachainSystem: $parachain_system:path, + ParachainInfo: $parachain_info:path, + }, + pallets_extra = { + $($pallet_name:ident: $pallet_path:path,)* + } + } + ), + + + ) => { + $( + pub struct $name; + + impl Parachain for $name { + type Runtime = $runtime; + type RuntimeOrigin = $runtime_origin; + type RuntimeCall = $runtime_call; + type RuntimeEvent = $runtime_event; + type XcmpMessageHandler = $xcmp_message_handler; + type LocationToAccountId = $location_to_account; + type System = $system; + type Balances = $balances_pallet; + type ParachainSystem = $parachain_system; + type ParachainInfo = $parachain_info; + } + + $crate::paste::paste! { + pub trait [<$name Pallet>] { + $( + type $pallet_name; + )* + } + + impl [<$name Pallet>] for $name { + $( + type $pallet_name = $pallet_path; + )* + } + } + + $crate::__impl_xcm_handlers_for_parachain!($name); + $crate::__impl_test_ext_for_parachain!($name, $genesis, $on_init); + )+ + }; +} + +#[macro_export] +macro_rules! __impl_xcm_handlers_for_parachain { + ($name:ident) => { + impl $crate::XcmpMessageHandler for $name { + fn handle_xcmp_messages< + 'a, + I: Iterator, + >( + iter: I, + max_weight: $crate::Weight, + ) -> $crate::Weight { + use $crate::{TestExt, XcmpMessageHandler}; + + $name::execute_with(|| { + ::XcmpMessageHandler::handle_xcmp_messages(iter, max_weight) + }) + } + } + }; +} + +#[macro_export] +macro_rules! __impl_test_ext_for_parachain { + // entry point: generate ext name + ($name:ident, $genesis:expr, $on_init:expr) => { + $crate::paste::paste! { + $crate::__impl_test_ext_for_parachain!(@impl $name, $genesis, $on_init, []); + } + }; + // impl + (@impl $name:ident, $genesis:expr, $on_init:expr, $ext_name:ident) => { + thread_local! { + pub static $ext_name: $crate::RefCell<$crate::sp_io::TestExternalities> + = $crate::RefCell::new(<$name>::build_new_ext($genesis)); + } + + impl TestExt for $name { + fn build_new_ext(storage: $crate::Storage) -> $crate::sp_io::TestExternalities { + let mut ext = sp_io::TestExternalities::new(storage); + ext.execute_with(|| { + #[allow(clippy::no_effect)] + $on_init; + sp_tracing::try_init_simple(); + ::System::set_block_number(1); + }); + ext + } + + fn new_ext() -> $crate::sp_io::TestExternalities { + <$name>::build_new_ext($genesis) + } + + fn reset_ext() { + $ext_name.with(|v| *v.borrow_mut() = <$name>::build_new_ext($genesis)); + } + + fn execute_with(execute: impl FnOnce() -> R) -> R { + use $crate::{Get, Hooks, NetworkComponent}; + + // Make sure the Network is initialized + <$name>::init(); + + let mut relay_block_number = <$name>::relay_block_number(); + relay_block_number += 1; + <$name>::set_relay_block_number(relay_block_number); + + let para_id = <$name>::para_id().into(); + + $ext_name.with(|v| { + v.borrow_mut().execute_with(|| { + // Make sure it has been recorded properly + let relay_block_number = <$name>::relay_block_number(); + let _ = ::ParachainSystem::set_validation_data( + ::RuntimeOrigin::none(), + <$name>::hrmp_channel_parachain_inherent_data(para_id, relay_block_number), + ); + }) + }); + + + let r = $ext_name.with(|v| v.borrow_mut().execute_with(execute)); + + // send messages if needed + $ext_name.with(|v| { + v.borrow_mut().execute_with(|| { + use sp_runtime::traits::Header as HeaderT; + + let block_number = ::System::block_number(); + let mock_header = HeaderT::new( + 0, + Default::default(), + Default::default(), + Default::default(), + Default::default(), + ); + + // get messages + ::ParachainSystem::on_finalize(block_number); + let collation_info = ::ParachainSystem::collect_collation_info(&mock_header); + + // send upward messages + let relay_block_number = <$name>::relay_block_number(); + for msg in collation_info.upward_messages.clone() { + <$name>::send_upward_message(para_id, msg); + } + + // send horizontal messages + for msg in collation_info.horizontal_messages { + <$name>::send_horizontal_messages( + msg.recipient.into(), + vec![(para_id.into(), relay_block_number, msg.data)].into_iter(), + ); + } + + // clean messages + ::ParachainSystem::on_initialize(block_number); + }) + }); + + <$name>::process_messages(); + + r + } + + fn ext_wrapper(func: impl FnOnce() -> R) -> R { + $ext_name.with(|v| { + v.borrow_mut().execute_with(|| { + func() + }) + }) + } + } + }; +} + +#[macro_export] +macro_rules! __impl_parachain { + ($network_name:ident, $parachain:ty) => { + impl $crate::NetworkComponent<$network_name> for $parachain { + fn network_name() -> &'static str { + stringify!($network_name) + } + } + + impl $parachain { + pub fn para_id() -> $crate::ParaId { + Self::ext_wrapper(|| ::ParachainInfo::get()) + } + + pub fn parent_location() -> $crate::MultiLocation { + (Parent).into() + } + + pub fn account_id_of(seed: &str) -> $crate::AccountId { + $crate::get_account_id_from_seed::(seed) + } + + pub fn account_data_of(account: AccountId) -> $crate::AccountData { + Self::ext_wrapper(|| ::System::account(account).data) + } + + pub fn sovereign_account_id_of(location: $crate::MultiLocation) -> $crate::AccountId { + ::LocationToAccountId::convert(location.into()).unwrap() + } + + pub fn fund_accounts(accounts: Vec<(AccountId, Balance)>) { + Self::ext_wrapper(|| { + for account in accounts { + let _ = ::Balances::force_set_balance( + ::RuntimeOrigin::root(), + account.0.into(), + account.1.into(), + ); + } + }); + } + + pub fn events() -> Vec<::RuntimeEvent> { + ::System::events() + .iter() + .map(|record| record.event.clone()) + .collect() + } + + fn prepare_for_xcmp() { + use $crate::NetworkComponent; + let para_id = Self::para_id(); + + ::ext_wrapper(|| { + use $crate::{Get, Hooks}; + + let block_number = ::System::block_number(); + + let _ = ::ParachainSystem::set_validation_data( + ::RuntimeOrigin::none(), + Self::hrmp_channel_parachain_inherent_data(para_id.into(), 1), + ); + // set `AnnouncedHrmpMessagesPerCandidate` + ::ParachainSystem::on_initialize(block_number); + }); + } + } + }; +} + +// Network Implementation +#[macro_export] +macro_rules! decl_test_networks { + ( + $( + pub struct $name:ident { + relay_chain = $relay_chain:ty, + parachains = vec![ $( $parachain:ty, )* ], + } + ), + + + ) => { + $( + pub struct $name; + + impl $name { + pub fn reset() { + use $crate::{TestExt, VecDeque}; + + $crate::INITIALIZED.with(|b| b.borrow_mut().remove(stringify!($name))); + $crate::DOWNWARD_MESSAGES.with(|b| b.borrow_mut().remove(stringify!($name))); + $crate::DMP_DONE.with(|b| b.borrow_mut().remove(stringify!($name))); + $crate::UPWARD_MESSAGES.with(|b| b.borrow_mut().remove(stringify!($name))); + $crate::HORIZONTAL_MESSAGES.with(|b| b.borrow_mut().remove(stringify!($name))); + $crate::RELAY_BLOCK_NUMBER.with(|b| b.borrow_mut().remove(stringify!($name))); + + <$relay_chain>::reset_ext(); + $( <$parachain>::reset_ext(); )* + $( <$parachain>::prepare_for_xcmp(); )* + } + } + + impl $crate::Network for $name { + fn _init() { + // If Network has not been itialized yet, it gets initialized + if $crate::INITIALIZED.with(|b| b.borrow_mut().get(stringify!($name)).is_none()) { + $crate::INITIALIZED.with(|b| b.borrow_mut().insert(stringify!($name).to_string(), true)); + $crate::DOWNWARD_MESSAGES.with(|b| b.borrow_mut().insert(stringify!($name).to_string(), $crate::VecDeque::new())); + $crate::DMP_DONE.with(|b| b.borrow_mut().insert(stringify!($name).to_string(), $crate::VecDeque::new())); + $crate::UPWARD_MESSAGES.with(|b| b.borrow_mut().insert(stringify!($name).to_string(), $crate::VecDeque::new())); + $crate::HORIZONTAL_MESSAGES.with(|b| b.borrow_mut().insert(stringify!($name).to_string(), $crate::VecDeque::new())); + $crate::RELAY_BLOCK_NUMBER.with(|b| b.borrow_mut().insert(stringify!($name).to_string(), 1)); + $crate::PARA_IDS.with(|b| b.borrow_mut().insert(stringify!($name).to_string(), Self::_para_ids())); + } + } + + fn _para_ids() -> Vec { + vec![$( + <$parachain>::para_id().into(), + )*] + } + + fn _relay_block_number() -> u32 { + $crate::RELAY_BLOCK_NUMBER.with(|v| *v.clone().borrow().get(stringify!($name)).unwrap()) + } + + fn _set_relay_block_number(block_number: u32) { + $crate::RELAY_BLOCK_NUMBER.with(|v| v.borrow_mut().insert(stringify!($name).to_string(), block_number)); + } + + fn _process_messages() { + while Self::_has_unprocessed_messages() { + Self::_process_upward_messages(); + Self::_process_horizontal_messages(); + Self::_process_downward_messages(); + } + } + + fn _has_unprocessed_messages() -> bool { + $crate::DOWNWARD_MESSAGES.with(|b| !b.borrow_mut().get_mut(stringify!($name)).unwrap().is_empty()) + || $crate::HORIZONTAL_MESSAGES.with(|b| !b.borrow_mut().get_mut(stringify!($name)).unwrap().is_empty()) + || $crate::UPWARD_MESSAGES.with(|b| !b.borrow_mut().get_mut(stringify!($name)).unwrap().is_empty()) + } + + fn _process_downward_messages() { + use $crate::{Bounded}; + use polkadot_parachain::primitives::RelayChainBlockNumber; + + while let Some((to_para_id, messages)) + = $crate::DOWNWARD_MESSAGES.with(|b| b.borrow_mut().get_mut(stringify!($name)).unwrap().pop_front()) { + $( + if $crate::PARA_IDS.with(|b| b.borrow_mut().get_mut(stringify!($name)).unwrap().contains(&to_para_id)) { + let mut msg_dedup: Vec<(RelayChainBlockNumber, Vec)> = Vec::new(); + for m in &messages { + msg_dedup.push((m.0, m.1.clone())); + } + msg_dedup.dedup(); + + let msgs = msg_dedup.clone().into_iter().filter(|m| { + !$crate::DMP_DONE.with(|b| b.borrow_mut().get_mut(stringify!($name)) + .unwrap_or(&mut $crate::VecDeque::new()) + .contains(&(to_para_id, m.0, m.1.clone())) + ) + }).collect::)>>(); + + use $crate::{EnqueueMessage, CumulusAggregateMessageOrigin, BoundedSlice, ServiceQueues, TestExt}; + type ParachainDmpQueue = < + <$parachain as Parachain>::Runtime + as + $crate::cumulus_pallet_parachain_system::Config + >::DmpQueue; + for m in msgs { + <$parachain>::execute_with(|| { + >::enqueue_message( + BoundedSlice::<_, _>::try_from(&m.1[..]).unwrap(), + CumulusAggregateMessageOrigin::Parent, + ); + ::service_queues(Weight::MAX); + }); + $crate::DMP_DONE.with(|b| b.borrow_mut().get_mut(stringify!($name)).unwrap().push_back((to_para_id, m.0, m.1))); + } + } else { + unreachable!(); + } + )* + } + } + + fn _process_horizontal_messages() { + use $crate::{XcmpMessageHandler, Bounded}; + + while let Some((to_para_id, messages)) + = $crate::HORIZONTAL_MESSAGES.with(|b| b.borrow_mut().get_mut(stringify!($name)).unwrap().pop_front()) { + let iter = messages.iter().map(|(p, b, m)| (*p, *b, &m[..])).collect::>().into_iter(); + $( + if $crate::PARA_IDS.with(|b| b.borrow_mut().get_mut(stringify!($name)).unwrap().contains(&to_para_id)) { + <$parachain>::handle_xcmp_messages(iter.clone(), $crate::Weight::max_value()); + } + )* + } + } + + fn _process_upward_messages() { + use $crate::{Bounded, ProcessMessage, WeightMeter}; + use sp_core::Encode; + while let Some((from_para_id, msg)) = $crate::UPWARD_MESSAGES.with(|b| b.borrow_mut().get_mut(stringify!($name)).unwrap().pop_front()) { + let mut weight_meter = WeightMeter::max_limit(); + let _ = <$relay_chain>::process_message( + &msg[..], + from_para_id.into(), + &mut weight_meter, + &mut msg.using_encoded(sp_core::blake2_256), + ); + } + } + + fn _hrmp_channel_parachain_inherent_data( + para_id: u32, + relay_parent_number: u32, + ) -> $crate::ParachainInherentData { + use $crate::cumulus_primitives_core::{relay_chain::HrmpChannelId, AbridgedHrmpChannel}; + + let mut sproof = $crate::RelayStateSproofBuilder::default(); + sproof.para_id = para_id.into(); + + // egress channel + let e_index = sproof.hrmp_egress_channel_index.get_or_insert_with(Vec::new); + for recipient_para_id in $crate::PARA_IDS.with(|b| b.borrow_mut().get_mut(stringify!($name)).unwrap().clone()) { + let recipient_para_id = $crate::ParaId::from(recipient_para_id); + if let Err(idx) = e_index.binary_search(&recipient_para_id) { + e_index.insert(idx, recipient_para_id); + } + + sproof + .hrmp_channels + .entry(HrmpChannelId { + sender: sproof.para_id, + recipient: recipient_para_id, + }) + .or_insert_with(|| AbridgedHrmpChannel { + max_capacity: 1024, + max_total_size: 1024 * 1024, + max_message_size: 1024 * 1024, + msg_count: 0, + total_size: 0, + mqc_head: Option::None, + }); + } + + let (relay_storage_root, proof) = sproof.into_state_root_and_proof(); + + $crate::ParachainInherentData { + validation_data: $crate::PersistedValidationData { + parent_head: Default::default(), + relay_parent_number, + relay_parent_storage_root: relay_storage_root, + max_pov_size: Default::default(), + }, + relay_chain_state: proof, + downward_messages: Default::default(), + horizontal_messages: Default::default(), + } + } + } + + $crate::__impl_relay!($name, $relay_chain); + + $( + $crate::__impl_parachain!($name, $parachain); + )* + )+ + }; +} + +#[macro_export] +macro_rules! assert_expected_events { + ( $chain:ident, vec![$( $event_pat:pat => { $($attr:ident : $condition:expr, )* }, )*] ) => { + let mut message: Vec = Vec::new(); + $( + let mut meet_conditions = true; + let mut event_message: Vec = Vec::new(); + + let event_received = <$chain>::events().iter().any(|event| { + $crate::log::debug!(target: format!("events::{}", stringify!($chain)).to_lowercase().as_str(), "{:?}", event); + + match event { + $event_pat => { + $( + if !$condition { + event_message.push(format!(" - The attribute {:?} = {:?} did not met the condition {:?}\n", stringify!($attr), $attr, stringify!($condition))); + meet_conditions &= $condition + } + )* + true + }, + _ => false + } + }); + + if event_received && !meet_conditions { + message.push(format!("\n\nEvent \x1b[31m{}\x1b[0m was received but some of its attributes did not meet the conditions:\n{}", stringify!($event_pat), event_message.concat())); + } else if !event_received { + message.push(format!("\n\nEvent \x1b[31m{}\x1b[0m was never received", stringify!($event_pat))); + } + )* + if !message.is_empty() { + panic!("{}", message.concat()) + } + } + +} + +#[macro_export] +macro_rules! bx { + ($e:expr) => { + Box::new($e) + }; +} + +pub mod helpers { + use super::Weight; + + pub fn within_threshold(threshold: u64, expected_value: u64, current_value: u64) -> bool { + let margin = (current_value * threshold) / 100; + let lower_limit = expected_value - margin; + let upper_limit = expected_value + margin; + + current_value >= lower_limit && current_value <= upper_limit + } + + pub fn weight_within_threshold( + (threshold_time, threshold_size): (u64, u64), + expected_weight: Weight, + weight: Weight, + ) -> bool { + let ref_time_within = + within_threshold(threshold_time, expected_weight.ref_time(), weight.ref_time()); + let proof_size_within = + within_threshold(threshold_size, expected_weight.proof_size(), weight.proof_size()); + + ref_time_within && proof_size_within + } +} diff --git a/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml b/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml new file mode 100644 index 00000000000..4e1260f9e41 --- /dev/null +++ b/zombienet/bridge-hubs/bridge_hub_rococo_local_network.toml @@ -0,0 +1,104 @@ +[settings] +node_spawn_timeout = 240 + +[relaychain] +default_command = "{{POLKADOT_BINARY_PATH}}" +default_args = [ "-lparachain=debug,xcm=trace" ] +chain = "rococo-local" + + [[relaychain.nodes]] + name = "alice-validator" + validator = true + rpc_port = 9932 + ws_port = 9942 + extra_args = ["--no-mdns --bootnodes {{'bob-validator'|zombie('multiAddress')}}"] + + [[relaychain.nodes]] + name = "bob-validator" + validator = true + rpc_port = 9933 + ws_port = 9943 + extra_args = ["--no-mdns --bootnodes {{'alice-validator'|zombie('multiAddress')}}"] + + [[relaychain.nodes]] + name = "charlie-validator" + validator = true + rpc_port = 9934 + ws_port = 9944 + extra_args = ["--no-mdns --bootnodes {{'alice-validator'|zombie('multiAddress')}}"] + +[[parachains]] +id = 1013 +chain = "bridge-hub-rococo-local" +cumulus_based = true + + # run alice as parachain collator + [[parachains.collators]] + name = "alice-collator" + validator = true + command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + rpc_port = 8933 + ws_port = 8943 + args = [ + "-lparachain=debug,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace", + ] + extra_args = [ + "--force-authoring", "--no-mdns", "--bootnodes {{'bob-collator'|zombie('multiAddress')}}", + "-- --port 41333 --rpc-port 48933 --ws-port 48943 --no-mdns", "--bootnodes {{'alice-validator'|zombie('multiAddress')}}" + ] + + # run bob as parachain collator + [[parachains.collators]] + name = "bob-collator" + validator = true + command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + rpc_port = 8934 + ws_port = 8944 + args = [ + "-lparachain=trace,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace", + ] + extra_args = [ + "--force-authoring", "--no-mdns", "--bootnodes {{'alice-collator'|zombie('multiAddress')}}", + "-- --port 41334 --rpc-port 48934 --ws-port 48944 --no-mdns", "--bootnodes {{'bob-validator'|zombie('multiAddress')}}" + ] + +[[parachains]] +id = 1000 +chain = "asset-hub-kusama-local" +cumulus_based = true + + [[parachains.collators]] + name = "rockmine-collator1" + rpc_port = 9911 + ws_port = 9910 + command = "{{POLKADOT_PARACHAIN_BINARY_PATH_FOR_ROCKMINE}}" + args = [ + "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace", + ] + extra_args = [ + "--no-mdns", "--bootnodes {{'rockmine-collator2'|zombie('multiAddress')}}", + "-- --port 51333 --rpc-port 58933 --ws-port 58943 --no-mdns", "--bootnodes {{'alice-validator'|zombie('multiAddress')}}" + ] + + [[parachains.collators]] + name = "rockmine-collator2" + command = "{{POLKADOT_PARACHAIN_BINARY_PATH_FOR_ROCKMINE}}" + args = [ + "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace", + ] + extra_args = [ + "--no-mdns", "--bootnodes {{'rockmine-collator1'|zombie('multiAddress')}}", + "-- --port 51433 --rpc-port 58833 --ws-port 58843 --no-mdns", "--bootnodes {{'alice-validator'|zombie('multiAddress')}}" + ] + +[[hrmp_channels]] +sender = 1000 +recipient = 1013 +max_capacity = 4 +max_message_size = 524288 + +[[hrmp_channels]] +sender = 1013 +recipient = 1000 +max_capacity = 4 +max_message_size = 524288 diff --git a/zombienet/bridge-hubs/bridge_hub_wococo_local_network.toml b/zombienet/bridge-hubs/bridge_hub_wococo_local_network.toml new file mode 100644 index 00000000000..7dcc8dd7232 --- /dev/null +++ b/zombienet/bridge-hubs/bridge_hub_wococo_local_network.toml @@ -0,0 +1,104 @@ +[settings] +node_spawn_timeout = 240 + +[relaychain] +default_command = "{{POLKADOT_BINARY_PATH}}" +default_args = [ "-lparachain=debug,xcm=trace" ] +chain = "wococo-local" + + [[relaychain.nodes]] + name = "alice-validator-wo" + validator = true + rpc_port = 9935 + ws_port = 9945 + extra_args = ["--no-mdns --bootnodes {{'bob-validator-wo'|zombie('multiAddress')}}"] + + [[relaychain.nodes]] + name = "bob-validator-wo" + validator = true + rpc_port = 9936 + ws_port = 9946 + extra_args = ["--no-mdns --bootnodes {{'alice-validator-wo'|zombie('multiAddress')}}"] + + [[relaychain.nodes]] + name = "charlie-validator-wo" + validator = true + rpc_port = 9937 + ws_port = 9947 + extra_args = ["--no-mdns --bootnodes {{'alice-validator-wo'|zombie('multiAddress')}}"] + +[[parachains]] +id = 1014 +chain = "bridge-hub-wococo-local" +cumulus_based = true + + # run alice as parachain collator + [[parachains.collators]] + name = "alice-collator-wo" + validator = true + command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + rpc_port = 8935 + ws_port = 8945 + args = [ + "-lparachain=debug,runtime::mmr=info,substrate=info,runtime=info,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace", + ] + extra_args = [ + "--force-authoring", "--no-mdns", "--bootnodes {{'bob-collator-wo'|zombie('multiAddress')}}", + "-- --port 41335 --rpc-port 48935 --ws-port 48945 --no-mdns", "--bootnodes {{'alice-validator-wo'|zombie('multiAddress')}}" + ] + + # run bob as parachain collator + [[parachains.collators]] + name = "bob-collator-wo" + validator = true + command = "{{POLKADOT_PARACHAIN_BINARY_PATH}}" + rpc_port = 8936 + ws_port = 8946 + args = [ + "-lparachain=trace,runtime::mmr=info,substrate=info,runtime=info,runtime::bridge-hub=trace,runtime::bridge=trace,runtime::bridge-dispatch=trace,bridge=trace,runtime::bridge-messages=trace,xcm=trace", + ] + extra_args = [ + "--force-authoring", "--no-mdns", "--bootnodes {{'alice-collator-wo'|zombie('multiAddress')}}", + "-- --port 41336 --rpc-port 48936 --ws-port 48946 --no-mdns", "--bootnodes {{'bob-validator-wo'|zombie('multiAddress')}}" + ] + +[[parachains]] +id = 1000 +chain = "asset-hub-westend-local" +cumulus_based = true + + [[parachains.collators]] + name = "wockmint-collator1" + rpc_port = 9011 + ws_port = 9010 + command = "{{POLKADOT_PARACHAIN_BINARY_PATH_FOR_WOCKMINT}}" + args = [ + "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace", + ] + extra_args = [ + "--no-mdns", "--bootnodes {{'wockmint-collator2'|zombie('multiAddress')}}", + "-- --port 31333 --rpc-port 38933 --ws-port 38943 --no-mdns", "--bootnodes {{'alice-validator-wo'|zombie('multiAddress')}}" + ] + + [[parachains.collators]] + name = "wockmint-collator2" + command = "{{POLKADOT_PARACHAIN_BINARY_PATH_FOR_WOCKMINT}}" + args = [ + "-lparachain=debug,xcm=trace,runtime::bridge-transfer=trace", + ] + extra_args = [ + "--no-mdns", "--bootnodes {{'wockmint-collator1'|zombie('multiAddress')}}", + "-- --port 31433 --rpc-port 38833 --ws-port 38843 --no-mdns", "--bootnodes {{'alice-validator-wo'|zombie('multiAddress')}}" + ] + +[[hrmp_channels]] +sender = 1000 +recipient = 1014 +max_capacity = 4 +max_message_size = 524288 + +[[hrmp_channels]] +sender = 1014 +recipient = 1000 +max_capacity = 4 +max_message_size = 524288 diff --git a/zombienet/examples/small_network.toml b/zombienet/examples/small_network.toml index ac5ee11e5bb..06ac0d0e5e7 100644 --- a/zombienet/examples/small_network.toml +++ b/zombienet/examples/small_network.toml @@ -14,7 +14,7 @@ chain = "rococo-local" [[parachains]] id = 2000 cumulus_based = true -chain = "statemine-local" +chain = "asset-hub-kusama-local" # run charlie as parachain collator [[parachains.collators]] diff --git a/zombienet/examples/statemine_kusama_local_network.toml b/zombienet/examples/statemine_kusama_local_network.toml index 01d1b0b2d21..1f3debfb9d2 100644 --- a/zombienet/examples/statemine_kusama_local_network.toml +++ b/zombienet/examples/statemine_kusama_local_network.toml @@ -21,7 +21,7 @@ chain = "kusama-local" [[parachains]] id = 1000 -chain = "statemine-local" +chain = "asset-hub-kusama-local" cumulus_based = true # run alice as parachain collator diff --git a/zombienet/tests/register-para.js b/zombienet/tests/register-para.js index c080904aefe..a8fbab94673 100644 --- a/zombienet/tests/register-para.js +++ b/zombienet/tests/register-para.js @@ -3,7 +3,18 @@ async function run(nodeName, networkInfo, args) { const para = networkInfo.paras[paraIdStr]; const relayNode = networkInfo.relay[0]; - await zombie.registerParachain(parseInt(paraIdStr,10),para.wasmPath, para.statePath, relayNode.wsUri, "//Alice", true); + const registerParachainOptions = { + id: parseInt(paraIdStr,10), + wasmPath: para.wasmPath, + statePath: para.statePath, + apiUrl: relayNode.wsUri, + onboardAsParachain: true, + seed: "//Alice", + finalization: true + }; + + + await zombie.registerParachain(registerParachainOptions); } module.exports = { run }