diff --git a/.github/scripts/update-wishlist-leaderboard.py b/.github/scripts/update-wishlist-leaderboard.py new file mode 100644 index 000000000000..caa30bec846d --- /dev/null +++ b/.github/scripts/update-wishlist-leaderboard.py @@ -0,0 +1,79 @@ +from github import Github +import re +import os +from datetime import date + +g = Github(os.getenv("GH_TOKEN")) + +# Regex pattern to match wish format: +wish_pattern = re.compile( + r"I wish for:? (https://github\.com/([a-zA-Z0-9_.-]+)/([a-zA-Z0-9_.-]+)/issues/(\d+))" +) + +wishlist_issue = g.get_repo(os.getenv("WISHLIST_REPOSITORY")).get_issue( + int(os.getenv("WISHLIST_ISSUE_NUMBER")) +) +new_leaderboard = ( + "| Feature Request | Summary | Votes | Status |\n| --- | --- | --- | --- |\n" +) +wishes = {} +issue_details = {} + +for comment in wishlist_issue.get_comments(): + # in the comment body, if there is a string `#(\d)`, replace it with + # https://github.com/paritytech/polkadot-sdk/issues/(number) + updated_body = re.sub( + r"#(\d+)", r"https://github.com/paritytech/polkadot-sdk/issues/\1", comment.body + ) + + matches = wish_pattern.findall(updated_body) + for match in matches: + url, org, repo_name, issue_id = match + issue_key = (url, org, repo_name, issue_id) + if issue_key not in wishes: + wishes[issue_key] = [] + + # Get the author and upvoters of the wish comment. + wishes[issue_key].append(comment.user.id) + wishes[issue_key].extend( + [ + reaction.user.id + for reaction in comment.get_reactions() + if reaction.content in ["+1", "heart", "rocket"] + ] + ) + + # Get upvoters of the desired issue. + desired_issue = g.get_repo(f"{org}/{repo_name}").get_issue(int(issue_id)) + wishes[issue_key].extend( + [ + reaction.user.id + for reaction in desired_issue.get_reactions() + if reaction.content in ["+1", "heart", "rocket"] + ] + ) + issue_details[url] = [ + desired_issue.title, + "👾 Open" if desired_issue.state == "open" else "✅Closed", + ] + +# Count unique wishes - the author of the wish, upvoters of the wish, and upvoters of the desired issue. +for key in wishes: + wishes[key] = len(list(set(wishes[key]))) + +# Sort wishes by count and add to the markdown table +sorted_wishes = sorted(wishes.items(), key=lambda x: x[1], reverse=True) +for (url, _, _, _), count in sorted_wishes: + [summary, status] = issue_details.get(url, "No summary available") + new_leaderboard += f"| {url} | {summary} | {count} | {status} |\n" +new_leaderboard += f"\n> Last updated: {date.today().strftime('%Y-%m-%d')}\n" +print(new_leaderboard) + +new_content = re.sub( + r"(\| Feature Request \|)(.*?)(> Last updated:)(.*?\n)", + new_leaderboard, + wishlist_issue.body, + flags=re.DOTALL, +) + +wishlist_issue.edit(body=new_content) diff --git a/.github/workflows/misc-sync-templates.yml b/.github/workflows/misc-sync-templates.yml index 835a3116d446..6fe907c76aca 100644 --- a/.github/workflows/misc-sync-templates.yml +++ b/.github/workflows/misc-sync-templates.yml @@ -158,7 +158,7 @@ jobs: timeout-minutes: 90 - name: Create PR on failure if: failure() && steps.check-compilation.outcome == 'failure' - uses: peter-evans/create-pull-request@5b4a9f6a9e2af26e5f02351490b90d01eb8ec1e5 # v5 + uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v5 with: path: "${{ env.template-path }}" token: ${{ steps.app_token.outputs.token }} diff --git a/.github/workflows/misc-update-wishlist-leaderboard.yml b/.github/workflows/misc-update-wishlist-leaderboard.yml new file mode 100644 index 000000000000..a825c4641124 --- /dev/null +++ b/.github/workflows/misc-update-wishlist-leaderboard.yml @@ -0,0 +1,36 @@ +name: Update wishlist leaderboard + +on: + schedule: + # Run every 3 hours + - cron: '0 */3 * * *' + +permissions: + contents: read + issues: write + +jobs: + update-wishlist-leaderboard: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install PyGithub + - name: Update developer wishlist + env: + GH_TOKEN: ${{ github.token }} + WISHLIST_REPOSITORY: "paritytech/polkadot-sdk" + WISHLIST_ISSUE_NUMBER: "3900" + run: python .github/scripts/update-wishlist-leaderboard.py + - name: Update user wishlist + env: + GH_TOKEN: ${{ github.token }} + WISHLIST_REPOSITORY: "paritytech/polkadot-sdk" + WISHLIST_ISSUE_NUMBER: "3901" + run: python .github/scripts/update-wishlist-leaderboard.py diff --git a/.github/workflows/release-50_publish-docker.yml b/.github/workflows/release-50_publish-docker.yml index 723883eaf64c..63124a489e9d 100644 --- a/.github/workflows/release-50_publish-docker.yml +++ b/.github/workflows/release-50_publish-docker.yml @@ -210,7 +210,7 @@ jobs: ./docker/scripts/build-injected.sh - name: Login to Dockerhub - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 with: username: ${{ secrets.CUMULUS_DOCKERHUB_USERNAME }} password: ${{ secrets.CUMULUS_DOCKERHUB_TOKEN }} @@ -275,7 +275,7 @@ jobs: ${{ runner.os }}-buildx- - name: Login to Docker Hub - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 with: username: ${{ secrets.POLKADOT_DOCKERHUB_USERNAME }} password: ${{ secrets.POLKADOT_DOCKERHUB_TOKEN }} @@ -288,7 +288,7 @@ jobs: - name: Build and push id: docker_build - uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 + uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 # v6.5.0 with: push: true file: docker/dockerfiles/polkadot/polkadot_injected_debian.Dockerfile diff --git a/.github/workflows/review-bot.yml b/.github/workflows/review-bot.yml index f1401406ae47..0d83b75b3bde 100644 --- a/.github/workflows/review-bot.yml +++ b/.github/workflows/review-bot.yml @@ -30,7 +30,7 @@ jobs: with: artifact-name: pr_number - name: "Evaluates PR reviews and assigns reviewers" - uses: paritytech/review-bot@v2.4.0 + uses: paritytech/review-bot@v2.5.0 with: repo-token: ${{ steps.app_token.outputs.token }} team-token: ${{ steps.app_token.outputs.token }} diff --git a/Cargo.lock b/Cargo.lock index 99dfbafafe28..630503f6041f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -580,7 +580,7 @@ dependencies = [ [[package]] name = "ark-secret-scalar" version = "0.0.2" -source = "git+https://github.com/w3f/ring-vrf?rev=e9782f9#e9782f938629c90f3adb3fff2358bc8d1386af3e" +source = "git+https://github.com/w3f/ring-vrf?rev=0fef826#0fef8266d851932ad25d6b41bc4b34d834d1e11d" dependencies = [ "ark-ec", "ark-ff 0.4.2", @@ -649,7 +649,7 @@ dependencies = [ [[package]] name = "ark-transcript" version = "0.0.2" -source = "git+https://github.com/w3f/ring-vrf?rev=e9782f9#e9782f938629c90f3adb3fff2358bc8d1386af3e" +source = "git+https://github.com/w3f/ring-vrf?rev=0fef826#0fef8266d851932ad25d6b41bc4b34d834d1e11d" dependencies = [ "ark-ff 0.4.2", "ark-serialize 0.4.2", @@ -1383,9 +1383,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line 0.21.0", "cc", @@ -1399,7 +1399,7 @@ dependencies = [ [[package]] name = "bandersnatch_vrfs" version = "0.0.4" -source = "git+https://github.com/w3f/ring-vrf?rev=e9782f9#e9782f938629c90f3adb3fff2358bc8d1386af3e" +source = "git+https://github.com/w3f/ring-vrf?rev=0fef826#0fef8266d851932ad25d6b41bc4b34d834d1e11d" dependencies = [ "ark-bls12-381", "ark-ec", @@ -1408,8 +1408,6 @@ dependencies = [ "ark-serialize 0.4.2", "ark-std 0.4.0", "dleq_vrf", - "fflonk", - "merlin", "rand_chacha", "rand_core", "ring 0.1.0", @@ -2173,7 +2171,6 @@ dependencies = [ "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", - "static_assertions", "substrate-wasm-builder", "testnet-parachains-constants", "xcm-runtime-apis", @@ -2331,7 +2328,6 @@ dependencies = [ "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", - "static_assertions", "substrate-wasm-builder", "testnet-parachains-constants", "westend-runtime-constants", @@ -2511,9 +2507,9 @@ checksum = "a2698f953def977c68f935bb0dfa959375ad4638570e969e2f1e9f433cbf1af6" [[package]] name = "cc" -version = "1.0.83" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" dependencies = [ "jobserver", "libc", @@ -2755,9 +2751,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.9" +version = "4.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +checksum = "8f6b81fb3c84f5563d509c59b5a48d935f689e993afa90fe39047f05adef9142" dependencies = [ "clap_builder", "clap_derive 4.5.8", @@ -2774,9 +2770,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.9" +version = "4.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +checksum = "5ca6706fd5224857d9ac5eb9355f6683563cc0541c7cd9d014043b57cbec78ac" dependencies = [ "anstream", "anstyle", @@ -2791,7 +2787,7 @@ version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "586a385f7ef2f8b4d86bddaa0c094794e7ccbfe5ffef1f434fe928143fc783a5" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", ] [[package]] @@ -3047,7 +3043,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/w3f/ring-proof#b273d33f9981e2bb3375ab45faeb537f7ee35224" +source = "git+https://github.com/w3f/ring-proof?rev=665f5f5#665f5f51af5734c7b6d90b985dd6861d4c5b4752" dependencies = [ "ark-ec", "ark-ff 0.4.2", @@ -3617,7 +3613,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.5.9", + "clap 4.5.10", "criterion-plot", "futures", "is-terminal", @@ -3751,7 +3747,7 @@ dependencies = [ name = "cumulus-client-cli" version = "0.7.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "parity-scale-codec", "sc-chain-spec", "sc-cli", @@ -4214,7 +4210,7 @@ name = "cumulus-pov-validator" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.5.9", + "clap 4.5.10", "parity-scale-codec", "polkadot-node-primitives", "polkadot-parachain-primitives", @@ -4541,7 +4537,7 @@ name = "cumulus-test-service" version = "0.1.0" dependencies = [ "async-trait", - "clap 4.5.9", + "clap 4.5.10", "criterion", "cumulus-client-cli", "cumulus-client-collator", @@ -4973,7 +4969,7 @@ checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632" [[package]] name = "dleq_vrf" version = "0.0.2" -source = "git+https://github.com/w3f/ring-vrf?rev=e9782f9#e9782f938629c90f3adb3fff2358bc8d1386af3e" +source = "git+https://github.com/w3f/ring-vrf?rev=0fef826#0fef8266d851932ad25d6b41bc4b34d834d1e11d" dependencies = [ "ark-ec", "ark-ff 0.4.2", @@ -5803,7 +5799,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap 4.5.9", + "clap 4.5.10", "comfy-table", "frame-benchmarking", "frame-support", @@ -5895,7 +5891,7 @@ dependencies = [ name = "frame-election-solution-type-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "frame-election-provider-solution-type", "frame-election-provider-support", "frame-support", @@ -5967,7 +5963,7 @@ dependencies = [ name = "frame-omni-bencher" version = "0.1.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "cumulus-primitives-proof-size-hostfunction", "env_logger 0.11.3", "frame-benchmarking-cli", @@ -7364,9 +7360,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.26" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] @@ -8729,7 +8725,7 @@ dependencies = [ name = "minimal-template-node" version = "0.0.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "docify", "futures", "futures-timer", @@ -9222,7 +9218,7 @@ name = "node-bench" version = "0.9.0-dev" dependencies = [ "array-bytes", - "clap 4.5.9", + "clap 4.5.10", "derive_more", "fs_extra", "futures", @@ -9301,7 +9297,7 @@ dependencies = [ name = "node-runtime-generate-bags" version = "3.0.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "generate-bags", "kitchensink-runtime", ] @@ -9310,7 +9306,7 @@ dependencies = [ name = "node-template-release" version = "3.0.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "flate2", "fs_extra", "glob", @@ -11991,6 +11987,7 @@ dependencies = [ "log", "pallet-balances", "pallet-bridge-messages", + "pallet-xcm-bridge-hub-router", "parity-scale-codec", "scale-info", "sp-core", @@ -12025,7 +12022,7 @@ dependencies = [ name = "parachain-template-node" version = "0.0.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "color-print", "cumulus-client-cli", "cumulus-client-collator", @@ -12985,7 +12982,7 @@ name = "polkadot-cli" version = "7.0.0" dependencies = [ "cfg-if", - "clap 4.5.9", + "clap 4.5.10", "frame-benchmarking-cli", "futures", "log", @@ -13845,7 +13842,7 @@ dependencies = [ "async-trait", "bridge-hub-rococo-runtime", "bridge-hub-westend-runtime", - "clap 4.5.9", + "clap 4.5.10", "collectives-westend-runtime", "color-print", "contracts-rococo-runtime", @@ -14829,7 +14826,7 @@ dependencies = [ "async-trait", "bincode", "bitvec", - "clap 4.5.9", + "clap 4.5.10", "clap-num", "color-eyre", "colored", @@ -14927,7 +14924,7 @@ version = "1.0.0" dependencies = [ "assert_matches", "async-trait", - "clap 4.5.9", + "clap 4.5.10", "color-eyre", "futures", "futures-timer", @@ -15069,7 +15066,7 @@ dependencies = [ name = "polkadot-voter-bags" version = "7.0.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "generate-bags", "sp-io", "westend-runtime", @@ -16192,12 +16189,12 @@ dependencies = [ name = "relay-utils" version = "0.1.0" dependencies = [ - "ansi_term", "anyhow", "async-std", "async-trait", "backoff", "bp-runtime", + "console", "env_logger 0.11.3", "futures", "isahc", @@ -16218,7 +16215,7 @@ dependencies = [ name = "remote-ext-tests-bags-list" version = "1.0.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "frame-system", "log", "pallet-bags-list-remote-tests", @@ -16291,13 +16288,14 @@ dependencies = [ [[package]] name = "ring" version = "0.1.0" -source = "git+https://github.com/w3f/ring-proof#b273d33f9981e2bb3375ab45faeb537f7ee35224" +source = "git+https://github.com/w3f/ring-proof?rev=665f5f5#665f5f51af5734c7b6d90b985dd6861d4c5b4752" dependencies = [ "ark-ec", "ark-ff 0.4.2", "ark-poly", "ark-serialize 0.4.2", "ark-std 0.4.0", + "arrayvec 0.7.4", "blake2 0.10.6", "common", "fflonk", @@ -17067,7 +17065,7 @@ name = "sc-chain-spec" version = "28.0.0" dependencies = [ "array-bytes", - "clap 4.5.9", + "clap 4.5.10", "docify", "log", "memmap2 0.9.3", @@ -17110,7 +17108,7 @@ version = "0.36.0" dependencies = [ "array-bytes", "chrono", - "clap 4.5.9", + "clap 4.5.10", "fdlimit", "futures", "futures-timer", @@ -17668,7 +17666,7 @@ dependencies = [ name = "sc-informant" version = "0.33.0" dependencies = [ - "ansi_term", + "console", "futures", "futures-timer", "log", @@ -18294,7 +18292,7 @@ dependencies = [ name = "sc-storage-monitor" version = "0.16.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "fs4", "log", "sp-core", @@ -18364,8 +18362,8 @@ dependencies = [ name = "sc-tracing" version = "28.0.0" dependencies = [ - "ansi_term", "chrono", + "console", "criterion", "is-terminal", "lazy_static", @@ -19716,7 +19714,7 @@ dependencies = [ name = "solochain-template-node" version = "0.0.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "frame-benchmarking-cli", "frame-system", "futures", @@ -20390,7 +20388,7 @@ dependencies = [ name = "sp-npos-elections-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "honggfuzz", "rand", "sp-npos-elections", @@ -20903,7 +20901,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" name = "staging-chain-spec-builder" version = "1.6.1" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "log", "sc-chain-spec", "serde_json", @@ -20916,7 +20914,7 @@ version = "3.0.0-dev" dependencies = [ "array-bytes", "assert_cmd", - "clap 4.5.9", + "clap 4.5.10", "clap_complete", "criterion", "futures", @@ -20951,7 +20949,7 @@ dependencies = [ name = "staging-node-inspect" version = "0.12.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -21224,7 +21222,7 @@ dependencies = [ name = "subkey" version = "9.0.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "sc-cli", ] @@ -21520,6 +21518,7 @@ dependencies = [ "console", "filetime", "frame-metadata", + "jobserver", "merkleized-metadata", "parity-scale-codec", "parity-wasm", @@ -21849,7 +21848,7 @@ dependencies = [ name = "test-parachain-adder-collator" version = "1.0.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "futures", "futures-timer", "log", @@ -21896,7 +21895,7 @@ dependencies = [ name = "test-parachain-undying-collator" version = "1.0.0" dependencies = [ - "clap 4.5.9", + "clap 4.5.10", "futures", "futures-timer", "log", diff --git a/Cargo.toml b/Cargo.toml index 3886014dc2b4..ba0526b21c36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -576,7 +576,6 @@ ahash = { version = "0.8.2" } alloy-primitives = { version = "0.4.2", default-features = false } alloy-sol-types = { version = "0.4.2", default-features = false } always-assert = { version = "0.1" } -ansi_term = { version = "0.12.1" } anyhow = { version = "1.0.81" } aquamarine = { version = "0.5.0" } arbitrary = { version = "1.3.2" } @@ -607,7 +606,7 @@ async-std = { version = "1.9.0" } async-trait = { version = "0.1.79" } asynchronous-codec = { version = "0.6" } backoff = { version = "0.4" } -backtrace = { version = "0.3.64" } +backtrace = { version = "0.3.71" } binary-merkle-tree = { path = "substrate/utils/binary-merkle-tree", default-features = false } bincode = { version = "1.3.3" } bip39 = { version = "2.0.0" } @@ -659,7 +658,7 @@ chain-spec-builder = { path = "substrate/bin/utils/chain-spec-builder", default- chain-spec-guide-runtime = { path = "docs/sdk/src/reference_docs/chain_spec_runtime" } chrono = { version = "0.4.31" } cid = { version = "0.9.0" } -clap = { version = "4.5.9" } +clap = { version = "4.5.10" } clap-num = { version = "1.0.2" } clap_complete = { version = "4.0.2" } coarsetime = { version = "0.1.22" } @@ -804,6 +803,7 @@ is-terminal = { version = "0.4.9" } is_executable = { version = "1.0.1" } isahc = { version = "1.2" } itertools = { version = "0.11" } +jobserver = { version = "0.1.26" } jsonpath_lib = { version = "0.3" } jsonrpsee = { version = "0.23.2" } jsonrpsee-core = { version = "0.23.2" } diff --git a/bridges/bin/runtime-common/src/integrity.rs b/bridges/bin/runtime-common/src/integrity.rs index f661db8a2205..a0a9367dd140 100644 --- a/bridges/bin/runtime-common/src/integrity.rs +++ b/bridges/bin/runtime-common/src/integrity.rs @@ -27,17 +27,25 @@ use frame_support::{storage::generator::StorageValue, traits::Get, weights::Weig use frame_system::limits; use pallet_bridge_messages::WeightInfoExt as _; +// Re-export to avoid include all dependencies everywhere. +#[doc(hidden)] +pub mod __private { + pub use bp_xcm_bridge_hub; + pub use static_assertions; +} + /// Macro that ensures that the runtime configuration and chain primitives crate are sharing /// the same types (nonce, block number, hash, hasher, account id and header). #[macro_export] macro_rules! assert_chain_types( ( runtime: $r:path, this_chain: $this:path ) => { { + use frame_system::{Config as SystemConfig, pallet_prelude::{BlockNumberFor, HeaderFor}}; + use $crate::integrity::__private::static_assertions::assert_type_eq_all; + // 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, pallet_prelude::{BlockNumberFor, HeaderFor}}; - use static_assertions::assert_type_eq_all; assert_type_eq_all!(<$r as SystemConfig>::Nonce, bp_runtime::NonceOf<$this>); assert_type_eq_all!(BlockNumberFor<$r>, bp_runtime::BlockNumberOf<$this>); @@ -60,14 +68,15 @@ macro_rules! assert_bridge_messages_pallet_types( 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 $crate::messages_xcm_extension::XcmAsPlainPayload; + use $crate::integrity::__private::static_assertions::assert_type_eq_all; use bp_messages::ChainWithMessages; use bp_runtime::Chain; use pallet_bridge_messages::Config as MessagesConfig; - use static_assertions::assert_type_eq_all; + + // 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) assert_type_eq_all!(<$r as MessagesConfig<$i>>::ThisChain, $this); assert_type_eq_all!(<$r as MessagesConfig<$i>>::BridgedChain, $bridged); diff --git a/bridges/modules/messages/src/proofs.rs b/bridges/modules/messages/src/proofs.rs index 18367029d72c..a3318833fa61 100644 --- a/bridges/modules/messages/src/proofs.rs +++ b/bridges/modules/messages/src/proofs.rs @@ -63,7 +63,7 @@ pub fn verify_messages_proof, I: 'static>( 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); + let messages_in_the_proof = nonces_range.saturating_len(); if messages_in_the_proof != MessageNonce::from(messages_count) { return Err(VerificationError::MessagesCountMismatch) } diff --git a/bridges/modules/messages/src/tests/mock.rs b/bridges/modules/messages/src/tests/mock.rs index ffdd536830b5..99da019dc084 100644 --- a/bridges/modules/messages/src/tests/mock.rs +++ b/bridges/modules/messages/src/tests/mock.rs @@ -225,7 +225,7 @@ impl crate::benchmarking::Config<()> for TestRuntime { use bp_runtime::RangeInclusiveExt; let dispatch_weight = - REGULAR_PAYLOAD.declared_weight * params.message_nonces.checked_len().unwrap_or(0); + REGULAR_PAYLOAD.declared_weight * params.message_nonces.saturating_len(); ( *prepare_messages_proof( params.message_nonces.into_iter().map(|n| message(n, REGULAR_PAYLOAD)).collect(), diff --git a/bridges/modules/xcm-bridge-hub/Cargo.toml b/bridges/modules/xcm-bridge-hub/Cargo.toml index 092df477265f..8fbf61a0a535 100644 --- a/bridges/modules/xcm-bridge-hub/Cargo.toml +++ b/bridges/modules/xcm-bridge-hub/Cargo.toml @@ -38,6 +38,8 @@ xcm-executor = { workspace = true } bp-header-chain = { workspace = true, default-features = true } pallet-balances = { workspace = true, default-features = true } sp-io = { workspace = true, default-features = true } +bp-runtime = { features = ["test-helpers"], workspace = true } +pallet-xcm-bridge-hub-router = { workspace = true } [features] default = ["std"] @@ -51,6 +53,7 @@ std = [ "frame-system/std", "log/std", "pallet-bridge-messages/std", + "pallet-xcm-bridge-hub-router/std", "scale-info/std", "sp-core/std", "sp-runtime/std", @@ -65,6 +68,7 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-bridge-messages/runtime-benchmarks", + "pallet-xcm-bridge-hub-router/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", @@ -74,5 +78,6 @@ try-runtime = [ "frame-system/try-runtime", "pallet-balances/try-runtime", "pallet-bridge-messages/try-runtime", + "pallet-xcm-bridge-hub-router/try-runtime", "sp-runtime/try-runtime", ] diff --git a/bridges/modules/xcm-bridge-hub/src/exporter.rs b/bridges/modules/xcm-bridge-hub/src/exporter.rs index 94ec8b5f106f..5bca3ad8e277 100644 --- a/bridges/modules/xcm-bridge-hub/src/exporter.rs +++ b/bridges/modules/xcm-bridge-hub/src/exporter.rs @@ -131,6 +131,7 @@ impl HaulBlob for DummyHaulBlob { mod tests { use super::*; use crate::mock::*; + use bp_runtime::RangeInclusiveExt; use frame_support::assert_ok; use xcm_executor::traits::export_xcm; @@ -138,8 +139,8 @@ mod tests { [GlobalConsensus(RelayNetwork::get()), Parachain(SIBLING_ASSET_HUB_ID)].into() } - fn universal_destination() -> InteriorLocation { - BridgedDestination::get() + fn bridged_relative_destination() -> InteriorLocation { + BridgedRelativeDestination::get() } #[test] @@ -149,7 +150,7 @@ mod tests { BridgedRelayNetwork::get(), 0, universal_source(), - universal_destination(), + bridged_relative_destination(), vec![Instruction::ClearOrigin].into(), )); }) @@ -163,7 +164,7 @@ mod tests { BridgedRelayNetwork::get(), 0, &mut None, - &mut Some(universal_destination()), + &mut Some(bridged_relative_destination()), &mut Some(Vec::new().into()), ), Err(SendError::MissingArgument), @@ -192,7 +193,7 @@ mod tests { BridgedRelayNetwork::get(), 0, &mut Some(universal_source()), - &mut Some(universal_destination()), + &mut Some(bridged_relative_destination()), &mut Some(Vec::new().into()), ) .unwrap() @@ -203,4 +204,37 @@ mod tests { ); }) } + + #[test] + fn exporter_is_compatible_with_pallet_xcm_bridge_hub_router() { + run_test(|| { + // valid routable destination + let dest = Location::new(2, BridgedUniversalDestination::get()); + let expected_lane_id = TEST_LANE_ID; + + // check before - no messages + assert_eq!( + pallet_bridge_messages::Pallet::::outbound_lane_data( + expected_lane_id + ) + .queued_messages() + .saturating_len(), + 0 + ); + + // send `ExportMessage(message)` by `pallet_xcm_bridge_hub_router`. + TestExportXcmWithXcmOverBridge::set_origin_for_execute(SiblingLocation::get()); + assert_ok!(send_xcm::(dest, Xcm::<()>::default())); + + // check after - a message ready to be relayed + assert_eq!( + pallet_bridge_messages::Pallet::::outbound_lane_data( + expected_lane_id + ) + .queued_messages() + .saturating_len(), + 1 + ); + }) + } } diff --git a/bridges/modules/xcm-bridge-hub/src/mock.rs b/bridges/modules/xcm-bridge-hub/src/mock.rs index df72e7a3c4fc..0cca32ba9e5f 100644 --- a/bridges/modules/xcm-bridge-hub/src/mock.rs +++ b/bridges/modules/xcm-bridge-hub/src/mock.rs @@ -25,14 +25,24 @@ use bp_messages::{ use bp_runtime::{messages::MessageDispatchResult, Chain, ChainId, HashOf}; use bridge_runtime_common::messages_xcm_extension::{SenderAndLane, XcmBlobHauler}; use codec::Encode; -use frame_support::{derive_impl, parameter_types, weights::RuntimeDbWeight}; +use frame_support::{ + assert_ok, derive_impl, parameter_types, + traits::{Everything, NeverEnsureOrigin}, + weights::RuntimeDbWeight, +}; use sp_core::H256; use sp_runtime::{ testing::Header as SubstrateHeader, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, ConstU128, ConstU32, IdentityLookup}, AccountId32, BuildStorage, StateVersion, }; +use sp_std::cell::RefCell; use xcm::prelude::*; +use xcm_builder::{ + AllowUnpaidExecutionFrom, FixedWeightBounds, InspectMessageQueues, NetworkExportTable, + NetworkExportTableItem, +}; +use xcm_executor::XcmExecutor; pub type AccountId = AccountId32; pub type Balance = u64; @@ -50,6 +60,7 @@ frame_support::construct_runtime! { Balances: pallet_balances::{Pallet, Event}, Messages: pallet_bridge_messages::{Pallet, Call, Event}, XcmOverBridge: pallet_xcm_bridge_hub::{Pallet}, + XcmOverBridgeRouter: pallet_xcm_bridge_hub_router, } } @@ -137,15 +148,34 @@ impl pallet_bridge_messages::WeightInfoExt for TestMessagesWeights { parameter_types! { pub const RelayNetwork: NetworkId = NetworkId::Kusama; - pub const BridgedRelayNetwork: NetworkId = NetworkId::Polkadot; - pub BridgedRelayNetworkLocation: Location = (Parent, GlobalConsensus(BridgedRelayNetwork::get())).into(); - pub const NonBridgedRelayNetwork: NetworkId = NetworkId::Rococo; - pub const BridgeReserve: Balance = 100_000; pub UniversalLocation: InteriorLocation = [ GlobalConsensus(RelayNetwork::get()), Parachain(THIS_BRIDGE_HUB_ID), ].into(); + pub SiblingLocation: Location = Location::new(1, [Parachain(SIBLING_ASSET_HUB_ID)]); + + pub const BridgedRelayNetwork: NetworkId = NetworkId::Polkadot; + pub BridgedRelayNetworkLocation: Location = (Parent, GlobalConsensus(BridgedRelayNetwork::get())).into(); + pub BridgedRelativeDestination: InteriorLocation = [Parachain(BRIDGED_ASSET_HUB_ID)].into(); + pub BridgedUniversalDestination: InteriorLocation = [GlobalConsensus(BridgedRelayNetwork::get()), Parachain(BRIDGED_ASSET_HUB_ID)].into(); + pub const NonBridgedRelayNetwork: NetworkId = NetworkId::Rococo; + + pub const BridgeDeposit: Balance = 100_000; pub const Penalty: Balance = 1_000; + + // configuration for pallet_xcm_bridge_hub_router + pub BridgeHubLocation: Location = Here.into(); + pub BridgeFeeAsset: AssetId = Location::here().into(); + pub BridgeTable: Vec + = vec![ + NetworkExportTableItem::new( + BridgedRelayNetwork::get(), + None, + BridgeHubLocation::get(), + None + ) + ]; + pub UnitWeightCost: Weight = Weight::from_parts(10, 10); } impl pallet_xcm_bridge_hub::Config for TestRuntime { @@ -160,16 +190,114 @@ impl pallet_xcm_bridge_hub::Config for TestRuntime { type LanesSupport = TestXcmBlobHauler; } +impl pallet_xcm_bridge_hub_router::Config<()> for TestRuntime { + type WeightInfo = (); + + type UniversalLocation = UniversalLocation; + type BridgedNetworkId = BridgedRelayNetwork; + type Bridges = NetworkExportTable; + type DestinationVersion = AlwaysLatest; + + type BridgeHubOrigin = NeverEnsureOrigin; + type ToBridgeHubSender = TestExportXcmWithXcmOverBridge; + + type ByteFee = ConstU128<0>; + type FeeAsset = BridgeFeeAsset; + + type WithBridgeHubChannel = (); +} + +pub struct XcmConfig; +impl xcm_executor::Config for XcmConfig { + type RuntimeCall = RuntimeCall; + type XcmSender = (); + type AssetTransactor = (); + type OriginConverter = (); + type IsReserve = (); + type IsTeleporter = (); + type UniversalLocation = UniversalLocation; + type Barrier = AllowUnpaidExecutionFrom; + type Weigher = FixedWeightBounds>; + type Trader = (); + type ResponseHandler = (); + type AssetTrap = (); + type AssetClaims = (); + type SubscriptionService = (); + type PalletInstancesInfo = (); + type MaxAssetsIntoHolding = (); + type AssetLocker = (); + type AssetExchanger = (); + type FeeManager = (); + // We just set `MessageExporter` as our `pallet_xcm_bridge_hub` instance. + type MessageExporter = (XcmOverBridge,); + type UniversalAliases = (); + type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; + type Aliasers = (); + type TransactionalProcessor = (); + type HrmpNewChannelOpenRequestHandler = (); + type HrmpChannelAcceptedHandler = (); + type HrmpChannelClosingHandler = (); + type XcmRecorder = (); +} + +thread_local! { + pub static EXECUTE_XCM_ORIGIN: RefCell> = RefCell::new(None); +} + +/// The `SendXcm` implementation directly executes XCM using `XcmExecutor`. +/// +/// We ensure that the `ExportMessage` produced by `pallet_xcm_bridge_hub_router` is compatible with +/// the `ExportXcm` implementation of `pallet_xcm_bridge_hub`. +/// +/// Note: The crucial part is that `ExportMessage` is processed by `XcmExecutor`, which calls the +/// `ExportXcm` implementation of `pallet_xcm_bridge_hub` as `MessageExporter`. +pub struct TestExportXcmWithXcmOverBridge; +impl SendXcm for TestExportXcmWithXcmOverBridge { + type Ticket = Xcm<()>; + + fn validate( + _: &mut Option, + message: &mut Option>, + ) -> SendResult { + Ok((message.take().unwrap(), Assets::new())) + } + + fn deliver(ticket: Self::Ticket) -> Result { + let xcm: Xcm = ticket.into(); + + let origin = EXECUTE_XCM_ORIGIN.with(|o| o.borrow().clone().unwrap()); + let mut hash = xcm.using_encoded(sp_io::hashing::blake2_256); + let outcome = XcmExecutor::::prepare_and_execute( + origin, + xcm, + &mut hash, + Weight::MAX, + Weight::zero(), + ); + assert_ok!(outcome.ensure_complete()); + + Ok(hash) + } +} +impl InspectMessageQueues for TestExportXcmWithXcmOverBridge { + fn get_messages() -> Vec<(VersionedLocation, Vec>)> { + todo!() + } +} +impl TestExportXcmWithXcmOverBridge { + pub fn set_origin_for_execute(origin: Location) { + EXECUTE_XCM_ORIGIN.with(|o| *o.borrow_mut() = Some(origin)); + } +} + parameter_types! { pub TestSenderAndLane: SenderAndLane = SenderAndLane { - location: Location::new(1, [Parachain(SIBLING_ASSET_HUB_ID)]), + location: SiblingLocation::get(), lane: TEST_LANE_ID, }; - pub BridgedDestination: InteriorLocation = [ - Parachain(BRIDGED_ASSET_HUB_ID) - ].into(); pub TestLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![ - (TestSenderAndLane::get(), (BridgedRelayNetwork::get(), BridgedDestination::get())) + (TestSenderAndLane::get(), (BridgedRelayNetwork::get(), BridgedRelativeDestination::get())) ]; } diff --git a/bridges/relays/utils/Cargo.toml b/bridges/relays/utils/Cargo.toml index 93e42763967b..2c3f37750486 100644 --- a/bridges/relays/utils/Cargo.toml +++ b/bridges/relays/utils/Cargo.toml @@ -11,11 +11,11 @@ publish = false workspace = true [dependencies] -ansi_term = { workspace = true } anyhow = { workspace = true } async-std = { workspace = true } async-trait = { workspace = true } backoff = { workspace = true } +console = { workspace = true } isahc = { workspace = true } env_logger = { workspace = true } futures = { workspace = true } diff --git a/bridges/relays/utils/src/initialize.rs b/bridges/relays/utils/src/initialize.rs index 64d710242710..cd0377caa3d6 100644 --- a/bridges/relays/utils/src/initialize.rs +++ b/bridges/relays/utils/src/initialize.rs @@ -16,6 +16,7 @@ //! Relayer initialization functions. +use console::style; use parking_lot::Mutex; use std::{cell::RefCell, fmt::Display, io::Write}; @@ -55,7 +56,7 @@ pub fn initialize_logger(with_timestamp: bool) { let timestamp = if cfg!(windows) { Either::Left(timestamp) } else { - Either::Right(ansi_term::Colour::Fixed(8).bold().paint(timestamp)) + Either::Right(style(timestamp).black().bright().bold().to_string()) }; writeln!( @@ -120,7 +121,7 @@ fn color_target(target: &str) -> impl Display + '_ { if cfg!(windows) { Either::Left(target) } else { - Either::Right(ansi_term::Colour::Fixed(8).paint(target)) + Either::Right(style(target).black().bright().to_string()) } } @@ -129,13 +130,12 @@ fn color_level(level: log::Level) -> impl Display { Either::Left(level) } else { let s = level.to_string(); - use ansi_term::Colour as Color; Either::Right(match level { - log::Level::Error => Color::Fixed(9).bold().paint(s), - log::Level::Warn => Color::Fixed(11).bold().paint(s), - log::Level::Info => Color::Fixed(10).paint(s), - log::Level::Debug => Color::Fixed(14).paint(s), - log::Level::Trace => Color::Fixed(12).paint(s), + log::Level::Error => style(s).red().bright().bold().to_string(), + log::Level::Warn => style(s).yellow().bright().bold().to_string(), + log::Level::Info => style(s).green().bright().to_string(), + log::Level::Debug => style(s).cyan().bright().to_string(), + log::Level::Trace => style(s).blue().bright().to_string(), }) } } diff --git a/cumulus/client/relay-chain-minimal-node/src/lib.rs b/cumulus/client/relay-chain-minimal-node/src/lib.rs index 9101b8154aa7..732a242e7295 100644 --- a/cumulus/client/relay-chain-minimal-node/src/lib.rs +++ b/cumulus/client/relay-chain-minimal-node/src/lib.rs @@ -176,8 +176,10 @@ async fn new_minimal_relay_chain, ) -> Result { let role = config.role.clone(); - let mut net_config = - sc_network::config::FullNetworkConfiguration::<_, _, Network>::new(&config.network); + let mut net_config = sc_network::config::FullNetworkConfiguration::<_, _, Network>::new( + &config.network, + config.prometheus_config.as_ref().map(|cfg| cfg.registry.clone()), + ); let metrics = Network::register_notification_metrics( config.prometheus_config.as_ref().map(|cfg| &cfg.registry), ); diff --git a/cumulus/parachains/common/src/impls.rs b/cumulus/parachains/common/src/impls.rs index 42ea50c75a8d..c1797c0a7513 100644 --- a/cumulus/parachains/common/src/impls.rs +++ b/cumulus/parachains/common/src/impls.rs @@ -67,7 +67,7 @@ where AccountIdOf: From + Into, ::RuntimeEvent: From>, { - fn on_unbalanceds( + fn on_unbalanceds( mut fees_then_tips: impl Iterator< Item = fungible::Credit>, >, diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs index 43cd5bb85d3d..3c0533f775e2 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/lib.rs @@ -40,7 +40,7 @@ mod imports { genesis::ED as PEOPLE_ROCOCO_ED, people_rococo_runtime::{ people, xcm_config::XcmConfig as PeopleRococoXcmConfig, - ExistentialDeposit as PeopleRococoExistentialDeposit, + ExistentialDeposit as PeopleRococoExistentialDeposit, Runtime as PeopleRuntime, }, PeopleRococoParaPallet as PeopleRococoPallet, }, @@ -48,8 +48,8 @@ mod imports { genesis::ED as ROCOCO_ED, rococo_runtime::{ xcm_config::XcmConfig as RococoXcmConfig, BasicDeposit, ByteDeposit, - MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as RococoOrigin, - SubAccountDeposit, + MaxAdditionalFields, MaxSubAccounts, Runtime as RococoRuntime, + RuntimeOrigin as RococoOrigin, SubAccountDeposit, }, RococoRelayPallet as RococoPallet, }, diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs index 342a8f053f60..10f0c61ed63c 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-rococo/src/tests/reap_identity.rs @@ -41,7 +41,7 @@ use crate::imports::*; use frame_support::BoundedVec; use pallet_balances::Event as BalancesEvent; -use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent}; +use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent, IdentityOf, SubsOf}; use people::{ BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain, IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain, @@ -266,9 +266,9 @@ fn assert_set_id_parachain(id: &Identity) { // No amount should be reserved as deposit amounts are set to 0. let reserved_balance = PeopleRococoBalances::reserved_balance(PeopleRococoSender::get()); assert_eq!(reserved_balance, 0); - assert!(PeopleRococoIdentity::identity(PeopleRococoSender::get()).is_some()); + assert!(IdentityOf::::get(PeopleRococoSender::get()).is_some()); - let (_, sub_accounts) = PeopleRococoIdentity::subs_of(PeopleRococoSender::get()); + let (_, sub_accounts) = SubsOf::::get(PeopleRococoSender::get()); match id.subs { Subs::Zero => assert_eq!(sub_accounts.len(), 0), @@ -314,10 +314,10 @@ fn assert_reap_id_relay(total_deposit: Balance, id: &Identity) { ] ); // Identity should be gone. - assert!(PeopleRococoIdentity::identity(RococoRelaySender::get()).is_none()); + assert!(IdentityOf::::get(RococoRelaySender::get()).is_none()); // Subs should be gone. - let (_, sub_accounts) = RococoIdentity::subs_of(RococoRelaySender::get()); + let (_, sub_accounts) = SubsOf::::get(RococoRelaySender::get()); assert_eq!(sub_accounts.len(), 0); let reserved_balance = RococoBalances::reserved_balance(RococoRelaySender::get()); diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs index 92f5d291ac84..689409fe5040 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/lib.rs @@ -40,7 +40,7 @@ mod imports { genesis::ED as PEOPLE_WESTEND_ED, people_westend_runtime::{ people, xcm_config::XcmConfig as PeopleWestendXcmConfig, - ExistentialDeposit as PeopleWestendExistentialDeposit, + ExistentialDeposit as PeopleWestendExistentialDeposit, Runtime as PeopleRuntime, }, PeopleWestendParaPallet as PeopleWestendPallet, }, @@ -48,8 +48,8 @@ mod imports { genesis::ED as WESTEND_ED, westend_runtime::{ xcm_config::XcmConfig as WestendXcmConfig, BasicDeposit, ByteDeposit, - MaxAdditionalFields, MaxSubAccounts, RuntimeOrigin as WestendOrigin, - SubAccountDeposit, + MaxAdditionalFields, MaxSubAccounts, Runtime as WestendRuntime, + RuntimeOrigin as WestendOrigin, SubAccountDeposit, }, WestendRelayPallet as WestendPallet, }, diff --git a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs index 28d1be853204..cfbf4d7d9580 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/people/people-westend/src/tests/reap_identity.rs @@ -41,7 +41,7 @@ use crate::imports::*; use frame_support::BoundedVec; use pallet_balances::Event as BalancesEvent; -use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent}; +use pallet_identity::{legacy::IdentityInfo, Data, Event as IdentityEvent, IdentityOf, SubsOf}; use people::{ BasicDeposit as BasicDepositParachain, ByteDeposit as ByteDepositParachain, IdentityInfo as IdentityInfoParachain, SubAccountDeposit as SubAccountDepositParachain, @@ -266,9 +266,9 @@ fn assert_set_id_parachain(id: &Identity) { // No amount should be reserved as deposit amounts are set to 0. let reserved_balance = PeopleWestendBalances::reserved_balance(PeopleWestendSender::get()); assert_eq!(reserved_balance, 0); - assert!(PeopleWestendIdentity::identity(PeopleWestendSender::get()).is_some()); + assert!(IdentityOf::::get(PeopleWestendSender::get()).is_some()); - let (_, sub_accounts) = PeopleWestendIdentity::subs_of(PeopleWestendSender::get()); + let (_, sub_accounts) = SubsOf::::get(PeopleWestendSender::get()); match id.subs { Subs::Zero => assert_eq!(sub_accounts.len(), 0), @@ -314,10 +314,10 @@ fn assert_reap_id_relay(total_deposit: Balance, id: &Identity) { ] ); // Identity should be gone. - assert!(PeopleWestendIdentity::identity(WestendRelaySender::get()).is_none()); + assert!(IdentityOf::::get(WestendRelaySender::get()).is_none()); // Subs should be gone. - let (_, sub_accounts) = WestendIdentity::subs_of(WestendRelaySender::get()); + let (_, sub_accounts) = SubsOf::::get(WestendRelaySender::get()); assert_eq!(sub_accounts.len(), 0); let reserved_balance = WestendBalances::reserved_balance(WestendRelaySender::get()); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index f09647854cd0..83bc12cf9b41 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -71,7 +71,7 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, EnsureSignedBy, }; -use pallet_asset_conversion_tx_payment::AssetConversionAdapter; +use pallet_asset_conversion_tx_payment::SwapAssetAdapter; use pallet_nfts::PalletFeatures; use parachains_common::{ impls::DealWithFees, @@ -798,11 +798,19 @@ impl pallet_collator_selection::Config for Runtime { type WeightInfo = weights::pallet_collator_selection::WeightInfo; } +parameter_types! { + pub StakingPot: AccountId = CollatorSelection::account_id(); +} + impl pallet_asset_conversion_tx_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Fungibles = LocalAndForeignAssets; - type OnChargeAssetTransaction = - AssetConversionAdapter; + type AssetId = xcm::v3::Location; + type OnChargeAssetTransaction = SwapAssetAdapter< + TokenLocationV3, + NativeAndAssets, + AssetConversion, + ResolveAssetTo, + >; } parameter_types! { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 178b886fc3e8..2d9de07f251f 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -55,7 +55,7 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, EnsureSignedBy, }; -use pallet_asset_conversion_tx_payment::AssetConversionAdapter; +use pallet_asset_conversion_tx_payment::SwapAssetAdapter; use pallet_nfts::{DestroyWitness, PalletFeatures}; use pallet_xcm::EnsureXcm; use parachains_common::{ @@ -787,11 +787,19 @@ impl pallet_collator_selection::Config for Runtime { type WeightInfo = weights::pallet_collator_selection::WeightInfo; } +parameter_types! { + pub StakingPot: AccountId = CollatorSelection::account_id(); +} + impl pallet_asset_conversion_tx_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Fungibles = LocalAndForeignAssets; - type OnChargeAssetTransaction = - AssetConversionAdapter; + type AssetId = xcm::v3::Location; + type OnChargeAssetTransaction = SwapAssetAdapter< + WestendLocationV3, + NativeAndAssets, + AssetConversion, + ResolveAssetTo, + >; } parameter_types! { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml index 987372984682..7a60a3f64840 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/Cargo.toml @@ -121,7 +121,6 @@ snowbridge-runtime-common = { workspace = true } bridge-hub-common = { workspace = true } [dev-dependencies] -static_assertions = { workspace = true, default-features = true } bridge-hub-test-utils = { workspace = true, default-features = true } bridge-runtime-common = { features = [ "integrity-test", diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_bulletin_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_bulletin_config.rs index d97e6a1d88e1..83b92918dc4f 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_bulletin_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_bulletin_config.rs @@ -28,7 +28,6 @@ use bp_messages::{ source_chain::FromBridgedChainMessagesDeliveryProof, target_chain::FromBridgedChainMessagesProof, LaneId, }; -use bp_runtime::Chain; use bridge_runtime_common::{ extensions::refund_relayer_extension::{ ActualFeeRefund, RefundBridgedMessages, RefundSignedExtensionAdapter, @@ -48,8 +47,6 @@ use xcm::{ use xcm_builder::BridgeBlobDispatcher; parameter_types! { - /// Bridge specific chain (network) identifier of the Rococo Bulletin Chain. - pub const RococoBulletinChainId: bp_runtime::ChainId = bp_polkadot_bulletin::PolkadotBulletin::ID; /// Interior location (relative to this runtime) of the with-RococoBulletin messages pallet. pub BridgeRococoToRococoBulletinMessagesPalletInstance: InteriorLocation = [ PalletInstance(::index() as u8) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_westend_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_westend_config.rs index fe854e20c244..9880e8a17c2b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_westend_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_westend_config.rs @@ -26,7 +26,6 @@ use bp_messages::{ source_chain::FromBridgedChainMessagesDeliveryProof, target_chain::FromBridgedChainMessagesProof, LaneId, }; -use bp_runtime::Chain; use bridge_runtime_common::{ extensions::refund_relayer_extension::{ ActualFeeRefund, RefundBridgedMessages, RefundSignedExtensionAdapter, @@ -47,7 +46,6 @@ use xcm::{ use xcm_builder::BridgeBlobDispatcher; parameter_types! { - pub const BridgeHubWestendChainId: bp_runtime::ChainId = bp_bridge_hub_westend::BridgeHubWestend::ID; pub BridgeRococoToWestendMessagesPalletInstance: InteriorLocation = [PalletInstance(::index() as u8)].into(); pub WestendGlobalConsensusNetwork: NetworkId = NetworkId::Westend; pub WestendGlobalConsensusNetworkLocation: Location = Location::new( diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 512c1199f439..062996ad4115 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -1416,7 +1416,8 @@ impl_runtime_apis! { impl BridgeMessagesConfig for Runtime { fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool { let bench_lane_id = >::bench_lane_id(); - let bridged_chain_id = bridge_to_westend_config::BridgeHubWestendChainId::get(); + use bp_runtime::Chain; + let bridged_chain_id =>::BridgedChain::ID; pallet_bridge_relayers::Pallet::::relayer_reward( relayer, bp_relayers::RewardsAccountParams::new( diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 2f11b4694e3b..8c077470ba1a 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -21,7 +21,6 @@ use super::{ }; use bp_messages::LaneId; use bp_relayers::{PayRewardFromAccount, RewardsAccountOwner, RewardsAccountParams}; -use bp_runtime::ChainId; use core::marker::PhantomData; use frame_support::{ parameter_types, @@ -212,7 +211,7 @@ impl xcm_executor::Config for XcmConfig { Self::AssetTransactor, crate::bridge_to_westend_config::WestendGlobalConsensusNetwork, crate::bridge_to_westend_config::AssetHubWestendParaId, - crate::bridge_to_westend_config::BridgeHubWestendChainId, + bp_bridge_hub_westend::BridgeHubWestend, crate::bridge_to_westend_config::AssetHubRococoToAssetHubWestendMessagesLane, >, XcmExportFeeToSibling< @@ -302,22 +301,22 @@ pub struct XcmExportFeeToRelayerRewardAccounts< AssetTransactor, DestNetwork, DestParaId, - DestBridgedChainId, + DestBridgedChain, BridgeLaneId, ->(PhantomData<(AssetTransactor, DestNetwork, DestParaId, DestBridgedChainId, BridgeLaneId)>); +>(PhantomData<(AssetTransactor, DestNetwork, DestParaId, DestBridgedChain, BridgeLaneId)>); impl< AssetTransactor: TransactAsset, DestNetwork: Get, DestParaId: Get, - DestBridgedChainId: Get, + DestBridgedChain: bp_runtime::Chain, BridgeLaneId: Get, > HandleFee for XcmExportFeeToRelayerRewardAccounts< AssetTransactor, DestNetwork, DestParaId, - DestBridgedChainId, + DestBridgedChain, BridgeLaneId, > { @@ -326,6 +325,8 @@ impl< if bridged_network == DestNetwork::get() && destination == [Parachain(DestParaId::get().into())]) { + let bridged_chain_id = DestBridgedChain::ID; + // We have 2 relayer rewards accounts: // - the SA of the source parachain on this BH: this pays the relayers for delivering // Source para -> Target Para message delivery confirmations @@ -337,7 +338,7 @@ impl< AccountId, >::rewards_account(RewardsAccountParams::new( BridgeLaneId::get(), - DestBridgedChainId::get(), + bridged_chain_id, RewardsAccountOwner::ThisChain, )); @@ -346,7 +347,7 @@ impl< AccountId, >::rewards_account(RewardsAccountParams::new( BridgeLaneId::get(), - DestBridgedChainId::get(), + bridged_chain_id, RewardsAccountOwner::BridgedChain, )); diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs index 1d3d9e55f7ee..ca0d89f038cb 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/tests/tests.rs @@ -147,7 +147,7 @@ mod bridge_hub_westend_tests { }; use bridge_hub_test_utils::test_cases::from_parachain; use bridge_to_westend_config::{ - BridgeHubWestendChainId, BridgeHubWestendLocation, WestendGlobalConsensusNetwork, + BridgeHubWestendLocation, WestendGlobalConsensusNetwork, WithBridgeHubWestendMessagesInstance, XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND, }; @@ -313,11 +313,14 @@ mod bridge_hub_westend_tests { } }), || ExportMessage { network: Westend, destination: [Parachain(bridge_to_westend_config::AssetHubWestendParaId::get().into())].into(), xcm: Xcm(vec![]) }, - XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND, Some((TokenLocation::get(), ExistentialDeposit::get()).into()), // value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer` Some((TokenLocation::get(), bp_bridge_hub_rococo::BridgeHubRococoBaseXcmFeeInRocs::get()).into()), - || PolkadotXcm::force_xcm_version(RuntimeOrigin::root(), Box::new(BridgeHubWestendLocation::get()), XCM_VERSION).expect("version saved!"), + || { + PolkadotXcm::force_xcm_version(RuntimeOrigin::root(), Box::new(BridgeHubWestendLocation::get()), XCM_VERSION).expect("version saved!"); + + XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND + }, ) } @@ -350,8 +353,7 @@ mod bridge_hub_westend_tests { _ => None, } }), - XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND, - || (), + || XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND, ) } @@ -363,11 +365,9 @@ mod bridge_hub_westend_tests { slot_durations(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID, - BridgeHubWestendChainId::get(), SIBLING_PARACHAIN_ID, Rococo, - XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND, - || (), + || XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND, construct_and_apply_extrinsic, ) } @@ -380,11 +380,9 @@ mod bridge_hub_westend_tests { slot_durations(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID, - BridgeHubWestendChainId::get(), SIBLING_PARACHAIN_ID, Rococo, - XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND, - || (), + || XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND, construct_and_apply_extrinsic, ) } @@ -454,9 +452,8 @@ mod bridge_hub_bulletin_tests { use bridge_common_config::BridgeGrandpaRococoBulletinInstance; use bridge_hub_test_utils::test_cases::from_grandpa_chain; use bridge_to_bulletin_config::{ - RococoBulletinChainId, RococoBulletinGlobalConsensusNetwork, - RococoBulletinGlobalConsensusNetworkLocation, WithRococoBulletinMessagesInstance, - XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN, + RococoBulletinGlobalConsensusNetwork, RococoBulletinGlobalConsensusNetworkLocation, + WithRococoBulletinMessagesInstance, XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN, }; // Para id of sibling chain used in tests. @@ -519,10 +516,13 @@ mod bridge_hub_bulletin_tests { destination: Here, xcm: Xcm(vec![]), }, - XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN, Some((TokenLocation::get(), ExistentialDeposit::get()).into()), None, - || PolkadotXcm::force_xcm_version(RuntimeOrigin::root(), Box::new(RococoBulletinGlobalConsensusNetworkLocation::get()), XCM_VERSION).expect("version saved!"), + || { + PolkadotXcm::force_xcm_version(RuntimeOrigin::root(), Box::new(RococoBulletinGlobalConsensusNetworkLocation::get()), XCM_VERSION).expect("version saved!"); + + XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN + }, ) } @@ -555,8 +555,7 @@ mod bridge_hub_bulletin_tests { _ => None, } }), - XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN, - || (), + || XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN, ) } @@ -567,11 +566,9 @@ mod bridge_hub_bulletin_tests { collator_session_keys(), slot_durations(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, - RococoBulletinChainId::get(), SIBLING_PARACHAIN_ID, Rococo, - XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN, - || (), + || XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN, construct_and_apply_extrinsic, ) } @@ -583,11 +580,9 @@ mod bridge_hub_bulletin_tests { collator_session_keys(), slot_durations(), bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, - RococoBulletinChainId::get(), SIBLING_PARACHAIN_ID, Rococo, - XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN, - || (), + || XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN, construct_and_apply_extrinsic, ) } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml index e2671d3d606d..4326cbf926d6 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml @@ -101,7 +101,6 @@ bridge-runtime-common = { workspace = true } bridge-hub-common = { workspace = true } [dev-dependencies] -static_assertions = { workspace = true, default-features = true } bridge-hub-test-utils = { workspace = true, default-features = true } bridge-runtime-common = { features = ["integrity-test"], workspace = true, default-features = true } sp-keyring = { workspace = true, default-features = true } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_rococo_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_rococo_config.rs index 42d5ef3eebdb..be4d40c2275f 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_rococo_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_rococo_config.rs @@ -25,7 +25,6 @@ use bp_messages::{ target_chain::FromBridgedChainMessagesProof, LaneId, }; use bp_parachains::SingleParaStoredHeaderDataBuilder; -use bp_runtime::Chain; use bridge_runtime_common::{ extensions::refund_relayer_extension::{ ActualFeeRefund, RefundBridgedMessages, RefundSignedExtensionAdapter, @@ -54,7 +53,6 @@ parameter_types! { pub const RococoBridgeParachainPalletName: &'static str = "Paras"; pub const MaxRococoParaHeadDataSize: u32 = bp_rococo::MAX_NESTED_PARACHAIN_HEAD_DATA_SIZE; - pub const BridgeHubRococoChainId: bp_runtime::ChainId = bp_bridge_hub_rococo::BridgeHubRococo::ID; pub BridgeWestendToRococoMessagesPalletInstance: InteriorLocation = [PalletInstance(::index() as u8)].into(); pub RococoGlobalConsensusNetwork: NetworkId = NetworkId::Rococo; pub RococoGlobalConsensusNetworkLocation: Location = Location::new( diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 5d4c35d6610a..42c768861bde 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -1100,7 +1100,8 @@ impl_runtime_apis! { impl BridgeMessagesConfig for Runtime { fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool { let bench_lane_id = >::bench_lane_id(); - let bridged_chain_id = bridge_to_rococo_config::BridgeHubRococoChainId::get(); + use bp_runtime::Chain; + let bridged_chain_id =>::BridgedChain::ID; pallet_bridge_relayers::Pallet::::relayer_reward( relayer, bp_relayers::RewardsAccountParams::new( diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/tests/tests.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/tests/tests.rs index 763271fd7af0..98a789eb4e00 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/tests/tests.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/tests/tests.rs @@ -27,9 +27,8 @@ use bridge_hub_westend_runtime::{ SignedExtra, TransactionPayment, UncheckedExtrinsic, }; use bridge_to_rococo_config::{ - BridgeGrandpaRococoInstance, BridgeHubRococoChainId, BridgeHubRococoLocation, - BridgeParachainRococoInstance, WithBridgeHubRococoMessagesInstance, - XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO, + BridgeGrandpaRococoInstance, BridgeHubRococoLocation, BridgeParachainRococoInstance, + WithBridgeHubRococoMessagesInstance, XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO, }; use codec::{Decode, Encode}; use frame_support::{dispatch::GetDispatchInfo, parameter_types, traits::ConstU8}; @@ -212,11 +211,14 @@ fn handle_export_message_from_system_parachain_add_to_outbound_queue_works() { } }), || ExportMessage { network: Rococo, destination: [Parachain(bridge_to_rococo_config::AssetHubRococoParaId::get().into())].into(), xcm: Xcm(vec![]) }, - XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO, Some((WestendLocation::get(), ExistentialDeposit::get()).into()), // value should be >= than value generated by `can_calculate_weight_for_paid_export_message_with_reserve_transfer` Some((WestendLocation::get(), bp_bridge_hub_westend::BridgeHubWestendBaseXcmFeeInWnds::get()).into()), - || PolkadotXcm::force_xcm_version(RuntimeOrigin::root(), Box::new(BridgeHubRococoLocation::get()), XCM_VERSION).expect("version saved!"), + || { + PolkadotXcm::force_xcm_version(RuntimeOrigin::root(), Box::new(BridgeHubRococoLocation::get()), XCM_VERSION).expect("version saved!"); + + XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO + }, ) } @@ -248,8 +250,7 @@ fn message_dispatch_routing_works() { _ => None, } }), - XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO, - || (), + || XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO, ) } @@ -260,11 +261,9 @@ fn relayed_incoming_message_works() { slot_durations(), bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID, bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID, - BridgeHubRococoChainId::get(), SIBLING_PARACHAIN_ID, Westend, - XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO, - || (), + || XCM_LANE_FOR_ASSET_HUB_WESTEND_TO_ASSET_HUB_ROCOCO, construct_and_apply_extrinsic, ) } diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_grandpa_chain.rs b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_grandpa_chain.rs index d6dfa93731a7..f2f0ccecba13 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_grandpa_chain.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_grandpa_chain.rs @@ -94,11 +94,9 @@ pub fn relayed_incoming_message_works( collator_session_key: CollatorSessionKeys, slot_durations: SlotDurations, runtime_para_id: u32, - bridged_chain_id: bp_runtime::ChainId, sibling_parachain_id: u32, local_relay_chain_id: NetworkId, - lane_id: LaneId, - prepare_configuration: impl Fn(), + prepare_configuration: impl Fn() -> LaneId, construct_and_apply_extrinsic: fn( sp_keyring::AccountKeyring, RuntimeCallOf, @@ -125,10 +123,11 @@ pub fn relayed_incoming_message_works( relayer_id_at_bridged_chain, message_destination, message_nonce, - xcm| { + xcm, + bridged_chain_id| { let relay_header_number = 5u32.into(); - prepare_configuration(); + let lane_id = prepare_configuration(); // start with bridged relay chain block#0 helpers::initialize_bridge_grandpa_pallet::( @@ -141,7 +140,6 @@ pub fn relayed_incoming_message_works( test_data::from_grandpa_chain::make_complex_relayer_delivery_proofs::< BridgedChainOf, ThisChainOf, - (), >( lane_id, xcm.into(), @@ -197,11 +195,9 @@ pub fn free_relay_extrinsic_works( collator_session_key: CollatorSessionKeys, slot_durations: SlotDurations, runtime_para_id: u32, - bridged_chain_id: bp_runtime::ChainId, sibling_parachain_id: u32, local_relay_chain_id: NetworkId, - lane_id: LaneId, - prepare_configuration: impl Fn(), + prepare_configuration: impl Fn() -> LaneId, construct_and_apply_extrinsic: fn( sp_keyring::AccountKeyring, RuntimeCallOf, @@ -235,8 +231,9 @@ pub fn free_relay_extrinsic_works( relayer_id_at_bridged_chain, message_destination, message_nonce, - xcm| { - prepare_configuration(); + xcm, + bridged_chain_id| { + let lane_id = prepare_configuration(); // start with bridged relay chain block#0 let initial_block_number = 0; @@ -266,7 +263,6 @@ pub fn free_relay_extrinsic_works( test_data::from_grandpa_chain::make_complex_relayer_delivery_proofs::< BridgedChainOf, ThisChainOf, - (), >( lane_id, xcm.into(), @@ -328,10 +324,8 @@ pub fn complex_relay_extrinsic_works( slot_durations: SlotDurations, runtime_para_id: u32, sibling_parachain_id: u32, - bridged_chain_id: bp_runtime::ChainId, local_relay_chain_id: NetworkId, - lane_id: LaneId, - prepare_configuration: impl Fn(), + prepare_configuration: impl Fn() -> LaneId, construct_and_apply_extrinsic: fn( sp_keyring::AccountKeyring, RuntimeCallOf, @@ -361,10 +355,11 @@ pub fn complex_relay_extrinsic_works( relayer_id_at_bridged_chain, message_destination, message_nonce, - xcm| { + xcm, + bridged_chain_id| { let relay_header_number = 1u32.into(); - prepare_configuration(); + let lane_id = prepare_configuration(); // start with bridged relay chain block#0 helpers::initialize_bridge_grandpa_pallet::( @@ -377,7 +372,6 @@ pub fn complex_relay_extrinsic_works( test_data::from_grandpa_chain::make_complex_relayer_delivery_proofs::< BridgedChainOf, ThisChainOf, - (), >( lane_id, xcm.into(), @@ -452,7 +446,6 @@ where test_data::from_grandpa_chain::make_complex_relayer_delivery_proofs::< BridgedChainOf, ThisChainOf, - (), >( LaneId::default(), vec![Instruction::<()>::ClearOrigin; 1_024].into(), @@ -557,7 +550,6 @@ where test_data::from_grandpa_chain::make_complex_relayer_delivery_proofs::< BridgedChainOf, ThisChainOf, - (), >( LaneId::default(), vec![Instruction::<()>::ClearOrigin; 1_024].into(), diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_parachain.rs b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_parachain.rs index 728b4e76b105..0988528c3f2a 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_parachain.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/from_parachain.rs @@ -104,11 +104,9 @@ pub fn relayed_incoming_message_works( slot_durations: SlotDurations, runtime_para_id: u32, bridged_para_id: u32, - bridged_chain_id: bp_runtime::ChainId, sibling_parachain_id: u32, local_relay_chain_id: NetworkId, - lane_id: LaneId, - prepare_configuration: impl Fn(), + prepare_configuration: impl Fn() -> LaneId, construct_and_apply_extrinsic: fn( sp_keyring::AccountKeyring, ::RuntimeCall, @@ -138,11 +136,12 @@ pub fn relayed_incoming_message_works( relayer_id_at_bridged_chain, message_destination, message_nonce, - xcm| { + xcm, + bridged_chain_id| { let para_header_number = 5; let relay_header_number = 1; - prepare_configuration(); + let lane_id = prepare_configuration(); // start with bridged relay chain block#0 helpers::initialize_bridge_grandpa_pallet::( @@ -162,7 +161,6 @@ pub fn relayed_incoming_message_works( >::BridgedChain, BridgedChainOf, ThisChainOf, - (), >( lane_id, xcm.into(), @@ -234,11 +232,9 @@ pub fn free_relay_extrinsic_works( slot_durations: SlotDurations, runtime_para_id: u32, bridged_para_id: u32, - bridged_chain_id: bp_runtime::ChainId, sibling_parachain_id: u32, local_relay_chain_id: NetworkId, - lane_id: LaneId, - prepare_configuration: impl Fn(), + prepare_configuration: impl Fn() -> LaneId, construct_and_apply_extrinsic: fn( sp_keyring::AccountKeyring, ::RuntimeCall, @@ -275,8 +271,9 @@ pub fn free_relay_extrinsic_works( relayer_id_at_bridged_chain, message_destination, message_nonce, - xcm| { - prepare_configuration(); + xcm, + bridged_chain_id| { + let lane_id = prepare_configuration(); // start with bridged relay chain block#0 let initial_block_number = 0; @@ -315,7 +312,6 @@ pub fn free_relay_extrinsic_works( >::BridgedChain, BridgedChainOf, ThisChainOf, - (), >( lane_id, xcm.into(), @@ -399,10 +395,8 @@ pub fn complex_relay_extrinsic_works( 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, - prepare_configuration: impl Fn(), + prepare_configuration: impl Fn() -> LaneId, construct_and_apply_extrinsic: fn( sp_keyring::AccountKeyring, ::RuntimeCall, @@ -435,11 +429,12 @@ pub fn complex_relay_extrinsic_works( relayer_id_at_bridged_chain, message_destination, message_nonce, - xcm| { + xcm, + bridged_chain_id| { let para_header_number = 5; let relay_header_number = 1; - prepare_configuration(); + let lane_id = prepare_configuration(); // start with bridged relay chain block#0 helpers::initialize_bridge_grandpa_pallet::( @@ -459,7 +454,6 @@ pub fn complex_relay_extrinsic_works( >::BridgedChain, BridgedChainOf, ThisChainOf, - (), >( lane_id, xcm.into(), @@ -557,7 +551,6 @@ where >::BridgedChain, BridgedChainOf, ThisChainOf, - (), >( LaneId::default(), vec![Instruction::<()>::ClearOrigin; 1_024].into(), @@ -628,7 +621,6 @@ where >::BridgedChain, BridgedChainOf, ThisChainOf, - (), >( LaneId::default(), 1, @@ -691,7 +683,6 @@ where >::BridgedChain, BridgedChainOf, ThisChainOf, - (), >( LaneId::default(), vec![Instruction::<()>::ClearOrigin; 1_024].into(), @@ -747,7 +738,6 @@ where >::BridgedChain, BridgedChainOf, ThisChainOf, - (), >( LaneId::default(), 1, diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/helpers.rs b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/helpers.rs index 78b8a170f0d4..c4b5e5583baa 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/helpers.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/helpers.rs @@ -22,6 +22,7 @@ use asset_test_utils::BasicParachainRuntime; use bp_messages::{LaneId, MessageNonce}; use bp_polkadot_core::parachains::{ParaHash, ParaId}; use bp_relayers::RewardsAccountParams; +use bp_runtime::Chain; use codec::Decode; use core::marker::PhantomData; use frame_support::{ @@ -267,6 +268,7 @@ pub fn relayed_incoming_message_works( InteriorLocation, MessageNonce, Xcm<()>, + bp_runtime::ChainId, ) -> CallsAndVerifiers, ) where Runtime: BasicParachainRuntime + cumulus_pallet_xcmp_queue::Config + BridgeMessagesConfig, @@ -278,6 +280,7 @@ pub fn relayed_incoming_message_works( let relayer_at_target = Bob; let relayer_id_on_target: AccountId32 = relayer_at_target.public().into(); let relayer_id_on_source = relayer_id_at_bridged_chain::(); + let bridged_chain_id = Runtime::BridgedChain::ID; assert_ne!(runtime_para_id, sibling_parachain_id); @@ -339,6 +342,7 @@ pub fn relayed_incoming_message_works( message_destination, message_nonce, xcm.clone().into(), + bridged_chain_id, ), ); diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/mod.rs index bc1c7ec5e032..a36a74dbbbc3 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/mod.rs @@ -320,10 +320,9 @@ pub fn handle_export_message_from_system_parachain_to_outbound_queue_works< dyn Fn(Vec) -> Option>, >, export_message_instruction: fn() -> Instruction, - expected_lane_id: LaneId, existential_deposit: Option, maybe_paid_export_message: Option, - prepare_configuration: impl Fn(), + prepare_configuration: impl Fn() -> LaneId, ) where Runtime: BasicParachainRuntime + BridgeMessagesConfig, XcmConfig: xcm_executor::Config, @@ -333,7 +332,7 @@ pub fn handle_export_message_from_system_parachain_to_outbound_queue_works< let sibling_parachain_location = Location::new(1, [Parachain(sibling_parachain_id)]); run_test::(collator_session_key, runtime_para_id, vec![], || { - prepare_configuration(); + let expected_lane_id = prepare_configuration(); // check queue before assert_eq!( @@ -430,8 +429,7 @@ pub fn message_dispatch_routing_works< unwrap_cumulus_pallet_xcmp_queue_event: Box< dyn Fn(Vec) -> Option>, >, - expected_lane_id: LaneId, - prepare_configuration: impl Fn(), + prepare_configuration: impl Fn() -> LaneId, ) where Runtime: BasicParachainRuntime + cumulus_pallet_xcmp_queue::Config @@ -459,7 +457,7 @@ pub fn message_dispatch_routing_works< assert_ne!(runtime_para_id, sibling_parachain_id); run_test::(collator_session_key, runtime_para_id, vec![], || { - prepare_configuration(); + let expected_lane_id = prepare_configuration(); let mut alice = [0u8; 32]; alice[0] = 1; diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/from_grandpa_chain.rs b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/from_grandpa_chain.rs index c61a31e5454b..5c1dc492a9d2 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/from_grandpa_chain.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/from_grandpa_chain.rs @@ -152,13 +152,9 @@ where } /// Prepare storage proofs of messages, stored at the (bridged) source GRANDPA chain. -pub fn make_complex_relayer_delivery_proofs< - BridgedChain, - ThisChainWithMessages, - InnerXcmRuntimeCall, ->( +pub fn make_complex_relayer_delivery_proofs( lane_id: LaneId, - xcm_message: Xcm, + xcm_message: Xcm<()>, message_nonce: MessageNonce, message_destination: Junctions, header_number: BlockNumberOf, diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/from_parachain.rs b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/from_parachain.rs index 897fe0d0b0f1..b99c275bd0df 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/from_parachain.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/from_parachain.rs @@ -195,10 +195,9 @@ pub fn make_complex_relayer_delivery_proofs< BridgedRelayChain, BridgedParachain, ThisChainWithMessages, - InnerXcmRuntimeCall, >( lane_id: LaneId, - xcm_message: Xcm, + xcm_message: Xcm<()>, message_nonce: MessageNonce, message_destination: Junctions, para_header_number: u32, @@ -267,7 +266,6 @@ pub fn make_complex_relayer_confirmation_proofs< BridgedRelayChain, BridgedParachain, ThisChainWithMessages, - InnerXcmRuntimeCall, >( lane_id: LaneId, para_header_number: u32, diff --git a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/mod.rs b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/mod.rs index ee3fc1ed2c41..106eacd799ca 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/mod.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_data/mod.rs @@ -32,20 +32,16 @@ use bp_messages::MessageNonce; use bp_runtime::BasicOperatingMode; use bp_test_utils::authority_list; use xcm::GetVersion; -use xcm_builder::{HaulBlob, HaulBlobError, HaulBlobExporter}; +use xcm_builder::{BridgeMessage, HaulBlob, HaulBlobError, HaulBlobExporter}; use xcm_executor::traits::{validate_export, ExportXcm}; -pub fn prepare_inbound_xcm( - xcm_message: Xcm, - destination: InteriorLocation, -) -> Vec { +pub fn prepare_inbound_xcm(xcm_message: Xcm<()>, destination: InteriorLocation) -> Vec { let location = xcm::VersionedInteriorLocation::from(destination); - let xcm = xcm::VersionedXcm::::from(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() + let xcm = xcm::VersionedXcm::<()>::from(xcm_message); + + // (double encoding, because `.encode()` is called on original Xcm BLOB when it is pushed to the + // storage) + BridgeMessage { universal_dest: location, message: xcm }.encode().encode() } /// Helper that creates InitializationData mock data, that can be used to initialize bridge diff --git a/cumulus/polkadot-parachain/src/service.rs b/cumulus/polkadot-parachain/src/service.rs index ef01f7f1f6a6..80698a2d7115 100644 --- a/cumulus/polkadot-parachain/src/service.rs +++ b/cumulus/polkadot-parachain/src/service.rs @@ -257,7 +257,10 @@ pub(crate) trait NodeSpec { 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::<_, _, Net>::new(¶chain_config.network); + let net_config = FullNetworkConfiguration::<_, _, Net>::new( + ¶chain_config.network, + prometheus_registry.clone(), + ); let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = build_network(BuildNetworkParams { diff --git a/cumulus/test/service/src/lib.rs b/cumulus/test/service/src/lib.rs index 51cdebbaf54e..503c2f24fd54 100644 --- a/cumulus/test/service/src/lib.rs +++ b/cumulus/test/service/src/lib.rs @@ -353,7 +353,11 @@ 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 prometheus_registry = parachain_config.prometheus_registry().cloned(); + let net_config = FullNetworkConfiguration::::new( + ¶chain_config.network, + prometheus_registry.clone(), + ); let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = build_network(BuildNetworkParams { @@ -372,8 +376,6 @@ where }) .await?; - let prometheus_registry = parachain_config.prometheus_registry().cloned(); - let keystore = params.keystore_container.keystore(); let rpc_builder = { let client = client.clone(); @@ -891,7 +893,6 @@ pub fn node_config( announce_block: true, data_path: root, base_path, - informant_output_format: Default::default(), wasm_runtime_overrides: None, runtime_cache_size: 2, }) diff --git a/polkadot/node/core/approval-voting/benches/approval-voting-regression-bench.rs b/polkadot/node/core/approval-voting/benches/approval-voting-regression-bench.rs index 687063dd0eb3..a18e667253d0 100644 --- a/polkadot/node/core/approval-voting/benches/approval-voting-regression-bench.rs +++ b/polkadot/node/core/approval-voting/benches/approval-voting-regression-bench.rs @@ -77,12 +77,12 @@ fn main() -> Result<(), String> { // We expect no variance for received and sent // but use 0.001 because we operate with floats messages.extend(average_usage.check_network_usage(&[ - ("Received from peers", 52942.4600, 0.001), - ("Sent to peers", 63547.0330, 0.001), + ("Received from peers", 52941.6071, 0.001), + ("Sent to peers", 63810.1859, 0.001), ])); messages.extend(average_usage.check_cpu_usage(&[ - ("approval-distribution", 7.4075, 0.1), - ("approval-voting", 9.9873, 0.1), + ("approval-distribution", 6.3912, 0.1), + ("approval-voting", 10.0578, 0.1), ])); if messages.is_empty() { diff --git a/polkadot/node/service/src/fake_runtime_api.rs b/polkadot/node/service/src/fake_runtime_api.rs index e971830c95cb..cdef39d5bdf1 100644 --- a/polkadot/node/service/src/fake_runtime_api.rs +++ b/polkadot/node/service/src/fake_runtime_api.rs @@ -252,12 +252,37 @@ sp_api::impl_runtime_apis! { unimplemented!() } + fn submit_report_fork_voting_unsigned_extrinsic( + _: sp_consensus_beefy::ForkVotingProof< + ::Header, + BeefyId, + sp_runtime::OpaqueValue + >, + _: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + unimplemented!() + } + + fn submit_report_future_block_voting_unsigned_extrinsic( + _: sp_consensus_beefy::FutureBlockVotingProof, + _: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + unimplemented!() + } + fn generate_key_ownership_proof( _: sp_consensus_beefy::ValidatorSetId, _: BeefyId, ) -> Option { unimplemented!() } + + fn generate_ancestry_proof( + _: BlockNumber, + _: Option, + ) -> Option { + unimplemented!() + } } impl sp_mmr_primitives::MmrApi for Runtime { diff --git a/polkadot/node/service/src/lib.rs b/polkadot/node/service/src/lib.rs index b4f63bd2aa06..5ca566d2c962 100644 --- a/polkadot/node/service/src/lib.rs +++ b/polkadot/node/service/src/lib.rs @@ -838,8 +838,10 @@ pub fn new_full< let auth_disc_publish_non_global_ips = config.network.allow_non_globals_in_dht; let auth_disc_public_addresses = config.network.public_addresses.clone(); - let mut net_config = - sc_network::config::FullNetworkConfiguration::<_, _, Network>::new(&config.network); + let mut net_config = sc_network::config::FullNetworkConfiguration::<_, _, Network>::new( + &config.network, + config.prometheus_config.as_ref().map(|cfg| cfg.registry.clone()), + ); let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); let peer_store_handle = net_config.peer_store_handle(); diff --git a/polkadot/node/subsystem-bench/src/lib/approval/mod.rs b/polkadot/node/subsystem-bench/src/lib/approval/mod.rs index 4ac044ea3459..404df2f8c653 100644 --- a/polkadot/node/subsystem-bench/src/lib/approval/mod.rs +++ b/polkadot/node/subsystem-bench/src/lib/approval/mod.rs @@ -28,6 +28,8 @@ use crate::{ dummy_builder, environment::{TestEnvironment, TestEnvironmentDependencies, MAX_TIME_OF_FLIGHT}, mock::{ + availability_recovery::MockAvailabilityRecovery, + candidate_validation::MockCandidateValidation, chain_api::{ChainApiState, MockChainApi}, network_bridge::{MockNetworkBridgeRx, MockNetworkBridgeTx}, runtime_api::{MockRuntimeApi, MockRuntimeApiCoreState}, @@ -59,13 +61,14 @@ use polkadot_node_subsystem_types::messages::{ApprovalDistributionMessage, Appro use polkadot_node_subsystem_util::metrics::Metrics; use polkadot_overseer::Handle as OverseerHandleReal; use polkadot_primitives::{ - BlockNumber, CandidateEvent, CandidateIndex, CandidateReceipt, Hash, Header, Slot, + BlockNumber, CandidateEvent, CandidateIndex, CandidateReceipt, Hash, Header, Slot, ValidatorId, ValidatorIndex, ASSIGNMENT_KEY_TYPE_ID, }; use prometheus::Registry; use sc_keystore::LocalKeystore; use sc_service::SpawnTaskHandle; use serde::{Deserialize, Serialize}; +use sp_application_crypto::AppCrypto; use sp_consensus_babe::Epoch as BabeEpoch; use sp_core::H256; use sp_keystore::Keystore; @@ -792,6 +795,12 @@ fn build_overseer( Some(state.test_authorities.key_seeds.get(NODE_UNDER_TEST as usize).unwrap().as_str()), ) .unwrap(); + keystore + .sr25519_generate_new( + ValidatorId::ID, + Some(state.test_authorities.key_seeds.get(NODE_UNDER_TEST as usize).unwrap().as_str()), + ) + .unwrap(); let system_clock = PastSystemClock::new(SystemClock {}, state.delta_tick_from_generated.clone()); @@ -831,7 +840,9 @@ fn build_overseer( .replace_chain_selection(|_| mock_chain_selection) .replace_runtime_api(|_| mock_runtime_api) .replace_network_bridge_tx(|_| mock_tx_bridge) - .replace_network_bridge_rx(|_| mock_rx_bridge); + .replace_network_bridge_rx(|_| mock_rx_bridge) + .replace_availability_recovery(|_| MockAvailabilityRecovery::new()) + .replace_candidate_validation(|_| MockCandidateValidation::new()); let (overseer, raw_handle) = dummy.build_with_connector(overseer_connector).expect("Should not fail"); diff --git a/polkadot/node/subsystem-bench/src/lib/mock/availability_recovery.rs b/polkadot/node/subsystem-bench/src/lib/mock/availability_recovery.rs new file mode 100644 index 000000000000..713226de6ad8 --- /dev/null +++ b/polkadot/node/subsystem-bench/src/lib/mock/availability_recovery.rs @@ -0,0 +1,73 @@ +// Copyright (C) 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 generic mock availability recovery suitable to be used in benchmarks. + +use std::sync::Arc; + +use futures::FutureExt; +use polkadot_node_primitives::{AvailableData, BlockData, PoV}; +use polkadot_node_subsystem::{ + messages::AvailabilityRecoveryMessage, overseer, SpawnedSubsystem, SubsystemError, +}; +use polkadot_node_subsystem_types::OverseerSignal; +use polkadot_primitives::{Hash, HeadData, PersistedValidationData}; + +pub struct MockAvailabilityRecovery {} + +impl MockAvailabilityRecovery { + pub fn new() -> Self { + Self {} + } +} + +#[overseer::subsystem(AvailabilityRecovery, error=SubsystemError, prefix=self::overseer)] +impl MockAvailabilityRecovery { + fn start(self, ctx: Context) -> SpawnedSubsystem { + let future = self.run(ctx).map(|_| Ok(())).boxed(); + + SpawnedSubsystem { name: "test-environment", future } + } +} + +#[overseer::contextbounds(AvailabilityRecovery, prefix = self::overseer)] +impl MockAvailabilityRecovery { + async fn run(self, mut ctx: Context) { + loop { + let msg = ctx.recv().await.expect("Overseer never fails us"); + match msg { + orchestra::FromOrchestra::Signal(signal) => + if signal == OverseerSignal::Conclude { + return + }, + orchestra::FromOrchestra::Communication { msg } => match msg { + AvailabilityRecoveryMessage::RecoverAvailableData(_, _, _, _, tx) => { + let available_data = AvailableData { + pov: Arc::new(PoV { block_data: BlockData(Vec::new()) }), + validation_data: PersistedValidationData { + parent_head: HeadData(Vec::new()), + relay_parent_number: 0, + relay_parent_storage_root: Hash::default(), + max_pov_size: 2, + }, + }; + tx.send(Ok(available_data)).unwrap(); + }, + }, + } + } + } +} diff --git a/polkadot/node/subsystem-bench/src/lib/mock/candidate_validation.rs b/polkadot/node/subsystem-bench/src/lib/mock/candidate_validation.rs new file mode 100644 index 000000000000..941fac2a38c6 --- /dev/null +++ b/polkadot/node/subsystem-bench/src/lib/mock/candidate_validation.rs @@ -0,0 +1,74 @@ +// Copyright (C) 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 generic mock candidate validation subsystem suitable for using in benchmarks, it +//! is responding with candidate valid for every request. + +use futures::FutureExt; +use polkadot_node_primitives::ValidationResult; +use polkadot_node_subsystem::{ + messages::CandidateValidationMessage, overseer, SpawnedSubsystem, SubsystemError, +}; +use polkadot_node_subsystem_types::OverseerSignal; +use polkadot_primitives::{CandidateCommitments, Hash, HeadData, PersistedValidationData}; + +pub struct MockCandidateValidation {} + +impl MockCandidateValidation { + pub fn new() -> Self { + Self {} + } +} + +#[overseer::subsystem(CandidateValidation, error=SubsystemError, prefix=self::overseer)] +impl MockCandidateValidation { + fn start(self, ctx: Context) -> SpawnedSubsystem { + let future = self.run(ctx).map(|_| Ok(())).boxed(); + + SpawnedSubsystem { name: "test-environment", future } + } +} + +#[overseer::contextbounds(CandidateValidation, prefix = self::overseer)] +impl MockCandidateValidation { + async fn run(self, mut ctx: Context) { + loop { + let msg = ctx.recv().await.expect("Overseer never fails us"); + match msg { + orchestra::FromOrchestra::Signal(signal) => + if signal == OverseerSignal::Conclude { + return + }, + orchestra::FromOrchestra::Communication { msg } => match msg { + CandidateValidationMessage::ValidateFromExhaustive { + response_sender, .. + } => response_sender + .send(Ok(ValidationResult::Valid( + CandidateCommitments::default(), + PersistedValidationData { + parent_head: HeadData(Vec::new()), + relay_parent_number: 0, + relay_parent_storage_root: Hash::default(), + max_pov_size: 2, + }, + ))) + .unwrap(), + _ => unimplemented!("Unexpected chain-api message"), + }, + } + } + } +} diff --git a/polkadot/node/subsystem-bench/src/lib/mock/mod.rs b/polkadot/node/subsystem-bench/src/lib/mock/mod.rs index 12766374bfa9..da4ac05e33b7 100644 --- a/polkadot/node/subsystem-bench/src/lib/mock/mod.rs +++ b/polkadot/node/subsystem-bench/src/lib/mock/mod.rs @@ -19,7 +19,9 @@ use polkadot_node_subsystem_types::Hash; use sp_consensus::SyncOracle; pub mod av_store; +pub mod availability_recovery; pub mod candidate_backing; +pub mod candidate_validation; pub mod chain_api; pub mod dummy; pub mod network_bridge; diff --git a/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs b/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs index ee45ea05c925..61523de1f1b5 100644 --- a/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs +++ b/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs @@ -26,9 +26,9 @@ use polkadot_node_subsystem::{ }; use polkadot_node_subsystem_types::OverseerSignal; use polkadot_primitives::{ - node_features, AsyncBackingParams, CandidateEvent, CandidateReceipt, CoreState, GroupIndex, - GroupRotationInfo, IndexedVec, NodeFeatures, OccupiedCore, ScheduledCore, SessionIndex, - SessionInfo, ValidationCode, ValidatorIndex, + node_features, ApprovalVotingParams, AsyncBackingParams, CandidateEvent, CandidateReceipt, + CoreState, GroupIndex, GroupRotationInfo, IndexedVec, NodeFeatures, OccupiedCore, + ScheduledCore, SessionIndex, SessionInfo, ValidationCode, ValidatorIndex, }; use sp_consensus_babe::Epoch as BabeEpoch; use sp_core::H256; @@ -297,6 +297,13 @@ impl MockRuntimeApi { gum::error!(target: LOG_TARGET, ?err, "validation code wasn't received"); } }, + RuntimeApiMessage::Request( + _parent, + RuntimeApiRequest::ApprovalVotingParams(_, tx), + ) => + if let Err(err) = tx.send(Ok(ApprovalVotingParams::default())) { + gum::error!(target: LOG_TARGET, ?err, "Voting params weren't received"); + }, // Long term TODO: implement more as needed. message => { unimplemented!("Unexpected runtime-api message: {:?}", message) diff --git a/polkadot/node/test/service/src/lib.rs b/polkadot/node/test/service/src/lib.rs index 35156a3a9372..a4e58253bb17 100644 --- a/polkadot/node/test/service/src/lib.rs +++ b/polkadot/node/test/service/src/lib.rs @@ -232,7 +232,6 @@ pub fn node_config( announce_block: true, data_path: root, base_path, - informant_output_format: Default::default(), } } diff --git a/polkadot/runtime/common/src/impls.rs b/polkadot/runtime/common/src/impls.rs index 7fdff814a2d5..b6a93cf53685 100644 --- a/polkadot/runtime/common/src/impls.rs +++ b/polkadot/runtime/common/src/impls.rs @@ -51,7 +51,7 @@ where ::AccountId: From, ::AccountId: Into, { - fn on_unbalanceds( + fn on_unbalanceds( mut fees_then_tips: impl Iterator>>, ) { if let Some(fees) = fees_then_tips.next() { diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 058b9c279f2a..2a1cb58fc17f 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -2054,7 +2054,7 @@ sp_api::impl_runtime_apis! { } } - #[api_version(4)] + #[api_version(5)] impl sp_consensus_beefy::BeefyApi for Runtime { fn beefy_genesis() -> Option { pallet_beefy::GenesisBlock::::get() @@ -2080,6 +2080,31 @@ sp_api::impl_runtime_apis! { ) } + fn submit_report_fork_voting_unsigned_extrinsic( + equivocation_proof: + sp_consensus_beefy::ForkVotingProof< + ::Header, + BeefyId, + sp_runtime::OpaqueValue + >, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_fork_voting_report( + equivocation_proof.try_into()?, + key_owner_proof.decode()?, + ) + } + + fn submit_report_future_block_voting_unsigned_extrinsic( + equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_future_block_voting_report( + equivocation_proof, + key_owner_proof.decode()?, + ) + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, authority_id: BeefyId, @@ -2090,6 +2115,17 @@ sp_api::impl_runtime_apis! { .map(|p| p.encode()) .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new) } + + fn generate_ancestry_proof( + prev_block_number: BlockNumber, + best_known_block_number: Option, + ) -> Option { + use sp_consensus_beefy::AncestryHelper; + + MmrLeaf::generate_proof(prev_block_number, best_known_block_number) + .map(|p| p.encode()) + .map(sp_runtime::OpaqueValue::new) + } } #[api_version(2)] diff --git a/polkadot/runtime/test-runtime/src/lib.rs b/polkadot/runtime/test-runtime/src/lib.rs index a8a369a68e66..8e34320d38f2 100644 --- a/polkadot/runtime/test-runtime/src/lib.rs +++ b/polkadot/runtime/test-runtime/src/lib.rs @@ -1029,12 +1029,38 @@ sp_api::impl_runtime_apis! { None } + fn submit_report_fork_voting_unsigned_extrinsic( + _equivocation_proof: + sp_consensus_beefy::ForkVotingProof< + ::Header, + BeefyId, + sp_runtime::OpaqueValue + >, + _key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + None + } + + fn submit_report_future_block_voting_unsigned_extrinsic( + _equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof, + _key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + None + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, _authority_id: BeefyId, ) -> Option { None } + + fn generate_ancestry_proof( + _prev_block_number: BlockNumber, + _best_known_block_number: Option, + ) -> Option { + None + } } impl mmr::MmrApi for Runtime { diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 13a69050c342..e582598d9d85 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -630,7 +630,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { ::MaxWeight; type MinerConfig = Self; type SlashHandler = (); // burn slashes - type RewardHandler = (); // nothing to do upon rewards + type RewardHandler = (); // rewards are minted from the void type BetterSignedThreshold = (); type OffchainRepeat = OffchainRepeat; type MinerTxPriority = NposSolutionPriority; @@ -2109,7 +2109,7 @@ sp_api::impl_runtime_apis! { } } - #[api_version(4)] + #[api_version(5)] impl sp_consensus_beefy::BeefyApi for Runtime { fn beefy_genesis() -> Option { pallet_beefy::GenesisBlock::::get() @@ -2135,6 +2135,31 @@ sp_api::impl_runtime_apis! { ) } + fn submit_report_fork_voting_unsigned_extrinsic( + equivocation_proof: + sp_consensus_beefy::ForkVotingProof< + ::Header, + BeefyId, + sp_runtime::OpaqueValue + >, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_fork_voting_report( + equivocation_proof.try_into()?, + key_owner_proof.decode()?, + ) + } + + fn submit_report_future_block_voting_unsigned_extrinsic( + equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_future_block_voting_report( + equivocation_proof, + key_owner_proof.decode()?, + ) + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, authority_id: BeefyId, @@ -2145,6 +2170,17 @@ sp_api::impl_runtime_apis! { .map(|p| p.encode()) .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new) } + + fn generate_ancestry_proof( + prev_block_number: BlockNumber, + best_known_block_number: Option, + ) -> Option { + use sp_consensus_beefy::AncestryHelper; + + BeefyMmrLeaf::generate_proof(prev_block_number, best_known_block_number) + .map(|p| p.encode()) + .map(sp_runtime::OpaqueValue::new) + } } impl mmr::MmrApi for Runtime { diff --git a/prdoc/pr_2923.prdoc b/prdoc/pr_2923.prdoc new file mode 100644 index 000000000000..88bf1d48dd84 --- /dev/null +++ b/prdoc/pr_2923.prdoc @@ -0,0 +1,16 @@ +title: "Use `console` crate instead of `ansi_term`" + +doc: + - audience: Node Dev + description: | + This PR replace obsoleted `ansi_term` to `console`. + +crates: + - name: relay-utils + bump: patch + - name: sc-informant + bump: patch + - name: sc-tracing + bump: patch + - name: sc-service + bump: major diff --git a/prdoc/pr_4488.prdoc b/prdoc/pr_4488.prdoc new file mode 100644 index 000000000000..d0b6a877be6b --- /dev/null +++ b/prdoc/pr_4488.prdoc @@ -0,0 +1,25 @@ +title: "Tx Payment: drop ED requirements for tx payments with exchangeable asset" + +doc: + - audience: Runtime Dev + description: | + Drop the Existential Deposit requirement for the asset amount exchangeable for the fee asset + (eg. DOT/KSM) during transaction payments. + + This achieved by using `SwapCredit` implementation of asset conversion, which works with + imbalances and does not require a temporary balance account within the transaction payment. + + This is a breaking change for the `pallet-asset-conversion-tx-payment` pallet, use examples + from PR for the migration. + +crates: + - name: pallet-asset-conversion-tx-payment + bump: major + - name: pallet-transaction-payment + bump: patch + - name: pallet-asset-conversion + bump: patch + - name: asset-hub-rococo-runtime + bump: patch + - name: asset-hub-westend-runtime + bump: patch diff --git a/prdoc/pr_4564.prdoc b/prdoc/pr_4564.prdoc new file mode 100644 index 000000000000..896e49ee6b9f --- /dev/null +++ b/prdoc/pr_4564.prdoc @@ -0,0 +1,32 @@ +title: "Make `OnUnbalanced::on_unbalanceds` work with `fungibles` `imbalances`" + +doc: + - audience: Runtime Dev + description: | + The `on_unbalanceds` function of `OnUnbalanced` trait accepts the `fungibles` `imbalances` + imbalances. This is done by replacing the `Imbalance` trait bound on imbalance type with + the `TryMerge` trait bound. The `TryMerge` trait is implemented for all imbalance types. + + ### Migration for `OnUnbalanced` trait implementations: + In case if you have a custom implementation of `on_unbalanceds` trait function, remove + it's `` type argument. + + ### Migration for custom imbalance types: + If you have your own imbalance types implementations, implement the `TryMerge` trait for it + introduced with this update. + +crates: + - name: frame-support + bump: major + - name: pallet-balances + bump: minor + - name: pallet-asset-conversion-tx-payment + bump: patch + - name: pallet-transaction-payment + bump: patch + - name: kitchensink-runtime + bump: patch + - name: polkadot-runtime-common + bump: patch + - name: parachains-common + bump: minor diff --git a/prdoc/pr_4586.prdoc b/prdoc/pr_4586.prdoc new file mode 100644 index 000000000000..46d166d0f977 --- /dev/null +++ b/prdoc/pr_4586.prdoc @@ -0,0 +1,22 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Removed `pallet::getter` usage from pallet-identity + +doc: + - audience: Runtime Dev + description: | + This PR removed the `pallet::getter`s from `pallet-identity`. + The syntax `StorageItem::::get()` should be used instead. + +crates: + - name: pallet-identity + bump: minor + - name: pallet-alliance + bump: none + - name: kitchensink-runtime + bump: none + - name: people-rococo-integration-tests + bump: none + - name: people-westend-integration-tests + bump: none diff --git a/prdoc/pr_4613.prdoc b/prdoc/pr_4613.prdoc new file mode 100644 index 000000000000..e6b2e6adc612 --- /dev/null +++ b/prdoc/pr_4613.prdoc @@ -0,0 +1,10 @@ +title: "pallet-conviction-voting: Include events for vote and remove vote" + +doc: + - audience: Runtime User + description: | + Introduce event called `Voted: { who: T::AccountId, vote: AccountVote> }` and `VoteRemoved: { who: T::AccountId, vote: AccountVote> }` + +crates: + - name: pallet-conviction-voting + bump: major diff --git a/prdoc/pr_4970.prdoc b/prdoc/pr_4970.prdoc new file mode 100644 index 000000000000..d86f1af1e860 --- /dev/null +++ b/prdoc/pr_4970.prdoc @@ -0,0 +1,14 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: "Remove `pallet::getter` usage from the transaction-payment pallet" + +doc: + - audience: Runtime Dev + description: | + This PR removes the `pallet::getter`s from `pallet-transaction-payment`. + The syntax `StorageItem::::get()` should be used instead. + +crates: + - name: pallet-transaction-payment + bump: minor diff --git a/prdoc/pr_4993.prdoc b/prdoc/pr_4993.prdoc new file mode 100644 index 000000000000..d822d5cd6c76 --- /dev/null +++ b/prdoc/pr_4993.prdoc @@ -0,0 +1,27 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Added BEEFY equivocation-related methods to BeefyApi + +doc: + - audience: Node Dev + description: | + This PR adds the `generate_ancestry_proof`, `submit_report_fork_voting_unsigned_extrinsic` and + `submit_report_future_block_voting_unsigned_extrinsic` to `BeefyApi` and bumps the `BeefyApi` version + from 4 to 5. + +crates: + - name: pallet-beefy + bump: minor + - name: pallet-beefy-mmr + bump: minor + - name: kitchensink-runtime + bump: major + - name: rococo-runtime + bump: major + - name: westend-runtime + bump: major + - name: sp-consensus-beefy + bump: minor + - name: polkadot-service + bump: patch diff --git a/prdoc/pr_5103.prdoc b/prdoc/pr_5103.prdoc new file mode 100644 index 000000000000..b0f72bf531f1 --- /dev/null +++ b/prdoc/pr_5103.prdoc @@ -0,0 +1,18 @@ +title: Skip genesis leaf to unblock syncing + +doc: + - audience: + - Node Operator + - Node Dev + description: | + This PR skips over the genesis block reported as leaf when calculating displaced branches. + In those cases, when the genesis block is reported as leaf, the node would compute the path + from the current finalized block to the genesis block. This operation is time consuming and + is enough to block syncing. In the current state, the genesis block is assumed to always be + part of the finalized chain. + +crates: +- name: sc-client-db + bump: none +- name: sp-blockchain + bump: patch diff --git a/prdoc/pr_5114.prdoc b/prdoc/pr_5114.prdoc new file mode 100644 index 000000000000..d57141490a3e --- /dev/null +++ b/prdoc/pr_5114.prdoc @@ -0,0 +1,16 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: "Remove not-audited warning" + +doc: + - audience: Runtime Dev + description: | + Pallets `tx-pause` and `safe-mode` have passed audit, this just removes a warning in the docs + to not use them. + +crates: + - name: pallet-safe-mode + bump: patch + - name: pallet-tx-pause + bump: patch diff --git a/substrate/bin/node/cli/benches/block_production.rs b/substrate/bin/node/cli/benches/block_production.rs index c16b25187e5f..8239637b3a9f 100644 --- a/substrate/bin/node/cli/benches/block_production.rs +++ b/substrate/bin/node/cli/benches/block_production.rs @@ -104,7 +104,6 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { announce_block: true, data_path: base_path.path().into(), base_path, - informant_output_format: Default::default(), wasm_runtime_overrides: None, }; diff --git a/substrate/bin/node/cli/benches/transaction_pool.rs b/substrate/bin/node/cli/benches/transaction_pool.rs index 6618f4b1132e..9a71a4ec585d 100644 --- a/substrate/bin/node/cli/benches/transaction_pool.rs +++ b/substrate/bin/node/cli/benches/transaction_pool.rs @@ -99,7 +99,6 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { announce_block: true, data_path: base_path.path().into(), base_path, - informant_output_format: Default::default(), wasm_runtime_overrides: None, }; diff --git a/substrate/bin/node/cli/src/service.rs b/substrate/bin/node/cli/src/service.rs index e57ca04f3b74..d58ca888d419 100644 --- a/substrate/bin/node/cli/src/service.rs +++ b/substrate/bin/node/cli/src/service.rs @@ -441,8 +441,10 @@ pub fn new_full_base::Hash>>( let auth_disc_publish_non_global_ips = config.network.allow_non_globals_in_dht; let auth_disc_public_addresses = config.network.public_addresses.clone(); - let mut net_config = - sc_network::config::FullNetworkConfiguration::<_, _, N>::new(&config.network); + let mut net_config = sc_network::config::FullNetworkConfiguration::<_, _, N>::new( + &config.network, + config.prometheus_config.as_ref().map(|cfg| cfg.registry.clone()), + ); let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); let peer_store_handle = net_config.peer_store_handle(); diff --git a/substrate/bin/node/runtime/src/impls.rs b/substrate/bin/node/runtime/src/impls.rs index 6c121fad624b..43e7a766e0e8 100644 --- a/substrate/bin/node/runtime/src/impls.rs +++ b/substrate/bin/node/runtime/src/impls.rs @@ -63,8 +63,8 @@ impl IdentityVerifier for AllianceIdentityVerifier { } fn has_good_judgement(who: &AccountId) -> bool { - use pallet_identity::Judgement; - crate::Identity::identity(who) + use pallet_identity::{IdentityOf, Judgement}; + IdentityOf::::get(who) .map(|(registration, _)| registration.judgements) .map_or(false, |judgements| { judgements @@ -74,7 +74,8 @@ impl IdentityVerifier for AllianceIdentityVerifier { } fn super_account_id(who: &AccountId) -> Option { - crate::Identity::super_of(who).map(|parent| parent.0) + use pallet_identity::SuperOf; + SuperOf::::get(who).map(|parent| parent.0) } } diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 78c7bba64579..fd8597563a02 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -69,6 +69,7 @@ use frame_system::{ pub use node_primitives::{AccountId, Signature}; use node_primitives::{AccountIndex, Balance, BlockNumber, Hash, Moment, Nonce}; use pallet_asset_conversion::{AccountIdConverter, Ascending, Chain, WithFirstAsset}; +use pallet_asset_conversion_tx_payment::SwapAssetAdapter; use pallet_broker::{CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600}; use pallet_election_provider_multi_phase::{GeometricDepositBase, SolutionAccuracyOf}; use pallet_identity::legacy::IdentityInfo; @@ -123,7 +124,7 @@ pub use sp_runtime::BuildStorage; pub mod impls; #[cfg(not(feature = "runtime-benchmarks"))] use impls::AllianceIdentityVerifier; -use impls::{AllianceProposalProvider, Author, CreditToBlockAuthor}; +use impls::{AllianceProposalProvider, Author}; /// Constant values used within the runtime. pub mod constants; @@ -189,7 +190,7 @@ type NegativeImbalance = >::NegativeImbalance; pub struct DealWithFees; impl OnUnbalanced for DealWithFees { - fn on_unbalanceds(mut fees_then_tips: impl Iterator) { + fn on_unbalanceds(mut fees_then_tips: impl Iterator) { if let Some(fees) = fees_then_tips.next() { // for fees, 80% to treasury, 20% to author let mut split = fees.ration(80, 20); @@ -574,22 +575,14 @@ impl pallet_transaction_payment::Config for Runtime { >; } -impl pallet_asset_tx_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Fungibles = Assets; - type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter< - pallet_assets::BalanceToAssetBalance, - CreditToBlockAuthor, - >; -} - impl pallet_asset_conversion_tx_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Fungibles = Assets; - type OnChargeAssetTransaction = pallet_asset_conversion_tx_payment::AssetConversionAdapter< - Balances, - AssetConversion, + type AssetId = NativeOrWithId; + type OnChargeAssetTransaction = SwapAssetAdapter< Native, + NativeAndAssets, + AssetConversion, + ResolveAssetTo, >; } @@ -859,7 +852,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type SignedDepositWeight = (); type SignedMaxWeight = MinerMaxWeight; type SlashHandler = (); // burn slashes - type RewardHandler = (); // nothing to do upon rewards + type RewardHandler = (); // rewards are minted from the void type DataProvider = Staking; type Fallback = onchain::OnChainExecution; type GovernanceFallback = onchain::OnChainExecution; @@ -1705,12 +1698,15 @@ parameter_types! { pub const Native: NativeOrWithId = NativeOrWithId::Native; } +pub type NativeAndAssets = + UnionOf, AccountId>; + impl pallet_asset_conversion::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Balance = u128; type HigherPrecisionBalance = sp_core::U256; type AssetKind = NativeOrWithId; - type Assets = UnionOf, AccountId>; + type Assets = NativeAndAssets; type PoolId = (Self::AssetKind, Self::AssetKind); type PoolLocator = Chain< WithFirstAsset< @@ -2259,9 +2255,6 @@ mod runtime { #[runtime::pallet_index(7)] pub type TransactionPayment = pallet_transaction_payment::Pallet; - #[runtime::pallet_index(8)] - pub type AssetTxPayment = pallet_asset_tx_payment::Pallet; - #[runtime::pallet_index(9)] pub type AssetConversionTxPayment = pallet_asset_conversion_tx_payment::Pallet; @@ -3038,7 +3031,7 @@ impl_runtime_apis! { } } - #[api_version(4)] + #[api_version(5)] impl sp_consensus_beefy::BeefyApi for Runtime { fn beefy_genesis() -> Option { pallet_beefy::GenesisBlock::::get() @@ -3064,6 +3057,31 @@ impl_runtime_apis! { ) } + fn submit_report_fork_voting_unsigned_extrinsic( + equivocation_proof: + sp_consensus_beefy::ForkVotingProof< + ::Header, + BeefyId, + sp_runtime::OpaqueValue + >, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_fork_voting_report( + equivocation_proof.try_into()?, + key_owner_proof.decode()?, + ) + } + + fn submit_report_future_block_voting_unsigned_extrinsic( + equivocation_proof: sp_consensus_beefy::FutureBlockVotingProof, + key_owner_proof: sp_consensus_beefy::OpaqueKeyOwnershipProof, + ) -> Option<()> { + Beefy::submit_unsigned_future_block_voting_report( + equivocation_proof, + key_owner_proof.decode()?, + ) + } + fn generate_key_ownership_proof( _set_id: sp_consensus_beefy::ValidatorSetId, authority_id: BeefyId, @@ -3072,6 +3090,17 @@ impl_runtime_apis! { .map(|p| p.encode()) .map(sp_consensus_beefy::OpaqueKeyOwnershipProof::new) } + + fn generate_ancestry_proof( + prev_block_number: BlockNumber, + best_known_block_number: Option, + ) -> Option { + use sp_consensus_beefy::AncestryHelper; + + MmrLeaf::generate_proof(prev_block_number, best_known_block_number) + .map(|p| p.encode()) + .map(sp_runtime::OpaqueValue::new) + } } impl pallet_mmr::primitives::MmrApi< diff --git a/substrate/client/chain-spec/src/chain_spec.rs b/substrate/client/chain-spec/src/chain_spec.rs index 5f90f549e022..aa3c1ba3e6f1 100644 --- a/substrate/client/chain-spec/src/chain_spec.rs +++ b/substrate/client/chain-spec/src/chain_spec.rs @@ -325,7 +325,7 @@ impl ChainSpecBuilder { name: "Development".to_string(), id: "dev".to_string(), chain_type: ChainType::Local, - genesis_build_action: GenesisBuildAction::Patch(Default::default()), + genesis_build_action: GenesisBuildAction::Patch(json::json!({})), boot_nodes: None, telemetry_endpoints: None, protocol_id: None, diff --git a/substrate/client/cli/src/config.rs b/substrate/client/cli/src/config.rs index 783c9313121f..283148a6d6ad 100644 --- a/substrate/client/cli/src/config.rs +++ b/substrate/client/cli/src/config.rs @@ -27,7 +27,7 @@ use names::{Generator, Name}; use sc_service::{ config::{ BasePath, Configuration, DatabaseSource, IpNetwork, KeystoreConfig, NetworkConfiguration, - NodeKeyConfig, OffchainWorkerConfig, OutputFormat, PrometheusConfig, PruningMode, Role, + NodeKeyConfig, OffchainWorkerConfig, PrometheusConfig, PruningMode, Role, RpcBatchRequestConfig, RpcMethods, TelemetryEndpoints, TransactionPoolOptions, WasmExecutionMethod, }, @@ -550,7 +550,6 @@ pub trait CliConfiguration: Sized { announce_block: self.announce_block()?, role, base_path, - informant_output_format: OutputFormat { enable_color: !self.disable_log_color()? }, runtime_cache_size, }) } diff --git a/substrate/client/cli/src/runner.rs b/substrate/client/cli/src/runner.rs index 6d986e38d2fb..b0dbccfa634c 100644 --- a/substrate/client/cli/src/runner.rs +++ b/substrate/client/cli/src/runner.rs @@ -291,7 +291,6 @@ mod tests { announce_block: true, base_path: sc_service::BasePath::new(root.clone()), data_path: root, - informant_output_format: Default::default(), runtime_cache_size: 2, }, runtime, diff --git a/substrate/client/consensus/beefy/src/keystore.rs b/substrate/client/consensus/beefy/src/keystore.rs index 8daf3440c7d2..888a11db89cb 100644 --- a/substrate/client/consensus/beefy/src/keystore.rs +++ b/substrate/client/consensus/beefy/src/keystore.rs @@ -20,7 +20,7 @@ use log::warn; use sp_application_crypto::{key_types::BEEFY as BEEFY_KEY_TYPE, AppCrypto, RuntimeAppPublic}; #[cfg(feature = "bls-experimental")] -use sp_core::ecdsa_bls377; +use sp_core::ecdsa_bls381; use sp_core::{ecdsa, keccak_256}; use sp_keystore::KeystorePtr; @@ -100,13 +100,13 @@ impl BeefyKeystore { }, #[cfg(feature = "bls-experimental")] - ecdsa_bls377::CRYPTO_ID => { - let public: ecdsa_bls377::Public = - ecdsa_bls377::Public::try_from(public.as_slice()).unwrap(); + ecdsa_bls381::CRYPTO_ID => { + let public: ecdsa_bls381::Public = + ecdsa_bls381::Public::try_from(public.as_slice()).unwrap(); let sig = store - .ecdsa_bls377_sign_with_keccak256(BEEFY_KEY_TYPE, &public, &message) + .ecdsa_bls381_sign_with_keccak256(BEEFY_KEY_TYPE, &public, &message) .map_err(|e| error::Error::Keystore(e.to_string()))? - .ok_or_else(|| error::Error::Signature("bls377_sign() failed".to_string()))?; + .ok_or_else(|| error::Error::Signature("bls381_sign() failed".to_string()))?; let sig_ref: &[u8] = sig.as_ref(); sig_ref.to_vec() }, @@ -146,8 +146,8 @@ impl BeefyKeystore { }), #[cfg(feature = "bls-experimental")] - ecdsa_bls377::CRYPTO_ID => store - .ecdsa_bls377_public_keys(BEEFY_KEY_TYPE) + ecdsa_bls381::CRYPTO_ID => store + .ecdsa_bls381_public_keys(BEEFY_KEY_TYPE) .drain(..) .map(|pk| AuthorityId::try_from(pk.as_ref())) .collect::, _>>() @@ -254,9 +254,9 @@ pub mod tests { AuthorityId::decode(&mut pk.as_ref()).unwrap() }, #[cfg(feature = "bls-experimental")] - ecdsa_bls377::CRYPTO_ID => { + ecdsa_bls381::CRYPTO_ID => { let pk = store - .ecdsa_bls377_generate_new(key_type, optional_seed.as_deref()) + .ecdsa_bls381_generate_new(key_type, optional_seed.as_deref()) .ok() .unwrap(); AuthorityId::decode(&mut pk.as_ref()).unwrap() @@ -452,7 +452,7 @@ pub mod tests { #[cfg(feature = "bls-experimental")] #[test] fn sign_error_for_ecdsa_n_bls() { - sign_error::("bls377_sign() failed"); + sign_error::("bls381_sign() failed"); } #[test] diff --git a/substrate/client/db/src/lib.rs b/substrate/client/db/src/lib.rs index acd165d91613..ba0cbc09d53d 100644 --- a/substrate/client/db/src/lib.rs +++ b/substrate/client/db/src/lib.rs @@ -3169,7 +3169,7 @@ pub(crate) mod tests { let displaced = blockchain.displaced_leaves_after_finalizing(a3_hash, a3_number).unwrap(); assert_eq!(blockchain.leaves().unwrap(), vec![a4_hash, genesis_hash]); - assert_eq!(displaced.displaced_leaves, vec![]); + assert_eq!(displaced.displaced_leaves, vec![(genesis_number, genesis_hash)]); assert_eq!(displaced.displaced_blocks, vec![]); } @@ -3177,7 +3177,7 @@ pub(crate) mod tests { let displaced = blockchain.displaced_leaves_after_finalizing(a4_hash, a4_number).unwrap(); assert_eq!(blockchain.leaves().unwrap(), vec![a4_hash, genesis_hash]); - assert_eq!(displaced.displaced_leaves, vec![]); + assert_eq!(displaced.displaced_leaves, vec![(genesis_number, genesis_hash)]); assert_eq!(displaced.displaced_blocks, vec![]); } diff --git a/substrate/client/informant/Cargo.toml b/substrate/client/informant/Cargo.toml index 9da2296deee3..aa54d9479f5c 100644 --- a/substrate/client/informant/Cargo.toml +++ b/substrate/client/informant/Cargo.toml @@ -16,7 +16,7 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -ansi_term = { workspace = true } +console = { workspace = true } futures = { workspace = true } futures-timer = { workspace = true } log = { workspace = true, default-features = true } diff --git a/substrate/client/informant/src/display.rs b/substrate/client/informant/src/display.rs index cdbb83b6596c..655bf21c7115 100644 --- a/substrate/client/informant/src/display.rs +++ b/substrate/client/informant/src/display.rs @@ -16,8 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::OutputFormat; -use ansi_term::Colour; +use console::style; use log::info; use sc_client_api::ClientInfo; use sc_network::NetworkStatus; @@ -47,19 +46,16 @@ pub struct InformantDisplay { last_total_bytes_inbound: u64, /// The last seen total of bytes sent. last_total_bytes_outbound: u64, - /// The format to print output in. - format: OutputFormat, } impl InformantDisplay { /// Builds a new informant display system. - pub fn new(format: OutputFormat) -> InformantDisplay { + pub fn new() -> InformantDisplay { InformantDisplay { last_number: None, last_update: Instant::now(), last_total_bytes_inbound: 0, last_total_bytes_outbound: 0, - format, } } @@ -144,17 +140,17 @@ impl InformantDisplay { info!( target: "substrate", - "{} {}{} ({} peers), best: #{} ({}), finalized #{} ({}), {} {}", + "{} {}{} ({} peers), best: #{} ({}), finalized #{} ({}), ⬇ {} ⬆ {}", level, - self.format.print_with_color(Colour::White.bold(), status), + style(&status).white().bold(), target, - self.format.print_with_color(Colour::White.bold(), num_connected_peers), - self.format.print_with_color(Colour::White.bold(), best_number), + style(num_connected_peers).white().bold(), + style(best_number).white().bold(), best_hash, - self.format.print_with_color(Colour::White.bold(), finalized_number), + style(finalized_number).white().bold(), info.chain.finalized_hash, - self.format.print_with_color(Colour::Green, format!("⬇ {}", TransferRateFormat(avg_bytes_per_sec_inbound))), - self.format.print_with_color(Colour::Red, format!("⬆ {}", TransferRateFormat(avg_bytes_per_sec_outbound))), + style(TransferRateFormat(avg_bytes_per_sec_inbound)).green(), + style(TransferRateFormat(avg_bytes_per_sec_outbound)).red(), ) } } diff --git a/substrate/client/informant/src/lib.rs b/substrate/client/informant/src/lib.rs index af778529ffc5..d44364539a29 100644 --- a/substrate/client/informant/src/lib.rs +++ b/substrate/client/informant/src/lib.rs @@ -18,7 +18,7 @@ //! Console informant. Prints sync progress and block events. Runs on the calling thread. -use ansi_term::{Colour, Style}; +use console::style; use futures::prelude::*; use futures_timer::Delay; use log::{debug, info, trace}; @@ -36,71 +36,15 @@ fn interval(duration: Duration) -> impl Stream + Unpin { futures::stream::unfold((), move |_| Delay::new(duration).map(|_| Some(((), ())))).map(drop) } -/// The format to print telemetry output in. -#[derive(Clone, Debug)] -pub struct OutputFormat { - /// Enable color output in logs. - /// - /// Is enabled by default. - pub enable_color: bool, -} - -impl Default for OutputFormat { - fn default() -> Self { - Self { enable_color: true } - } -} - -enum ColorOrStyle { - Color(Colour), - Style(Style), -} - -impl From for ColorOrStyle { - fn from(value: Colour) -> Self { - Self::Color(value) - } -} - -impl From