diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 37839791456b..a92dc0bb006c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,3 +2,5 @@ /.github/ @paritytech/ci @chevdor /scripts/ci/ @paritytech/ci @chevdor /.gitlab-ci.yml @paritytech/ci +# lingua.dic is not managed by CI team +/scripts/ci/gitlab/lingua.dic diff --git a/.github/workflows/auto-label-prs.yml b/.github/workflows/auto-label-prs.yml index f0b8e9b343e2..50539b80b98b 100644 --- a/.github/workflows/auto-label-prs.yml +++ b/.github/workflows/auto-label-prs.yml @@ -8,13 +8,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Label drafts - uses: andymckay/labeler@master + uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 # 1.0.4 if: github.event.pull_request.draft == true with: add-labels: 'A3-inprogress' remove-labels: 'A0-pleasereview' - name: Label PRs - uses: andymckay/labeler@master + uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 # 1.0.4 if: github.event.pull_request.draft == false && ! contains(github.event.pull_request.labels.*.name, 'A2-insubstantial') with: add-labels: 'A0-pleasereview' diff --git a/.github/workflows/release-10_candidate.yml b/.github/workflows/release-10_candidate.yml index 51a82bc4f593..acffa6842d49 100644 --- a/.github/workflows/release-10_candidate.yml +++ b/.github/workflows/release-10_candidate.yml @@ -34,7 +34,7 @@ jobs: echo "::set-output name=first_rc::true" fi - name: Apply new tag - uses: tvdias/github-tagger@v0.0.2 + uses: tvdias/github-tagger@ed7350546e3e503b5e942dffd65bc8751a95e49d # v0.0.2 with: # We can't use the normal GITHUB_TOKEN for the following reason: # https://docs.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token @@ -42,7 +42,7 @@ jobs: repo-token: "${{ secrets.RELEASE_BRANCH_TOKEN }}" tag: ${{ steps.compute_tag.outputs.new_tag }} - id: create-issue - uses: JasonEtco/create-an-issue@v2 + uses: JasonEtco/create-an-issue@9e6213aec58987fa7d2f4deb8b256b99e63107a2 # v2.6.0 # Only create the issue if it's the first release candidate if: steps.compute_tag.outputs.first_rc == 'true' env: diff --git a/.github/workflows/release-50_publish-docker-release.yml b/.github/workflows/release-50_publish-docker-release.yml index 86bc38252741..5a9d683bc3b3 100644 --- a/.github/workflows/release-50_publish-docker-release.yml +++ b/.github/workflows/release-50_publish-docker-release.yml @@ -12,7 +12,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@f211e3e9ded2d9377c8cadc4489a4e38014bc4c9 # v1.7 + uses: docker/setup-buildx-action@95cb08cb2672c73d4ffd2f422e6d11953d2a9c70 # v2.1.0 - name: Cache Docker layers uses: actions/cache@v3 with: diff --git a/.github/workflows/release-51_publish-docker-manual.yml b/.github/workflows/release-51_publish-docker-manual.yml index 6386d8676769..e0bcf99a8d60 100644 --- a/.github/workflows/release-51_publish-docker-manual.yml +++ b/.github/workflows/release-51_publish-docker-manual.yml @@ -19,7 +19,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@f211e3e9ded2d9377c8cadc4489a4e38014bc4c9 # v1.7 + uses: docker/setup-buildx-action@95cb08cb2672c73d4ffd2f422e6d11953d2a9c70 # v2.1.0 - name: Cache Docker layers uses: actions/cache@v3 with: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94f700f7b985..0dd640186bb8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,10 +15,13 @@ # moment of time. stages: - - stage1 - - stage2 - - stage3 - - stage4 + - weights + - check + - test + - build + - publish + - zombienet + - short-benchmarks workflow: rules: @@ -32,13 +35,13 @@ variables: CI_IMAGE: "paritytech/ci-linux:production" DOCKER_OS: "debian:stretch" ARCH: "x86_64" - ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.2.51" + ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.2.78" PIPELINE_SCRIPTS_TAG: "v0.4" default: cache: {} -.collect-artifacts: &collect-artifacts +.collect-artifacts: artifacts: name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}" when: on_success @@ -46,7 +49,7 @@ default: paths: - ./artifacts/ -.collect-artifacts-short: &collect-artifacts-short +.collect-artifacts-short: artifacts: name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}" when: on_success @@ -56,18 +59,19 @@ default: # collecting vars for pipeline stopper # they will be used if the job fails -.pipeline-stopper-vars: &pipeline-stopper-vars +.pipeline-stopper-vars: + before_script: - echo "FAILED_JOB_URL=${CI_JOB_URL}" > pipeline-stopper.env - echo "FAILED_JOB_NAME=${CI_JOB_NAME}" >> pipeline-stopper.env - echo "FAILED_JOB_NAME=${CI_JOB_NAME}" >> pipeline-stopper.env - echo "PR_NUM=${CI_COMMIT_REF_NAME}" >> pipeline-stopper.env -.pipeline-stopper-artifacts: &pipeline-stopper-artifacts +.pipeline-stopper-artifacts: artifacts: reports: dotenv: pipeline-stopper.env -.kubernetes-env: &kubernetes-env +.kubernetes-env: retry: max: 2 when: @@ -78,7 +82,7 @@ default: tags: - kubernetes-parity-build -.docker-env: &docker-env +.docker-env: image: "${CI_IMAGE}" retry: max: 2 @@ -90,20 +94,20 @@ default: tags: - linux-docker -.compiler-info: &compiler-info +.compiler-info: before_script: - rustup show - cargo --version - sccache -s -.test-refs: &test-refs +.test-refs: rules: - if: $CI_PIPELINE_SOURCE == "web" - if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_COMMIT_REF_NAME == "master" - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs -.common-refs: &common-refs +.common-refs: # these jobs run always* rules: - if: $CI_PIPELINE_SOURCE == "web" @@ -113,13 +117,13 @@ default: - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 - if: $CI_COMMIT_REF_NAME =~ /^release-v[0-9]+\.[0-9]+.*$/ # i.e. release-v0.9.27 -.test-pr-refs: &test-pr-refs +.test-pr-refs: rules: - if: $CI_PIPELINE_SOURCE == "pipeline" when: never - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs -.zombienet-refs: &zombienet-refs +.zombienet-refs: rules: - if: $CI_PIPELINE_SOURCE == "pipeline" when: never @@ -128,14 +132,14 @@ default: - if: $CI_COMMIT_REF_NAME == "master" - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs -.deploy-testnet-refs: &deploy-testnet-refs +.deploy-testnet-refs: rules: - if: $CI_PIPELINE_SOURCE == "pipeline" when: never - if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_COMMIT_REF_NAME == "master" -.publish-refs: &publish-refs +.publish-refs: rules: - if: $CI_PIPELINE_SOURCE == "pipeline" when: never @@ -145,14 +149,11 @@ default: - if: $CI_COMMIT_REF_NAME == "master" - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 -.build-push-image: &build-push-image - <<: *kubernetes-env +.build-push-image: + extends: + - .kubernetes-env image: quay.io/buildah/stable - variables: &image-variables - GIT_STRATEGY: none - DOCKER_USER: ${PARITYPR_USER} - DOCKER_PASS: ${PARITYPR_PASS} - before_script: &check-versions + before_script: - test -s ./artifacts/VERSION || exit 1 - test -s ./artifacts/EXTRATAG || exit 1 - VERSION="$(cat ./artifacts/VERSION)" @@ -179,864 +180,36 @@ default: after_script: - buildah logout --all -#### stage: stage1 - -check-runtime: - stage: stage1 - image: paritytech/tools:latest - <<: *kubernetes-env - rules: - - if: $CI_COMMIT_REF_NAME =~ /^release-v[0-9]+\.[0-9]+.*$/ # i.e. release-v0.9.27 - variables: - GITLAB_API: "https://gitlab.parity.io/api/v4" - GITHUB_API_PROJECT: "parity%2Finfrastructure%2Fgithub-api" - script: - - ./scripts/ci/gitlab/check_runtime.sh - allow_failure: true +include: + # weights jobs + - scripts/ci/gitlab/pipeline/weights.yml + # check jobs + - scripts/ci/gitlab/pipeline/check.yml + # test jobs + - scripts/ci/gitlab/pipeline/test.yml + # build jobs + - scripts/ci/gitlab/pipeline/build.yml + # short-benchmarks jobs + - scripts/ci/gitlab/pipeline/short-benchmarks.yml + # publish jobs + - scripts/ci/gitlab/pipeline/publish.yml + # zombienet jobs + - scripts/ci/gitlab/pipeline/zombienet.yml -cargo-fmt: - stage: stage1 - <<: *docker-env - <<: *test-refs - script: - - cargo +nightly --version - - cargo +nightly fmt --all -- --check - allow_failure: true -build-linux-stable: - stage: stage1 - <<: *docker-env - <<: *compiler-info - <<: *collect-artifacts - <<: *common-refs - variables: - RUST_TOOLCHAIN: stable - # Enable debug assertions since we are running optimized builds for testing - # but still want to have debug assertions. - RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" - # Ensure we run the UI tests. - RUN_UI_TESTS: 1 - script: - - time cargo build --profile testnet --features pyroscope --verbose --bin polkadot - - sccache -s - # pack artifacts - - mkdir -p ./artifacts - - VERSION="${CI_COMMIT_REF_NAME}" # will be tag or branch name - - mv ./target/testnet/polkadot ./artifacts/. - - pushd artifacts - - sha256sum polkadot | tee polkadot.sha256 - - shasum -c polkadot.sha256 - - popd - - EXTRATAG="${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}" - - echo "Polkadot version = ${VERSION} (EXTRATAG = ${EXTRATAG})" - - echo -n ${VERSION} > ./artifacts/VERSION - - echo -n ${EXTRATAG} > ./artifacts/EXTRATAG - - cp -r scripts/* ./artifacts -test-linux-stable: - stage: stage1 - <<: *docker-env - <<: *common-refs - <<: *pipeline-stopper-artifacts - before_script: - - rustup show - - cargo --version - - *pipeline-stopper-vars - variables: - RUST_TOOLCHAIN: stable - # Enable debug assertions since we are running optimized builds for testing - # but still want to have debug assertions. - RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" - script: - - time cargo test --workspace --profile testnet --verbose --locked --features=runtime-benchmarks,runtime-metrics - - - -spellcheck: - stage: stage1 - <<: *docker-env - <<: *test-refs - script: - - cargo spellcheck --version - # compare with the commit parent to the PR, given it's from a default branch - - git fetch origin +${CI_DEFAULT_BRANCH}:${CI_DEFAULT_BRANCH} - - echo "___Spellcheck is going to check your diff___" - - cargo spellcheck list-files -vvv $(git diff --diff-filter=AM --name-only $(git merge-base ${CI_COMMIT_SHA} ${CI_DEFAULT_BRANCH} -- :^bridges)) - - time cargo spellcheck check -vvv --cfg=scripts/ci/gitlab/spellcheck.toml --checkers hunspell --code 1 - $(git diff --diff-filter=AM --name-only $(git merge-base ${CI_COMMIT_SHA} ${CI_DEFAULT_BRANCH} -- :^bridges)) - allow_failure: true - -build-test-collators: - stage: stage1 - <<: *collect-artifacts - <<: *docker-env - <<: *compiler-info - <<: *test-refs - script: - - time cargo build --profile testnet --verbose -p test-parachain-adder-collator - - time cargo build --profile testnet --verbose -p test-parachain-undying-collator - - sccache -s - # pack artifacts - - mkdir -p ./artifacts - - mv ./target/testnet/adder-collator ./artifacts/. - - mv ./target/testnet/undying-collator ./artifacts/. - - echo -n "${CI_COMMIT_REF_NAME}" > ./artifacts/VERSION - - echo -n "${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}" > ./artifacts/EXTRATAG - - echo "adder-collator version = $(cat ./artifacts/VERSION) (EXTRATAG = $(cat ./artifacts/EXTRATAG))" - - echo "undying-collator version = $(cat ./artifacts/VERSION) (EXTRATAG = $(cat ./artifacts/EXTRATAG))" - - cp -r ./scripts/* ./artifacts - -build-malus: - stage: stage1 - <<: *collect-artifacts - <<: *docker-env - <<: *compiler-info - <<: *test-refs - script: - - time cargo build --profile testnet --verbose -p polkadot-test-malus - - sccache -s - # pack artifacts - - mkdir -p ./artifacts - - mv ./target/testnet/malus ./artifacts/. - - echo -n "${CI_COMMIT_REF_NAME}" > ./artifacts/VERSION - - echo -n "${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}" > ./artifacts/EXTRATAG - - echo "polkadot-test-malus = $(cat ./artifacts/VERSION) (EXTRATAG = $(cat ./artifacts/EXTRATAG))" - - cp -r ./scripts/* ./artifacts - -build-staking-miner: - stage: stage1 - <<: *collect-artifacts - <<: *docker-env - <<: *compiler-info - <<: *common-refs - script: - - time cargo build --locked --release --package staking-miner - # pack artifacts - - mkdir -p ./artifacts - - mv ./target/release/staking-miner ./artifacts/. - - echo -n "${CI_COMMIT_REF_NAME}" > ./artifacts/VERSION - - echo -n "${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}" > ./artifacts/EXTRATAG - - echo "staking-miner = $(cat ./artifacts/VERSION) (EXTRATAG = $(cat ./artifacts/EXTRATAG))" - - cp -r ./scripts/* ./artifacts - -#### stage: stage2 - -.check-dependent-project: &check-dependent-project - stage: stage2 - # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs - needs: - - job: cargo-fmt - artifacts: false - <<: *docker-env - <<: *test-pr-refs - script: - - git clone - --depth=1 - "--branch=$PIPELINE_SCRIPTS_TAG" - https://github.com/paritytech/pipeline-scripts - - ./pipeline-scripts/check_dependent_project.sh - --org paritytech - --dependent-repo "$DEPENDENT_REPO" - --github-api-token "$GITHUB_PR_TOKEN" - --extra-dependencies "$EXTRA_DEPENDENCIES" - --companion-overrides "$COMPANION_OVERRIDES" - -check-dependent-cumulus: - <<: *check-dependent-project - variables: - DEPENDENT_REPO: cumulus - EXTRA_DEPENDENCIES: substrate - COMPANION_OVERRIDES: | - polkadot: release-v* - cumulus: polkadot-v* - -test-node-metrics: - stage: stage2 - # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs - needs: - - job: cargo-fmt - artifacts: false - <<: *docker-env - <<: *compiler-info - <<: *test-refs - variables: - RUST_TOOLCHAIN: stable - # Enable debug assertions since we are running optimized builds for testing - # but still want to have debug assertions. - RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" - script: - - time cargo test --profile testnet --verbose --locked --features=runtime-metrics -p polkadot-node-metrics - -test-deterministic-wasm: - stage: stage2 - # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs - needs: - - job: cargo-fmt - artifacts: false - <<: *test-refs - <<: *docker-env - <<: *compiler-info - script: - - ./scripts/ci/gitlab/test_deterministic_wasm.sh - -check-transaction-versions: - stage: stage2 - <<: *test-refs - <<: *docker-env - image: node:15 - needs: - - job: build-linux-stable - artifacts: true - before_script: - - apt-get -y update; apt-get -y install jq lsof - - npm install --ignore-scripts -g @polkadot/metadata-cmp - # Set git config - - git config remote.origin.url "https://github.com/paritytech/polkadot.git" - - git fetch origin release - script: - - ./scripts/ci/gitlab/check_extrinsics_ordering.sh - - - -# This image is used in testnets -# Release image is handled by the Github Action here: -# .github/workflows/publish-docker-release.yml -publish-polkadot-debug-image: - stage: stage2 - <<: *build-push-image - rules: - # Don't run when triggered from another pipeline - - if: $CI_PIPELINE_SOURCE == "pipeline" - when: never - - if: $CI_PIPELINE_SOURCE == "web" - - if: $CI_PIPELINE_SOURCE == "schedule" - - if: $CI_COMMIT_REF_NAME == "master" - - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 - variables: - <<: *image-variables - # scripts/ci/dockerfiles/polkadot_injected_debug.Dockerfile - DOCKERFILE: ci/dockerfiles/polkadot_injected_debug.Dockerfile - IMAGE_NAME: docker.io/paritypr/polkadot-debug - needs: - - job: build-linux-stable - artifacts: true - after_script: - # pass artifacts to the zombienet-tests job - # https://docs.gitlab.com/ee/ci/multi_project_pipelines.html#with-variable-inheritance - - echo "PARACHAINS_IMAGE_NAME=${IMAGE_NAME}" > ./artifacts/parachains.env - - echo "PARACHAINS_IMAGE_TAG=$(cat ./artifacts/EXTRATAG)" >> ./artifacts/parachains.env - artifacts: - reports: - # this artifact is used in zombienet-tests job - dotenv: ./artifacts/parachains.env - expire_in: 1 days - -publish-test-collators-image: - # service image for Simnet - stage: stage2 - <<: *build-push-image - <<: *zombienet-refs - variables: - <<: *image-variables - # scripts/ci/dockerfiles/collator_injected.Dockerfile - DOCKERFILE: ci/dockerfiles/collator_injected.Dockerfile - IMAGE_NAME: docker.io/paritypr/colander - needs: - - job: build-test-collators - artifacts: true - after_script: - - buildah logout --all - # pass artifacts to the zombienet-tests job - - echo "COLLATOR_IMAGE_NAME=${IMAGE_NAME}" > ./artifacts/collator.env - - echo "COLLATOR_IMAGE_TAG=$(cat ./artifacts/EXTRATAG)" >> ./artifacts/collator.env - artifacts: - reports: - # this artifact is used in zombienet-tests job - dotenv: ./artifacts/collator.env - -publish-malus-image: - # service image for Simnet - stage: stage2 - <<: *build-push-image - <<: *zombienet-refs - variables: - <<: *image-variables - # scripts/ci/dockerfiles/malus_injected.Dockerfile - DOCKERFILE: ci/dockerfiles/malus_injected.Dockerfile - IMAGE_NAME: docker.io/paritypr/malus - needs: - - job: build-malus - artifacts: true - after_script: - - buildah logout "$IMAGE_NAME" - # pass artifacts to the zombienet-tests job - - echo "MALUS_IMAGE_NAME=${IMAGE_NAME}" > ./artifacts/malus.env - - echo "MALUS_IMAGE_TAG=$(cat ./artifacts/EXTRATAG)" >> ./artifacts/malus.env - artifacts: - reports: - # this artifact is used in zombienet-tests job - dotenv: ./artifacts/malus.env - -publish-staking-miner-image: - stage: stage2 - <<: *build-push-image - <<: *publish-refs - variables: - <<: *image-variables - # scripts/ci/dockerfiles/staking-miner/staking-miner_injected.Dockerfile - DOCKERFILE: ci/dockerfiles/staking-miner/staking-miner_injected.Dockerfile - IMAGE_NAME: docker.io/paritytech/staking-miner - GIT_STRATEGY: none - DOCKER_USER: ${Docker_Hub_User_Parity} - DOCKER_PASS: ${Docker_Hub_Pass_Parity} - needs: - - job: build-staking-miner - artifacts: true - - -publish-s3-release: &publish-s3 - stage: stage3 - needs: - - job: build-linux-stable - artifacts: true - <<: *kubernetes-env - image: paritytech/awscli:latest - variables: - GIT_STRATEGY: none - PREFIX: "builds/polkadot/${ARCH}-${DOCKER_OS}" - rules: - - if: $CI_PIPELINE_SOURCE == "pipeline" - when: never - # publishing binaries nightly - - if: $CI_PIPELINE_SOURCE == "schedule" - before_script: - - *check-versions - script: - - echo "uploading objects to https://releases.parity.io/${PREFIX}/${VERSION}" - - aws s3 sync --acl public-read ./artifacts/ s3://${AWS_BUCKET}/${PREFIX}/${VERSION}/ - - echo "update objects at https://releases.parity.io/${PREFIX}/${EXTRATAG}" - - find ./artifacts -type f | while read file; do - name="${file#./artifacts/}"; - aws s3api copy-object - --copy-source ${AWS_BUCKET}/${PREFIX}/${VERSION}/${name} - --bucket ${AWS_BUCKET} --key ${PREFIX}/${EXTRATAG}/${name}; - done - - | - cat <<-EOM - | - | polkadot binary paths: - | - | - https://releases.parity.io/${PREFIX}/${EXTRATAG}/polkadot - | - https://releases.parity.io/${PREFIX}/${VERSION}/polkadot - | - EOM - after_script: - - aws s3 ls s3://${AWS_BUCKET}/${PREFIX}/${EXTRATAG}/ - --recursive --human-readable --summarize - -update_polkadot_weights: &update-weights - stage: stage2 - timeout: 1d - when: manual - variables: - RUNTIME: polkadot - artifacts: - paths: - - ${RUNTIME}_weights_${CI_COMMIT_SHORT_SHA}.patch - script: - - ./scripts/ci/run_benches_for_runtime.sh $RUNTIME - - git diff -P > ${RUNTIME}_weights_${CI_COMMIT_SHORT_SHA}.patch - # uses the "shell" executors - tags: - - weights - -update_kusama_weights: - <<: *update-weights - variables: - RUNTIME: kusama - -update_westend_weights: - <<: *update-weights - variables: - RUNTIME: westend - -update_rococo_weights: - <<: *update-weights - variables: - RUNTIME: rococo - -#### stage: stage3 - -build-rustdoc: - stage: stage3 - # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs - needs: - - job: test-deterministic-wasm - artifacts: false - <<: *docker-env - <<: *test-refs - variables: - SKIP_WASM_BUILD: 1 - artifacts: - name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}-doc" - when: on_success - expire_in: 1 days - paths: - - ./crate-docs/ - script: - # FIXME: it fails with `RUSTDOCFLAGS="-Dwarnings"` and `--all-features` - # FIXME: return to stable when https://github.com/rust-lang/rust/issues/96937 gets into stable - - time cargo +nightly doc --workspace --verbose --no-deps - - rm -f ./target/doc/.lock - - mv ./target/doc ./crate-docs - # FIXME: remove me after CI image gets nonroot - - chown -R nonroot:nonroot ./crate-docs - - echo "" > ./crate-docs/index.html - -build-implementers-guide: - stage: stage3 - # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs - needs: - - job: test-deterministic-wasm - artifacts: false - <<: *test-refs - <<: *docker-env - <<: *collect-artifacts-short - script: - - cargo install mdbook mdbook-mermaid mdbook-linkcheck - - mdbook build ./roadmap/implementers-guide - - mkdir -p artifacts - - mv roadmap/implementers-guide/book artifacts/ - # FIXME: remove me after CI image gets nonroot - - chown -R nonroot:nonroot artifacts/ - -check-try-runtime: - stage: stage3 - # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs - needs: - - job: test-node-metrics - artifacts: false - <<: *test-refs - <<: *docker-env - <<: *compiler-info - script: - # Check that everything compiles with `try-runtime` feature flag. - - cargo check --features try-runtime --all - -# More info can be found here: https://github.com/paritytech/polkadot/pull/5865 -# Works only in PRs -check-runtime-migration: - stage: stage3 - # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs - needs: - - job: test-node-metrics - artifacts: false - <<: *test-pr-refs - <<: *docker-env - <<: *compiler-info - script: - - | - export has_runtimemigration_label=$(curl -sS -H "Accept: application/vnd.github+json" \ - -H "Authorization: token $GITHUB_PR_TOKEN" \ - https://api.github.com/repos/paritytech/polkadot/issues/$CI_COMMIT_REF_NAME/labels | grep "E1" | wc -l) - - | - if [[ $has_runtimemigration_label != 0 ]]; then - echo "Found label runtimemigration. Running tests" - export RUST_LOG=remote-ext=debug,runtime=debug - time cargo test --release -p westend-runtime -p polkadot-runtime -p kusama-runtime --features try-runtime - else - echo "runtimemigration label not found. Skipping" - fi - - -check-no-default-features: - stage: stage3 - # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs - needs: - - job: test-deterministic-wasm - artifacts: false - <<: *test-refs - <<: *docker-env - <<: *compiler-info - script: - # Check that polkadot-cli will compile no default features. - - pushd ./node/service && cargo check --no-default-features && popd - - pushd ./cli && cargo check --no-default-features --features "service" && popd - - sccache -s - -build-short-benchmark: - stage: stage3 - <<: *test-refs - <<: *docker-env - <<: *collect-artifacts - # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs - needs: - - job: test-node-metrics - artifacts: false - script: - - cargo +nightly build --profile release --locked --features=runtime-benchmarks - - mkdir artifacts - - cp ./target/release/polkadot ./artifacts/ +#### stage: .post deploy-parity-testnet: - stage: stage3 - # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs - needs: - - job: test-deterministic-wasm - artifacts: false - <<: *deploy-testnet-refs + stage: .post + extends: + - .deploy-testnet-refs variables: POLKADOT_CI_COMMIT_NAME: "${CI_COMMIT_REF_NAME}" POLKADOT_CI_COMMIT_REF: "${CI_COMMIT_SHORT_SHA}" allow_failure: false trigger: "parity/infrastructure/parity-testnet" -zombienet-tests-parachains-smoke-test: - stage: stage3 - image: "${ZOMBIENET_IMAGE}" - <<: *kubernetes-env - <<: *zombienet-refs - needs: - - job: publish-polkadot-debug-image - - job: publish-malus-image - - job: publish-test-collators-image - variables: - GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/smoke" - before_script: - - echo "Zombie-net Tests Config" - - echo "${ZOMBIENET_IMAGE}" - - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" - - echo "${MALUS_IMAGE_NAME} ${MALUS_IMAGE_TAG}" - - echo "${GH_DIR}" - - export DEBUG=zombie,zombie::network-node - - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} - - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} - - export COL_IMAGE="docker.io/paritypr/colander:4519" # The collator image is fixed - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh - --github-remote-dir="${GH_DIR}" - --test="0001-parachains-smoke-test.feature" - allow_failure: false - retry: 2 - tags: - - zombienet-polkadot-integration-test - -zombienet-tests-parachains-pvf: - stage: stage3 - image: "${ZOMBIENET_IMAGE}" - <<: *kubernetes-env - <<: *zombienet-refs - needs: - - job: publish-polkadot-debug-image - - job: publish-test-collators-image - variables: - GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/functional" - before_script: - - echo "Zombie-net Tests Config" - - echo "${ZOMBIENET_IMAGE}" - - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" - - echo "COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG}" - - echo "${GH_DIR}" - - export DEBUG=zombie,zombie::network-node - - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} - - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} - - export COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG} - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh - --github-remote-dir="${GH_DIR}" - --test="0001-parachains-pvf.feature" - allow_failure: false - retry: 2 - tags: - - zombienet-polkadot-integration-test - -zombienet-tests-parachains-disputes: - stage: stage3 - image: "${ZOMBIENET_IMAGE}" - <<: *kubernetes-env - <<: *zombienet-refs - needs: - - job: publish-polkadot-debug-image - - job: publish-test-collators-image - - job: publish-malus-image - variables: - GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/functional" - before_script: - - echo "Zombie-net Tests Config" - - echo "${ZOMBIENET_IMAGE_NAME}" - - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" - - echo "${MALUS_IMAGE_NAME} ${MALUS_IMAGE_TAG}" - - echo "${GH_DIR}" - - export DEBUG=zombie,zombie::network-node - - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} - - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} - - export COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG} - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh - --github-remote-dir="${GH_DIR}" - --test="0002-parachains-disputes.feature" - allow_failure: false - retry: 2 - tags: - - zombienet-polkadot-integration-test - -zombienet-tests-parachains-disputes-garbage-candidate: - stage: stage3 - image: "${ZOMBIENET_IMAGE}" - <<: *kubernetes-env - <<: *zombienet-refs - needs: - - job: publish-polkadot-debug-image - - job: publish-test-collators-image - - job: publish-malus-image - variables: - GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/functional" - before_script: - - echo "Zombie-net Tests Config" - - echo "${ZOMBIENET_IMAGE_NAME}" - - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" - - echo "${MALUS_IMAGE_NAME} ${MALUS_IMAGE_TAG}" - - echo "${GH_DIR}" - - export DEBUG=zombie,zombie::network-node - - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} - - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} - - export COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG} - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh - --github-remote-dir="${GH_DIR}" - --test="0003-parachains-garbage-candidate.feature" - allow_failure: false - retry: 2 - tags: - - zombienet-polkadot-integration-test - -zombienet-test-parachains-upgrade-smoke-test: - stage: stage3 - image: "${ZOMBIENET_IMAGE}" - <<: *kubernetes-env - <<: *zombienet-refs - needs: - - job: publish-polkadot-debug-image - - job: publish-malus-image - - job: publish-test-collators-image - variables: - GH_DIR: 'https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/smoke' - before_script: - - echo "ZombieNet Tests Config" - - echo "${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG}" - - echo "docker.io/parity/polkadot-collator:latest" - - echo "${ZOMBIENET_IMAGE}" - - echo "${GH_DIR}" - - export DEBUG=zombie,zombie::network-node - - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} - - export COL_IMAGE="docker.io/parity/polkadot-collator:latest" # Use cumulus lastest image - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh - --github-remote-dir="${GH_DIR}" - --test="0002-parachains-upgrade-smoke-test.feature" - allow_failure: true - retry: 2 - tags: - - zombienet-polkadot-integration-test - -zombienet-tests-misc-paritydb: - stage: stage3 - image: "${ZOMBIENET_IMAGE}" - <<: *kubernetes-env - <<: *zombienet-refs - needs: - - job: publish-polkadot-debug-image - - job: publish-test-collators-image - artifacts: true - variables: - GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/misc" - before_script: - - echo "Zombie-net Tests Config" - - echo "${ZOMBIENET_IMAGE_NAME}" - - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" - - echo "${GH_DIR}" - - export DEBUG=zombie,zombie::network-node - - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} - - export COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG} - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh - --github-remote-dir="${GH_DIR}" - --test="0001-paritydb.feature" - allow_failure: false - retry: 2 - tags: - - zombienet-polkadot-integration-test - -zombienet-tests-malus-dispute-valid: - stage: stage3 - image: "${ZOMBIENET_IMAGE}" - <<: *kubernetes-env - <<: *zombienet-refs - needs: - - job: publish-polkadot-debug-image - - job: publish-malus-image - - job: publish-test-collators-image - variables: - GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/node/malus/integrationtests" - before_script: - - echo "Zombie-net Tests Config" - - echo "${ZOMBIENET_IMAGE_NAME}" - - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" - - echo "${MALUS_IMAGE_NAME} ${MALUS_IMAGE_TAG}" - - echo "${GH_DIR}" - - export DEBUG=zombie* - - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} - - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} - - export COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG} - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh - --github-remote-dir="${GH_DIR}" - --test="0001-dispute-valid-block.feature" - allow_failure: false - retry: 2 - tags: - - zombienet-polkadot-integration-test - -zombienet-tests-deregister-register-validator: - stage: stage3 - image: "${ZOMBIENET_IMAGE}" - <<: *kubernetes-env - <<: *zombienet-refs - needs: - - job: publish-polkadot-debug-image - artifacts: true - variables: - GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/smoke" - before_script: - - echo "Zombie-net Tests Config" - - echo "${ZOMBIENET_IMAGE_NAME}" - - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" - - echo "${GH_DIR}" - - export DEBUG=zombie* - - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} - - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh - --github-remote-dir="${GH_DIR}" - --test="0003-deregister-register-validator-smoke.feature" - allow_failure: false - retry: 2 - tags: - - zombienet-polkadot-integration-test - -zombienet-tests-beefy-and-mmr: - stage: stage3 - image: "${ZOMBIENET_IMAGE}" - <<: *kubernetes-env - <<: *zombienet-refs - needs: - - job: publish-polkadot-debug-image - variables: - GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/functional" - before_script: - - echo "Zombie-net Tests Config" - - echo "${ZOMBIENET_IMAGE_NAME}" - - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" - - echo "${GH_DIR}" - - export DEBUG=zombie* - - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} - script: - - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh - --github-remote-dir="${GH_DIR}" - --test="0003-beefy-and-mmr.feature" - allow_failure: true - retry: 2 - tags: - - zombienet-polkadot-integration-test - -#### stage: stage4 - -publish-rustdoc: - stage: stage4 - <<: *kubernetes-env - image: paritytech/tools:latest - variables: - GIT_DEPTH: 100 - rules: - - if: $CI_PIPELINE_SOURCE == "pipeline" - when: never - - if: $CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_REF_NAME == "master" - - if: $CI_COMMIT_REF_NAME == "master" - # `needs:` can be removed after CI image gets nonroot. In this case `needs:` stops other - # artifacts from being dowloaded by this job. - needs: - - job: build-rustdoc - artifacts: true - - job: build-implementers-guide - artifacts: true - script: - # Save README and docs - - cp -r ./crate-docs/ /tmp/doc/ - - cp -r ./artifacts/book/ /tmp/ - # setup ssh - - eval $(ssh-agent) - - ssh-add - <<< ${GITHUB_SSH_PRIV_KEY} - - mkdir ~/.ssh && touch ~/.ssh/known_hosts - - ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts - # Set git config - - git config user.email "devops-team@parity.io" - - git config user.name "${GITHUB_USER}" - - git config remote.origin.url "git@github.com:/paritytech/${CI_PROJECT_NAME}.git" - - git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" - - git fetch origin gh-pages - - git checkout gh-pages - # Remove everything and restore generated docs and README - - cp index.html /tmp - - cp README.md /tmp - - rm -rf ./* - # dir for rustdoc - - mkdir -p doc - # dir for implementors guide - - mkdir -p book - - mv /tmp/doc/* doc/ - - mv /tmp/book/html/* book/ - - mv /tmp/index.html . - - mv /tmp/README.md . - # Upload files - - git add --all --force - # `git commit` has an exit code of > 0 if there is nothing to commit. - # This causes GitLab to exit immediately and marks this job failed. - # We don't want to mark the entire job failed if there's nothing to - # publish though, hence the `|| true`. - - git commit -m "Updated docs for ${CI_COMMIT_REF_NAME}" || - echo "___Nothing to commit___" - - git push origin gh-pages --force - - echo "___Rustdoc was successfully published to https://paritytech.github.io/polkadot/___" - after_script: - - rm -rf .git/ ./* - -# Run all pallet benchmarks only once to check if there are any errors -short-benchmark-polkadot: &short-bench - stage: stage4 - <<: *test-pr-refs - <<: *docker-env - # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs - needs: - - job: build-short-benchmark - artifacts: true - variables: - RUNTIME: polkadot - script: - - ./artifacts/polkadot benchmark pallet --execution wasm --wasm-execution compiled --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1 - -short-benchmark-kusama: - <<: *short-bench - variables: - RUNTIME: kusama - -short-benchmark-westend: - <<: *short-bench - variables: - RUNTIME: westend - -#### stage: .post - # This job cancels the whole pipeline if any of provided jobs fail. # In a DAG, every jobs chain is executed independently of others. The `fail_fast` principle suggests # to fail the pipeline as soon as possible to shorten the feedback loop. @@ -1054,10 +227,8 @@ short-benchmark-westend: PR_NUM: "${PR_NUM}" trigger: project: "parity/infrastructure/ci_cd/pipeline-stopper" - # remove branch, when pipeline-stopper for polakdot is updated to the same branch - branch: "as-improve" -cancel-pipeline-test-linux-stable: +.cancel-pipeline-test-linux-stable: extends: .cancel-pipeline-template needs: - job: test-linux-stable diff --git a/Cargo.lock b/Cargo.lock index bc268f794ffe..52a38873940b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,7 +33,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", ] [[package]] @@ -68,7 +68,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.3", "once_cell", "version_check", ] @@ -88,15 +88,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf688625d06217d5b1bb0ea9d9c44a1635fd0ee3534466388d18203174f4d11" -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -108,24 +99,30 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.63" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26fa4d7e3f2eebadf743988fc8aec9fa9a9e82611acafd77c1462ed6262440a" +checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" [[package]] name = "approx" -version = "0.5.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +checksum = "072df7202e63b127ab55acfe16ce97013d5b97bf160489336d3f1840fd78e99e" dependencies = [ "num-traits", ] [[package]] name = "arbitrary" -version = "1.1.4" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "510c76ecefdceada737ea728f4f9a84bd2e1ef29f1ba555e560940fe279954de" + +[[package]] +name = "array-bytes" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8931eb436ab9bf1980c6cb2b9d1ba5390cd6793b2c6e2d2ea8147da3570c2a2e" +checksum = "6a913633b0c922e6b745072795f50d90ebea78ba31a57e2ac8c2fc7b50950949" [[package]] name = "arrayref" @@ -192,9 +189,9 @@ dependencies = [ [[package]] name = "async-channel" -version = "1.7.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" +checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" dependencies = [ "concurrent-queue", "event-listener", @@ -217,26 +214,26 @@ dependencies = [ [[package]] name = "async-global-executor" -version = "2.3.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da5b41ee986eed3f524c380e6d64965aea573882a8907682ad100f7859305ca" +checksum = "9586ec52317f36de58453159d48351bc244bc24ced3effc1fce22f3d48664af6" dependencies = [ "async-channel", "async-executor", "async-io", - "async-lock", + "async-mutex", "blocking", "futures-lite", + "num_cpus", "once_cell", ] [[package]] name = "async-io" -version = "1.9.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e21f3a490c72b3b0cf44962180e60045de2925d8dff97918f7ee43c8f637c7" +checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" dependencies = [ - "autocfg", "concurrent-queue", "futures-lite", "libc", @@ -252,21 +249,29 @@ dependencies = [ [[package]] name = "async-lock" -version = "2.5.0" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6a8ea61bf9947a1007c5cada31e647dbc77b103c679858150003ba697ea798b" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-mutex" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6" +checksum = "479db852db25d9dbf6204e6cb6253698f175c15726470f78af0d918e99d6156e" dependencies = [ "event-listener", ] [[package]] name = "async-process" -version = "1.5.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02111fd8655a613c25069ea89fc8d9bb89331fa77486eb3bc059ee757cfa481c" +checksum = "83137067e3a2a6a06d67168e49e68a0957d215410473a740cea95a2425c0b7c6" dependencies = [ "async-io", - "autocfg", "blocking", "cfg-if 1.0.0", "event-listener", @@ -299,7 +304,7 @@ dependencies = [ "log", "memchr", "once_cell", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.7", "pin-utils", "slab", "wasm-bindgen-futures", @@ -307,9 +312,9 @@ dependencies = [ [[package]] name = "async-std-resolver" -version = "0.21.2" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2f8a4a203be3325981310ab243a28e6e4ea55b6519bffce05d41ab60e09ad8" +checksum = "6ba50e24d9ee0a8950d3d03fc6d0dd10aa14b5de3b101949b4e160f7fee7c723" dependencies = [ "async-std", "async-trait", @@ -322,9 +327,9 @@ dependencies = [ [[package]] name = "async-task" -version = "4.3.0" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" +checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" [[package]] name = "async-trait" @@ -347,7 +352,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.7", ] [[package]] @@ -369,30 +374,30 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.66" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +checksum = "5e121dee8023ce33ab248d9ce1493df03c3b38a659b240096fcbd7048ff9c31f" dependencies = [ "addr2line", "cc", "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.29.0", + "object 0.27.1", "rustc-demangle", ] [[package]] name = "base-x" -version = "0.2.11" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" +checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" [[package]] name = "base16ct" @@ -412,11 +417,17 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64ct" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2b2456fd614d856680dcd9fcc660a51a820fa09daef2e49772b56a193c8474" + [[package]] name = "beef" -version = "0.5.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" +checksum = "bed554bd50246729a1ec158d08aa3235d1b69d94ad120ebe187e28894787e736" dependencies = [ "serde", ] @@ -424,14 +435,14 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "array-bytes", "async-trait", "beefy-primitives", "fnv", "futures", "futures-timer", - "hex", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -441,6 +452,7 @@ dependencies = [ "sc-finality-grandpa", "sc-keystore", "sc-network", + "sc-network-common", "sc-network-gossip", "sc-utils", "sp-api", @@ -448,7 +460,7 @@ dependencies = [ "sp-arithmetic", "sp-blockchain", "sp-consensus", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keystore", "sp-mmr-primitives", "sp-runtime", @@ -460,7 +472,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -472,7 +484,7 @@ dependencies = [ "sc-rpc", "sc-utils", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", "thiserror", ] @@ -480,32 +492,30 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "beefy-primitives", "sp-api", + "sp-runtime", ] [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "scale-info", + "serde", "sp-api", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", + "sp-io", + "sp-mmr-primitives", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] -[[package]] -name = "bimap" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc0455254eb5c6964c4545d8bac815e1a1be4f3afe0ae695ea539c12d728d44b" - [[package]] name = "bincode" version = "1.3.3" @@ -517,9 +527,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.59.2" +version = "0.60.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6" dependencies = [ "bitflags", "cexpr", @@ -613,7 +623,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding 0.1.5", + "block-padding", "byte-tools", "byteorder", "generic-array 0.12.4", @@ -625,17 +635,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "block-padding 0.2.1", - "generic-array 0.14.6", + "generic-array 0.14.4", ] [[package]] name = "block-buffer" -version = "0.10.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", ] [[package]] @@ -647,17 +656,11 @@ dependencies = [ "byte-tools", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "blocking" -version = "1.2.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc" +checksum = "046e47d4b2d391b1f6f8b407b1deb8dee56c1852ccd868becf2710f601b5f427" dependencies = [ "async-channel", "async-task", @@ -704,15 +707,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.11.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" +checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" [[package]] name = "byte-slice-cast" -version = "1.2.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" +checksum = "1d30c751592b77c499e7bce34d99d67c2c11bdc0574e9a488ddade14150a4698" [[package]] name = "byte-tools" @@ -745,15 +748,15 @@ dependencies = [ [[package]] name = "cache-padded" -version = "1.2.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" +checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" [[package]] name = "camino" -version = "1.1.1" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +checksum = "52d74260d9bf6944e2208aa46841b4b8f0d7ffc0849a06837b2f510337f86b2b" dependencies = [ "serde", ] @@ -775,16 +778,16 @@ checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" dependencies = [ "camino", "cargo-platform", - "semver 1.0.13", + "semver 1.0.4", "serde", "serde_json", ] [[package]] name = "cc" -version = "1.0.73" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" dependencies = [ "jobserver", ] @@ -798,6 +801,15 @@ dependencies = [ "nom", ] +[[package]] +name = "cfg-expr" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +dependencies = [ + "smallvec", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -818,9 +830,9 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "chacha20" -version = "0.8.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +checksum = "01b72a433d0cf2aef113ba70f62634c56fddb0f244e6377185c56a7cadbd8f91" dependencies = [ "cfg-if 1.0.0", "cipher", @@ -830,9 +842,9 @@ dependencies = [ [[package]] name = "chacha20poly1305" -version = "0.9.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" +checksum = "3b84ed6d1d5f7aa9bdde921a5090e0ca4d934d250ea3b402a5fab3a994e28a2a" dependencies = [ "aead", "chacha20", @@ -843,16 +855,14 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.22" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" dependencies = [ - "iana-time-zone", - "js-sys", + "libc", "num-integer", "num-traits", "time", - "wasm-bindgen", "winapi", ] @@ -875,7 +885,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", ] [[package]] @@ -889,37 +899,35 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.3.3" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b" +checksum = "fa66045b9cb23c2e9c1520732030608b02ee07e5cfaa5a521ec15ded7fa24c90" dependencies = [ "glob", "libc", - "libloading 0.7.3", + "libloading", ] [[package]] name = "clap" -version = "3.2.20" +version = "4.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd" +checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f" dependencies = [ "atty", "bitflags", "clap_derive", "clap_lex", - "indexmap", "once_cell", "strsim", "termcolor", - "textwrap", ] [[package]] name = "clap_derive" -version = "3.2.18" +version = "4.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad" dependencies = [ "heck", "proc-macro-error", @@ -930,22 +938,13 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" dependencies = [ "os_str_bytes", ] -[[package]] -name = "cmake" -version = "0.1.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" -dependencies = [ - "cc", -] - [[package]] name = "coarsetime" version = "0.1.22" @@ -960,9 +959,9 @@ dependencies = [ [[package]] name = "color-eyre" -version = "0.6.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" +checksum = "8ebf286c900a6d5867aeff75cfee3192857bb7f24b547d4f0df2ed6baa812c90" dependencies = [ "backtrace", "eyre", @@ -973,9 +972,9 @@ dependencies = [ [[package]] name = "comfy-table" -version = "6.1.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85914173c2f558d61613bfbbf1911f14e630895087a7ed2fafc0f5319e1536e7" +checksum = "121d8a5b0346092c18a4b2fd6f620d7a06f0eb7ac0a45860939a0884bc579c56" dependencies = [ "strum", "strum_macros", @@ -984,9 +983,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "1.2.4" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" +checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" dependencies = [ "cache-padded", ] @@ -1011,9 +1010,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" dependencies = [ "core-foundation-sys", "libc", @@ -1036,37 +1035,39 @@ dependencies = [ [[package]] name = "cpp_demangle" -version = "0.3.5" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +checksum = "931ab2a3e6330a07900b8e7ca4e106cdcbb93f2b9a52df55e54ee53d8305b55d" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "cpufeatures" -version = "0.2.4" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc948ebb96241bb40ab73effeb80d9f93afaad49359d159a5e61be51619fe813" +checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" dependencies = [ "libc", ] [[package]] name = "cranelift-bforest" -version = "0.85.3" +version = "0.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "749d0d6022c9038dccf480bdde2a38d435937335bf2bb0f14e815d94517cdce8" +checksum = "b27bbd3e6c422cf6282b047bcdd51ecd9ca9f3497a3be0132ffa08e509b824b0" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.85.3" +version = "0.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94370cc7b37bf652ccd8bb8f09bd900997f7ccf97520edfc75554bb5c4abbea" +checksum = "872f5d4557a411b087bd731df6347c142ae1004e6467a144a7e33662e5715a01" dependencies = [ + "arrayvec 0.7.2", + "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", @@ -1081,33 +1082,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.85.3" +version = "0.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a3cea8fdab90e44018c5b9a1dfd460d8ee265ac354337150222a354628bdb6" +checksum = "21b49fdebb29c62c1fc4da1eeebd609e9d530ecde24a9876def546275f73a244" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.85.3" +version = "0.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ac72f76f2698598951ab26d8c96eaa854810e693e7dd52523958b5909fde6b2" +checksum = "5fc0c091e2db055d4d7f6b7cec2d2ead286bcfaea3357c6a52c2a2613a8cb5ac" [[package]] name = "cranelift-entity" -version = "0.85.3" +version = "0.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09eaeacfcd2356fe0e66b295e8f9d59fdd1ac3ace53ba50de14d628ec902f72d" +checksum = "354a9597be87996c9b278655e68b8447f65dd907256855ad773864edee8d985c" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.85.3" +version = "0.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba69c9980d5ffd62c18a2bde927855fcd7c8dc92f29feaf8636052662cbd99c" +checksum = "0cd8dd3fb8b82c772f4172e87ae1677b971676fffa7c4e3398e3047e650a266b" dependencies = [ "cranelift-codegen", "log", @@ -1117,15 +1118,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.85.3" +version = "0.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2920dc1e05cac40304456ed3301fde2c09bd6a9b0210bcfa2f101398d628d5b" +checksum = "b82527802b1f7d8da288adc28f1dc97ea52943f5871c041213f7b5035ac698a7" [[package]] name = "cranelift-native" -version = "0.85.3" +version = "0.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04dfa45f9b2a6f587c564d6b63388e00cd6589d2df6ea2758cf79e1a13285e6" +checksum = "c30ba8b910f1be023af0c39109cb28a8809734942a6b3eecbf2de8993052ea5e" dependencies = [ "cranelift-codegen", "libc", @@ -1134,9 +1135,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.85.3" +version = "0.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31a46513ae6f26f3f267d8d75b5373d555fbbd1e68681f348d99df43f747ec54" +checksum = "776a8916d201894aca9637a20814f1e11abc62acd5cfbe0b4eb2e63922756971" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1150,18 +1151,18 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "crossbeam-channel" -version = "0.5.6" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -1169,9 +1170,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ "cfg-if 1.0.0", "crossbeam-epoch", @@ -1180,23 +1181,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.10" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ - "autocfg", "cfg-if 1.0.0", "crossbeam-utils", + "lazy_static", "memoffset", - "once_cell", "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.3.6" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7" +checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -1204,9 +1204,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.11" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" +checksum = "8ff1f980957787286a554052d03c7aee98d99cc32e09f6d45f0a814133c87978" dependencies = [ "cfg-if 1.0.0", "once_cell", @@ -1224,7 +1224,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", "rand_core 0.6.3", "subtle", "zeroize", @@ -1232,11 +1232,11 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", "typenum", ] @@ -1246,7 +1246,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", "subtle", ] @@ -1256,15 +1256,15 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", "subtle", ] [[package]] name = "ctor" -version = "0.1.23" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdffe87e1d521a10f9696f833fe502293ea446d7f256c06128293a4119bdf4cb" +checksum = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa" dependencies = [ "quote", "syn", @@ -1279,17 +1279,6 @@ dependencies = [ "cipher", ] -[[package]] -name = "cuckoofilter" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b810a8449931679f64cd7eef1bbd0fa315801b6d5d9cdc1ace2804d6529eee18" -dependencies = [ - "byteorder", - "fnv", - "rand 0.7.3", -] - [[package]] name = "curve25519-dalek" version = "2.1.3" @@ -1357,9 +1346,9 @@ dependencies = [ [[package]] name = "debugid" -version = "0.7.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ee87af31d84ef885378aebca32be3d682b0e0dc119d5b4860a2c5bb5046730" +checksum = "f91cf5a8c2f2097e2a32627123508635d47ce10563d999ec1a95addf08b502ba" dependencies = [ "uuid", ] @@ -1399,9 +1388,9 @@ dependencies = [ [[package]] name = "diff" -version = "0.1.13" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" +checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" [[package]] name = "difflib" @@ -1424,7 +1413,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", ] [[package]] @@ -1433,7 +1422,7 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" dependencies = [ - "block-buffer 0.10.2", + "block-buffer 0.10.0", "crypto-common", "subtle", ] @@ -1459,9 +1448,9 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.7" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" dependencies = [ "libc", "redox_users", @@ -1481,9 +1470,9 @@ dependencies = [ [[package]] name = "dissimilar" -version = "1.0.4" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c97b9233581d84b8e1e689cdd3a47b6f69770084fc246e86a7f78b0d9c1d4a5" +checksum = "31ad93652f40969dead8d4bf897a41e9462095152eb21c56e5830537e41179dd" [[package]] name = "dlmalloc" @@ -1501,7 +1490,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" dependencies = [ "byteorder", - "quick-error", + "quick-error 1.2.3", ] [[package]] @@ -1510,6 +1499,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "downcast" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" + [[package]] name = "downcast-rs" version = "1.2.0" @@ -1518,9 +1513,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6053ff46b5639ceb91756a85a4c8914668393a03170efd79c8884a529d80656" +checksum = "5caaa75cbd2b960ff1e5392d2cfb1f44717fffe12fc1f32b7b5d1267f99732a6" [[package]] name = "dyn-clonable" @@ -1545,9 +1540,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.9" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" +checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" [[package]] name = "ecdsa" @@ -1563,9 +1558,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "1.5.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +checksum = "74e1069e39f1454367eb2de793ed062fac4c35c2934b76a81d90dd9abcd28816" dependencies = [ "signature", ] @@ -1580,7 +1575,7 @@ dependencies = [ "ed25519", "rand 0.7.3", "serde", - "sha2 0.9.9", + "sha2 0.9.8", "zeroize", ] @@ -1593,16 +1588,16 @@ dependencies = [ "curve25519-dalek 3.2.0", "hex", "rand_core 0.6.3", - "sha2 0.9.9", + "sha2 0.9.8", "thiserror", "zeroize", ] [[package]] name = "either" -version = "1.8.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "elliptic-curve" @@ -1614,7 +1609,7 @@ dependencies = [ "crypto-bigint", "der", "ff", - "generic-array 0.14.6", + "generic-array 0.14.4", "group", "rand_core 0.6.3", "sec1", @@ -1624,18 +1619,18 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.31" +version = "0.8.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "enum-as-inner" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73" +checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" dependencies = [ "heck", "proc-macro2", @@ -1674,6 +1669,19 @@ dependencies = [ "syn", ] +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime 1.3.0", + "log", + "regex", + "termcolor", +] + [[package]] name = "env_logger" version = "0.9.0" @@ -1681,7 +1689,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" dependencies = [ "atty", - "humantime", + "humantime 2.1.0", "log", "regex", "termcolor", @@ -1695,9 +1703,9 @@ checksum = "68b91989ae21441195d7d9b9993a2f9295c7e1a8c96255d8b729accddc124797" [[package]] name = "erased-serde" -version = "0.3.23" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54558e0ba96fbe24280072642eceb9d7d442e32c7ec0ea9e7ecd7b4ea2cf4e11" +checksum = "ad132dd8d0d0b546348d7d86cb3191aad14b34e5f979781fc005c80d4ac67ffd" dependencies = [ "serde", ] @@ -1725,9 +1733,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "2.5.3" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] name = "exit-future" @@ -1771,9 +1779,9 @@ dependencies = [ [[package]] name = "eyre" -version = "0.6.8" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +checksum = "221239d1d5ea86bf5d6f91c9d6bc3646ffe471b08ff9b0f91c44f115ac969d2b" dependencies = [ "indenter", "once_cell", @@ -1793,9 +1801,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "1.8.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" dependencies = [ "instant", ] @@ -1852,9 +1860,9 @@ dependencies = [ [[package]] name = "ff" -version = "0.11.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" +checksum = "b2958d04124b9f27f175eaeb9a9f383d026098aa837eadd8ba22c11f13a05b9e" dependencies = [ "rand_core 0.6.3", "subtle", @@ -1862,11 +1870,11 @@ dependencies = [ [[package]] name = "file-per-thread-logger" -version = "0.1.5" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e16290574b39ee41c71aeb90ae960c504ebaf1e2a1c87bd52aa56ed6e1a02f" +checksum = "4fdbe0d94371f9ce939b555dd342d0686cc4c0cadbcd4b61d70af5ff97eb4126" dependencies = [ - "env_logger", + "env_logger 0.7.1", "log", ] @@ -1879,7 +1887,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -1912,9 +1920,9 @@ dependencies = [ [[package]] name = "fixed-hash" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", "rand 0.8.5", @@ -1924,21 +1932,32 @@ dependencies = [ [[package]] name = "fixedbitset" -version = "0.4.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +checksum = "398ea4fabe40b9b0d885340a2a991a44c8a645624075ad966d21f88688e2b69e" [[package]] name = "flate2" -version = "1.0.24" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" dependencies = [ + "cfg-if 1.0.0", "crc32fast", + "libc", "libz-sys", "miniz_oxide", ] +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1963,7 +1982,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", ] @@ -1978,10 +1997,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fragile" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85dcb89d2b10c5f6133de2efd8c11959ce9dbb46a2f7a4cab208c4eeda6ce1ab" + [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-system", @@ -1993,19 +2018,21 @@ dependencies = [ "serde", "sp-api", "sp-application-crypto", + "sp-core", "sp-io", "sp-runtime", - "sp-runtime-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-runtime-interface", + "sp-std", + "sp-storage", ] [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "Inflector", + "array-bytes", "chrono", "clap", "comfy-table", @@ -2015,7 +2042,6 @@ dependencies = [ "gethostname", "handlebars", "hash-db", - "hex", "itertools", "kvdb", "lazy_static", @@ -2037,15 +2063,15 @@ dependencies = [ "serde_nanos", "sp-api", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-database", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-externalities", "sp-inherents", "sp-keystore", "sp-runtime", "sp-state-machine", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-storage", + "sp-trie", "tempfile", "thiserror", "thousands", @@ -2054,7 +2080,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2065,7 +2091,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2075,23 +2101,24 @@ dependencies = [ "sp-arithmetic", "sp-npos-elections", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-system", + "frame-try-runtime", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-tracing", ] [[package]] @@ -2109,7 +2136,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "bitflags", "frame-metadata", @@ -2125,25 +2152,28 @@ dependencies = [ "smallvec", "sp-api", "sp-arithmetic", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-core-hashing-proc-macro", "sp-inherents", "sp-io", "sp-runtime", "sp-staking", "sp-state-machine", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-tracing", + "sp-weights", "tt-call", ] [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "Inflector", + "cfg-expr", "frame-support-procedural-tools", + "itertools", "proc-macro2", "quote", "syn", @@ -2152,7 +2182,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2164,7 +2194,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "proc-macro2", "quote", @@ -2174,7 +2204,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2185,11 +2215,11 @@ dependencies = [ "scale-info", "serde", "sp-arithmetic", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", "sp-state-machine", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "sp-version", "trybuild", ] @@ -2197,7 +2227,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-system", @@ -2208,39 +2238,40 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "log", "parity-scale-codec", "scale-info", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "sp-version", + "sp-weights", ] [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "sp-api", @@ -2249,31 +2280,20 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", + "parity-scale-codec", "sp-api", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "fs-err" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64db3e262960f0662f43a6366788d5f10f7f244b8f7d7d987f560baf5ded5c50" - -[[package]] -name = "fs-swap" -version = "0.2.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d47dad3685eceed8488986cad3d5027165ea5edb164331770e2059555f10a5" -dependencies = [ - "lazy_static", - "libc", - "libloading 0.5.2", - "winapi", -] +checksum = "5ebd3504ad6116843b8375ad70df74e7bfe83cac77a1f3fe73200c844d43bfe0" [[package]] name = "fs2" @@ -2299,9 +2319,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.24" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" dependencies = [ "futures-channel", "futures-core", @@ -2314,9 +2334,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.24" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +checksum = "2bfc52cbddcfd745bf1740338492bb0bd83d76c67b445f91c5fb29fae29ecaa1" dependencies = [ "futures-core", "futures-sink", @@ -2324,15 +2344,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.24" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" +checksum = "d2acedae88d38235936c3922476b10fced7b2b68136f5e3c03c2d5be348a1115" [[package]] name = "futures-executor" -version = "0.3.24" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" dependencies = [ "futures-core", "futures-task", @@ -2342,9 +2362,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.24" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" +checksum = "93a66fc6d035a26a3ae255a6d2bca35eda63ae4c5512bef54449113f7a1228e5" [[package]] name = "futures-lite" @@ -2357,15 +2377,15 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.7", "waker-fn", ] [[package]] name = "futures-macro" -version = "0.3.24" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +checksum = "0db9cce532b0eae2ccf2766ab246f114b56b9cf6d445e00c2549fbc100ca045d" dependencies = [ "proc-macro2", "quote", @@ -2374,9 +2394,9 @@ dependencies = [ [[package]] name = "futures-rustls" -version = "0.22.2" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" +checksum = "e01fe9932a224b72b45336d96040aa86386d674a31d0af27d800ea7bc8ca97fe" dependencies = [ "futures-io", "rustls", @@ -2385,15 +2405,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.24" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" +checksum = "ca0bae1fe9752cf7fd9b0064c674ae63f97b37bc714d745cbde0afb7ec4e6765" [[package]] name = "futures-task" -version = "0.3.24" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" +checksum = "842fc63b931f4056a24d59de13fb1272134ce261816e063e634ad0c15cdc5306" [[package]] name = "futures-timer" @@ -2403,9 +2423,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.24" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +checksum = "f0828a5471e340229c11c77ca80017937ce3c58cb788a17e5f1c2d5c485a9577" dependencies = [ "futures-channel", "futures-core", @@ -2414,7 +2434,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.7", "pin-utils", "slab", ] @@ -2431,7 +2451,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "chrono", "frame-election-provider-support", @@ -2454,9 +2474,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" dependencies = [ "typenum", "version_check", @@ -2487,13 +2507,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.10.0+wasi-snapshot-preview1", ] [[package]] @@ -2508,9 +2528,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.26.2" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" dependencies = [ "fallible-iterator", "indexmap", @@ -2519,9 +2539,9 @@ dependencies = [ [[package]] name = "git2" -version = "0.14.4" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0155506aab710a86160ddb504a480d2964d7ab5b9e62419be69e0032bc5931c" +checksum = "3826a6e0e2215d7a41c2bfc7c9244123969273f3476b939a226aac0ab56e9e3c" dependencies = [ "bitflags", "libc", @@ -2538,9 +2558,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "globset" -version = "0.4.9" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" +checksum = "10463d9ff00a2a068db14231982f5132edebad0d7660cd956a1c30292dbcbfbd" dependencies = [ "aho-corasick", "bstr", @@ -2551,14 +2571,15 @@ dependencies = [ [[package]] name = "gloo-timers" -version = "0.2.4" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb7d06c1c8cc2a29bee7ec961009a0b2caa0793ee4900c2ffb348734ba1c8f9" +checksum = "47204a46aaff920a1ea58b11d03dec6f704287d27561724a4631e450654a891f" dependencies = [ "futures-channel", "futures-core", "js-sys", "wasm-bindgen", + "web-sys", ] [[package]] @@ -2574,9 +2595,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.14" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be" +checksum = "d9f1f717ddc7b2ba36df7e871fd88db79326551d3d6f1fc406fbfd28b582ff8e" dependencies = [ "bytes", "fnv", @@ -2587,22 +2608,22 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util", + "tokio-util 0.6.9", "tracing", ] [[package]] name = "handlebars" -version = "4.3.3" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360d9740069b2f6cbb63ce2dbaa71a20d3185350cbb990d7bebeb9318415eb17" +checksum = "99d6a30320f094710245150395bc763ad23128d6a1ebbad7594dc4164b62c56b" dependencies = [ "log", "pest", "pest_derive", + "quick-error 2.0.1", "serde", "serde_json", - "thiserror", ] [[package]] @@ -2620,15 +2641,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] - [[package]] name = "hashbrown" version = "0.12.3" @@ -2665,12 +2677,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" -[[package]] -name = "hex_fmt" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" - [[package]] name = "hmac" version = "0.8.1" @@ -2698,7 +2704,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", - "generic-array 0.14.6", + "generic-array 0.14.4", "hmac 0.8.1", ] @@ -2710,7 +2716,7 @@ checksum = "848e9c511092e0daa0a35a63e8e6e475a3e8f870741448b9f6028d69b142f18e" dependencies = [ "arbitrary", "lazy_static", - "memmap2 0.5.7", + "memmap2 0.5.0", "rustc_version", ] @@ -2733,25 +2739,25 @@ checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ "bytes", "fnv", - "itoa 1.0.3", + "itoa 1.0.1", ] [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.7", ] [[package]] name = "httparse" -version = "1.8.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" [[package]] name = "httpdate" @@ -2759,6 +2765,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error 1.2.3", +] + [[package]] name = "humantime" version = "2.1.0" @@ -2780,8 +2795,8 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.3", - "pin-project-lite 0.2.9", + "itoa 1.0.1", + "pin-project-lite 0.2.7", "socket2", "tokio", "tower-service", @@ -2817,20 +2832,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "iana-time-zone" -version = "0.1.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c495f162af0bf17656d0014a0eded5f3cd2f365fdd204548c2869db89359dc7" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "js-sys", - "once_cell", - "wasm-bindgen", - "winapi", -] - [[package]] name = "idna" version = "0.2.3" @@ -2854,9 +2855,9 @@ dependencies = [ [[package]] name = "if-watch" -version = "1.1.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "015a7df1eb6dda30df37f34b63ada9b7b352984b0e84de2a20ed526345000791" +checksum = "065c008e570a43c00de6aed9714035e5ea6a498c255323db9091722af6ee67dd" dependencies = [ "async-io", "core-foundation", @@ -2881,9 +2882,9 @@ dependencies = [ [[package]] name = "impl-serde" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" dependencies = [ "serde", ] @@ -2912,7 +2913,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", - "hashbrown 0.12.3", + "hashbrown", "serde", ] @@ -2927,9 +2928,9 @@ dependencies = [ [[package]] name = "integer-encoding" -version = "3.0.4" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" +checksum = "90c11140ffea82edce8dcd74137ce9324ec24b3cf0175fc9d7e29164da9915b8" [[package]] name = "integer-sqrt" @@ -2942,15 +2943,9 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec58677acfea8a15352d42fc87d11d63596ade9239e0a7c9352914417515dbe6" - -[[package]] -name = "io-lifetimes" -version = "0.7.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06" +checksum = "24c3f4eff5495aee4c0399d7b6a0dc2b6e81be84242ffbfcf253ebacccc1d0cb" [[package]] name = "ip_network" @@ -2972,9 +2967,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.5.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" +checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" [[package]] name = "itertools" @@ -2993,9 +2988,9 @@ checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "itoa" -version = "1.0.3" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "jobserver" @@ -3008,9 +3003,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.59" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" dependencies = [ "wasm-bindgen", ] @@ -3046,7 +3041,7 @@ dependencies = [ "thiserror", "tokio", "tokio-rustls", - "tokio-util", + "tokio-util 0.7.1", "tracing", "webpki-roots", ] @@ -3154,7 +3149,7 @@ dependencies = [ "soketto", "tokio", "tokio-stream", - "tokio-util", + "tokio-util 0.7.1", "tracing", "tracing-futures", ] @@ -3173,13 +3168,13 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.2" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" +checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" [[package]] name = "kusama-runtime" -version = "0.9.28" +version = "0.9.31" dependencies = [ "beefy-primitives", "bitvec", @@ -3202,10 +3197,12 @@ dependencies = [ "pallet-bounties", "pallet-child-bounties", "pallet-collective", + "pallet-conviction-voting", "pallet-democracy", "pallet-election-provider-multi-phase", "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", + "pallet-fast-unstake", "pallet-gilt", "pallet-grandpa", "pallet-identity", @@ -3220,7 +3217,9 @@ dependencies = [ "pallet-offences-benchmarking", "pallet-preimage", "pallet-proxy", + "pallet-ranked-collective", "pallet-recovery", + "pallet-referenda", "pallet-scheduler", "pallet-session", "pallet-session-benchmarking", @@ -3234,6 +3233,7 @@ dependencies = [ "pallet-treasury", "pallet-utility", "pallet-vesting", + "pallet-whitelist", "pallet-xcm", "pallet-xcm-benchmarks", "parity-scale-codec", @@ -3253,7 +3253,7 @@ dependencies = [ "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-io", "sp-keyring", @@ -3263,10 +3263,10 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-tracing", "sp-transaction-pool", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-trie", "sp-version", "static_assertions", "substrate-wasm-builder", @@ -3279,13 +3279,15 @@ dependencies = [ [[package]] name = "kusama-runtime-constants" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", "smallvec", + "sp-core", "sp-runtime", + "sp-weights", ] [[package]] @@ -3299,9 +3301,9 @@ dependencies = [ [[package]] name = "kvdb" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a301d8ecb7989d4a6e2c57a49baca77d353bdbf879909debe3f375fe25d61f86" +checksum = "585089ceadba0197ffe9af6740ab350b325e3c1f5fccfbc3522e0250c750409b" dependencies = [ "parity-util-mem", "smallvec", @@ -3309,9 +3311,9 @@ dependencies = [ [[package]] name = "kvdb-memorydb" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece7e668abd21387aeb6628130a6f4c802787f014fa46bc83221448322250357" +checksum = "40d109c87bfb7759edd2a49b2649c1afe25af785d930ad6a38479b4dc70dd873" dependencies = [ "kvdb", "parity-util-mem", @@ -3320,15 +3322,13 @@ dependencies = [ [[package]] name = "kvdb-rocksdb" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca7fbdfd71cd663dceb0faf3367a99f8cf724514933e9867cec4995b6027cbc1" +checksum = "c076cc2cdbac89b9910c853a36c957d3862a779f31c2661174222cefb49ee597" dependencies = [ - "fs-swap", "kvdb", "log", "num_cpus", - "owning_ref", "parity-util-mem", "parking_lot 0.12.1", "regex", @@ -3338,9 +3338,9 @@ dependencies = [ [[package]] name = "kvdb-shared-tests" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9001edd3459aa1503ea84215cf4618a6e2e020f51682494cc6f5ab1150e68e" +checksum = "de82a1adb7ade192c0090dd56d059a626191c0638c795eb68aff4b0bd2c1f9be" dependencies = [ "kvdb", ] @@ -3359,15 +3359,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.132" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "libgit2-sys" -version = "0.13.4+1.4.2" +version = "0.13.2+1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0fa6563431ede25f5cc7f6d803c6afbc1c5d3ad3d4925d12c882bf2b526f5d1" +checksum = "3a42de9a51a5c12e00fc0e4ca6bc2ea43582fc6418488e8f615e905d886f258b" dependencies = [ "cc", "libc", @@ -3377,19 +3377,9 @@ dependencies = [ [[package]] name = "libloading" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -dependencies = [ - "cc", - "winapi", -] - -[[package]] -name = "libloading" -version = "0.7.3" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +checksum = "afe203d669ec979b7128619bae5a63b7b42e9203c1b29146079ee05e2f604b52" dependencies = [ "cfg-if 1.0.0", "winapi", @@ -3397,28 +3387,24 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.5" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "292a948cd991e376cf75541fe5b97a1081d713c618b4f1b9500f8844e49eb565" +checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" [[package]] name = "libp2p" -version = "0.46.1" +version = "0.49.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81327106887e42d004fbdab1fef93675be2e2e07c1b95fce45e2cc813485611d" +checksum = "ec878fda12ebec479186b3914ebc48ff180fa4c51847e11a1a68bf65249e02c1" dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.7", + "getrandom 0.2.3", "instant", "lazy_static", - "libp2p-autonat", "libp2p-core", - "libp2p-deflate", "libp2p-dns", - "libp2p-floodsub", - "libp2p-gossipsub", "libp2p-identify", "libp2p-kad", "libp2p-mdns", @@ -3426,49 +3412,24 @@ dependencies = [ "libp2p-mplex", "libp2p-noise", "libp2p-ping", - "libp2p-plaintext", - "libp2p-pnet", - "libp2p-relay", - "libp2p-rendezvous", "libp2p-request-response", "libp2p-swarm", "libp2p-swarm-derive", "libp2p-tcp", - "libp2p-uds", "libp2p-wasm-ext", "libp2p-websocket", "libp2p-yamux", "multiaddr", "parking_lot 0.12.1", "pin-project", - "rand 0.7.3", "smallvec", ] -[[package]] -name = "libp2p-autonat" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4decc51f3573653a9f4ecacb31b1b922dd20c25a6322bb15318ec04287ec46f9" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-request-response", - "libp2p-swarm", - "log", - "prost", - "prost-build", - "rand 0.8.5", -] - [[package]] name = "libp2p-core" -version = "0.34.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf9b94cefab7599b2d3dff2f93bee218c6621d68590b23ede4485813cbcece6" +checksum = "799676bb0807c788065e57551c6527d461ad572162b0519d1958946ff9e0539d" dependencies = [ "asn1_der", "bs58", @@ -3479,7 +3440,6 @@ dependencies = [ "futures-timer", "instant", "lazy_static", - "libsecp256k1", "log", "multiaddr", "multihash", @@ -3489,9 +3449,8 @@ dependencies = [ "prost", "prost-build", "rand 0.8.5", - "ring", "rw-stream-sink", - "sha2 0.10.3", + "sha2 0.10.2", "smallvec", "thiserror", "unsigned-varint", @@ -3499,22 +3458,11 @@ dependencies = [ "zeroize", ] -[[package]] -name = "libp2p-deflate" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0183dc2a3da1fbbf85e5b6cf51217f55b14f5daea0c455a9536eef646bfec71" -dependencies = [ - "flate2", - "futures", - "libp2p-core", -] - [[package]] name = "libp2p-dns" -version = "0.34.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cbf54723250fa5d521383be789bf60efdabe6bacfb443f87da261019a49b4b5" +checksum = "2322c9fb40d99101def6a01612ee30500c89abbbecb6297b3cd252903a4c1720" dependencies = [ "async-std-resolver", "futures", @@ -3525,57 +3473,11 @@ dependencies = [ "trust-dns-resolver", ] -[[package]] -name = "libp2p-floodsub" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98a4b6ffd53e355775d24b76f583fdda54b3284806f678499b57913adb94f231" -dependencies = [ - "cuckoofilter", - "fnv", - "futures", - "libp2p-core", - "libp2p-swarm", - "log", - "prost", - "prost-build", - "rand 0.7.3", - "smallvec", -] - -[[package]] -name = "libp2p-gossipsub" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b4b888cfbeb1f5551acd3aa1366e01bf88ede26cc3c4645d0d2d004d5ca7b0" -dependencies = [ - "asynchronous-codec", - "base64", - "byteorder", - "bytes", - "fnv", - "futures", - "hex_fmt", - "instant", - "libp2p-core", - "libp2p-swarm", - "log", - "prometheus-client", - "prost", - "prost-build", - "rand 0.7.3", - "regex", - "sha2 0.10.3", - "smallvec", - "unsigned-varint", - "wasm-timer", -] - [[package]] name = "libp2p-identify" -version = "0.37.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50b585518f8efd06f93ac2f976bd672e17cdac794644b3117edd078e96bda06" +checksum = "dcf9a121f699e8719bda2e6e9e9b6ddafc6cff4602471d6481c1067930ccb29b" dependencies = [ "asynchronous-codec", "futures", @@ -3583,7 +3485,7 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "lru 0.7.8", + "lru 0.8.0", "prost", "prost-build", "prost-codec", @@ -3594,9 +3496,9 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.38.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740862893bb5f06ac24acc9d49bdeadc3a5e52e51818a30a25c1f3519da2c851" +checksum = "6721c200e2021f6c3fab8b6cf0272ead8912d871610ee194ebd628cecf428f22" dependencies = [ "arrayvec 0.7.2", "asynchronous-codec", @@ -3611,8 +3513,8 @@ dependencies = [ "log", "prost", "prost-build", - "rand 0.7.3", - "sha2 0.10.3", + "rand 0.8.5", + "sha2 0.10.2", "smallvec", "thiserror", "uint", @@ -3622,16 +3524,15 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.38.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66e5e5919509603281033fd16306c61df7a4428ce274b67af5e14b07de5cdcb2" +checksum = "761704e727f7d68d58d7bc2231eafae5fc1b9814de24290f126df09d4bd37a15" dependencies = [ "async-io", "data-encoding", "dns-parser", "futures", "if-watch", - "lazy_static", "libp2p-core", "libp2p-swarm", "log", @@ -3643,25 +3544,23 @@ dependencies = [ [[package]] name = "libp2p-metrics" -version = "0.7.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8aff4a1abef42328fbb30b17c853fff9be986dc39af17ee39f9c5f755c5e0c" +checksum = "9ee31b08e78b7b8bfd1c4204a9dd8a87b4fcdf6dafc57eb51701c1c264a81cb9" dependencies = [ "libp2p-core", - "libp2p-gossipsub", "libp2p-identify", "libp2p-kad", "libp2p-ping", - "libp2p-relay", "libp2p-swarm", "prometheus-client", ] [[package]] name = "libp2p-mplex" -version = "0.34.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61fd1b20638ec209c5075dfb2e8ce6a7ea4ec3cd3ad7b77f7a477c06d53322e2" +checksum = "692664acfd98652de739a8acbb0a0d670f1d67190a49be6b4395e22c37337d89" dependencies = [ "asynchronous-codec", "bytes", @@ -3670,16 +3569,16 @@ dependencies = [ "log", "nohash-hasher", "parking_lot 0.12.1", - "rand 0.7.3", + "rand 0.8.5", "smallvec", "unsigned-varint", ] [[package]] name = "libp2p-noise" -version = "0.37.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "762408cb5d84b49a600422d7f9a42c18012d8da6ebcd570f9a4a4290ba41fb6f" +checksum = "048155686bd81fe6cb5efdef0c6290f25ad32a0a42e8f4f72625cf6a505a206f" dependencies = [ "bytes", "curve25519-dalek 3.2.0", @@ -3690,7 +3589,7 @@ dependencies = [ "prost", "prost-build", "rand 0.8.5", - "sha2 0.10.3", + "sha2 0.10.2", "snow", "static_assertions", "x25519-dalek", @@ -3699,105 +3598,25 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "100a6934ae1dbf8a693a4e7dd1d730fd60b774dafc45688ed63b554497c6c925" -dependencies = [ - "futures", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-swarm", - "log", - "rand 0.7.3", - "void", -] - -[[package]] -name = "libp2p-plaintext" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be27bf0820a6238a4e06365b096d428271cce85a129cf16f2fe9eb1610c4df86" -dependencies = [ - "asynchronous-codec", - "bytes", - "futures", - "libp2p-core", - "log", - "prost", - "prost-build", - "unsigned-varint", - "void", -] - -[[package]] -name = "libp2p-pnet" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1a458bbda880107b5b36fcb9b5a1ef0c329685da0e203ed692a8ebe64cc92c" -dependencies = [ - "futures", - "log", - "pin-project", - "rand 0.7.3", - "salsa20", - "sha3 0.9.1", -] - -[[package]] -name = "libp2p-relay" -version = "0.10.0" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4931547ee0cce03971ccc1733ff05bb0c4349fd89120a39e9861e2bbe18843c3" +checksum = "7228b9318d34689521349a86eb39a3c3a802c9efc99a0568062ffb80913e3f91" dependencies = [ - "asynchronous-codec", - "bytes", - "either", "futures", "futures-timer", "instant", "libp2p-core", "libp2p-swarm", "log", - "pin-project", - "prost", - "prost-build", - "prost-codec", "rand 0.8.5", - "smallvec", - "static_assertions", - "thiserror", - "void", -] - -[[package]] -name = "libp2p-rendezvous" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9511c9672ba33284838e349623319c8cad2d18cfad243ae46c6b7e8a2982ea4e" -dependencies = [ - "asynchronous-codec", - "bimap", - "futures", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-swarm", - "log", - "prost", - "prost-build", - "rand 0.8.5", - "sha2 0.10.3", - "thiserror", - "unsigned-varint", "void", ] [[package]] name = "libp2p-request-response" -version = "0.19.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "508a189e2795d892c8f5c1fa1e9e0b1845d32d7b0b249dbf7b05b18811361843" +checksum = "8827af16a017b65311a410bb626205a9ad92ec0473967618425039fa5231adc1" dependencies = [ "async-trait", "bytes", @@ -3806,16 +3625,16 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "rand 0.7.3", + "rand 0.8.5", "smallvec", "unsigned-varint", ] [[package]] name = "libp2p-swarm" -version = "0.37.0" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ac5be6c2de2d1ff3f7693fda6faf8a827b1f3e808202277783fea9f527d114" +checksum = "46d13df7c37807965d82930c0e4b04a659efcb6cca237373b206043db5398ecf" dependencies = [ "either", "fnv", @@ -3825,7 +3644,7 @@ dependencies = [ "libp2p-core", "log", "pin-project", - "rand 0.7.3", + "rand 0.8.5", "smallvec", "thiserror", "void", @@ -3833,48 +3652,36 @@ dependencies = [ [[package]] name = "libp2p-swarm-derive" -version = "0.28.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f54a64b6957249e0ce782f8abf41d97f69330d02bf229f0672d864f0650cc76" +checksum = "a0eddc4497a8b5a506013c40e8189864f9c3a00db2b25671f428ae9007f3ba32" dependencies = [ + "heck", "quote", "syn", ] [[package]] name = "libp2p-tcp" -version = "0.34.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a6771dc19aa3c65d6af9a8c65222bfc8fcd446630ddca487acd161fa6096f3b" +checksum = "9839d96761491c6d3e238e70554b856956fca0ab60feb9de2cd08eed4473fa92" dependencies = [ "async-io", "futures", "futures-timer", "if-watch", - "ipnet", "libc", "libp2p-core", "log", "socket2", ] -[[package]] -name = "libp2p-uds" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d125e3e5f0d58f3c6ac21815b20cf4b6a88b8db9dc26368ea821838f4161fd4d" -dependencies = [ - "async-std", - "futures", - "libp2p-core", - "log", -] - [[package]] name = "libp2p-wasm-ext" -version = "0.34.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec894790eec3c1608f8d1a8a0bdf0dbeb79ed4de2dce964222011c2896dfa05a" +checksum = "a17b5b8e7a73e379e47b1b77f8a82c4721e97eca01abcd18e9cd91a23ca6ce97" dependencies = [ "futures", "js-sys", @@ -3886,9 +3693,9 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.36.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9808e57e81be76ff841c106b4c5974fb4d41a233a7bdd2afbf1687ac6def3818" +checksum = "3758ae6f89b2531a24b6d9f5776bda6a626b60a57600d7185d43dfa75ca5ecc4" dependencies = [ "either", "futures", @@ -3905,12 +3712,13 @@ dependencies = [ [[package]] name = "libp2p-yamux" -version = "0.38.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6dea686217a06072033dc025631932810e2f6ad784e4fafa42e27d311c7a81c" +checksum = "30f079097a21ad017fc8139460630286f02488c8c13b26affb46623aa20d8845" dependencies = [ "futures", "libp2p-core", + "log", "parking_lot 0.12.1", "thiserror", "yamux", @@ -3918,9 +3726,9 @@ dependencies = [ [[package]] name = "librocksdb-sys" -version = "0.6.1+6.28.2" +version = "0.8.0+7.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc587013734dadb7cf23468e531aa120788b87243648be42e2d3a072186291" +checksum = "611804e4666a25136fcc5f8cf425ab4d26c7f74ea245ffe92ea23b85b6420b5d" dependencies = [ "bindgen", "bzip2-sys", @@ -3933,9 +3741,9 @@ dependencies = [ [[package]] name = "libsecp256k1" -version = "0.7.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" +checksum = "b0452aac8bab02242429380e9b2f94ea20cea2b37e2c1777a1358799bbe97f37" dependencies = [ "arrayref", "base64", @@ -3946,7 +3754,7 @@ dependencies = [ "libsecp256k1-gen-genmult", "rand 0.8.5", "serde", - "sha2 0.9.9", + "sha2 0.9.8", "typenum", ] @@ -3981,9 +3789,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.8" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" dependencies = [ "cc", "libc", @@ -3993,9 +3801,9 @@ dependencies = [ [[package]] name = "linked-hash-map" -version = "0.5.6" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "linked_hash_set" @@ -4016,12 +3824,6 @@ dependencies = [ "statrs", ] -[[package]] -name = "linux-raw-sys" -version = "0.0.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5284f00d480e1c39af34e72f8ad60b94f47007e3481cd3b731c1d67190ddc7b7" - [[package]] name = "linux-raw-sys" version = "0.0.46" @@ -4030,11 +3832,10 @@ checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" [[package]] name = "lock_api" -version = "0.4.8" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f80bf5aacaf25cbfc8210d1cfb718f2bf3b11c4c54e5afe36c236853a8ec390" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" dependencies = [ - "autocfg", "scopeguard", ] @@ -4051,20 +3852,20 @@ dependencies = [ [[package]] name = "lru" -version = "0.6.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ea2d928b485416e8908cff2d97d621db22b27f7b3b6729e438bcf42c671ba91" +checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" dependencies = [ - "hashbrown 0.11.2", + "hashbrown", ] [[package]] name = "lru" -version = "0.7.8" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999beba7b6e8345721bd280141ed958096a2e4abdf74f67ff4ce49b4b54e47a" +checksum = "936d98d2ddd79c18641c6709e7bb09981449694e402d1a0f0f657ea8d61f4a51" dependencies = [ - "hashbrown 0.12.3", + "hashbrown", ] [[package]] @@ -4078,9 +3879,9 @@ dependencies = [ [[package]] name = "lz4" -version = "1.24.0" +version = "1.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9e2dd86df36ce760a60f6ff6ad526f7ba1f14ba0356f8254fb6905e6494df1" +checksum = "aac20ed6991e01bf6a2e68cc73df2b389707403662a8ba89f68511fb340f724c" dependencies = [ "libc", "lz4-sys", @@ -4088,9 +3889,9 @@ dependencies = [ [[package]] name = "lz4-sys" -version = "1.9.4" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" +checksum = "dca79aa95d8b3226213ad454d328369853be3a1382d89532a854f4d69640acae" dependencies = [ "cc", "libc", @@ -4152,17 +3953,17 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "memfd" -version = "0.4.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6627dc657574b49d6ad27105ed671822be56e0d2547d413bfbf3e8d8fa92e7a" +checksum = "480b5a5de855d11ff13195950bdc8b98b5e942ef47afc447f6615cdcc4e15d80" dependencies = [ - "libc", + "rustix", ] [[package]] @@ -4176,47 +3977,47 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.5.7" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95af15f345b17af2efc8ead6080fb8bc376f8cec1b35277b935637595fe77498" +checksum = "4647a11b578fead29cdbb34d4adef8dd3dc35b876c9c6d5240d83f205abfe96e" dependencies = [ "libc", ] [[package]] name = "memoffset" -version = "0.6.5" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] [[package]] name = "memory-db" -version = "0.29.0" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6566c70c1016f525ced45d7b7f97730a2bafb037c788211d0c186ef5b2189f0a" +checksum = "34ac11bb793c28fa095b7554466f53b3a60a2cd002afdac01bcf135cbd73a269" dependencies = [ "hash-db", - "hashbrown 0.12.3", + "hashbrown", "parity-util-mem", ] [[package]] name = "memory-lru" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beeb98b3d1ed2c0054bd81b5ba949a0243c3ccad751d45ea898fa8059fa2860a" +checksum = "ce95ae042940bad7e312857b929ee3d11b8f799a80cb7b9c7ec5125516906395" dependencies = [ - "lru 0.6.6", + "lru 0.8.0", ] [[package]] name = "memory_units" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" [[package]] name = "merlin" @@ -4255,30 +4056,63 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.5.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", + "autocfg", ] [[package]] name = "mio" -version = "0.8.4" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" dependencies = [ "libc", "log", + "miow", + "ntapi", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "winapi", ] [[package]] -name = "more-asserts" -version = "0.2.2" +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + +[[package]] +name = "mockall" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" +checksum = "e2be9a9090bc1cac2930688fa9478092a64c6a92ddc6ae0692d46b37d9cab709" +dependencies = [ + "cfg-if 1.0.0", + "downcast", + "fragile", + "lazy_static", + "mockall_derive", + "predicates", + "predicates-tree", +] + +[[package]] +name = "mockall_derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86d702a0530a0141cf4ed147cf5ec7be6f2c187d4e37fcbefc39cf34116bfe8f" +dependencies = [ + "cfg-if 1.0.0", + "proc-macro2", + "quote", + "syn", +] [[package]] name = "multiaddr" @@ -4311,9 +4145,9 @@ dependencies = [ [[package]] name = "multihash" -version = "0.16.3" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" +checksum = "e3db354f401db558759dfc1e568d010a5d4146f4d3f637be1275ec4a3cf09689" dependencies = [ "blake2b_simd", "blake2s_simd", @@ -4321,8 +4155,8 @@ dependencies = [ "core2", "digest 0.10.3", "multihash-derive", - "sha2 0.10.3", - "sha3 0.10.2", + "sha2 0.10.2", + "sha3", "unsigned-varint", ] @@ -4348,9 +4182,9 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "multistream-select" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "363a84be6453a70e63513660f4894ef815daf88e3356bffcda9ca27d810ce83b" +checksum = "9bc41247ec209813e2fd414d6e16b9d94297dacf3cd613fa6ef09cd4d9755c10" dependencies = [ "bytes", "futures", @@ -4370,7 +4204,7 @@ dependencies = [ "matrixmultiply", "nalgebra-macros", "num-complex", - "num-rational 0.4.1", + "num-rational 0.4.0", "num-traits", "rand 0.8.5", "rand_distr", @@ -4406,9 +4240,9 @@ checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" [[package]] name = "native-tls" -version = "0.2.10" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" +checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d" dependencies = [ "lazy_static", "libc", @@ -4503,9 +4337,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.24.2" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" +checksum = "8f17df307904acd05aa8e32e97bb20f2a0df1728bbc2d771ae8f9a90463441e9" dependencies = [ "bitflags", "cfg-if 1.0.0", @@ -4527,12 +4361,28 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" [[package]] name = "nom" -version = "7.1.1" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" dependencies = [ "memchr", "minimal-lexical", + "version_check", +] + +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi", ] [[package]] @@ -4546,11 +4396,22 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-complex" -version = "0.4.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" +checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085" dependencies = [ "num-traits", ] @@ -4567,9 +4428,9 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ "autocfg", "num-traits", @@ -4582,27 +4443,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ "autocfg", - "num-bigint", + "num-bigint 0.2.6", "num-integer", "num-traits", ] [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" dependencies = [ "autocfg", + "num-bigint 0.4.3", "num-integer", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ "autocfg", "libm", @@ -4610,9 +4472,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ "hermit-abi", "libc", @@ -4620,13 +4482,10 @@ dependencies = [ [[package]] name = "object" -version = "0.28.4" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" dependencies = [ - "crc32fast", - "hashbrown 0.11.2", - "indexmap", "memchr", ] @@ -4636,14 +4495,17 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ + "crc32fast", + "hashbrown", + "indexmap", "memchr", ] [[package]] name = "once_cell" -version = "1.14.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" [[package]] name = "opaque-debug" @@ -4659,41 +4521,29 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.41" +version = "0.10.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0" +checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" dependencies = [ "bitflags", "cfg-if 1.0.0", "foreign-types", "libc", "once_cell", - "openssl-macros", "openssl-sys", ] -[[package]] -name = "openssl-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "openssl-probe" -version = "0.1.5" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" [[package]] name = "openssl-sys" -version = "0.9.75" +version = "0.9.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f" +checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" dependencies = [ "autocfg", "cc", @@ -4704,7 +4554,9 @@ dependencies = [ [[package]] name = "orchestra" -version = "0.0.1" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aab54694ddaa8a9b703724c6ef04272b2d27bc32d2c855aae5cdd1857216b43" dependencies = [ "async-trait", "dyn-clonable", @@ -4713,27 +4565,23 @@ dependencies = [ "orchestra-proc-macro", "pin-project", "prioritized-metered-channel", - "rustversion", "thiserror", "tracing", - "trybuild", ] [[package]] name = "orchestra-proc-macro" -version = "0.0.1" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a702b2f6bf592b3eb06c00d80d05afaf7a8eff6b41bb361e397d799acc21b45a" dependencies = [ - "assert_matches", "expander 0.0.6", "itertools", - "orchestra", "petgraph", "proc-macro-crate", "proc-macro2", "quote", "syn", - "thiserror", - "tracing", ] [[package]] @@ -4747,38 +4595,29 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.3.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" [[package]] name = "output_vt100" -version = "0.1.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" +checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" dependencies = [ "winapi", ] -[[package]] -name = "owning_ref" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" -dependencies = [ - "stable_deref_trait", -] - [[package]] name = "owo-colors" -version = "3.5.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +checksum = "20448fd678ec04e6ea15bbe0476874af65e98a01515d667aa49f1434dc44ebf4" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -4786,13 +4625,13 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-system", @@ -4802,13 +4641,13 @@ dependencies = [ "sp-application-crypto", "sp-authority-discovery", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-system", @@ -4817,13 +4656,13 @@ dependencies = [ "scale-info", "sp-authorship", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -4841,13 +4680,13 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4857,17 +4696,17 @@ dependencies = [ "pallet-balances", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-tracing", ] [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-election-provider-support", "frame-support", @@ -4876,17 +4715,17 @@ dependencies = [ "pallet-bags-list", "pallet-staking", "remote-externalities", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-storage", + "sp-tracing", ] [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -4895,13 +4734,13 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "beefy-primitives", "frame-support", @@ -4911,19 +4750,19 @@ dependencies = [ "scale-info", "serde", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "array-bytes", "beefy-merkle-tree", "beefy-primitives", "frame-support", "frame-system", - "hex", "log", "pallet-beefy", "pallet-mmr", @@ -4931,16 +4770,16 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -4949,16 +4788,16 @@ dependencies = [ "pallet-treasury", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -4968,16 +4807,16 @@ dependencies = [ "pallet-treasury", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -4985,47 +4824,67 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-conviction-voting" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" +dependencies = [ + "assert_matches", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "serde", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", "log", + "pallet-election-provider-support-benchmarking", "parity-scale-codec", "rand 0.7.3", "scale-info", "sp-arithmetic", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-npos-elections", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "static_assertions", "strum", ] @@ -5033,7 +4892,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5046,7 +4905,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -5054,17 +4913,38 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-npos-elections", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", +] + +[[package]] +name = "pallet-fast-unstake" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-staking", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", ] [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -5073,13 +4953,13 @@ dependencies = [ "scale-info", "sp-arithmetic", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -5090,19 +4970,19 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-finality-grandpa", "sp-io", "sp-runtime", "sp-session", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5112,13 +4992,13 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -5128,34 +5008,34 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-keyring", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -5163,16 +5043,16 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5180,24 +5060,24 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-mmr-primitives", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "jsonrpsee", "parity-scale-codec", "serde", "sp-api", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-mmr-primitives", "sp-runtime", ] @@ -5205,39 +5085,40 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-system", "log", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5249,24 +5130,25 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", + "sp-runtime-interface", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "sp-api", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-system", @@ -5277,13 +5159,13 @@ dependencies = [ "serde", "sp-runtime", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5300,59 +5182,96 @@ dependencies = [ "scale-info", "sp-runtime", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-ranked-collective" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", + "sp-arithmetic", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-referenda" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "assert_matches", "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", "scale-info", + "serde", + "sp-arithmetic", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -5362,13 +5281,13 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-system", @@ -5377,19 +5296,19 @@ dependencies = [ "pallet-timestamp", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", "sp-session", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-trie", ] [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -5399,13 +5318,13 @@ dependencies = [ "rand 0.7.3", "sp-runtime", "sp-session", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-system", @@ -5413,13 +5332,13 @@ dependencies = [ "rand_chacha 0.2.2", "scale-info", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5436,13 +5355,13 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5453,7 +5372,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "log", "sp-arithmetic", @@ -5462,7 +5381,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-system", @@ -5470,13 +5389,13 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -5487,14 +5406,14 @@ dependencies = [ "sp-inherents", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "sp-timestamp", ] [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -5504,39 +5423,39 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-support", "frame-system", "parity-scale-codec", "scale-info", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", "parity-scale-codec", "sp-api", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-rpc", "sp-runtime", ] @@ -5544,7 +5463,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5555,7 +5474,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -5566,29 +5485,44 @@ dependencies = [ "scale-info", "serde", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", +] + +[[package]] +name = "pallet-uniques" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", ] [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-benchmarking", "frame-support", @@ -5597,12 +5531,27 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", +] + +[[package]] +name = "pallet-whitelist" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std", ] [[package]] name = "pallet-xcm" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-support", "frame-system", @@ -5613,10 +5562,10 @@ dependencies = [ "polkadot-runtime-parachains", "scale-info", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "xcm", "xcm-builder", "xcm-executor", @@ -5624,7 +5573,7 @@ dependencies = [ [[package]] name = "pallet-xcm-benchmarks" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-benchmarking", "frame-support", @@ -5637,11 +5586,11 @@ dependencies = [ "polkadot-primitives", "polkadot-runtime-common", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-tracing", "xcm", "xcm-builder", "xcm-executor", @@ -5701,12 +5650,12 @@ checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" [[package]] name = "parity-util-mem" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c32561d248d352148124f036cac253a644685a21dc9fea383eb4907d7bd35a8f" +checksum = "0d32c34f4f5ca7f9196001c0aba5a1f9a5a12382c8944b8b0f90233282d1e8f8" dependencies = [ "cfg-if 1.0.0", - "hashbrown 0.12.3", + "hashbrown", "impl-trait-for-tuples", "parity-util-mem-derive", "parking_lot 0.12.1", @@ -5739,9 +5688,9 @@ dependencies = [ [[package]] name = "parity-wasm" -version = "0.42.2" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" +checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" [[package]] name = "parking" @@ -5767,7 +5716,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.3", + "parking_lot_core 0.9.1", ] [[package]] @@ -5786,22 +5735,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.3" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.32.0", ] [[package]] name = "paste" -version = "1.0.9" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" [[package]] name = "pbkdf2" @@ -5835,19 +5784,18 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pest" -version = "2.3.0" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0560d531d1febc25a3c9398a62a71256c0178f2e3443baedd9ad4bb8c9deb4" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" dependencies = [ - "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.3.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "905708f7f674518498c1f8d644481440f476d39ca6ecae83319bba7c6c12da91" +checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" dependencies = [ "pest", "pest_generator", @@ -5855,9 +5803,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.3.0" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5803d8284a629cc999094ecd630f55e91b561a1d1ba75e233b00ae13b91a69ad" +checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" dependencies = [ "pest", "pest_meta", @@ -5868,20 +5816,20 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.3.0" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1538eb784f07615c6d9a8ab061089c6c54a344c5b4301db51990ca1c241e8c04" +checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" dependencies = [ - "once_cell", + "maplit", "pest", - "sha-1 0.10.0", + "sha-1 0.8.2", ] [[package]] name = "petgraph" -version = "0.6.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" +checksum = "4a13a2fa9d0b63e5f22328828741e523766fff0ee9e779316902290dff3f824f" dependencies = [ "fixedbitset", "indexmap", @@ -5915,9 +5863,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" [[package]] name = "pin-utils" @@ -5925,11 +5873,22 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" +dependencies = [ + "der", + "spki", + "zeroize", +] + [[package]] name = "pkg-config" -version = "0.3.25" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" [[package]] name = "platforms" @@ -5939,25 +5898,25 @@ checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" [[package]] name = "polkadot" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_cmd", "color-eyre", - "nix 0.24.2", + "nix 0.24.1", "parity-util-mem", "polkadot-cli", "polkadot-core-primitives", - "remote-externalities", + "substrate-rpc-client", "tempfile", "tokio", ] [[package]] name = "polkadot-approval-distribution" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", - "env_logger", + "env_logger 0.9.0", "futures", "log", "polkadot-node-network-protocol", @@ -5966,22 +5925,23 @@ dependencies = [ "polkadot-node-subsystem-test-helpers", "polkadot-node-subsystem-util", "polkadot-primitives", + "polkadot-primitives-test-helpers", "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.5.1", "schnorrkel", "sp-authority-discovery", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "tracing-gum", ] [[package]] name = "polkadot-availability-bitfield-distribution" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "bitvec", - "env_logger", + "env_logger 0.9.0", "futures", "log", "maplit", @@ -5993,7 +5953,8 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-authority-discovery", + "sp-core", "sp-keyring", "sp-keystore", "tracing-gum", @@ -6001,14 +5962,14 @@ dependencies = [ [[package]] name = "polkadot-availability-distribution" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "derive_more", "fatality", "futures", "futures-timer", - "lru 0.7.8", + "lru 0.8.0", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6020,25 +5981,25 @@ dependencies = [ "polkadot-primitives-test-helpers", "rand 0.8.5", "sc-network", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-keystore", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-tracing", "thiserror", "tracing-gum", ] [[package]] name = "polkadot-availability-recovery" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", - "env_logger", + "env_logger 0.9.0", "fatality", "futures", "futures-timer", "log", - "lru 0.7.8", + "lru 0.8.0", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6051,7 +6012,7 @@ dependencies = [ "rand 0.8.5", "sc-network", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "thiserror", "tracing-gum", @@ -6059,7 +6020,7 @@ dependencies = [ [[package]] name = "polkadot-cli" -version = "0.9.28" +version = "0.9.31" dependencies = [ "clap", "frame-benchmarking-cli", @@ -6075,9 +6036,9 @@ dependencies = [ "sc-service", "sc-sysinfo", "sc-tracing", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-trie", "substrate-build-script-utils", "thiserror", "try-runtime-cli", @@ -6085,7 +6046,7 @@ dependencies = [ [[package]] name = "polkadot-client" -version = "0.9.28" +version = "0.9.31" dependencies = [ "beefy-primitives", "frame-benchmarking", @@ -6111,7 +6072,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-finality-grandpa", "sp-inherents", "sp-keyring", @@ -6119,7 +6080,7 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-storage", "sp-timestamp", "sp-transaction-pool", "westend-runtime", @@ -6127,11 +6088,12 @@ dependencies = [ [[package]] name = "polkadot-collator-protocol" -version = "0.9.28" +version = "0.9.31" dependencies = [ "always-assert", "assert_matches", - "env_logger", + "bitvec", + "env_logger 0.9.0", "fatality", "futures", "futures-timer", @@ -6145,7 +6107,7 @@ dependencies = [ "polkadot-primitives", "polkadot-primitives-test-helpers", "sc-network", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-keystore", "sp-runtime", @@ -6155,19 +6117,19 @@ dependencies = [ [[package]] name = "polkadot-core-primitives" -version = "0.9.28" +version = "0.9.31" dependencies = [ "parity-scale-codec", "parity-util-mem", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "polkadot-dispute-distribution" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "async-trait", @@ -6175,8 +6137,9 @@ dependencies = [ "fatality", "futures", "futures-timer", + "indexmap", "lazy_static", - "lru 0.7.8", + "lru 0.8.0", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6191,27 +6154,27 @@ dependencies = [ "sp-application-crypto", "sp-keyring", "sp-keystore", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-tracing", "thiserror", "tracing-gum", ] [[package]] name = "polkadot-erasure-coding" -version = "0.9.28" +version = "0.9.31" dependencies = [ "parity-scale-codec", "polkadot-node-primitives", "polkadot-primitives", "reed-solomon-novelpoly", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", + "sp-core", + "sp-trie", "thiserror", ] [[package]] name = "polkadot-gossip-support" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "async-trait", @@ -6229,16 +6192,16 @@ dependencies = [ "sp-application-crypto", "sp-authority-discovery", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-keystore", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-tracing", "tracing-gum", ] [[package]] name = "polkadot-network-bridge" -version = "0.9.28" +version = "0.9.31" dependencies = [ "always-assert", "assert_matches", @@ -6259,7 +6222,7 @@ dependencies = [ "sc-network", "sc-network-common", "sp-consensus", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "thiserror", "tracing-gum", @@ -6267,7 +6230,7 @@ dependencies = [ [[package]] name = "polkadot-node-collation-generation" -version = "0.9.28" +version = "0.9.31" dependencies = [ "futures", "parity-scale-codec", @@ -6278,7 +6241,7 @@ dependencies = [ "polkadot-node-subsystem-util", "polkadot-primitives", "polkadot-primitives-test-helpers", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-maybe-compressed-blob", "thiserror", "tracing-gum", @@ -6286,7 +6249,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-approval-voting" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "async-trait", @@ -6296,7 +6259,7 @@ dependencies = [ "futures-timer", "kvdb", "kvdb-memorydb", - "lru 0.7.8", + "lru 0.8.0", "merlin", "parity-scale-codec", "parking_lot 0.12.1", @@ -6315,7 +6278,7 @@ dependencies = [ "sp-consensus", "sp-consensus-babe", "sp-consensus-slots", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-keystore", "sp-runtime", @@ -6325,11 +6288,11 @@ dependencies = [ [[package]] name = "polkadot-node-core-av-store" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "bitvec", - "env_logger", + "env_logger 0.9.0", "futures", "futures-timer", "kvdb", @@ -6345,7 +6308,7 @@ dependencies = [ "polkadot-overseer", "polkadot-primitives", "polkadot-primitives-test-helpers", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "thiserror", "tracing-gum", @@ -6353,7 +6316,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-backing" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "bitvec", @@ -6369,17 +6332,17 @@ dependencies = [ "polkadot-statement-table", "sc-keystore", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-keystore", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-tracing", "thiserror", "tracing-gum", ] [[package]] name = "polkadot-node-core-bitfield-signing" -version = "0.9.28" +version = "0.9.31" dependencies = [ "futures", "polkadot-node-subsystem", @@ -6395,7 +6358,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-candidate-validation" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "async-trait", @@ -6409,7 +6372,7 @@ dependencies = [ "polkadot-parachain", "polkadot-primitives", "polkadot-primitives-test-helpers", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-maybe-compressed-blob", "tracing-gum", @@ -6417,7 +6380,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-chain-api" -version = "0.9.28" +version = "0.9.31" dependencies = [ "futures", "maplit", @@ -6430,13 +6393,13 @@ dependencies = [ "sc-client-api", "sc-consensus-babe", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "tracing-gum", ] [[package]] name = "polkadot-node-core-chain-selection" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "futures", @@ -6450,14 +6413,14 @@ dependencies = [ "polkadot-node-subsystem-test-helpers", "polkadot-node-subsystem-util", "polkadot-primitives", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "thiserror", "tracing-gum", ] [[package]] name = "polkadot-node-core-dispute-coordinator" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "fatality", @@ -6465,7 +6428,7 @@ dependencies = [ "futures-timer", "kvdb", "kvdb-memorydb", - "lru 0.7.8", + "lru 0.8.0", "parity-scale-codec", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -6475,7 +6438,7 @@ dependencies = [ "polkadot-primitives-test-helpers", "sc-keystore", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-keystore", "thiserror", @@ -6484,7 +6447,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-parachains-inherent" -version = "0.9.28" +version = "0.9.31" dependencies = [ "async-trait", "futures", @@ -6500,7 +6463,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-provisioner" -version = "0.9.28" +version = "0.9.31" dependencies = [ "bitvec", "fatality", @@ -6521,7 +6484,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf" -version = "0.9.28" +version = "0.9.31" dependencies = [ "always-assert", "assert_matches", @@ -6533,7 +6496,7 @@ dependencies = [ "parity-scale-codec", "pin-project", "polkadot-core-primitives", - "polkadot-node-subsystem-util", + "polkadot-node-metrics", "polkadot-parachain", "rand 0.8.5", "rayon", @@ -6541,12 +6504,12 @@ dependencies = [ "sc-executor-common", "sc-executor-wasmtime", "slotmap", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", + "sp-externalities", "sp-io", "sp-maybe-compressed-blob", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-wasm-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-tracing", + "sp-wasm-interface", "tempfile", "test-parachain-adder", "test-parachain-halt", @@ -6555,7 +6518,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-pvf-checker" -version = "0.9.28" +version = "0.9.31" dependencies = [ "futures", "futures-timer", @@ -6568,7 +6531,7 @@ dependencies = [ "polkadot-primitives-test-helpers", "sc-keystore", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-keystore", "sp-runtime", @@ -6578,7 +6541,7 @@ dependencies = [ [[package]] name = "polkadot-node-core-runtime-api" -version = "0.9.28" +version = "0.9.31" dependencies = [ "futures", "memory-lru", @@ -6593,14 +6556,14 @@ dependencies = [ "sp-api", "sp-authority-discovery", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "tracing-gum", ] [[package]] name = "polkadot-node-jaeger" -version = "0.9.28" +version = "0.9.31" dependencies = [ "async-std", "lazy_static", @@ -6611,13 +6574,13 @@ dependencies = [ "polkadot-node-primitives", "polkadot-primitives", "sc-network", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "thiserror", ] [[package]] name = "polkadot-node-metrics" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_cmd", "bs58", @@ -6625,7 +6588,7 @@ dependencies = [ "futures-timer", "hyper", "log", - "nix 0.24.2", + "nix 0.24.1", "parity-scale-codec", "polkadot-primitives", "polkadot-test-service", @@ -6645,7 +6608,7 @@ dependencies = [ [[package]] name = "polkadot-node-network-protocol" -version = "0.9.28" +version = "0.9.31" dependencies = [ "async-trait", "derive_more", @@ -6660,6 +6623,7 @@ dependencies = [ "rand_chacha 0.3.1", "sc-authority-discovery", "sc-network", + "sc-network-common", "strum", "thiserror", "tracing-gum", @@ -6667,7 +6631,7 @@ dependencies = [ [[package]] name = "polkadot-node-primitives" -version = "0.9.28" +version = "0.9.31" dependencies = [ "bounded-vec", "futures", @@ -6680,7 +6644,7 @@ dependencies = [ "sp-application-crypto", "sp-consensus-babe", "sp-consensus-vrf", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keystore", "sp-maybe-compressed-blob", "thiserror", @@ -6689,7 +6653,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem" -version = "0.9.28" +version = "0.9.31" dependencies = [ "polkadot-node-jaeger", "polkadot-node-subsystem-types", @@ -6698,7 +6662,7 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-test-helpers" -version = "0.9.28" +version = "0.9.31" dependencies = [ "async-trait", "futures", @@ -6709,14 +6673,14 @@ dependencies = [ "polkadot-primitives", "sc-keystore", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-keystore", ] [[package]] name = "polkadot-node-subsystem-types" -version = "0.9.28" +version = "0.9.31" dependencies = [ "async-trait", "derive_more", @@ -6738,12 +6702,12 @@ dependencies = [ [[package]] name = "polkadot-node-subsystem-util" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "async-trait", "derive_more", - "env_logger", + "env_logger 0.9.0", "fatality", "futures", "itertools", @@ -6751,7 +6715,7 @@ dependencies = [ "kvdb-shared-tests", "lazy_static", "log", - "lru 0.7.8", + "lru 0.8.0", "parity-db", "parity-scale-codec", "parity-util-mem", @@ -6769,7 +6733,7 @@ dependencies = [ "prioritized-metered-channel", "rand 0.8.5", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keystore", "tempfile", "thiserror", @@ -6778,14 +6742,14 @@ dependencies = [ [[package]] name = "polkadot-overseer" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "async-trait", "femme", "futures", "futures-timer", - "lru 0.7.8", + "lru 0.8.0", "orchestra", "parity-util-mem", "parking_lot 0.12.1", @@ -6798,13 +6762,13 @@ dependencies = [ "prioritized-metered-channel", "sc-client-api", "sp-api", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "tracing-gum", ] [[package]] name = "polkadot-parachain" -version = "0.9.28" +version = "0.9.31" dependencies = [ "derive_more", "frame-support", @@ -6813,16 +6777,16 @@ dependencies = [ "polkadot-core-primitives", "scale-info", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "polkadot-performance-test" -version = "0.9.28" +version = "0.9.31" dependencies = [ - "env_logger", + "env_logger 0.9.0", "kusama-runtime", "log", "polkadot-erasure-coding", @@ -6834,7 +6798,7 @@ dependencies = [ [[package]] name = "polkadot-primitives" -version = "0.9.28" +version = "0.9.31" dependencies = [ "bitvec", "frame-system", @@ -6850,31 +6814,32 @@ dependencies = [ "sp-arithmetic", "sp-authority-discovery", "sp-consensus-slots", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-io", "sp-keystore", "sp-runtime", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-trie", "sp-version", ] [[package]] name = "polkadot-primitives-test-helpers" -version = "0.9.28" +version = "0.9.31" dependencies = [ "polkadot-primitives", "rand 0.8.5", "sp-application-crypto", + "sp-core", "sp-keyring", "sp-runtime", ] [[package]] name = "polkadot-rpc" -version = "0.9.28" +version = "0.9.31" dependencies = [ "beefy-gadget", "beefy-gadget-rpc", @@ -6905,7 +6870,7 @@ dependencies = [ [[package]] name = "polkadot-runtime" -version = "0.9.28" +version = "0.9.31" dependencies = [ "beefy-primitives", "bitvec", @@ -6931,6 +6896,7 @@ dependencies = [ "pallet-election-provider-multi-phase", "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", + "pallet-fast-unstake", "pallet-grandpa", "pallet-identity", "pallet-im-online", @@ -6939,6 +6905,7 @@ dependencies = [ "pallet-multisig", "pallet-nomination-pools", "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-runtime-api", "pallet-offences", "pallet-offences-benchmarking", "pallet-preimage", @@ -6973,7 +6940,7 @@ dependencies = [ "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-io", "sp-keyring", @@ -6983,16 +6950,15 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-tracing", "sp-transaction-pool", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-trie", "sp-version", "static_assertions", "substrate-wasm-builder", "tiny-keccak", "tokio", - "trie-db 0.23.1", "xcm", "xcm-builder", "xcm-executor", @@ -7000,7 +6966,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-common" -version = "0.9.28" +version = "0.9.31" dependencies = [ "beefy-primitives", "bitvec", @@ -7036,7 +7002,7 @@ dependencies = [ "serde_json", "slot-range-helper", "sp-api", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-io", "sp-keystore", @@ -7044,37 +7010,38 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "static_assertions", - "trie-db 0.23.1", "xcm", ] [[package]] name = "polkadot-runtime-constants" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", "smallvec", + "sp-core", "sp-runtime", + "sp-weights", ] [[package]] name = "polkadot-runtime-metrics" -version = "0.9.28" +version = "0.9.31" dependencies = [ "bs58", "parity-scale-codec", "polkadot-primitives", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-tracing", ] [[package]] name = "polkadot-runtime-parachains" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "bitflags", @@ -7107,7 +7074,7 @@ dependencies = [ "serde", "sp-api", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-io", "sp-keyring", @@ -7115,8 +7082,8 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-tracing", "static_assertions", "thousands", "xcm", @@ -7125,13 +7092,14 @@ dependencies = [ [[package]] name = "polkadot-service" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "async-trait", "beefy-gadget", "beefy-primitives", - "env_logger", + "env_logger 0.9.0", + "frame-support", "frame-system-rpc-runtime-api", "futures", "hex-literal", @@ -7140,7 +7108,7 @@ dependencies = [ "kvdb", "kvdb-rocksdb", "log", - "lru 0.7.8", + "lru 0.8.0", "pallet-babe", "pallet-im-online", "pallet-staking", @@ -7213,7 +7181,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-finality-grandpa", "sp-inherents", "sp-io", @@ -7222,10 +7190,10 @@ dependencies = [ "sp-runtime", "sp-session", "sp-state-machine", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-storage", "sp-timestamp", "sp-transaction-pool", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-trie", "substrate-prometheus-endpoint", "tempfile", "thiserror", @@ -7236,7 +7204,7 @@ dependencies = [ [[package]] name = "polkadot-statement-distribution" -version = "0.9.28" +version = "0.9.31" dependencies = [ "arrayvec 0.5.2", "assert_matches", @@ -7256,27 +7224,27 @@ dependencies = [ "sc-network", "sp-application-crypto", "sp-authority-discovery", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-keystore", "sp-staking", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-tracing", "thiserror", "tracing-gum", ] [[package]] name = "polkadot-statement-table" -version = "0.9.28" +version = "0.9.31" dependencies = [ "parity-scale-codec", "polkadot-primitives", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", ] [[package]] name = "polkadot-test-client" -version = "0.9.28" +version = "0.9.31" dependencies = [ "futures", "parity-scale-codec", @@ -7291,7 +7259,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-keyring", "sp-runtime", @@ -7302,7 +7270,7 @@ dependencies = [ [[package]] name = "polkadot-test-malus" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "async-trait", @@ -7323,14 +7291,15 @@ dependencies = [ "polkadot-node-subsystem-types", "polkadot-node-subsystem-util", "polkadot-primitives", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "rand 0.8.5", + "sp-core", "sp-keystore", "tracing-gum", ] [[package]] name = "polkadot-test-runtime" -version = "0.9.28" +version = "0.9.31" dependencies = [ "beefy-primitives", "bitvec", @@ -7372,7 +7341,7 @@ dependencies = [ "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-io", "sp-keyring", @@ -7381,9 +7350,9 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "sp-transaction-pool", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-trie", "sp-version", "substrate-wasm-builder", "test-runtime-constants", @@ -7395,7 +7364,7 @@ dependencies = [ [[package]] name = "polkadot-test-service" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-benchmarking", "frame-system", @@ -7434,7 +7403,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-finality-grandpa", "sp-inherents", "sp-keyring", @@ -7450,7 +7419,7 @@ dependencies = [ [[package]] name = "polkadot-voter-bags" -version = "0.9.28" +version = "0.9.31" dependencies = [ "clap", "generate-bags", @@ -7462,11 +7431,10 @@ dependencies = [ [[package]] name = "polling" -version = "2.3.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899b00b9c8ab553c743b3e11e87c5c7d423b2a2de229ba95b24a756344748011" +checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" dependencies = [ - "autocfg", "cfg-if 1.0.0", "libc", "log", @@ -7519,32 +7487,35 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" [[package]] name = "predicates" -version = "2.1.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5aab5be6e4732b473071984b3164dbbfb7a3674d30ea5ff44410b6bcd960c3c" +checksum = "95e5a7689e456ab905c22c2b48225bb921aba7c8dfa58440d68ba13f6222a715" dependencies = [ "difflib", + "float-cmp", "itertools", + "normalize-line-endings", "predicates-core", + "regex", ] [[package]] name = "predicates-core" -version = "1.0.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da1c2388b1513e1b605fcec39a95e0a9e8ef088f71443ef37099fa9ae6673fcb" +checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" [[package]] name = "predicates-tree" -version = "1.0.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d86de6de25020a36c6d3643a86d9a6a9f552107c0559c60ea03551b5e16c032" +checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7" dependencies = [ "predicates-core", "termtree", @@ -7552,21 +7523,21 @@ dependencies = [ [[package]] name = "pretty_assertions" -version = "1.3.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" +checksum = "c89f989ac94207d048d92db058e4f6ec7342b0971fc58d1271ca148b799b3563" dependencies = [ + "ansi_term", "ctor", "diff", "output_vt100", - "yansi", ] [[package]] name = "primitive-types" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" +checksum = "5cfd65aea0c5fa0bfcc7c9e7ca828c921ef778f43d325325ec84bda371bfa75a" dependencies = [ "fixed-hash", "impl-codec", @@ -7578,15 +7549,14 @@ dependencies = [ [[package]] name = "prioritized-metered-channel" version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382698e48a268c832d0b181ed438374a6bb708a82a8ca273bb0f61c74cf209c4" dependencies = [ - "assert_matches", "coarsetime", "crossbeam-queue", "derive_more", - "env_logger", "futures", "futures-timer", - "log", "nanorand", "thiserror", "tracing", @@ -7594,11 +7564,10 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.2.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ - "once_cell", "thiserror", "toml", ] @@ -7638,35 +7607,35 @@ dependencies = [ [[package]] name = "prometheus" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cface98dfa6d645ea4c789839f176e4b072265d085bfcc48eaa8d137f58d3c39" +checksum = "b7f64969ffd5dd8f39bd57a68ac53c163a095ed9d0fb707146da1b27025a3504" dependencies = [ "cfg-if 1.0.0", "fnv", "lazy_static", "memchr", - "parking_lot 0.12.1", + "parking_lot 0.11.2", "thiserror", ] [[package]] name = "prometheus-client" -version = "0.16.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1abe0255c04d15f571427a2d1e00099016506cf3297b53853acd2b7eb87825" +checksum = "83cd1b99916654a69008fd66b4f9397fbe08e6e51dfe23d4417acf5d3b8cb87c" dependencies = [ "dtoa", - "itoa 1.0.3", - "owning_ref", + "itoa 1.0.1", + "parking_lot 0.12.1", "prometheus-client-derive-text-encode", ] [[package]] name = "prometheus-client-derive-text-encode" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e12d01b9d66ad9eb4529c57666b6263fc1993cb30261d83ead658fdd932652" +checksum = "66a455fbcb954c1a7decf3c586e860fd7889cddf4b8e164be736dbac95a953cd" dependencies = [ "proc-macro2", "quote", @@ -7675,21 +7644,20 @@ dependencies = [ [[package]] name = "prometheus-parse" -version = "0.2.3" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef7a8ed15bcffc55fe0328931ef20d393bb89ad704756a37bd20cffb4804f306" +checksum = "c996f3caea1c51aa034c0d2dfd8447a12c555f4567b02677ef8a865ac4cce712" dependencies = [ "chrono", - "itertools", "lazy_static", "regex", ] [[package]] name = "prost" -version = "0.10.4" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71adf41db68aa0daaefc69bb30bcd68ded9b9abaad5d1fbb6304c4fb390e083e" +checksum = "399c3c31cdec40583bb68f0b18403400d01ec4289c383aa047560439952c4dd7" dependencies = [ "bytes", "prost-derive", @@ -7697,13 +7665,11 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.10.4" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae5a4388762d5815a9fc0dea33c56b021cdc8dde0c55e0c9ca57197254b0cab" +checksum = "7f835c582e6bd972ba8347313300219fed5bfa52caf175298d860b61ff6069bb" dependencies = [ "bytes", - "cfg-if 1.0.0", - "cmake", "heck", "itertools", "lazy_static", @@ -7719,9 +7685,9 @@ dependencies = [ [[package]] name = "prost-codec" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00af1e92c33b4813cc79fda3f2dbf56af5169709be0202df730e9ebc3e4cd007" +checksum = "011ae9ff8359df7915f97302d591cdd9e0e27fbd5a4ddc5bd13b71079bb20987" dependencies = [ "asynchronous-codec", "bytes", @@ -7732,9 +7698,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b670f45da57fb8542ebdbb6105a925fe571b67f9e7ed9f47a06a84e72b4e7cc" +checksum = "7345d5f0e08c0536d7ac7229952590239e77abf0a0100a1b1d890add6ea96364" dependencies = [ "anyhow", "itertools", @@ -7745,9 +7711,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.10.1" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d0a014229361011dc8e69c8a1ec6c2e8d0f2af7c91e3ea3f5b2170298461e68" +checksum = "4dfaa718ad76a44b3415e6c4d53b17c8f99160dcb3a99b10470fce8ad43f6e3e" dependencies = [ "bytes", "prost", @@ -7755,9 +7721,9 @@ dependencies = [ [[package]] name = "psm" -version = "0.1.20" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f446d0a6efba22928558c4fb4ce0b3fd6c89b0061343e390bf01a703742b8125" +checksum = "cd136ff4382c4753fc061cb9e4712ab2af263376b95bbd5bd8cd50c020b78e69" dependencies = [ "cc", ] @@ -7781,6 +7747,12 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quicksink" version = "0.1.2" @@ -7794,9 +7766,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.21" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" dependencies = [ "proc-macro2", ] @@ -7867,14 +7839,14 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.3", ] [[package]] name = "rand_distr" -version = "0.4.3" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" +checksum = "964d548f8e7d12e102ef183a0de7e98180c9f8729f555897a857b96e48122d2f" dependencies = [ "num-traits", "rand 0.8.5", @@ -7915,9 +7887,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.5.3" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" dependencies = [ "autocfg", "crossbeam-deque", @@ -7927,34 +7899,34 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.9.3" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" dependencies = [ "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", + "lazy_static", "num_cpus", ] [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.3", "redox_syscall", - "thiserror", ] [[package]] @@ -7966,24 +7938,24 @@ dependencies = [ "derive_more", "fs-err", "itertools", - "static_init", + "static_init 0.5.2", "thiserror", ] [[package]] name = "ref-cast" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed13bcd201494ab44900a96490291651d200730904221832b9547d24a87d332b" +checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5234cd6063258a5e32903b53b1b6ac043a0541c8adc1f610f67b0326c7a578fa" +checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2" dependencies = [ "proc-macro2", "quote", @@ -7992,9 +7964,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.2.3" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a8d23b35d7177df3b9d31ed8a9ab4bf625c668be77a319d4f5efd4a5257701c" +checksum = "d43a209257d978ef079f3d446331d0f1794f5e0fc19b306a199983857833a779" dependencies = [ "fxhash", "log", @@ -8004,9 +7976,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ "aho-corasick", "memchr", @@ -8024,25 +7996,13 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" - -[[package]] -name = "region" -version = "2.2.0" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" -dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", -] +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "remote-ext-tests-bags-list" -version = "0.9.28" +version = "0.9.31" dependencies = [ "clap", "frame-system", @@ -8052,8 +8012,8 @@ dependencies = [ "pallet-bags-list-remote-tests", "polkadot-runtime", "polkadot-runtime-constants", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", + "sp-tracing", "tokio", "westend-runtime", "westend-runtime-constants", @@ -8062,18 +8022,18 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ - "env_logger", - "jsonrpsee", + "env_logger 0.9.0", "log", "parity-scale-codec", "serde", "serde_json", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", "sp-version", + "substrate-rpc-client", ] [[package]] @@ -8108,7 +8068,7 @@ dependencies = [ "mime", "native-tls", "percent-encoding", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.7", "serde", "serde_json", "serde_urlencoded", @@ -8129,7 +8089,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" dependencies = [ "hostname", - "quick-error", + "quick-error 1.2.3", ] [[package]] @@ -8160,9 +8120,9 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "620f4129485ff1a7128d184bc687470c21c7951b64779ebc9cfdad3dcd920290" +checksum = "7e9562ea1d70c0cc63a34a22d977753b50cca91cc6b6527750463bd5dd8697bc" dependencies = [ "libc", "librocksdb-sys", @@ -8170,7 +8130,7 @@ dependencies = [ [[package]] name = "rococo-runtime" -version = "0.9.28" +version = "0.9.31" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -8188,23 +8148,37 @@ dependencies = [ "pallet-balances", "pallet-beefy", "pallet-beefy-mmr", + "pallet-bounties", + "pallet-child-bounties", "pallet-collective", + "pallet-democracy", + "pallet-elections-phragmen", + "pallet-gilt", "pallet-grandpa", + "pallet-identity", "pallet-im-online", "pallet-indices", "pallet-membership", "pallet-mmr", "pallet-multisig", "pallet-offences", + "pallet-preimage", "pallet-proxy", + "pallet-recovery", + "pallet-scheduler", "pallet-session", + "pallet-society", "pallet-staking", "pallet-sudo", "pallet-timestamp", + "pallet-tips", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", "pallet-utility", + "pallet-vesting", "pallet-xcm", + "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-parachain", "polkadot-primitives", @@ -8212,25 +8186,31 @@ dependencies = [ "polkadot-runtime-parachains", "rococo-runtime-constants", "scale-info", + "separator", "serde", "serde_derive", + "serde_json", "smallvec", "sp-api", "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-io", + "sp-keyring", "sp-mmr-primitives", "sp-offchain", "sp-runtime", "sp-session", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "sp-transaction-pool", + "sp-trie", "sp-version", + "static_assertions", "substrate-wasm-builder", + "tiny-keccak", "xcm", "xcm-builder", "xcm-executor", @@ -8238,20 +8218,22 @@ dependencies = [ [[package]] name = "rococo-runtime-constants" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", "smallvec", + "sp-core", "sp-runtime", + "sp-weights", ] [[package]] name = "rpassword" -version = "5.0.1" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc936cf8a7ea60c58f030fd36a612a48f440610214dc54bc36431f9ea0c3efb" +checksum = "26b763cb66df1c928432cc35053f8bd4cec3335d8559fc16010017d16b3c1680" dependencies = [ "libc", "winapi", @@ -8268,7 +8250,7 @@ dependencies = [ "log", "netlink-packet-route", "netlink-proto", - "nix 0.24.2", + "nix 0.24.1", "thiserror", ] @@ -8296,21 +8278,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.13", -] - -[[package]] -name = "rustix" -version = "0.33.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938a344304321a9da4973b9ff4f9f8db9caf4597dfd9dda6a60b523340a0fff0" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes 0.5.3", - "libc", - "linux-raw-sys 0.0.42", - "winapi", + "semver 1.0.4", ] [[package]] @@ -8321,17 +8289,17 @@ checksum = "72c825b8aa8010eb9ee99b75f05e10180b9278d161583034d7574c9d617aeada" dependencies = [ "bitflags", "errno", - "io-lifetimes 0.7.3", + "io-lifetimes", "libc", - "linux-raw-sys 0.0.46", - "windows-sys", + "linux-raw-sys", + "windows-sys 0.36.1", ] [[package]] name = "rustls" -version = "0.20.6" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aab8ee6c7097ed6057f43c187a62418d0c05a4bd5f18b3571db50ee0f9ce033" +checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84" dependencies = [ "log", "ring", @@ -8341,9 +8309,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.6.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" +checksum = "5ca9ebdfa27d3fc180e42879037b5338ab1c040c06affd00d8338598e7800943" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -8353,18 +8321,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" +checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" dependencies = [ "base64", ] [[package]] name = "rustversion" -version = "1.0.9" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" [[package]] name = "rw-stream-sink" @@ -8379,18 +8347,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" - -[[package]] -name = "salsa20" -version = "0.9.0" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0fbb5f676da676c260ba276a8f43a8dc67cf02d1438423aeb1c677a7212686" -dependencies = [ - "cipher", -] +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" [[package]] name = "same-file" @@ -8404,19 +8363,20 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "log", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-wasm-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", + "sp-wasm-interface", "thiserror", ] [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "async-trait", "futures", "futures-timer", "ip_network", @@ -8427,12 +8387,11 @@ dependencies = [ "prost-build", "rand 0.7.3", "sc-client-api", - "sc-network", "sc-network-common", "sp-api", "sp-authority-discovery", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keystore", "sp-runtime", "substrate-prometheus-endpoint", @@ -8442,7 +8401,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "futures", "futures-timer", @@ -8456,7 +8415,7 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-consensus", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-runtime", "substrate-prometheus-endpoint", @@ -8465,14 +8424,14 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "sc-client-api", "sp-api", "sp-block-builder", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-runtime", "sp-state-machine", @@ -8481,24 +8440,24 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "impl-trait-for-tuples", - "memmap2 0.5.7", + "memmap2 0.5.0", "parity-scale-codec", "sc-chain-spec-derive", - "sc-network", + "sc-network-common", "sc-telemetry", "serde", "serde_json", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", ] [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8509,13 +8468,13 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "array-bytes", "chrono", "clap", "fdlimit", "futures", - "hex", "libp2p", "log", "names", @@ -8527,6 +8486,7 @@ dependencies = [ "sc-client-db", "sc-keystore", "sc-network", + "sc-network-common", "sc-service", "sc-telemetry", "sc-tracing", @@ -8534,7 +8494,7 @@ dependencies = [ "serde", "serde_json", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-keystore", "sp-panic-handler", @@ -8548,7 +8508,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "fnv", "futures", @@ -8562,21 +8522,21 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-consensus", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-database", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-externalities", "sp-keystore", "sp-runtime", "sp-state-machine", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-storage", + "sp-trie", "substrate-prometheus-endpoint", ] [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "hash-db", "kvdb", @@ -8591,17 +8551,17 @@ dependencies = [ "sc-state-db", "sp-arithmetic", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-database", "sp-runtime", "sp-state-machine", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-trie", ] [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "futures", @@ -8615,7 +8575,7 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-consensus", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", "sp-state-machine", "substrate-prometheus-endpoint", @@ -8625,14 +8585,14 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "fork-tree", "futures", "log", "merlin", - "num-bigint", + "num-bigint 0.2.6", "num-rational 0.2.4", "num-traits", "parity-scale-codec", @@ -8654,7 +8614,7 @@ dependencies = [ "sp-consensus-babe", "sp-consensus-slots", "sp-consensus-vrf", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-io", "sp-keystore", @@ -8667,7 +8627,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "futures", "jsonrpsee", @@ -8680,7 +8640,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keystore", "sp-runtime", "thiserror", @@ -8689,7 +8649,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8702,7 +8662,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "futures", @@ -8716,18 +8676,17 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-slots", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-runtime", "sp-state-machine", - "sp-timestamp", "thiserror", ] [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "lazy_static", "lru 0.7.8", @@ -8737,16 +8696,16 @@ dependencies = [ "sc-executor-wasmi", "sc-executor-wasmtime", "sp-api", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-core-hashing-proc-macro", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-externalities", "sp-io", "sp-panic-handler", - "sp-runtime-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-runtime-interface", "sp-tasks", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-trie", "sp-version", - "sp-wasm-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-wasm-interface", "tracing", "wasmi", ] @@ -8754,14 +8713,14 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "environmental", "parity-scale-codec", "sc-allocator", "sp-maybe-compressed-blob", "sp-sandbox", - "sp-wasm-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-wasm-interface", "thiserror", "wasm-instrument", "wasmi", @@ -8770,51 +8729,51 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "log", "parity-scale-codec", "sc-allocator", "sc-executor-common", - "sp-runtime-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-runtime-interface", "sp-sandbox", - "sp-wasm-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-wasm-interface", "wasmi", ] [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "cfg-if 1.0.0", "libc", "log", "once_cell", "parity-scale-codec", - "parity-wasm 0.42.2", - "rustix 0.35.9", + "parity-wasm 0.45.0", + "rustix", "sc-allocator", "sc-executor-common", - "sp-runtime-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-runtime-interface", "sp-sandbox", - "sp-wasm-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-wasm-interface", "wasmtime", ] [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "ahash", + "array-bytes", "async-trait", "dyn-clone", "finality-grandpa", "fork-tree", "futures", "futures-timer", - "hex", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -8835,7 +8794,7 @@ dependencies = [ "sp-arithmetic", "sp-blockchain", "sp-consensus", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-finality-grandpa", "sp-keystore", "sp-runtime", @@ -8846,7 +8805,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "finality-grandpa", "futures", @@ -8859,7 +8818,7 @@ dependencies = [ "serde", "serde_json", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", "thiserror", ] @@ -8867,7 +8826,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "ansi_term", "futures", @@ -8884,14 +8843,14 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "array-bytes", "async-trait", - "hex", "parking_lot 0.12.1", "serde_json", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keystore", "thiserror", ] @@ -8899,8 +8858,9 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "array-bytes", "async-trait", "asynchronous-codec", "bitflags", @@ -8911,7 +8871,6 @@ dependencies = [ "fork-tree", "futures", "futures-timer", - "hex", "ip_network", "libp2p", "linked-hash-map", @@ -8922,7 +8881,6 @@ dependencies = [ "parking_lot 0.12.1", "pin-project", "prost", - "prost-build", "rand 0.7.3", "sc-block-builder", "sc-client-api", @@ -8936,40 +8894,64 @@ dependencies = [ "sp-arithmetic", "sp-blockchain", "sp-consensus", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", "substrate-prometheus-endpoint", "thiserror", "unsigned-varint", - "void", "zeroize", ] +[[package]] +name = "sc-network-bitswap" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" +dependencies = [ + "cid", + "futures", + "libp2p", + "log", + "prost", + "prost-build", + "sc-client-api", + "sc-network-common", + "sp-blockchain", + "sp-runtime", + "thiserror", + "unsigned-varint", + "void", +] + [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "bitflags", "bytes", "futures", + "futures-timer", "libp2p", + "linked_hash_set", "parity-scale-codec", "prost-build", "sc-consensus", "sc-peerset", + "serde", "smallvec", + "sp-blockchain", "sp-consensus", "sp-finality-grandpa", "sp-runtime", + "substrate-prometheus-endpoint", "thiserror", ] [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "ahash", "futures", @@ -8977,8 +8959,8 @@ dependencies = [ "libp2p", "log", "lru 0.7.8", - "sc-network", "sc-network-common", + "sc-peerset", "sp-runtime", "substrate-prometheus-endpoint", "tracing", @@ -8987,10 +8969,10 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "array-bytes", "futures", - "hex", "libp2p", "log", "parity-scale-codec", @@ -9000,7 +8982,7 @@ dependencies = [ "sc-network-common", "sc-peerset", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", "thiserror", ] @@ -9008,14 +8990,15 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "array-bytes", "fork-tree", "futures", - "hex", "libp2p", "log", "lru 0.7.8", + "mockall", "parity-scale-codec", "prost", "prost-build", @@ -9023,39 +9006,60 @@ dependencies = [ "sc-consensus", "sc-network-common", "sc-peerset", + "sc-utils", "smallvec", "sp-arithmetic", "sp-blockchain", "sp-consensus", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-finality-grandpa", "sp-runtime", "thiserror", ] +[[package]] +name = "sc-network-transactions" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" +dependencies = [ + "array-bytes", + "futures", + "hex", + "libp2p", + "log", + "parity-scale-codec", + "pin-project", + "sc-network-common", + "sc-peerset", + "sp-consensus", + "sp-runtime", + "substrate-prometheus-endpoint", +] + [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "array-bytes", "bytes", "fnv", "futures", "futures-timer", - "hex", "hyper", "hyper-rustls", + "libp2p", "num_cpus", "once_cell", "parity-scale-codec", "parking_lot 0.12.1", "rand 0.7.3", "sc-client-api", - "sc-network", "sc-network-common", + "sc-peerset", "sc-utils", "sp-api", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-offchain", "sp-runtime", "threadpool", @@ -9065,7 +9069,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "futures", "libp2p", @@ -9078,7 +9082,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9087,7 +9091,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "futures", "hash-db", @@ -9105,7 +9109,7 @@ dependencies = [ "serde_json", "sp-api", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keystore", "sp-offchain", "sp-rpc", @@ -9117,7 +9121,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "futures", "jsonrpsee", @@ -9129,10 +9133,10 @@ dependencies = [ "scale-info", "serde", "serde_json", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-rpc", "sp-runtime", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-tracing", "sp-version", "thiserror", ] @@ -9140,7 +9144,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "futures", "jsonrpsee", @@ -9150,10 +9154,29 @@ dependencies = [ "tokio", ] +[[package]] +name = "sc-rpc-spec-v2" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" +dependencies = [ + "futures", + "hex", + "jsonrpsee", + "parity-scale-codec", + "sc-chain-spec", + "sc-transaction-pool-api", + "serde", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-runtime", + "thiserror", +] + [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "directories", @@ -9177,12 +9200,15 @@ dependencies = [ "sc-informant", "sc-keystore", "sc-network", + "sc-network-bitswap", "sc-network-common", "sc-network-light", "sc-network-sync", + "sc-network-transactions", "sc-offchain", "sc-rpc", "sc-rpc-server", + "sc-rpc-spec-v2", "sc-sysinfo", "sc-telemetry", "sc-tracing", @@ -9196,19 +9222,20 @@ dependencies = [ "sp-block-builder", "sp-blockchain", "sp-consensus", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", + "sp-externalities", "sp-inherents", "sp-keystore", "sp-runtime", "sp-session", "sp-state-machine", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-storage", + "sp-tracing", "sp-transaction-pool", "sp-transaction-storage-proof", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-trie", "sp-version", + "static_init 1.0.3", "substrate-prometheus-endpoint", "tempfile", "thiserror", @@ -9220,7 +9247,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "log", "parity-scale-codec", @@ -9228,13 +9255,13 @@ dependencies = [ "parity-util-mem-derive", "parking_lot 0.12.1", "sc-client-api", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", ] [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -9253,7 +9280,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "futures", "libc", @@ -9264,15 +9291,15 @@ dependencies = [ "sc-telemetry", "serde", "serde_json", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "chrono", "futures", @@ -9290,7 +9317,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "ansi_term", "atty", @@ -9308,10 +9335,10 @@ dependencies = [ "serde", "sp-api", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-rpc", "sp-runtime", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-tracing", "thiserror", "tracing", "tracing-log", @@ -9321,7 +9348,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9332,8 +9359,9 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "async-trait", "futures", "futures-timer", "linked-hash-map", @@ -9347,9 +9375,9 @@ dependencies = [ "serde", "sp-api", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-tracing", "sp-transaction-pool", "substrate-prometheus-endpoint", "thiserror", @@ -9358,8 +9386,9 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "async-trait", "futures", "log", "serde", @@ -9371,7 +9400,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "futures", "futures-timer", @@ -9409,12 +9438,12 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.20" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" dependencies = [ "lazy_static", - "windows-sys", + "winapi", ] [[package]] @@ -9458,7 +9487,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" dependencies = [ "der", - "generic-array 0.14.6", + "generic-array 0.14.4", + "pkcs8", "subtle", "zeroize", ] @@ -9492,9 +9522,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.7.0" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" dependencies = [ "bitflags", "core-foundation", @@ -9505,9 +9535,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.6.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" dependencies = [ "core-foundation-sys", "libc", @@ -9524,9 +9554,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.13" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" +checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" dependencies = [ "serde", ] @@ -9545,18 +9575,18 @@ checksum = "f97841a747eef040fcd2e7b3b9a220a7205926e60488e673d9e4926d27772ce5" [[package]] name = "serde" -version = "1.0.144" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.144" +version = "1.0.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" dependencies = [ "proc-macro2", "quote", @@ -9578,7 +9608,7 @@ version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" dependencies = [ - "itoa 1.0.3", + "itoa 1.0.1", "ryu", "serde", ] @@ -9599,11 +9629,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.3", + "itoa 1.0.1", "ryu", "serde", ] +[[package]] +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + [[package]] name = "sha-1" version = "0.9.8" @@ -9642,9 +9684,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.9" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", @@ -9655,9 +9697,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.3" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" dependencies = [ "cfg-if 1.0.0", "cpufeatures", @@ -9666,21 +9708,9 @@ dependencies = [ [[package]] name = "sha3" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "keccak", - "opaque-debug 0.3.0", -] - -[[package]] -name = "sha3" -version = "0.10.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a31480366ec990f395a61b7c08122d99bd40544fdb5abcfc1b06bb29994312c" +checksum = "31f935e31cf406e8c0e96c2815a5516181b7004ae8c5f296293221e9b1e356bd" dependencies = [ "digest 0.10.3", "keccak", @@ -9756,12 +9786,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.7" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" -dependencies = [ - "autocfg", -] +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "slice-group-by" @@ -9771,13 +9798,13 @@ checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" [[package]] name = "slot-range-helper" -version = "0.9.28" +version = "0.9.31" dependencies = [ "enumn", "parity-scale-codec", "paste", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] @@ -9791,9 +9818,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.9.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "snap" @@ -9814,15 +9841,15 @@ dependencies = [ "rand_core 0.6.3", "ring", "rustc_version", - "sha2 0.10.3", + "sha2 0.10.2", "subtle", ] [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", "winapi", @@ -9847,16 +9874,17 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "hash-db", "log", "parity-scale-codec", "sp-api-proc-macro", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", "sp-state-machine", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-trie", "sp-version", "thiserror", ] @@ -9864,7 +9892,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "blake2", "proc-macro-crate", @@ -9876,72 +9904,72 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "sp-arithmetic" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "integer-sqrt", "num-traits", "parity-scale-codec", "scale-info", "serde", - "sp-debug-derive 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-debug-derive", + "sp-std", "static_assertions", ] [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "scale-info", "sp-api", "sp-application-crypto", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "parity-scale-codec", "sp-inherents", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "sp-api", "sp-inherents", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "futures", "log", @@ -9959,18 +9987,18 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "futures", "futures-timer", "log", "parity-scale-codec", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-runtime", "sp-state-machine", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "sp-version", "thiserror", ] @@ -9978,7 +10006,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "merlin", @@ -9990,102 +10018,56 @@ dependencies = [ "sp-consensus", "sp-consensus-slots", "sp-consensus-vrf", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-keystore", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "sp-timestamp", ] [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "scale-info", "serde", "sp-arithmetic", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "sp-timestamp", ] [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "scale-info", "schnorrkel", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "sp-core" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#e986f05062a5c7a8608967febcd5c1d2bb02eb40" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "array-bytes", "base58", "bitflags", - "blake2-rfc", + "blake2", "byteorder", "dyn-clonable", "ed25519-zebra", "futures", "hash-db", "hash256-std-hasher", - "hex", - "impl-serde", - "lazy_static", - "libsecp256k1", - "log", - "merlin", - "num-traits", - "parity-scale-codec", - "parity-util-mem", - "parking_lot 0.12.1", - "primitive-types", - "rand 0.7.3", - "regex", - "scale-info", - "schnorrkel", - "secp256k1", - "secrecy", - "serde", - "sp-core-hashing 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-debug-derive 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-runtime-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "ss58-registry", - "substrate-bip39", - "thiserror", - "tiny-bip39", - "wasmi", - "zeroize", -] - -[[package]] -name = "sp-core" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" -dependencies = [ - "base58", - "bitflags", - "blake2-rfc", - "byteorder", - "dyn-clonable", - "ed25519-dalek", - "futures", - "hash-db", - "hash256-std-hasher", - "hex", "impl-serde", "lazy_static", "libsecp256k1", @@ -10103,12 +10085,12 @@ dependencies = [ "secp256k1", "secrecy", "serde", - "sp-core-hashing 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-debug-derive 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-runtime-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core-hashing", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", "ss58-registry", "substrate-bip39", "thiserror", @@ -10120,46 +10102,32 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#e986f05062a5c7a8608967febcd5c1d2bb02eb40" -dependencies = [ - "blake2", - "byteorder", - "digest 0.10.3", - "sha2 0.10.3", - "sha3 0.10.2", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "twox-hash", -] - -[[package]] -name = "sp-core-hashing" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "blake2", "byteorder", "digest 0.10.3", - "sha2 0.10.3", - "sha3 0.10.2", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sha2 0.10.2", + "sha3", + "sp-std", "twox-hash", ] [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "proc-macro2", "quote", - "sp-core-hashing 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core-hashing", "syn", ] [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -10168,17 +10136,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#e986f05062a5c7a8608967febcd5c1d2bb02eb40" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sp-debug-derive" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "proc-macro2", "quote", @@ -10188,29 +10146,18 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#e986f05062a5c7a8608967febcd5c1d2bb02eb40" -dependencies = [ - "environmental", - "parity-scale-codec", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", -] - -[[package]] -name = "sp-externalities" -version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "environmental", "parity-scale-codec", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-storage", ] [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "finality-grandpa", "log", @@ -10219,30 +10166,30 @@ dependencies = [ "serde", "sp-api", "sp-application-crypto", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keystore", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "impl-trait-for-tuples", "parity-scale-codec", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "thiserror", ] [[package]] name = "sp-io" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "bytes", "futures", @@ -10252,15 +10199,15 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "secp256k1", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", + "sp-externalities", "sp-keystore", - "sp-runtime-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-runtime-interface", "sp-state-machine", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-wasm-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-tracing", + "sp-trie", + "sp-wasm-interface", "tracing", "tracing-core", ] @@ -10268,10 +10215,10 @@ dependencies = [ [[package]] name = "sp-keyring" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "lazy_static", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", "strum", ] @@ -10279,7 +10226,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "futures", @@ -10288,15 +10235,15 @@ dependencies = [ "parking_lot 0.12.1", "schnorrkel", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", + "sp-externalities", "thiserror", ] [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "thiserror", "zstd", @@ -10305,46 +10252,47 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "log", "parity-scale-codec", + "scale-info", "serde", "sp-api", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-debug-derive 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", + "sp-debug-derive", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "scale-info", "serde", "sp-arithmetic", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "sp-api", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", ] [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "backtrace", "lazy_static", @@ -10354,17 +10302,17 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "rustc-hash", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", ] [[package]] name = "sp-runtime" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "either", "hash256-std-hasher", @@ -10378,63 +10326,34 @@ dependencies = [ "serde", "sp-application-crypto", "sp-arithmetic", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", -] - -[[package]] -name = "sp-runtime-interface" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#e986f05062a5c7a8608967febcd5c1d2bb02eb40" -dependencies = [ - "bytes", - "impl-trait-for-tuples", - "parity-scale-codec", - "primitive-types", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-runtime-interface-proc-macro 5.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-wasm-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "static_assertions", + "sp-std", + "sp-weights", ] [[package]] name = "sp-runtime-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec", "primitive-types", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-runtime-interface-proc-macro 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-storage 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-wasm-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-externalities", + "sp-runtime-interface-proc-macro", + "sp-std", + "sp-storage", + "sp-tracing", + "sp-wasm-interface", "static_assertions", ] [[package]] name = "sp-runtime-interface-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#e986f05062a5c7a8608967febcd5c1d2bb02eb40" -dependencies = [ - "Inflector", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "sp-runtime-interface-proc-macro" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "Inflector", "proc-macro-crate", @@ -10446,46 +10365,46 @@ dependencies = [ [[package]] name = "sp-sandbox" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "log", "parity-scale-codec", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-wasm-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-wasm-interface", "wasmi", ] [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", ] [[package]] name = "sp-state-machine" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "hash-db", "log", @@ -10493,70 +10412,52 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "rand 0.7.3", - "smallvec", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-panic-handler", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "thiserror", - "tracing", - "trie-root", -] - -[[package]] -name = "sp-std" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#e986f05062a5c7a8608967febcd5c1d2bb02eb40" - -[[package]] -name = "sp-std" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" - -[[package]] -name = "sp-storage" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#e986f05062a5c7a8608967febcd5c1d2bb02eb40" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "ref-cast", - "serde", - "sp-debug-derive 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", + "smallvec", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-std", + "sp-trie", + "thiserror", + "tracing", + "trie-root", ] +[[package]] +name = "sp-std" +version = "4.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" + [[package]] name = "sp-storage" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "impl-serde", "parity-scale-codec", "ref-cast", "serde", - "sp-debug-derive 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-debug-derive", + "sp-std", ] [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "log", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", + "sp-externalities", "sp-io", - "sp-runtime-interface 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-runtime-interface", + "sp-std", ] [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "futures-timer", @@ -10565,29 +10466,17 @@ dependencies = [ "sp-api", "sp-inherents", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "thiserror", ] [[package]] name = "sp-tracing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#e986f05062a5c7a8608967febcd5c1d2bb02eb40" -dependencies = [ - "parity-scale-codec", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "tracing", - "tracing-core", - "tracing-subscriber 0.2.25", -] - -[[package]] -name = "sp-tracing" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "tracing", "tracing-core", "tracing-subscriber 0.2.25", @@ -10596,7 +10485,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "sp-api", "sp-runtime", @@ -10605,27 +10494,27 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "async-trait", "log", "parity-scale-codec", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-trie", ] [[package]] name = "sp-trie" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#e986f05062a5c7a8608967febcd5c1d2bb02eb40" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "ahash", "hash-db", - "hashbrown 0.12.3", + "hashbrown", "lazy_static", "lru 0.7.8", "memory-db", @@ -10633,43 +10522,27 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", + "sp-core", + "sp-std", "thiserror", "tracing", - "trie-db 0.24.0", - "trie-root", -] - -[[package]] -name = "sp-trie" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" -dependencies = [ - "hash-db", - "memory-db", - "parity-scale-codec", - "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "thiserror", - "trie-db 0.23.1", + "trie-db", "trie-root", ] [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "impl-serde", "parity-scale-codec", - "parity-wasm 0.42.2", + "parity-wasm 0.45.0", "scale-info", "serde", "sp-core-hashing-proc-macro", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "sp-version-proc-macro", "thiserror", ] @@ -10677,7 +10550,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10688,26 +10561,30 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#e986f05062a5c7a8608967febcd5c1d2bb02eb40" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "impl-trait-for-tuples", "log", "parity-scale-codec", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", + "sp-std", "wasmi", + "wasmtime", ] [[package]] -name = "sp-wasm-interface" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +name = "sp-weights" +version = "4.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "impl-trait-for-tuples", - "log", "parity-scale-codec", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "wasmi", - "wasmtime", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic", + "sp-core", + "sp-debug-derive", + "sp-std", ] [[package]] @@ -10716,11 +10593,21 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spki" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "ss58-registry" -version = "1.28.0" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c8a1e645fa0bd3e81a90e592a677f7ada3182ac338c4a71cd9ec0ba911f6abb" +checksum = "b0837b5d62f42082c9d56cd946495ae273a3c68083b637b9153341d5e465146d" dependencies = [ "Inflector", "num-format", @@ -10739,7 +10626,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "staking-miner" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_cmd", "clap", @@ -10766,7 +10653,7 @@ dependencies = [ "serde_json", "signal-hook", "signal-hook-tokio", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-npos-elections", "sp-runtime", @@ -10774,7 +10661,7 @@ dependencies = [ "sub-tokens", "thiserror", "tokio", - "tracing-subscriber 0.3.15", + "tracing-subscriber 0.3.11", "westend-runtime", ] @@ -10793,7 +10680,22 @@ dependencies = [ "cfg_aliases", "libc", "parking_lot 0.11.2", - "static_init_macro", + "static_init_macro 0.5.0", +] + +[[package]] +name = "static_init" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" +dependencies = [ + "bitflags", + "cfg_aliases", + "libc", + "parking_lot 0.11.2", + "parking_lot_core 0.8.5", + "static_init_macro 1.0.2", + "winapi", ] [[package]] @@ -10809,6 +10711,19 @@ dependencies = [ "syn", ] +[[package]] +name = "static_init_macro" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a2595fc3aa78f2d0e45dd425b22282dd863273761cc77780914b2cf3003acf" +dependencies = [ + "cfg_aliases", + "memchr", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "statrs" version = "0.15.0" @@ -10839,9 +10754,9 @@ dependencies = [ [[package]] name = "strum_macros" -version = "0.24.3" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +checksum = "6878079b17446e4d3eba6192bb0a2950d5b14f0ed8424b852310e5a94345d0ef" dependencies = [ "heck", "proc-macro2", @@ -10867,14 +10782,14 @@ dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", "schnorrkel", - "sha2 0.9.9", + "sha2 0.9.8", "zeroize", ] [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "platforms", ] @@ -10882,7 +10797,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -10896,14 +10811,14 @@ dependencies = [ "sp-api", "sp-block-builder", "sp-blockchain", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-runtime", ] [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "futures-util", "hyper", @@ -10913,10 +10828,23 @@ dependencies = [ "tokio", ] +[[package]] +name = "substrate-rpc-client" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" +dependencies = [ + "async-trait", + "jsonrpsee", + "log", + "sc-rpc-api", + "serde", + "sp-runtime", +] + [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "jsonrpsee", "log", @@ -10925,23 +10853,23 @@ dependencies = [ "sc-rpc-api", "scale-info", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", "sp-state-machine", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "trie-db 0.23.1", + "sp-std", + "sp-trie", + "trie-db", ] [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ + "array-bytes", "async-trait", "futures", - "hex", "parity-scale-codec", "sc-client-api", "sc-client-db", @@ -10953,7 +10881,7 @@ dependencies = [ "serde_json", "sp-blockchain", "sp-consensus", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "sp-keystore", "sp-runtime", @@ -10963,7 +10891,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "futures", "substrate-test-utils-derive", @@ -10973,7 +10901,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10984,7 +10912,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "ansi_term", "build-helper", @@ -11015,21 +10943,21 @@ dependencies = [ [[package]] name = "symbolic-common" -version = "8.8.0" +version = "8.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f551f902d5642e58039aee6a9021a61037926af96e071816361644983966f540" +checksum = "e92a52f07eed9afba3d6f883652cde7cd75fcf327dd44e84f210958379158737" dependencies = [ "debugid", - "memmap2 0.5.7", + "memmap2 0.5.0", "stable_deref_trait", "uuid", ] [[package]] name = "symbolic-demangle" -version = "8.8.0" +version = "8.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4564ca7b4e6eb14105aa8bbbce26e080f6b5d9c4373e67167ab31f7b86443750" +checksum = "c9abc81544d9964975269165bfe5ad198d8b9e2e809c46527323f95588a57693" dependencies = [ "cpp_demangle", "rustc-demangle", @@ -11038,9 +10966,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.99" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" dependencies = [ "proc-macro2", "quote", @@ -11088,9 +11016,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.4" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" +checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" [[package]] name = "tempfile" @@ -11108,35 +11036,35 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.3" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] [[package]] name = "termtree" -version = "0.2.4" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b" +checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" [[package]] name = "test-parachain-adder" -version = "0.9.28" +version = "0.9.31" dependencies = [ "dlmalloc", "parity-scale-codec", "polkadot-parachain", "sp-io", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "substrate-wasm-builder", "tiny-keccak", ] [[package]] name = "test-parachain-adder-collator" -version = "0.9.28" +version = "0.9.31" dependencies = [ "clap", "futures", @@ -11153,7 +11081,7 @@ dependencies = [ "polkadot-test-service", "sc-cli", "sc-service", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "substrate-test-utils", "test-parachain-adder", @@ -11162,28 +11090,28 @@ dependencies = [ [[package]] name = "test-parachain-halt" -version = "0.9.28" +version = "0.9.31" dependencies = [ "substrate-wasm-builder", ] [[package]] name = "test-parachain-undying" -version = "0.9.28" +version = "0.9.31" dependencies = [ "dlmalloc", "log", "parity-scale-codec", "polkadot-parachain", "sp-io", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "substrate-wasm-builder", "tiny-keccak", ] [[package]] name = "test-parachain-undying-collator" -version = "0.9.28" +version = "0.9.31" dependencies = [ "clap", "futures", @@ -11200,7 +11128,7 @@ dependencies = [ "polkadot-test-service", "sc-cli", "sc-service", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-keyring", "substrate-test-utils", "test-parachain-undying", @@ -11209,10 +11137,10 @@ dependencies = [ [[package]] name = "test-parachains" -version = "0.9.28" +version = "0.9.31" dependencies = [ "parity-scale-codec", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "test-parachain-adder", "test-parachain-halt", "tiny-keccak", @@ -11220,35 +11148,31 @@ dependencies = [ [[package]] name = "test-runtime-constants" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", "smallvec", + "sp-core", "sp-runtime", + "sp-weights", ] -[[package]] -name = "textwrap" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" - [[package]] name = "thiserror" -version = "1.0.33" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d0a539a918745651435ac7db7a18761589a94cd7e94cd56999f828bf73c8a57" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.33" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c251e90f708e16c49a16f4917dc2131e75222b72edfa9cb7f7c58ae56aae0c09" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", @@ -11294,9 +11218,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-ctl" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb833c46ecbf8b6daeccb347cefcabf9c1beb5c9b0f853e1cec45632d9963e69" +checksum = "e37706572f4b151dff7a0146e040804e9c26fe3a3118591112f05cf12a4216c1" dependencies = [ "libc", "paste", @@ -11305,9 +11229,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.4.3+5.2.1-patched.2" +version = "0.5.2+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1792ccb507d955b46af42c123ea8863668fae24d03721e40cad6a41773dbb49" +checksum = "ec45c14da997d0925c7835883e4d5c181f196fa142f8c19d7643d1e9af2592c3" dependencies = [ "cc", "fs_extra", @@ -11316,9 +11240,9 @@ dependencies = [ [[package]] name = "tikv-jemallocator" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b7bcecfafe4998587d636f9ae9d55eb9d0499877b88757767c346875067098" +checksum = "20612db8a13a6c06d57ec83953694185a367e16945f66565e8028d2c0bd76979" dependencies = [ "libc", "tikv-jemalloc-sys", @@ -11347,7 +11271,7 @@ dependencies = [ "pbkdf2 0.4.0", "rand 0.7.3", "rustc-hash", - "sha2 0.9.9", + "sha2 0.9.8", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -11365,9 +11289,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" dependencies = [ "tinyvec_macros", ] @@ -11380,11 +11304,10 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.21.0" +version = "1.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89797afd69d206ccd11fb0ea560a44bbb87731d020670e79416d442919257d42" +checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" dependencies = [ - "autocfg", "bytes", "libc", "memchr", @@ -11392,7 +11315,7 @@ dependencies = [ "num_cpus", "once_cell", "parking_lot 0.12.1", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.7", "signal-hook-registry", "socket2", "tokio-macros", @@ -11401,9 +11324,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.8.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" dependencies = [ "proc-macro2", "quote", @@ -11422,9 +11345,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.23.4" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" dependencies = [ "rustls", "tokio", @@ -11438,15 +11361,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df54d54117d6fdc4e4fea40fe1e4e566b3505700e148a6827e59b34b0d2600d9" dependencies = [ "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.7", "tokio", ] [[package]] name = "tokio-tungstenite" -version = "0.17.2" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181" +checksum = "06cda1232a49558c46f8a504d5b93101d42c0bf7f911f12a105ba48168f821ae" dependencies = [ "futures-util", "log", @@ -11456,52 +11379,64 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.3" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite 0.2.7", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" +checksum = "0edfdeb067411dba2044da6d1cb2df793dd35add7888d73c16e3381ded401764" dependencies = [ "bytes", "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.7", "tokio", - "tracing", ] [[package]] name = "toml" -version = "0.5.9" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.36" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" +checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" dependencies = [ "cfg-if 1.0.0", - "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.7", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.22" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" +checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b" dependencies = [ "proc-macro2", "quote", @@ -11510,9 +11445,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.29" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" +checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7" dependencies = [ "once_cell", "valuable", @@ -11530,7 +11465,7 @@ dependencies = [ [[package]] name = "tracing-gum" -version = "0.9.28" +version = "0.9.31" dependencies = [ "polkadot-node-jaeger", "polkadot-primitives", @@ -11540,7 +11475,7 @@ dependencies = [ [[package]] name = "tracing-gum-proc-macro" -version = "0.9.28" +version = "0.9.31" dependencies = [ "assert_matches", "expander 0.0.6", @@ -11563,9 +11498,9 @@ dependencies = [ [[package]] name = "tracing-serde" -version = "0.1.3" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b" dependencies = [ "serde", "tracing-core", @@ -11596,13 +11531,13 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.15" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b" +checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596" dependencies = [ "ansi_term", + "lazy_static", "matchers 0.1.0", - "once_cell", "regex", "sharded-slab", "smallvec", @@ -11612,19 +11547,6 @@ dependencies = [ "tracing-log", ] -[[package]] -name = "trie-db" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32d034c0d3db64b43c31de38e945f15b40cd4ca6d2dcfc26d4798ce8de4ab83" -dependencies = [ - "hash-db", - "hashbrown 0.12.3", - "log", - "rustc-hex", - "smallvec", -] - [[package]] name = "trie-db" version = "0.24.0" @@ -11632,7 +11554,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "004e1e8f92535694b4cb1444dc5a8073ecf0815e3357f729638b9f8fc4062908" dependencies = [ "hash-db", - "hashbrown 0.12.3", + "hashbrown", "log", "rustc-hex", "smallvec", @@ -11649,9 +11571,9 @@ dependencies = [ [[package]] name = "trust-dns-proto" -version = "0.21.2" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c31f240f59877c3d4bb3b3ea0ec5a6a0cff07323580ff8c7a605cd7d08b255d" +checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" dependencies = [ "async-trait", "cfg-if 1.0.0", @@ -11663,30 +11585,30 @@ dependencies = [ "idna", "ipnet", "lazy_static", - "log", "rand 0.8.5", "smallvec", "thiserror", "tinyvec", + "tracing", "url", ] [[package]] name = "trust-dns-resolver" -version = "0.21.2" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ba72c2ea84515690c9fcef4c6c660bb9df3036ed1051686de84605b74fd558" +checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" dependencies = [ "cfg-if 1.0.0", "futures-util", "ipconfig", "lazy_static", - "log", "lru-cache", "parking_lot 0.12.1", "resolv-conf", "smallvec", "thiserror", + "tracing", "trust-dns-proto", ] @@ -11699,10 +11621,10 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28#34a0621761c4a333cb2074ff720f7acbfb92dbb8" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163091384c4c10b6d76f5cb80dac0834f38" dependencies = [ "clap", - "jsonrpsee", + "frame-try-runtime", "log", "parity-scale-codec", "remote-externalities", @@ -11711,21 +11633,23 @@ dependencies = [ "sc-executor", "sc-service", "serde", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-externalities 0.12.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", + "sp-externalities", "sp-io", "sp-keystore", "sp-runtime", "sp-state-machine", "sp-version", + "sp-weights", + "substrate-rpc-client", "zstd", ] [[package]] name = "trybuild" -version = "1.0.64" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f408301c7480f9e6294eb779cfc907f54bd901a9660ef24d7f233ed5376485" +checksum = "7fc92f558afb6d1d7c6f175eb8d615b8ef49c227543e68e19c123d4ee43d8a7d" dependencies = [ "dissimilar", "glob", @@ -11745,9 +11669,9 @@ checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" [[package]] name = "tungstenite" -version = "0.17.3" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" +checksum = "d96a2dea40e7570482f28eb57afbe42d97551905da6a9400acc5c328d24004f5" dependencies = [ "base64", "byteorder", @@ -11776,21 +11700,21 @@ dependencies = [ [[package]] name = "typenum" -version = "1.15.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" [[package]] name = "ucd-trie" -version = "0.1.4" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" [[package]] name = "uint" -version = "0.9.3" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f03af7ccf01dd611cc450a0d10dbc9b745770d096473e2faf0ca6e2d66d1e0" +checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" dependencies = [ "byteorder", "crunchy", @@ -11809,21 +11733,21 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" [[package]] name = "unicode-ident" -version = "1.0.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" +checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" [[package]] name = "unicode-normalization" -version = "0.1.21" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" dependencies = [ "tinyvec", ] @@ -11836,9 +11760,9 @@ checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" -version = "0.2.3" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "universal-hash" @@ -11846,7 +11770,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.4", "subtle", ] @@ -11920,9 +11844,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "void" @@ -11986,9 +11910,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.82" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ "cfg-if 1.0.0", "serde", @@ -11998,13 +11922,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.82" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" dependencies = [ "bumpalo", + "lazy_static", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -12013,9 +11937,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.32" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa76fb221a1f8acddf5b54ace85912606980ad661ac7a503b4570ffd3a624dad" +checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -12025,9 +11949,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.82" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12035,9 +11959,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.82" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ "proc-macro2", "quote", @@ -12048,9 +11972,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.82" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" [[package]] name = "wasm-gc-api" @@ -12065,11 +11989,11 @@ dependencies = [ [[package]] name = "wasm-instrument" -version = "0.1.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "962e5b0401bbb6c887f54e69b8c496ea36f704df65db73e81fd5ff8dc3e63a9f" +checksum = "aa1dafb3e60065305741e83db35c6c2584bb3725b692b5b66148a38d72ace6cd" dependencies = [ - "parity-wasm 0.42.2", + "parity-wasm 0.45.0", ] [[package]] @@ -12089,58 +12013,63 @@ dependencies = [ [[package]] name = "wasmi" -version = "0.9.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca00c5147c319a8ec91ec1a0edbec31e566ce2c9cc93b3f9bb86a9efd0eb795d" +checksum = "fc13b3c219ca9aafeec59150d80d89851df02e0061bc357b4d66fc55a8d38787" dependencies = [ - "downcast-rs", - "libc", - "libm", - "memory_units", - "num-rational 0.2.4", - "num-traits", - "parity-wasm 0.42.2", + "parity-wasm 0.45.0", "wasmi-validation", + "wasmi_core", ] [[package]] name = "wasmi-validation" -version = "0.4.1" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" +dependencies = [ + "parity-wasm 0.45.0", +] + +[[package]] +name = "wasmi_core" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "165343ecd6c018fc09ebcae280752702c9a2ef3e6f8d02f1cfcbdb53ef6d7937" +checksum = "e0a088e8c4c59c6f2b9eae169bf86328adccc477c00b56d3661e3e9fb397b184" dependencies = [ - "parity-wasm 0.42.2", + "downcast-rs", + "libm", + "memory_units", + "num-rational 0.4.0", + "num-traits", ] [[package]] name = "wasmparser" -version = "0.85.0" +version = "0.89.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570460c58b21e9150d2df0eaaedbb7816c34bcec009ae0dcc976e40ba81463e7" +checksum = "ab5d3e08b13876f96dd55608d03cd4883a0545884932d5adf11925876c96daef" dependencies = [ "indexmap", ] [[package]] name = "wasmtime" -version = "0.38.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f50eadf868ab6a04b7b511460233377d0bfbb92e417b2f6a98b98fef2e098f5" +checksum = "8a10dc9784d8c3a33c970e3939180424955f08af2e7f20368ec02685a0e8f065" dependencies = [ "anyhow", - "backtrace", "bincode", "cfg-if 1.0.0", "indexmap", - "lazy_static", "libc", "log", - "object 0.28.4", + "object 0.29.0", "once_cell", "paste", "psm", "rayon", - "region", "serde", "target-lexicon", "wasmparser", @@ -12149,14 +12078,23 @@ dependencies = [ "wasmtime-environ", "wasmtime-jit", "wasmtime-runtime", - "winapi", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee4dbdc6daf68528cad1275ac91e3f51848ce9824385facc94c759f529decdf8" +dependencies = [ + "cfg-if 1.0.0", ] [[package]] name = "wasmtime-cache" -version = "0.38.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1df23c642e1376892f3b72f311596976979cbf8b85469680cdd3a8a063d12a2" +checksum = "9f507f3fa1ee1b2f9a83644e2514242b1dfe580782c0eb042f1ef70255bc4ffe" dependencies = [ "anyhow", "base64", @@ -12164,19 +12102,19 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.33.7", + "rustix", "serde", - "sha2 0.9.9", + "sha2 0.9.8", "toml", - "winapi", + "windows-sys 0.36.1", "zstd", ] [[package]] name = "wasmtime-cranelift" -version = "0.38.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f264ff6b4df247d15584f2f53d009fbc90032cfdc2605b52b961bffc71b6eccd" +checksum = "8f03cf79d982fc68e94ba0bea6a300a3b94621c4eb9705eece0a4f06b235a3b5" dependencies = [ "anyhow", "cranelift-codegen", @@ -12186,8 +12124,7 @@ dependencies = [ "cranelift-wasm", "gimli", "log", - "more-asserts", - "object 0.28.4", + "object 0.29.0", "target-lexicon", "thiserror", "wasmparser", @@ -12196,17 +12133,16 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "0.38.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "839d2820e4b830f4b9e7aa08d4c0acabf4a5036105d639f6dfa1c6891c73bdc6" +checksum = "5c587c62e91c5499df62012b87b88890d0eb470b2ffecc5964e9da967b70c77c" dependencies = [ "anyhow", "cranelift-entity", "gimli", "indexmap", "log", - "more-asserts", - "object 0.28.4", + "object 0.29.0", "serde", "target-lexicon", "thiserror", @@ -12216,9 +12152,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "0.38.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef0a0bcbfa18b946d890078ba0e1bc76bcc53eccfb40806c0020ec29dcd1bd49" +checksum = "047839b5dabeae5424a078c19b8cc897e5943a7fadc69e3d888b9c9a897666b3" dependencies = [ "addr2line", "anyhow", @@ -12227,38 +12163,36 @@ dependencies = [ "cpp_demangle", "gimli", "log", - "object 0.28.4", - "region", + "object 0.29.0", "rustc-demangle", - "rustix 0.33.7", + "rustix", "serde", "target-lexicon", "thiserror", "wasmtime-environ", "wasmtime-jit-debug", "wasmtime-runtime", - "winapi", + "windows-sys 0.36.1", ] [[package]] name = "wasmtime-jit-debug" -version = "0.38.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4779d976206c458edd643d1ac622b6c37e4a0800a8b1d25dfbf245ac2f2cac" +checksum = "b299569abf6f99b7b8e020afaf84a700e8636c6a42e242069267322cd5818235" dependencies = [ - "lazy_static", - "object 0.28.4", - "rustix 0.33.7", + "object 0.29.0", + "once_cell", + "rustix", ] [[package]] name = "wasmtime-runtime" -version = "0.38.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7eb6ffa169eb5dcd18ac9473c817358cd57bc62c244622210566d473397954a" +checksum = "ae79e0515160bd5abee5df50a16c4eb8db9f71b530fc988ae1d9ce34dcb8dd01" dependencies = [ "anyhow", - "backtrace", "cc", "cfg-if 1.0.0", "indexmap", @@ -12267,21 +12201,21 @@ dependencies = [ "mach", "memfd", "memoffset", - "more-asserts", + "paste", "rand 0.8.5", - "region", - "rustix 0.33.7", + "rustix", "thiserror", + "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", - "winapi", + "windows-sys 0.36.1", ] [[package]] name = "wasmtime-types" -version = "0.38.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d932b0ac5336f7308d869703dd225610a6a3aeaa8e968c52b43eed96cefb1c2" +checksum = "790cf43ee8e2d5dad1780af30f00d7a972b74725fb1e4f90c28d62733819b185" dependencies = [ "cranelift-entity", "serde", @@ -12291,9 +12225,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.59" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" dependencies = [ "js-sys", "wasm-bindgen", @@ -12311,9 +12245,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.22.4" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1c760f0d366a6c24a02ed7816e23e691f5d92291f94d15e836006fd11b04daf" +checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449" dependencies = [ "webpki", ] @@ -12329,7 +12263,7 @@ dependencies = [ [[package]] name = "westend-runtime" -version = "0.9.28" +version = "0.9.31" dependencies = [ "beefy-primitives", "bitvec", @@ -12353,6 +12287,7 @@ dependencies = [ "pallet-election-provider-multi-phase", "pallet-election-provider-support-benchmarking", "pallet-elections-phragmen", + "pallet-fast-unstake", "pallet-grandpa", "pallet-identity", "pallet-im-online", @@ -12398,7 +12333,7 @@ dependencies = [ "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-inherents", "sp-io", "sp-keyring", @@ -12408,10 +12343,10 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-tracing", "sp-transaction-pool", - "sp-trie 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-trie", "sp-version", "substrate-wasm-builder", "tiny-keccak", @@ -12424,24 +12359,26 @@ dependencies = [ [[package]] name = "westend-runtime-constants" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", "smallvec", + "sp-core", "sp-runtime", + "sp-weights", ] [[package]] name = "which" -version = "4.3.0" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +checksum = "ea187a8ef279bc014ec368c27a920da2024d2a711109bfbe3440585d5cf27ad9" dependencies = [ "either", + "lazy_static", "libc", - "once_cell", ] [[package]] @@ -12494,6 +12431,19 @@ dependencies = [ "windows_x86_64_msvc 0.34.0", ] +[[package]] +name = "windows-sys" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" +dependencies = [ + "windows_aarch64_msvc 0.32.0", + "windows_i686_gnu 0.32.0", + "windows_i686_msvc 0.32.0", + "windows_x86_64_gnu 0.32.0", + "windows_x86_64_msvc 0.32.0", +] + [[package]] name = "windows-sys" version = "0.36.1" @@ -12507,6 +12457,12 @@ dependencies = [ "windows_x86_64_msvc 0.36.1", ] +[[package]] +name = "windows_aarch64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" + [[package]] name = "windows_aarch64_msvc" version = "0.34.0" @@ -12519,6 +12475,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[package]] +name = "windows_i686_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" + [[package]] name = "windows_i686_gnu" version = "0.34.0" @@ -12531,6 +12493,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[package]] +name = "windows_i686_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" + [[package]] name = "windows_i686_msvc" version = "0.34.0" @@ -12543,6 +12511,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[package]] +name = "windows_x86_64_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" + [[package]] name = "windows_x86_64_gnu" version = "0.34.0" @@ -12555,6 +12529,12 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[package]] +name = "windows_x86_64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" + [[package]] name = "windows_x86_64_msvc" version = "0.34.0" @@ -12607,7 +12587,7 @@ dependencies = [ [[package]] name = "xcm" -version = "0.9.28" +version = "0.9.31" dependencies = [ "derivative", "impl-trait-for-tuples", @@ -12615,13 +12595,14 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", + "sp-io", "sp-runtime", "xcm-procedural", ] [[package]] name = "xcm-builder" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-support", "frame-system", @@ -12635,17 +12616,17 @@ dependencies = [ "polkadot-runtime-parachains", "scale-info", "sp-arithmetic", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "xcm", "xcm-executor", ] [[package]] name = "xcm-executor" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-benchmarking", "frame-support", @@ -12653,16 +12634,16 @@ dependencies = [ "log", "parity-scale-codec", "sp-arithmetic", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "xcm", ] [[package]] name = "xcm-executor-integration-tests" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-support", "frame-system", @@ -12675,14 +12656,14 @@ dependencies = [ "sp-keyring", "sp-runtime", "sp-state-machine", - "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-tracing", "xcm", "xcm-executor", ] [[package]] name = "xcm-procedural" -version = "0.9.28" +version = "0.9.31" dependencies = [ "Inflector", "proc-macro2", @@ -12692,7 +12673,7 @@ dependencies = [ [[package]] name = "xcm-simulator" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-support", "parity-scale-codec", @@ -12701,28 +12682,31 @@ dependencies = [ "polkadot-parachain", "polkadot-runtime-parachains", "sp-io", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "xcm", "xcm-executor", ] [[package]] name = "xcm-simulator-example" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-support", "frame-system", + "log", "pallet-balances", + "pallet-uniques", "pallet-xcm", "parity-scale-codec", "polkadot-core-primitives", "polkadot-parachain", "polkadot-runtime-parachains", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", + "sp-tracing", "xcm", "xcm-builder", "xcm-executor", @@ -12731,7 +12715,7 @@ dependencies = [ [[package]] name = "xcm-simulator-fuzzer" -version = "0.9.28" +version = "0.9.31" dependencies = [ "frame-support", "frame-system", @@ -12743,10 +12727,10 @@ dependencies = [ "polkadot-parachain", "polkadot-runtime-parachains", "scale-info", - "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-core", "sp-io", "sp-runtime", - "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.28)", + "sp-std", "xcm", "xcm-builder", "xcm-executor", @@ -12767,17 +12751,11 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "yansi" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" - [[package]] name = "zeroize" -version = "1.5.7" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" dependencies = [ "zeroize_derive", ] @@ -12796,7 +12774,7 @@ dependencies = [ [[package]] name = "zombienet-backchannel" -version = "0.9.28" +version = "0.9.31" dependencies = [ "futures-util", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 11b558b862d2..450cc0f2d1da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ path = "src/main.rs" name = "polkadot" description = "Implementation of a `https://polkadot.network` node in Rust based on the Substrate framework." license = "GPL-3.0-only" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" rust-version = "1.57.0" # custom profiles @@ -15,14 +15,14 @@ readme = "README.md" [dependencies] polkadot-cli = { path = "cli", features = [ "kusama-native", "westend-native", "rococo-native" ] } color-eyre = { version = "0.6.1", default-features = false } -parity-util-mem = { version = "0.11.0", default-features = false, features = ["jemalloc-global"] } +parity-util-mem = { version = "0.12.0", default-features = false, features = ["jemalloc-global"] } [dev-dependencies] assert_cmd = "2.0.4" nix = "0.24.1" tempfile = "3.2.0" tokio = "1.19.2" -remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-rpc-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-core-primitives = { path = "core-primitives" } [workspace] @@ -83,8 +83,6 @@ members = [ "node/network/gossip-support", "node/network/dispute-distribution", "node/overseer", - "node/orchestra", - "node/orchestra/proc-macro", "node/malus", "node/primitives", "node/service", @@ -96,7 +94,6 @@ members = [ "node/gum", "node/gum/proc-macro", "node/metrics", - "node/metered-channel", "node/test/client", "node/test/performance-test", "node/test/service", @@ -128,9 +125,9 @@ maintenance = { status = "actively-developed" } # # This list is ordered alphabetically. [profile.dev.package] -blake2b_simd = { opt-level = 3 } blake2 = { opt-level = 3 } blake2-rfc = { opt-level = 3 } +blake2b_simd = { opt-level = 3 } chacha20poly1305 = { opt-level = 3 } cranelift-codegen = { opt-level = 3 } cranelift-wasm = { opt-level = 3 } @@ -141,8 +138,8 @@ curve25519-dalek = { opt-level = 3 } ed25519-dalek = { opt-level = 3 } flate2 = { opt-level = 3 } futures-channel = { opt-level = 3 } -hashbrown = { opt-level = 3 } hash-db = { opt-level = 3 } +hashbrown = { opt-level = 3 } hmac = { opt-level = 3 } httparse = { opt-level = 3 } integer-sqrt = { opt-level = 3 } @@ -154,8 +151,8 @@ libz-sys = { opt-level = 3 } mio = { opt-level = 3 } nalgebra = { opt-level = 3 } num-bigint = { opt-level = 3 } -parking_lot_core = { opt-level = 3 } parking_lot = { opt-level = 3 } +parking_lot_core = { opt-level = 3 } percent-encoding = { opt-level = 3 } primitive-types = { opt-level = 3 } reed-solomon-novelpoly = { opt-level = 3 } @@ -165,6 +162,7 @@ sha2 = { opt-level = 3 } sha3 = { opt-level = 3 } smallvec = { opt-level = 3 } snow = { opt-level = 3 } +substrate-bip39 = {opt-level = 3} twox-hash = { opt-level = 3 } uint = { opt-level = 3 } wasmi = { opt-level = 3 } @@ -199,7 +197,6 @@ try-runtime = [ "polkadot-cli/try-runtime" ] fast-runtime = [ "polkadot-cli/fast-runtime" ] runtime-metrics = [ "polkadot-cli/runtime-metrics" ] pyroscope = ["polkadot-cli/pyroscope"] -staging-client = ["polkadot-cli/staging-client"] # Configuration for building a .deb package - for use with `cargo-deb` [package.metadata.deb] diff --git a/README.md b/README.md index 7679ebec5984..55b66f6ea619 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ dnf install polkadot Make sure you have the support software installed from the **Build from Source** section below this section. -If you want to install Polkadot in your PATH, you can do so with with: +If you want to install Polkadot in your PATH, you can do so with: ```bash cargo install --git https://github.com/paritytech/polkadot --tag polkadot --locked diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 93d86ffb9c34..8fc390e3932a 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-cli" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Polkadot Relay-chain Client Node" edition = "2021" @@ -14,7 +14,7 @@ wasm-opt = false crate-type = ["cdylib", "rlib"] [dependencies] -clap = { version = "3.1", features = ["derive"], optional = true } +clap = { version = "4.0.9", features = ["derive"], optional = true } log = "0.4.17" thiserror = "1.0.31" futures = "0.3.21" @@ -25,22 +25,22 @@ polkadot-client = { path = "../node/client", optional = true } polkadot-node-core-pvf = { path = "../node/core/pvf", optional = true } polkadot-performance-test = { path = "../node/test/performance-test", optional = true } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.28" } -try-runtime-cli = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.28" } -sc-cli = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.28" } -sc-service = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.31" } +try-runtime-cli = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.31" } +sc-cli = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.31" } +sc-service = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.31" } polkadot-node-metrics = { path = "../node/metrics" } -sc-tracing = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.28" } -sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-tracing = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.31" } +sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } # this crate is used only to enable `trie-memory-tracker` feature # see https://github.com/paritytech/substrate/pull/6745 -sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } [build-dependencies] -substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] default = ["wasmtime", "db", "cli", "hostperfcheck", "full-node", "trie-memory-tracker", "polkadot-native"] @@ -56,7 +56,11 @@ cli = [ "polkadot-client", "polkadot-node-core-pvf", ] -runtime-benchmarks = ["service/runtime-benchmarks", "polkadot-node-metrics/runtime-benchmarks"] +runtime-benchmarks = [ + "service/runtime-benchmarks", + "polkadot-node-metrics/runtime-benchmarks", + "polkadot-performance-test?/runtime-benchmarks" +] trie-memory-tracker = ["sp-trie/memory-tracker"] full-node = ["service/full-node"] try-runtime = ["service/try-runtime"] @@ -74,4 +78,3 @@ rococo-native = ["service/rococo-native"] malus = ["full-node", "service/malus"] runtime-metrics = ["service/runtime-metrics", "polkadot-node-metrics/runtime-metrics"] -staging-client = ["service/staging-client"] diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 804c4a9f81c6..a6b7f4a3d5c9 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -43,16 +43,16 @@ pub enum Subcommand { Revert(sc_cli::RevertCmd), #[allow(missing_docs)] - #[clap(name = "prepare-worker", hide = true)] + #[command(name = "prepare-worker", hide = true)] PvfPrepareWorker(ValidationWorkerCommand), #[allow(missing_docs)] - #[clap(name = "execute-worker", hide = true)] + #[command(name = "execute-worker", hide = true)] PvfExecuteWorker(ValidationWorkerCommand), /// Sub-commands concerned with benchmarking. /// The pallet benchmarking moved to the `pallet` sub-command. - #[clap(subcommand)] + #[command(subcommand)] Benchmark(frame_benchmarking_cli::BenchmarkCmd), /// Runs performance checks such as PVF compilation in order to measure machine @@ -68,7 +68,7 @@ pub enum Subcommand { TryRuntime, /// Key management CLI utilities - #[clap(subcommand)] + #[command(subcommand)] Key(sc_cli::KeySubcommand), /// Db meta columns information. @@ -84,22 +84,22 @@ pub struct ValidationWorkerCommand { #[allow(missing_docs)] #[derive(Debug, Parser)] -#[cfg_attr(feature = "malus", derive(Clone))] +#[group(skip)] pub struct RunCmd { #[allow(missing_docs)] #[clap(flatten)] pub base: sc_cli::RunCmd, /// Force using Kusama native runtime. - #[clap(long = "force-kusama")] + #[arg(long = "force-kusama")] pub force_kusama: bool, /// Force using Westend native runtime. - #[clap(long = "force-westend")] + #[arg(long = "force-westend")] pub force_westend: bool, /// Force using Rococo native runtime. - #[clap(long = "force-rococo")] + #[arg(long = "force-rococo")] pub force_rococo: bool, /// Setup a GRANDPA scheduled voting pause. @@ -108,25 +108,25 @@ pub struct RunCmd { /// blocks). After the given block number is finalized the GRANDPA voter /// will temporarily stop voting for new blocks until the given delay has /// elapsed (i.e. until a block at height `pause_block + delay` is imported). - #[clap(long = "grandpa-pause", number_of_values(2))] + #[arg(long = "grandpa-pause", num_args = 2)] pub grandpa_pause: Vec, /// Enable the BEEFY gadget (only on Rococo or Wococo for now). - #[clap(long)] + #[arg(long)] pub beefy: bool, /// Add the destination address to the jaeger agent. /// /// Must be valid socket address, of format `IP:Port` /// commonly `127.0.0.1:6831`. - #[clap(long)] + #[arg(long)] pub jaeger_agent: Option, /// Add the destination address to the `pyroscope` agent. /// /// Must be valid socket address, of format `IP:Port` /// commonly `127.0.0.1:4040`. - #[clap(long)] + #[arg(long)] pub pyroscope_server: Option, /// Disable automatic hardware benchmarks. @@ -136,20 +136,20 @@ pub struct RunCmd { /// /// The results are then printed out in the logs, and also sent as part of /// telemetry, if telemetry is enabled. - #[clap(long)] + #[arg(long)] pub no_hardware_benchmarks: bool, /// Overseer message capacity override. /// /// **Dangerous!** Do not touch unless explicitly adviced to. - #[clap(long)] + #[arg(long)] pub overseer_channel_capacity_override: Option, } #[allow(missing_docs)] #[derive(Debug, Parser)] pub struct Cli { - #[clap(subcommand)] + #[command(subcommand)] pub subcommand: Option, #[clap(flatten)] pub run: RunCmd, diff --git a/cli/src/command.rs b/cli/src/command.rs index a7ab8f67aad7..5ce7c05162c1 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -512,6 +512,15 @@ pub fn run() -> Result<()> { let chain_spec = &runner.config().chain_spec; match cmd { + #[cfg(not(feature = "runtime-benchmarks"))] + BenchmarkCmd::Storage(_) => + return Err(sc_cli::Error::Input( + "Compile with --features=runtime-benchmarks \ + to enable storage benchmarks." + .into(), + ) + .into()), + #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Storage(cmd) => runner.sync_run(|mut config| { let (client, backend, _, _) = service::new_chain_ops(&mut config, None)?; let db = backend.expose_db(); @@ -552,14 +561,25 @@ pub fn run() -> Result<()> { unwrap_client!( client, - cmd.run(client.clone(), inherent_data, &ext_factory) - .map_err(Error::SubstrateCli) + cmd.run( + client.clone(), + inherent_data, + Vec::new(), + &ext_factory + ) + .map_err(Error::SubstrateCli) ) }, BenchmarkCmd::Overhead(cmd) => unwrap_client!( client, - cmd.run(config, client.clone(), inherent_data, &remark_builder) - .map_err(Error::SubstrateCli) + cmd.run( + config, + client.clone(), + inherent_data, + Vec::new(), + &remark_builder + ) + .map_err(Error::SubstrateCli) ), _ => unreachable!("Ensured by the outside match; qed"), } diff --git a/core-primitives/Cargo.toml b/core-primitives/Cargo.toml index 2f9cd15d03cc..e3eea6a3f424 100644 --- a/core-primitives/Cargo.toml +++ b/core-primitives/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "polkadot-core-primitives" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } parity-scale-codec = { version = "3.1.5", default-features = false, features = [ "derive" ] } -parity-util-mem = { version = "0.11.0", default-features = false, optional = true } +parity-util-mem = { version = "0.12.0", default-features = false, optional = true } [features] default = [ "std" ] diff --git a/erasure-coding/Cargo.toml b/erasure-coding/Cargo.toml index 4535e015465c..7df14eaf5799 100644 --- a/erasure-coding/Cargo.toml +++ b/erasure-coding/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-erasure-coding" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -9,6 +9,6 @@ polkadot-primitives = { path = "../primitives" } polkadot-node-primitives = { package = "polkadot-node-primitives", path = "../node/primitives" } novelpoly = { package = "reed-solomon-novelpoly", version = "1.0.0" } parity-scale-codec = { version = "3.1.5", default-features = false, features = ["std", "derive"] } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } thiserror = "1.0.31" diff --git a/erasure-coding/fuzzer/Cargo.toml b/erasure-coding/fuzzer/Cargo.toml index ee5a371fe1f3..6c8ad88e3955 100644 --- a/erasure-coding/fuzzer/Cargo.toml +++ b/erasure-coding/fuzzer/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "erasure_coding_fuzzer" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] polkadot-erasure-coding = { path = ".." } honggfuzz = "0.5" +polkadot-primitives = { path = "../../primitives" } primitives = { package = "polkadot-node-primitives", path = "../../node/primitives/" } [[bin]] diff --git a/erasure-coding/fuzzer/src/round_trip.rs b/erasure-coding/fuzzer/src/round_trip.rs index 3d5ea5927458..daa57a566fbb 100644 --- a/erasure-coding/fuzzer/src/round_trip.rs +++ b/erasure-coding/fuzzer/src/round_trip.rs @@ -2,6 +2,7 @@ use polkadot_erasure_coding::*; use primitives::{AvailableData, BlockData, PoV}; use std::sync::Arc; use honggfuzz::fuzz; +use polkadot_primitives::v2::PersistedValidationData; fn main() { diff --git a/node/client/Cargo.toml b/node/client/Cargo.toml index 35886d891ae6..bebbb1a66e2c 100644 --- a/node/client/Cargo.toml +++ b/node/client/Cargo.toml @@ -1,41 +1,41 @@ [package] name = "polkadot-client" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] -frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } -sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-storage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-offchain = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-storage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-offchain = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } -sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-service = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-service = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } -beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } # Polkadot Runtimes polkadot-runtime = { path = "../../runtime/polkadot", optional = true } diff --git a/node/client/src/benchmarking.rs b/node/client/src/benchmarking.rs index 02c0d316c0ad..7990bc88d218 100644 --- a/node/client/src/benchmarking.rs +++ b/node/client/src/benchmarking.rs @@ -49,9 +49,9 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder { fn build(&self, nonce: u32) -> std::result::Result { with_client! { self.client.as_ref(), client, { - use runtime::{Call, SystemCall}; + use runtime::{RuntimeCall, SystemCall}; - let call = Call::System(SystemCall::remark { remark: vec![] }); + let call = RuntimeCall::System(SystemCall::remark { remark: vec![] }); let signer = Sr25519Keyring::Bob.pair(); let period = polkadot_runtime_common::BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64; @@ -92,9 +92,9 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder { fn build(&self, nonce: u32) -> std::result::Result { with_client! { self.client.as_ref(), client, { - use runtime::{Call, BalancesCall}; + use runtime::{RuntimeCall, BalancesCall}; - let call = Call::Balances(BalancesCall::transfer_keep_alive { + let call = RuntimeCall::Balances(BalancesCall::transfer_keep_alive { dest: self.dest.clone().into(), value: self.value.into(), }); @@ -113,14 +113,14 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder { /// /// Should only be used for benchmarking since it makes strong assumptions /// about the chain state that these calls will be valid for. -trait BenchmarkCallSigner { +trait BenchmarkCallSigner { /// Signs a call together with the signed extensions of the specific runtime. /// /// Only works if the current block is the genesis block since the /// `CheckMortality` check is mocked by using the genesis block. fn sign_call( &self, - call: Call, + call: RuntimeCall, nonce: u32, current_block: u64, period: u64, @@ -130,12 +130,12 @@ trait BenchmarkCallSigner { } #[cfg(feature = "polkadot")] -impl BenchmarkCallSigner +impl BenchmarkCallSigner for FullClient { fn sign_call( &self, - call: polkadot_runtime::Call, + call: polkadot_runtime::RuntimeCall, nonce: u32, current_block: u64, period: u64, @@ -186,12 +186,12 @@ impl BenchmarkCallSigner } #[cfg(feature = "westend")] -impl BenchmarkCallSigner +impl BenchmarkCallSigner for FullClient { fn sign_call( &self, - call: westend_runtime::Call, + call: westend_runtime::RuntimeCall, nonce: u32, current_block: u64, period: u64, @@ -240,12 +240,12 @@ impl BenchmarkCallSigner } #[cfg(feature = "kusama")] -impl BenchmarkCallSigner +impl BenchmarkCallSigner for FullClient { fn sign_call( &self, - call: kusama_runtime::Call, + call: kusama_runtime::RuntimeCall, nonce: u32, current_block: u64, period: u64, @@ -294,12 +294,12 @@ impl BenchmarkCallSigner } #[cfg(feature = "rococo")] -impl BenchmarkCallSigner +impl BenchmarkCallSigner for FullClient { fn sign_call( &self, - call: rococo_runtime::Call, + call: rococo_runtime::RuntimeCall, nonce: u32, current_block: u64, period: u64, diff --git a/node/client/src/lib.rs b/node/client/src/lib.rs index 41b0048f0e46..a254973b99c2 100644 --- a/node/client/src/lib.rs +++ b/node/client/src/lib.rs @@ -128,7 +128,7 @@ pub trait RuntimeApiCollection: + ParachainHost + sp_block_builder::BlockBuilder + frame_system_rpc_runtime_api::AccountNonceApi - + sp_mmr_primitives::MmrApi::Hash> + + sp_mmr_primitives::MmrApi::Hash, BlockNumber> + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi + sp_api::Metadata + sp_offchain::OffchainWorkerApi @@ -149,7 +149,7 @@ where + ParachainHost + sp_block_builder::BlockBuilder + frame_system_rpc_runtime_api::AccountNonceApi - + sp_mmr_primitives::MmrApi::Hash> + + sp_mmr_primitives::MmrApi::Hash, BlockNumber> + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi + sp_api::Metadata + sp_offchain::OffchainWorkerApi @@ -421,63 +421,63 @@ impl sc_client_api::BlockBackend for Client { impl sc_client_api::StorageProvider for Client { fn storage( &self, - id: &BlockId, + hash: &::Hash, key: &StorageKey, ) -> sp_blockchain::Result> { with_client! { self, client, { - client.storage(id, key) + client.storage(hash, key) } } } fn storage_keys( &self, - id: &BlockId, + hash: &::Hash, key_prefix: &StorageKey, ) -> sp_blockchain::Result> { with_client! { self, client, { - client.storage_keys(id, key_prefix) + client.storage_keys(hash, key_prefix) } } } fn storage_hash( &self, - id: &BlockId, + hash: &::Hash, key: &StorageKey, ) -> sp_blockchain::Result::Hash>> { with_client! { self, client, { - client.storage_hash(id, key) + client.storage_hash(hash, key) } } } fn storage_pairs( &self, - id: &BlockId, + hash: &::Hash, key_prefix: &StorageKey, ) -> sp_blockchain::Result> { with_client! { self, client, { - client.storage_pairs(id, key_prefix) + client.storage_pairs(hash, key_prefix) } } } fn storage_keys_iter<'a>( &self, - id: &BlockId, + hash: &::Hash, prefix: Option<&'a StorageKey>, start_key: Option<&StorageKey>, ) -> sp_blockchain::Result< @@ -487,14 +487,14 @@ impl sc_client_api::StorageProvider for Client { self, client, { - client.storage_keys_iter(id, prefix, start_key) + client.storage_keys_iter(hash, prefix, start_key) } } } fn child_storage( &self, - id: &BlockId, + hash: &::Hash, child_info: &ChildInfo, key: &StorageKey, ) -> sp_blockchain::Result> { @@ -502,14 +502,14 @@ impl sc_client_api::StorageProvider for Client { self, client, { - client.child_storage(id, child_info, key) + client.child_storage(hash, child_info, key) } } } fn child_storage_keys( &self, - id: &BlockId, + hash: &::Hash, child_info: &ChildInfo, key_prefix: &StorageKey, ) -> sp_blockchain::Result> { @@ -517,14 +517,14 @@ impl sc_client_api::StorageProvider for Client { self, client, { - client.child_storage_keys(id, child_info, key_prefix) + client.child_storage_keys(hash, child_info, key_prefix) } } } fn child_storage_keys_iter<'a>( &self, - id: &BlockId, + hash: &::Hash, child_info: ChildInfo, prefix: Option<&'a StorageKey>, start_key: Option<&StorageKey>, @@ -535,14 +535,14 @@ impl sc_client_api::StorageProvider for Client { self, client, { - client.child_storage_keys_iter(id, child_info, prefix, start_key) + client.child_storage_keys_iter(hash, child_info, prefix, start_key) } } } fn child_storage_hash( &self, - id: &BlockId, + hash: &::Hash, child_info: &ChildInfo, key: &StorageKey, ) -> sp_blockchain::Result::Hash>> { @@ -550,7 +550,7 @@ impl sc_client_api::StorageProvider for Client { self, client, { - client.child_storage_hash(id, child_info, key) + client.child_storage_hash(hash, child_info, key) } } } diff --git a/node/collation-generation/Cargo.toml b/node/collation-generation/Cargo.toml index 3a67b6d2399d..c32f8e04e4c8 100644 --- a/node/collation-generation/Cargo.toml +++ b/node/collation-generation/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-collation-generation" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -12,8 +12,8 @@ polkadot-node-primitives = { path = "../primitives" } polkadot-node-subsystem = { path = "../subsystem" } polkadot-node-subsystem-util = { path = "../subsystem-util" } polkadot-primitives = { path = "../../primitives" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } thiserror = "1.0.31" parity-scale-codec = { version = "3.1.5", default-features = false, features = ["bit-vec", "derive"] } diff --git a/node/core/approval-voting/Cargo.toml b/node/core/approval-voting/Cargo.toml index 7f3923b6ff7d..8940c5b28efd 100644 --- a/node/core/approval-voting/Cargo.toml +++ b/node/core/approval-voting/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-core-approval-voting" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -10,10 +10,10 @@ futures-timer = "3.0.2" parity-scale-codec = { version = "3.1.5", default-features = false, features = ["bit-vec", "derive"] } gum = { package = "tracing-gum", path = "../../gum" } bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] } -lru = "0.7" +lru = "0.8" merlin = "2.0" schnorrkel = "0.9.1" -kvdb = "0.11.0" +kvdb = "0.12.0" derive_more = "0.99.17" thiserror = "1.0.31" @@ -24,21 +24,21 @@ polkadot-primitives = { path = "../../../primitives" } polkadot-node-primitives = { path = "../../primitives" } polkadot-node-jaeger = { path = "../../jaeger" } -sc-keystore = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-consensus = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-consensus-slots = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", default-features = false, features = ["full_crypto"] , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sc-keystore = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-consensus = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-consensus-slots = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", default-features = false, features = ["full_crypto"] , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } [dev-dependencies] -async-trait = "0.1.56" +async-trait = "0.1.57" parking_lot = "0.12.0" rand_core = "0.5.1" # should match schnorrkel -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } assert_matches = "1.4.0" -kvdb-memorydb = "0.11.0" +kvdb-memorydb = "0.12.0" test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } diff --git a/node/core/approval-voting/src/import.rs b/node/core/approval-voting/src/import.rs index d43bf40546ae..5413c271e0d6 100644 --- a/node/core/approval-voting/src/import.rs +++ b/node/core/approval-voting/src/import.rs @@ -1296,6 +1296,38 @@ pub(crate) mod tests { } ); + // Caching of sesssions needs sessoion of first unfinalied block. + assert_matches!( + handle.recv().await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber( + s_tx, + )) => { + let _ = s_tx.send(Ok(header.number)); + } + ); + + assert_matches!( + handle.recv().await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash( + block_number, + s_tx, + )) => { + assert_eq!(block_number, header.number); + let _ = s_tx.send(Ok(Some(header.hash()))); + } + ); + + assert_matches!( + handle.recv().await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + h, + RuntimeApiRequest::SessionIndexForChild(s_tx), + )) => { + assert_eq!(h, header.hash()); + let _ = s_tx.send(Ok(session)); + } + ); + // determine_new_blocks exits early as the parent_hash is in the DB assert_matches!( diff --git a/node/core/approval-voting/src/lib.rs b/node/core/approval-voting/src/lib.rs index 342fc0341b99..467d8be612e9 100644 --- a/node/core/approval-voting/src/lib.rs +++ b/node/core/approval-voting/src/lib.rs @@ -70,6 +70,7 @@ use std::{ collections::{ btree_map::Entry as BTMEntry, hash_map::Entry as HMEntry, BTreeMap, HashMap, HashSet, }, + num::NonZeroUsize, sync::Arc, time::Duration, }; @@ -104,7 +105,11 @@ const APPROVAL_CHECKING_TIMEOUT: Duration = Duration::from_secs(120); /// Value rather arbitrarily: Should not be hit in practice, it exists to more easily diagnose dead /// lock issues for example. const WAIT_FOR_SIGS_TIMEOUT: Duration = Duration::from_millis(500); -const APPROVAL_CACHE_SIZE: usize = 1024; +const APPROVAL_CACHE_SIZE: NonZeroUsize = match NonZeroUsize::new(1024) { + Some(cap) => cap, + None => panic!("Approval cache size must be non-zero."), +}; + const TICK_TOO_FAR_IN_FUTURE: Tick = 20; // 10 seconds. const APPROVAL_DELAY: Tick = 2; const LOG_TARGET: &str = "parachain::approval-voting"; @@ -1210,8 +1215,24 @@ async fn get_approval_signatures_for_candidate( candidate_hash: CandidateHash, tx: oneshot::Sender>, ) -> SubsystemResult<()> { + let send_votes = |votes| { + if let Err(_) = tx.send(votes) { + gum::debug!( + target: LOG_TARGET, + "Sending approval signatures back failed, as receiver got closed." + ); + } + }; let entry = match db.load_candidate_entry(&candidate_hash)? { - None => return Ok(()), + None => { + send_votes(HashMap::new()); + gum::debug!( + target: LOG_TARGET, + ?candidate_hash, + "Sent back empty votes because the candidate was not found in db." + ); + return Ok(()) + }, Some(e) => e, }; @@ -1261,13 +1282,7 @@ async fn get_approval_signatures_for_candidate( target: LOG_TARGET, "Request for approval signatures got cancelled by `approval-distribution`." ), - Some(Ok(votes)) => - if let Err(_) = tx.send(votes) { - gum::debug!( - target: LOG_TARGET, - "Sending approval signatures back failed, as receiver got closed" - ); - }, + Some(Ok(votes)) => send_votes(votes), } }; diff --git a/node/core/approval-voting/src/tests.rs b/node/core/approval-voting/src/tests.rs index 66d1402ed6dc..bdb7a8c929b3 100644 --- a/node/core/approval-voting/src/tests.rs +++ b/node/core/approval-voting/src/tests.rs @@ -807,6 +807,37 @@ async fn import_block( } ); + assert_matches!( + overseer_recv(overseer).await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber( + s_tx, + )) => { + let _ = s_tx.send(Ok(number)); + } + ); + + assert_matches!( + overseer_recv(overseer).await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash( + block_number, + s_tx, + )) => { + assert_eq!(block_number, number); + let _ = s_tx.send(Ok(Some(hashes[number as usize].0))); + } + ); + + assert_matches!( + overseer_recv(overseer).await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + h, + RuntimeApiRequest::SessionIndexForChild(s_tx), + )) => { + assert_eq!(h, hashes[number as usize].0); + let _ = s_tx.send(Ok(number.into())); + } + ); + if !fork { assert_matches!( overseer_recv(overseer).await, diff --git a/node/core/av-store/Cargo.toml b/node/core/av-store/Cargo.toml index f6e154948fec..b4d19e430aad 100644 --- a/node/core/av-store/Cargo.toml +++ b/node/core/av-store/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "polkadot-node-core-av-store" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] futures = "0.3.21" futures-timer = "3.0.2" -kvdb = "0.11.0" +kvdb = "0.12.0" thiserror = "1.0.31" gum = { package = "tracing-gum", path = "../../gum" } bitvec = "1.0.0" @@ -24,11 +24,11 @@ polkadot-node-primitives = { path = "../../primitives" } log = "0.4.17" env_logger = "0.9.0" assert_matches = "1.4.0" -kvdb-memorydb = "0.11.0" +kvdb-memorydb = "0.12.0" -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } parking_lot = "0.12.0" test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } diff --git a/node/core/av-store/src/lib.rs b/node/core/av-store/src/lib.rs index cd1685e32ea8..4fbbf3740ab0 100644 --- a/node/core/av-store/src/lib.rs +++ b/node/core/av-store/src/lib.rs @@ -792,8 +792,9 @@ fn note_block_included( macro_rules! peek_num { ($iter:ident) => { match $iter.peek() { - Some((k, _)) => decode_unfinalized_key(&k[..]).ok().map(|(b, _, _)| b), - None => None, + Some(Ok((k, _))) => Ok(decode_unfinalized_key(&k[..]).ok().map(|(b, _, _)| b)), + Some(Err(_)) => Err($iter.next().expect("peek returned Some(Err); qed").unwrap_err()), + None => Ok(None), } }; } @@ -819,10 +820,10 @@ async fn process_block_finalized( let mut iter = subsystem .db .iter_with_prefix(subsystem.config.col_meta, &start_prefix) - .take_while(|(k, _)| &k[..] < &end_prefix[..]) + .take_while(|r| r.as_ref().map_or(true, |(k, _v)| &k[..] < &end_prefix[..])) .peekable(); - match peek_num!(iter) { + match peek_num!(iter)? { None => break, // end of iterator. Some(n) => n, } @@ -867,10 +868,10 @@ async fn process_block_finalized( let iter = subsystem .db .iter_with_prefix(subsystem.config.col_meta, &start_prefix) - .take_while(|(k, _)| &k[..] < &end_prefix[..]) + .take_while(|r| r.as_ref().map_or(true, |(k, _v)| &k[..] < &end_prefix[..])) .peekable(); - let batch = load_all_at_finalized_height(iter, batch_num, batch_finalized_hash); + let batch = load_all_at_finalized_height(iter, batch_num, batch_finalized_hash)?; // Now that we've iterated over the entire batch at this finalized height, // update the meta. @@ -890,22 +891,22 @@ async fn process_block_finalized( // loads all candidates at the finalized height and maps them to `true` if finalized // and `false` if unfinalized. fn load_all_at_finalized_height( - mut iter: std::iter::Peekable, Box<[u8]>)>>, + mut iter: std::iter::Peekable>>, block_number: BlockNumber, finalized_hash: Hash, -) -> impl IntoIterator { +) -> io::Result> { // maps candidate hashes to true if finalized, false otherwise. let mut candidates = HashMap::new(); // Load all candidates that were included at this height. loop { - match peek_num!(iter) { + match peek_num!(iter)? { None => break, // end of iterator. Some(n) if n != block_number => break, // end of batch. _ => {}, } - let (k, _v) = iter.next().expect("`peek` used to check non-empty; qed"); + let (k, _v) = iter.next().expect("`peek` used to check non-empty; qed")?; let (_, block_hash, candidate_hash) = decode_unfinalized_key(&k[..]).expect("`peek_num` checks validity of key; qed"); @@ -916,7 +917,7 @@ fn load_all_at_finalized_height( } } - candidates + Ok(candidates) } fn update_blocks_at_finalized_height( @@ -1214,9 +1215,10 @@ fn prune_all(db: &Arc, config: &Config, clock: &dyn Clock) -> Resu let mut tx = DBTransaction::new(); let iter = db .iter_with_prefix(config.col_meta, &range_start[..]) - .take_while(|(k, _)| &k[..] < &range_end[..]); + .take_while(|r| r.as_ref().map_or(true, |(k, _v)| &k[..] < &range_end[..])); - for (k, _v) in iter { + for r in iter { + let (k, _v) = r?; tx.delete(config.col_meta, &k[..]); let (_, candidate_hash) = match decode_pruning_key(&k[..]) { diff --git a/node/core/backing/Cargo.toml b/node/core/backing/Cargo.toml index 4a412f80346a..1fb8c9f46d99 100644 --- a/node/core/backing/Cargo.toml +++ b/node/core/backing/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "polkadot-node-core-backing" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] futures = "0.3.21" -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-primitives = { path = "../../../primitives" } polkadot-node-primitives = { path = "../../primitives" } polkadot-node-subsystem = {path = "../../subsystem" } @@ -19,11 +19,11 @@ thiserror = "1.0.31" fatality = "0.0.6" [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures = { version = "0.3.21", features = ["thread-pool"] } assert_matches = "1.4.0" polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } diff --git a/node/core/backing/src/lib.rs b/node/core/backing/src/lib.rs index dbc6e3f81903..a9ae518e3103 100644 --- a/node/core/backing/src/lib.rs +++ b/node/core/backing/src/lib.rs @@ -621,6 +621,7 @@ async fn request_pov( sender: &mut impl overseer::CandidateBackingSenderTrait, relay_parent: Hash, from_validator: ValidatorIndex, + para_id: ParaId, candidate_hash: CandidateHash, pov_hash: Hash, ) -> Result, Error> { @@ -629,6 +630,7 @@ async fn request_pov( .send_message(AvailabilityDistributionMessage::FetchPoV { relay_parent, from_validator, + para_id, candidate_hash, pov_hash, tx, @@ -697,8 +699,15 @@ async fn validate_and_make_available( PoVData::Ready(pov) => pov, PoVData::FetchFromValidator { from_validator, candidate_hash, pov_hash } => { let _span = span.as_ref().map(|s| s.child("request-pov")); - match request_pov(&mut sender, relay_parent, from_validator, candidate_hash, pov_hash) - .await + match request_pov( + &mut sender, + relay_parent, + from_validator, + candidate.descriptor.para_id, + candidate_hash, + pov_hash, + ) + .await { Err(Error::FetchPoV) => { tx_command diff --git a/node/core/bitfield-signing/Cargo.toml b/node/core/bitfield-signing/Cargo.toml index 0e94151da3d3..93e7e6683fc5 100644 --- a/node/core/bitfield-signing/Cargo.toml +++ b/node/core/bitfield-signing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-core-bitfield-signing" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -10,7 +10,7 @@ gum = { package = "tracing-gum", path = "../../gum" } polkadot-primitives = { path = "../../../primitives" } polkadot-node-subsystem = { path = "../../subsystem" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } wasm-timer = "0.2.5" thiserror = "1.0.31" diff --git a/node/core/candidate-validation/Cargo.toml b/node/core/candidate-validation/Cargo.toml index bae737ab72f3..ad1da736e01f 100644 --- a/node/core/candidate-validation/Cargo.toml +++ b/node/core/candidate-validation/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "polkadot-node-core-candidate-validation" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] -async-trait = "0.1.53" +async-trait = "0.1.57" futures = "0.3.21" gum = { package = "tracing-gum", path = "../../gum" } -sp-maybe-compressed-blob = { package = "sp-maybe-compressed-blob", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-maybe-compressed-blob = { package = "sp-maybe-compressed-blob", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } parity-scale-codec = { version = "3.1.5", default-features = false, features = ["bit-vec", "derive"] } polkadot-primitives = { path = "../../../primitives" } @@ -22,9 +22,9 @@ polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-node-core-pvf = { path = "../pvf" } [dev-dependencies] -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures = { version = "0.3.21", features = ["thread-pool"] } assert_matches = "1.4.0" polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } diff --git a/node/core/candidate-validation/src/lib.rs b/node/core/candidate-validation/src/lib.rs index 1f51c1ec7701..c3775ba1c453 100644 --- a/node/core/candidate-validation/src/lib.rs +++ b/node/core/candidate-validation/src/lib.rs @@ -501,10 +501,11 @@ async fn validate_candidate_exhaustive( let _timer = metrics.time_validate_candidate_exhaustive(); let validation_code_hash = validation_code.hash(); + let para_id = candidate_receipt.descriptor.para_id.clone(); gum::debug!( target: LOG_TARGET, ?validation_code_hash, - para_id = ?candidate_receipt.descriptor.para_id, + ?para_id, "About to validate a candidate.", ); @@ -514,6 +515,7 @@ async fn validate_candidate_exhaustive( &*pov, &validation_code_hash, ) { + gum::info!(target: LOG_TARGET, ?para_id, "Invalid candidate (basic checks)"); return Ok(ValidationResult::Invalid(e)) } @@ -523,7 +525,7 @@ async fn validate_candidate_exhaustive( ) { Ok(code) => code, Err(e) => { - gum::debug!(target: LOG_TARGET, err=?e, "Invalid validation code"); + gum::info!(target: LOG_TARGET, ?para_id, err=?e, "Invalid candidate (validation code)"); // If the validation code is invalid, the candidate certainly is. return Ok(ValidationResult::Invalid(InvalidCandidate::CodeDecompressionFailure)) @@ -534,7 +536,7 @@ async fn validate_candidate_exhaustive( match sp_maybe_compressed_blob::decompress(&pov.block_data.0, POV_BOMB_LIMIT) { Ok(block_data) => BlockData(block_data.to_vec()), Err(e) => { - gum::debug!(target: LOG_TARGET, err=?e, "Invalid PoV code"); + gum::info!(target: LOG_TARGET, ?para_id, err=?e, "Invalid candidate (PoV code)"); // If the PoV is invalid, the candidate certainly is. return Ok(ValidationResult::Invalid(InvalidCandidate::PoVDecompressionFailure)) @@ -552,12 +554,8 @@ async fn validate_candidate_exhaustive( .validate_candidate(raw_validation_code.to_vec(), timeout, params) .await; - if let Err(ref e) = result { - gum::debug!( - target: LOG_TARGET, - error = ?e, - "Failed to validate candidate", - ); + if let Err(ref error) = result { + gum::info!(target: LOG_TARGET, ?para_id, ?error, "Failed to validate candidate",); } match result { @@ -576,6 +574,7 @@ async fn validate_candidate_exhaustive( Ok(res) => if res.head_data.hash() != candidate_receipt.descriptor.para_head { + gum::info!(target: LOG_TARGET, ?para_id, "Invalid candidate (para_head)"); Ok(ValidationResult::Invalid(InvalidCandidate::ParaHeadHashMismatch)) } else { let outputs = CandidateCommitments { @@ -587,6 +586,12 @@ async fn validate_candidate_exhaustive( hrmp_watermark: res.hrmp_watermark, }; if candidate_receipt.commitments_hash != outputs.hash() { + gum::info!( + target: LOG_TARGET, + ?para_id, + "Invalid candidate (commitments hash)" + ); + // If validation produced a new set of commitments, we treat the candidate as invalid. Ok(ValidationResult::Invalid(InvalidCandidate::CommitmentsHashMismatch)) } else { diff --git a/node/core/chain-api/Cargo.toml b/node/core/chain-api/Cargo.toml index 522acab2ec15..ff815a46e646 100644 --- a/node/core/chain-api/Cargo.toml +++ b/node/core/chain-api/Cargo.toml @@ -1,18 +1,18 @@ [package] name = "polkadot-node-core-chain-api" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] futures = "0.3.21" gum = { package = "tracing-gum", path = "../../gum" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-primitives = { path = "../../../primitives" } polkadot-node-subsystem = {path = "../../subsystem" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } -sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [dev-dependencies] futures = { version = "0.3.21", features = ["thread-pool"] } @@ -20,4 +20,4 @@ maplit = "1.0.2" parity-scale-codec = "3.1.5" polkadot-node-primitives = { path = "../../primitives" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } diff --git a/node/core/chain-selection/Cargo.toml b/node/core/chain-selection/Cargo.toml index 07cdbf45a3f8..a1e75625c32e 100644 --- a/node/core/chain-selection/Cargo.toml +++ b/node/core/chain-selection/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "polkadot-node-core-chain-selection" description = "Chain Selection Subsystem" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -13,13 +13,13 @@ polkadot-primitives = { path = "../../../primitives" } polkadot-node-primitives = { path = "../../primitives" } polkadot-node-subsystem = { path = "../../subsystem" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } -kvdb = "0.11.0" +kvdb = "0.12.0" thiserror = "1.0.31" parity-scale-codec = "3.1.5" [dev-dependencies] polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } parking_lot = "0.12.0" assert_matches = "1" -kvdb-memorydb = "0.11.0" +kvdb-memorydb = "0.12.0" diff --git a/node/core/chain-selection/src/db_backend/v1.rs b/node/core/chain-selection/src/db_backend/v1.rs index db117ff945df..a037d27baaea 100644 --- a/node/core/chain-selection/src/db_backend/v1.rs +++ b/node/core/chain-selection/src/db_backend/v1.rs @@ -235,16 +235,21 @@ impl Backend for DbBackend { self.inner.iter_with_prefix(self.config.col_data, &STAGNANT_AT_PREFIX[..]); let val = stagnant_at_iter - .filter_map(|(k, v)| { - match (decode_stagnant_at_key(&mut &k[..]), >::decode(&mut &v[..]).ok()) { - (Some(at), Some(stagnant_at)) => Some((at, stagnant_at)), - _ => None, - } + .filter_map(|r| match r { + Ok((k, v)) => + match (decode_stagnant_at_key(&mut &k[..]), >::decode(&mut &v[..]).ok()) + { + (Some(at), Some(stagnant_at)) => Some(Ok((at, stagnant_at))), + _ => None, + }, + Err(e) => Some(Err(e)), }) .enumerate() - .take_while(|(idx, (at, _))| *at <= up_to.into() && *idx < max_elements) + .take_while(|(idx, r)| { + r.as_ref().map_or(true, |(at, _)| *at <= up_to.into() && *idx < max_elements) + }) .map(|(_, v)| v) - .collect::>(); + .collect::, _>>()?; Ok(val) } @@ -254,10 +259,13 @@ impl Backend for DbBackend { self.inner.iter_with_prefix(self.config.col_data, &BLOCK_HEIGHT_PREFIX[..]); let val = blocks_at_height_iter - .filter_map(|(k, _)| decode_block_height_key(&k[..])) + .filter_map(|r| match r { + Ok((k, _)) => decode_block_height_key(&k[..]).map(Ok), + Err(e) => Some(Err(e)), + }) .next(); - Ok(val) + val.transpose().map_err(Error::from) } fn load_blocks_by_number(&self, number: BlockNumber) -> Result, Error> { diff --git a/node/core/dispute-coordinator/Cargo.toml b/node/core/dispute-coordinator/Cargo.toml index ba858dff751c..9c78180baa71 100644 --- a/node/core/dispute-coordinator/Cargo.toml +++ b/node/core/dispute-coordinator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-core-dispute-coordinator" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -8,9 +8,9 @@ edition = "2021" futures = "0.3.21" gum = { package = "tracing-gum", path = "../../gum" } parity-scale-codec = "3.1.5" -kvdb = "0.11.0" +kvdb = "0.12.0" thiserror = "1.0.31" -lru = "0.7.7" +lru = "0.8.0" fatality = "0.0.6" polkadot-primitives = { path = "../../../primitives" } @@ -18,19 +18,19 @@ polkadot-node-primitives = { path = "../../primitives" } polkadot-node-subsystem = { path = "../../subsystem" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } -sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [dev-dependencies] -kvdb-memorydb = "0.11.0" +kvdb-memorydb = "0.12.0" polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } assert_matches = "1.4.0" test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } futures-timer = "3.0.2" -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] # If not enabled, the dispute coordinator will do nothing. diff --git a/node/core/dispute-coordinator/src/db/v1.rs b/node/core/dispute-coordinator/src/db/v1.rs index 4d33949db644..2c643d341de2 100644 --- a/node/core/dispute-coordinator/src/db/v1.rs +++ b/node/core/dispute-coordinator/src/db/v1.rs @@ -16,6 +16,7 @@ //! `V1` database for the dispute coordinator. +use polkadot_node_primitives::DisputeStatus; use polkadot_node_subsystem::{SubsystemError, SubsystemResult}; use polkadot_node_subsystem_util::database::{DBTransaction, Database}; use polkadot_primitives::v2::{ @@ -31,7 +32,6 @@ use crate::{ backend::{Backend, BackendWriteOp, OverlayedBackend}, error::{FatalError, FatalResult}, metrics::Metrics, - status::DisputeStatus, DISPUTE_WINDOW, LOG_TARGET, }; diff --git a/node/core/dispute-coordinator/src/initialized.rs b/node/core/dispute-coordinator/src/initialized.rs index e37459dc5142..5f29245f33f8 100644 --- a/node/core/dispute-coordinator/src/initialized.rs +++ b/node/core/dispute-coordinator/src/initialized.rs @@ -26,8 +26,8 @@ use futures::{ use sc_keystore::LocalKeystore; use polkadot_node_primitives::{ - CandidateVotes, DisputeMessage, DisputeMessageCheckError, SignedDisputeStatement, - DISPUTE_WINDOW, + CandidateVotes, DisputeMessage, DisputeMessageCheckError, DisputeStatus, + SignedDisputeStatement, Timestamp, DISPUTE_WINDOW, }; use polkadot_node_subsystem::{ messages::{ @@ -49,7 +49,7 @@ use crate::{ error::{log_error, Error, FatalError, FatalResult, JfyiError, JfyiResult, Result}, import::{CandidateEnvironment, CandidateVoteState}, metrics::Metrics, - status::{get_active_with_status, Clock, DisputeStatus, Timestamp}, + status::{get_active_with_status, Clock}, DisputeCoordinatorSubsystem, LOG_TARGET, }; @@ -599,7 +599,9 @@ impl Initialized { }; gum::trace!(target: LOG_TARGET, "Loaded recent disputes from db"); - let _ = tx.send(recent_disputes.keys().cloned().collect()); + let _ = tx.send( + recent_disputes.into_iter().map(|(k, v)| (k.0, k.1, v)).collect::>(), + ); }, DisputeCoordinatorMessage::ActiveDisputes(tx) => { // Return error if session information is missing. @@ -890,11 +892,7 @@ impl Initialized { .queue_participation( ctx, priority, - ParticipationRequest::new( - new_state.candidate_receipt().clone(), - session, - env.validators().len(), - ), + ParticipationRequest::new(new_state.candidate_receipt().clone(), session), ) .await; log_error(r)?; diff --git a/node/core/dispute-coordinator/src/lib.rs b/node/core/dispute-coordinator/src/lib.rs index 03193a9d68ea..6289eb2f11a2 100644 --- a/node/core/dispute-coordinator/src/lib.rs +++ b/node/core/dispute-coordinator/src/lib.rs @@ -304,7 +304,6 @@ impl DisputeCoordinatorSubsystem { Some(info) => info.validators.clone(), }; - let n_validators = validators.len(); let voted_indices = votes.voted_indices(); // Determine if there are any missing local statements for this dispute. Validators are @@ -335,11 +334,7 @@ impl DisputeCoordinatorSubsystem { if missing_local_statement { participation_requests.push(( ParticipationPriority::with_priority_if(is_included), - ParticipationRequest::new( - votes.candidate_receipt.clone(), - session, - n_validators, - ), + ParticipationRequest::new(votes.candidate_receipt.clone(), session), )); } } diff --git a/node/core/dispute-coordinator/src/participation/mod.rs b/node/core/dispute-coordinator/src/participation/mod.rs index 3c066641d9f4..874f37e63213 100644 --- a/node/core/dispute-coordinator/src/participation/mod.rs +++ b/node/core/dispute-coordinator/src/participation/mod.rs @@ -27,7 +27,7 @@ use futures_timer::Delay; use polkadot_node_primitives::{ValidationResult, APPROVAL_EXECUTION_TIMEOUT}; use polkadot_node_subsystem::{ - messages::{AvailabilityRecoveryMessage, AvailabilityStoreMessage, CandidateValidationMessage}, + messages::{AvailabilityRecoveryMessage, CandidateValidationMessage}, overseer, ActiveLeavesUpdate, RecoveryError, }; use polkadot_node_subsystem_util::runtime::get_validation_code_by_hash; @@ -213,7 +213,6 @@ impl Participation { } /// Dequeue until `MAX_PARALLEL_PARTICIPATIONS` is reached. - async fn dequeue_until_capacity( &mut self, ctx: &mut Context, @@ -320,38 +319,6 @@ async fn participate( }, }; - // we dispatch a request to store the available data for the candidate. We - // want to maximize data availability for other potential checkers involved - // in the dispute - let (store_available_data_tx, store_available_data_rx) = oneshot::channel(); - sender - .send_message(AvailabilityStoreMessage::StoreAvailableData { - candidate_hash: *req.candidate_hash(), - n_validators: req.n_validators() as u32, - available_data: available_data.clone(), - tx: store_available_data_tx, - }) - .await; - - match store_available_data_rx.await { - Err(oneshot::Canceled) => { - gum::warn!( - target: LOG_TARGET, - "`Oneshot` got cancelled when storing available data {:?}", - req.candidate_hash(), - ); - }, - Ok(Err(err)) => { - gum::warn!( - target: LOG_TARGET, - ?err, - "Failed to store available data for candidate {:?}", - req.candidate_hash(), - ); - }, - Ok(Ok(())) => {}, - } - // Issue a request to validate the candidate with the provided exhaustive // parameters // diff --git a/node/core/dispute-coordinator/src/participation/queues/mod.rs b/node/core/dispute-coordinator/src/participation/queues/mod.rs index 158bcfd2d3b6..3ec217628625 100644 --- a/node/core/dispute-coordinator/src/participation/queues/mod.rs +++ b/node/core/dispute-coordinator/src/participation/queues/mod.rs @@ -78,7 +78,6 @@ pub struct ParticipationRequest { candidate_hash: CandidateHash, candidate_receipt: CandidateReceipt, session: SessionIndex, - n_validators: usize, } /// Whether a `ParticipationRequest` should be put on best-effort or the priority queue. @@ -122,12 +121,8 @@ pub enum QueueError { impl ParticipationRequest { /// Create a new `ParticipationRequest` to be queued. - pub fn new( - candidate_receipt: CandidateReceipt, - session: SessionIndex, - n_validators: usize, - ) -> Self { - Self { candidate_hash: candidate_receipt.hash(), candidate_receipt, session, n_validators } + pub fn new(candidate_receipt: CandidateReceipt, session: SessionIndex) -> Self { + Self { candidate_hash: candidate_receipt.hash(), candidate_receipt, session } } pub fn candidate_receipt(&'_ self) -> &'_ CandidateReceipt { @@ -139,9 +134,6 @@ impl ParticipationRequest { pub fn session(&self) -> SessionIndex { self.session } - pub fn n_validators(&self) -> usize { - self.n_validators - } pub fn into_candidate_info(self) -> (CandidateHash, CandidateReceipt) { let Self { candidate_hash, candidate_receipt, .. } = self; (candidate_hash, candidate_receipt) diff --git a/node/core/dispute-coordinator/src/participation/queues/tests.rs b/node/core/dispute-coordinator/src/participation/queues/tests.rs index 03c8e1f3b658..4e9019ebb499 100644 --- a/node/core/dispute-coordinator/src/participation/queues/tests.rs +++ b/node/core/dispute-coordinator/src/participation/queues/tests.rs @@ -25,7 +25,7 @@ fn make_participation_request(hash: Hash) -> ParticipationRequest { let mut receipt = dummy_candidate_receipt(dummy_hash()); // make it differ: receipt.commitments_hash = hash; - ParticipationRequest::new(receipt, 1, 100) + ParticipationRequest::new(receipt, 1) } /// Make dummy comparator for request, based on the given block number. diff --git a/node/core/dispute-coordinator/src/participation/tests.rs b/node/core/dispute-coordinator/src/participation/tests.rs index 3ccb652fecc1..03772b1918dc 100644 --- a/node/core/dispute-coordinator/src/participation/tests.rs +++ b/node/core/dispute-coordinator/src/participation/tests.rs @@ -29,10 +29,7 @@ use parity_scale_codec::Encode; use polkadot_node_primitives::{AvailableData, BlockData, InvalidCandidate, PoV}; use polkadot_node_subsystem::{ jaeger, - messages::{ - AllMessages, DisputeCoordinatorMessage, RuntimeApiMessage, RuntimeApiRequest, - ValidationFailed, - }, + messages::{AllMessages, DisputeCoordinatorMessage, RuntimeApiMessage, RuntimeApiRequest}, ActivatedLeaf, ActiveLeavesUpdate, LeafStatus, SpawnGlue, }; use polkadot_node_subsystem_test_helpers::{ @@ -71,9 +68,8 @@ async fn participate_with_commitments_hash( receipt }; let session = 1; - let n_validators = 10; - let req = ParticipationRequest::new(candidate_receipt, session, n_validators); + let req = ParticipationRequest::new(candidate_receipt, session); participation .queue_participation(ctx, ParticipationPriority::BestEffort, req) @@ -116,7 +112,6 @@ pub async fn participation_full_happy_path( ) { recover_available_data(ctx_handle).await; fetch_validation_code(ctx_handle).await; - store_available_data(ctx_handle, true).await; assert_matches!( ctx_handle.recv().await, @@ -185,20 +180,6 @@ async fn fetch_validation_code(virtual_overseer: &mut VirtualOverseer) -> Hash { ) } -async fn store_available_data(virtual_overseer: &mut VirtualOverseer, success: bool) { - assert_matches!( - virtual_overseer.recv().await, - AllMessages::AvailabilityStore(AvailabilityStoreMessage::StoreAvailableData { tx, .. }) => { - if success { - tx.send(Ok(())).unwrap(); - } else { - tx.send(Err(())).unwrap(); - } - }, - "overseer did not receive store available data request", - ); -} - #[test] fn same_req_wont_get_queued_if_participation_is_already_running() { futures::executor::block_on(async { @@ -423,7 +404,6 @@ fn cast_invalid_vote_if_validation_fails_or_is_invalid() { fetch_validation_code(&mut ctx_handle).await, participation.recent_block.unwrap().1 ); - store_available_data(&mut ctx_handle, true).await; assert_matches!( ctx_handle.recv().await, @@ -461,7 +441,6 @@ fn cast_invalid_vote_if_commitments_dont_match() { fetch_validation_code(&mut ctx_handle).await, participation.recent_block.unwrap().1 ); - store_available_data(&mut ctx_handle, true).await; assert_matches!( ctx_handle.recv().await, @@ -499,7 +478,6 @@ fn cast_valid_vote_if_validation_passes() { fetch_validation_code(&mut ctx_handle).await, participation.recent_block.unwrap().1 ); - store_available_data(&mut ctx_handle, true).await; assert_matches!( ctx_handle.recv().await, @@ -521,42 +499,3 @@ fn cast_valid_vote_if_validation_passes() { ); }) } - -#[test] -fn failure_to_store_available_data_does_not_preclude_participation() { - futures::executor::block_on(async { - let (mut ctx, mut ctx_handle) = make_our_subsystem_context(TaskExecutor::new()); - - let (sender, mut worker_receiver) = mpsc::channel(1); - let mut participation = Participation::new(sender); - activate_leaf(&mut ctx, &mut participation, 10).await.unwrap(); - participate(&mut ctx, &mut participation).await.unwrap(); - - recover_available_data(&mut ctx_handle).await; - assert_eq!( - fetch_validation_code(&mut ctx_handle).await, - participation.recent_block.unwrap().1 - ); - // the store available data request should fail: - store_available_data(&mut ctx_handle, false).await; - - assert_matches!( - ctx_handle.recv().await, - AllMessages::CandidateValidation( - CandidateValidationMessage::ValidateFromExhaustive(_, _, _, _, timeout, tx) - ) if timeout == APPROVAL_EXECUTION_TIMEOUT => { - tx.send(Err(ValidationFailed("fail".to_string()))).unwrap(); - }, - "overseer did not receive candidate validation message", - ); - - let result = participation - .get_participation_result(&mut ctx, worker_receiver.next().await.unwrap()) - .await - .unwrap(); - assert_matches!( - result.outcome, - ParticipationOutcome::Invalid => {} - ); - }) -} diff --git a/node/core/dispute-coordinator/src/scraping/mod.rs b/node/core/dispute-coordinator/src/scraping/mod.rs index 6fcae077ad8a..7d5d33e1ff4b 100644 --- a/node/core/dispute-coordinator/src/scraping/mod.rs +++ b/node/core/dispute-coordinator/src/scraping/mod.rs @@ -14,7 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use std::collections::{BTreeMap, HashSet}; +use std::{ + collections::{BTreeMap, HashSet}, + num::NonZeroUsize, +}; use futures::channel::oneshot; use lru::LruCache; @@ -44,7 +47,10 @@ mod tests; /// `last_observed_blocks` LRU. This means, this value should the very least be as large as the /// number of expected forks for keeping chain scraping efficient. Making the LRU much larger than /// that has very limited use. -const LRU_OBSERVED_BLOCKS_CAPACITY: usize = 20; +const LRU_OBSERVED_BLOCKS_CAPACITY: NonZeroUsize = match NonZeroUsize::new(20) { + Some(cap) => cap, + None => panic!("Observed blocks cache size must be non-zero"), +}; /// Chain scraper /// @@ -55,7 +61,7 @@ const LRU_OBSERVED_BLOCKS_CAPACITY: usize = 20; /// - Monitors for inclusion events to keep track of candidates that have been included on chains. /// - Calls `FetchOnChainVotes` for each block to gather potentially missed votes from chain. /// -/// With this information it provies a `CandidateComparator` and as a return value of +/// With this information it provides a `CandidateComparator` and as a return value of /// `process_active_leaves_update` any scraped votes. pub struct ChainScraper { /// All candidates we have seen included, which not yet have been finalized. @@ -136,7 +142,7 @@ impl ChainScraper { let mut on_chain_votes = Vec::new(); for (block_number, block_hash) in block_numbers.zip(block_hashes) { - gum::trace!(?block_number, ?block_hash, "In ancestor processesing."); + gum::trace!(?block_number, ?block_hash, "In ancestor processing."); self.process_candidate_events(sender, block_number, block_hash).await?; diff --git a/node/core/dispute-coordinator/src/status.rs b/node/core/dispute-coordinator/src/status.rs index d2ad551bd9ad..6332c3653274 100644 --- a/node/core/dispute-coordinator/src/status.rs +++ b/node/core/dispute-coordinator/src/status.rs @@ -14,125 +14,18 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use std::time::{SystemTime, UNIX_EPOCH}; - -use parity_scale_codec::{Decode, Encode}; +use polkadot_node_primitives::{dispute_is_inactive, DisputeStatus, Timestamp}; use polkadot_primitives::v2::{CandidateHash, SessionIndex}; +use std::time::{SystemTime, UNIX_EPOCH}; use crate::LOG_TARGET; -/// The choice here is fairly arbitrary. But any dispute that concluded more than a few minutes ago -/// is not worth considering anymore. Changing this value has little to no bearing on consensus, -/// and really only affects the work that the node might do on startup during periods of many -/// disputes. -pub const ACTIVE_DURATION_SECS: Timestamp = 180; - -/// Timestamp based on the 1 Jan 1970 UNIX base, which is persistent across node restarts and OS reboots. -pub type Timestamp = u64; - -/// The status of dispute. This is a state machine which can be altered by the -/// helper methods. -#[derive(Debug, Clone, Copy, Encode, Decode, PartialEq)] -pub enum DisputeStatus { - /// The dispute is active and unconcluded. - #[codec(index = 0)] - Active, - /// The dispute has been concluded in favor of the candidate - /// since the given timestamp. - #[codec(index = 1)] - ConcludedFor(Timestamp), - /// The dispute has been concluded against the candidate - /// since the given timestamp. - /// - /// This takes precedence over `ConcludedFor` in the case that - /// both are true, which is impossible unless a large amount of - /// validators are participating on both sides. - #[codec(index = 2)] - ConcludedAgainst(Timestamp), - /// Dispute has been confirmed (more than `byzantine_threshold` have already participated/ or - /// we have seen the candidate included already/participated successfully ourselves). - #[codec(index = 3)] - Confirmed, -} - -impl DisputeStatus { - /// Initialize the status to the active state. - pub fn active() -> DisputeStatus { - DisputeStatus::Active - } - - /// Move status to confirmed status, if not yet concluded/confirmed already. - pub fn confirm(self) -> DisputeStatus { - match self { - DisputeStatus::Active => DisputeStatus::Confirmed, - DisputeStatus::Confirmed => DisputeStatus::Confirmed, - DisputeStatus::ConcludedFor(_) | DisputeStatus::ConcludedAgainst(_) => self, - } - } - - /// Check whether the dispute is not a spam dispute. - pub fn is_confirmed_concluded(&self) -> bool { - match self { - &DisputeStatus::Confirmed | - &DisputeStatus::ConcludedFor(_) | - DisputeStatus::ConcludedAgainst(_) => true, - &DisputeStatus::Active => false, - } - } - - /// Transition the status to a new status after observing the dispute has concluded for the candidate. - /// This may be a no-op if the status was already concluded. - pub fn concluded_for(self, now: Timestamp) -> DisputeStatus { - match self { - DisputeStatus::Active | DisputeStatus::Confirmed => DisputeStatus::ConcludedFor(now), - DisputeStatus::ConcludedFor(at) => DisputeStatus::ConcludedFor(std::cmp::min(at, now)), - against => against, - } - } - - /// Transition the status to a new status after observing the dispute has concluded against the candidate. - /// This may be a no-op if the status was already concluded. - pub fn concluded_against(self, now: Timestamp) -> DisputeStatus { - match self { - DisputeStatus::Active | DisputeStatus::Confirmed => - DisputeStatus::ConcludedAgainst(now), - DisputeStatus::ConcludedFor(at) => - DisputeStatus::ConcludedAgainst(std::cmp::min(at, now)), - DisputeStatus::ConcludedAgainst(at) => - DisputeStatus::ConcludedAgainst(std::cmp::min(at, now)), - } - } - - /// Whether the disputed candidate is possibly invalid. - pub fn is_possibly_invalid(&self) -> bool { - match self { - DisputeStatus::Active | - DisputeStatus::Confirmed | - DisputeStatus::ConcludedAgainst(_) => true, - DisputeStatus::ConcludedFor(_) => false, - } - } - - /// Yields the timestamp this dispute concluded at, if any. - pub fn concluded_at(&self) -> Option { - match self { - DisputeStatus::Active | DisputeStatus::Confirmed => None, - DisputeStatus::ConcludedFor(at) | DisputeStatus::ConcludedAgainst(at) => Some(*at), - } - } -} - /// Get active disputes as iterator, preserving its `DisputeStatus`. pub fn get_active_with_status( recent_disputes: impl Iterator, now: Timestamp, ) -> impl Iterator { - recent_disputes.filter_map(move |(disputed, status)| { - status - .concluded_at() - .filter(|at| *at + ACTIVE_DURATION_SECS < now) - .map_or(Some((disputed, status)), |_| None) - }) + recent_disputes.filter(move |(_, status)| !dispute_is_inactive(status, &now)) } pub trait Clock: Send + Sync { diff --git a/node/core/dispute-coordinator/src/tests.rs b/node/core/dispute-coordinator/src/tests.rs index 39fdc3a037e5..aaef00999259 100644 --- a/node/core/dispute-coordinator/src/tests.rs +++ b/node/core/dispute-coordinator/src/tests.rs @@ -49,6 +49,7 @@ use sp_keyring::Sr25519Keyring; use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; use ::test_helpers::{dummy_candidate_receipt_bad_sig, dummy_digest, dummy_hash}; +use polkadot_node_primitives::{Timestamp, ACTIVE_DURATION_SECS}; use polkadot_node_subsystem::{ jaeger, messages::{AllMessages, BlockDescription, RuntimeApiMessage, RuntimeApiRequest}, @@ -66,7 +67,7 @@ use crate::{ backend::Backend, metrics::Metrics, participation::{participation_full_happy_path, participation_missing_availability}, - status::{Clock, Timestamp, ACTIVE_DURATION_SECS}, + status::Clock, Config, DisputeCoordinatorSubsystem, }; @@ -238,13 +239,15 @@ impl TestState { ))) .await; - self.handle_sync_queries(virtual_overseer, block_hash, session).await; + self.handle_sync_queries(virtual_overseer, block_hash, block_number, session) + .await; } async fn handle_sync_queries( &mut self, virtual_overseer: &mut VirtualOverseer, block_hash: Hash, + block_number: BlockNumber, session: SessionIndex, ) { // Order of messages is not fixed (different on initializing): @@ -277,11 +280,45 @@ impl TestState { finished_steps.got_session_information = true; assert_eq!(h, block_hash); let _ = tx.send(Ok(session)); + + // Queries for fetching earliest unfinalized block session. See `RollingSessionWindow`. + assert_matches!( + overseer_recv(virtual_overseer).await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber( + s_tx, + )) => { + let _ = s_tx.send(Ok(block_number)); + } + ); + + assert_matches!( + overseer_recv(virtual_overseer).await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash( + number, + s_tx, + )) => { + assert_eq!(block_number, number); + let _ = s_tx.send(Ok(Some(block_hash))); + } + ); + + assert_matches!( + overseer_recv(virtual_overseer).await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + h, + RuntimeApiRequest::SessionIndexForChild(s_tx), + )) => { + assert_eq!(h, block_hash); + let _ = s_tx.send(Ok(session)); + } + ); + // No queries, if subsystem knows about this session already. if self.known_session == Some(session) { continue } self.known_session = Some(session); + loop { // answer session info queries until the current session is reached. assert_matches!( @@ -360,7 +397,8 @@ impl TestState { ))) .await; - self.handle_sync_queries(virtual_overseer, *leaf, session).await; + self.handle_sync_queries(virtual_overseer, *leaf, n as BlockNumber, session) + .await; } } diff --git a/node/core/parachains-inherent/Cargo.toml b/node/core/parachains-inherent/Cargo.toml index f46a8d47be87..615a87c058cb 100644 --- a/node/core/parachains-inherent/Cargo.toml +++ b/node/core/parachains-inherent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-core-parachains-inherent" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -9,9 +9,9 @@ futures = "0.3.21" futures-timer = "3.0.2" gum = { package = "tracing-gum", path = "../../gum" } thiserror = "1.0.31" -async-trait = "0.1.53" +async-trait = "0.1.57" polkadot-node-subsystem = { path = "../../subsystem" } polkadot-primitives = { path = "../../../primitives" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } diff --git a/node/core/parachains-inherent/src/lib.rs b/node/core/parachains-inherent/src/lib.rs index af14216749ff..e9441d21aefe 100644 --- a/node/core/parachains-inherent/src/lib.rs +++ b/node/core/parachains-inherent/src/lib.rs @@ -57,6 +57,11 @@ impl ParachainsInherentDataProvider { ) -> Result { let pid = async { let (sender, receiver) = futures::channel::oneshot::channel(); + gum::trace!( + target: LOG_TARGET, + relay_parent = ?parent, + "Inherent data requested by Babe" + ); overseer.wait_for_activation(parent, sender).await; receiver .await @@ -64,6 +69,11 @@ impl ParachainsInherentDataProvider { .map_err(|e| Error::Subsystem(e))?; let (sender, receiver) = futures::channel::oneshot::channel(); + gum::trace!( + target: LOG_TARGET, + relay_parent = ?parent, + "Requesting inherent data (after having waited for activation)" + ); overseer .send_msg( ProvisionerMessage::RequestInherentData(parent, sender), diff --git a/node/core/provisioner/Cargo.toml b/node/core/provisioner/Cargo.toml index bc8270412d88..fbaea19618f6 100644 --- a/node/core/provisioner/Cargo.toml +++ b/node/core/provisioner/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-core-provisioner" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -13,15 +13,12 @@ polkadot-primitives = { path = "../../../primitives" } polkadot-node-primitives = { path = "../../primitives" } polkadot-node-subsystem = { path = "../../subsystem" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } -futures-timer = "3.0.2" rand = "0.8.5" +futures-timer = "3.0.2" fatality = "0.0.6" [dev-dependencies] -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } - -[features] -staging-client = [] diff --git a/node/core/provisioner/src/disputes/mod.rs b/node/core/provisioner/src/disputes/mod.rs new file mode 100644 index 000000000000..bd19e101bb2e --- /dev/null +++ b/node/core/provisioner/src/disputes/mod.rs @@ -0,0 +1,53 @@ +// Copyright 2017-2022 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 . + +//! The disputes module is responsible for selecting dispute votes to be sent with the inherent data. It contains two +//! different implementations, extracted in two separate modules - `random_selection` and `prioritized_selection`. Which +//! implementation will be executed depends on the version of the runtime. Runtime v2 supports `random_selection`. Runtime +//! `v3` and above - `prioritized_selection`. The entrypoint to these implementations is the `select_disputes` function. +//! `prioritized_selection` is considered superior and will be the default one in the future. Refer to the documentation of +//! the modules for more details about each implementation. + +use crate::LOG_TARGET; +use futures::channel::oneshot; +use polkadot_node_primitives::CandidateVotes; +use polkadot_node_subsystem::{messages::DisputeCoordinatorMessage, overseer}; +use polkadot_primitives::v2::{CandidateHash, SessionIndex}; + +/// Request the relevant dispute statements for a set of disputes identified by `CandidateHash` and the `SessionIndex`. +async fn request_votes( + sender: &mut impl overseer::ProvisionerSenderTrait, + disputes_to_query: Vec<(SessionIndex, CandidateHash)>, +) -> Vec<(SessionIndex, CandidateHash, CandidateVotes)> { + let (tx, rx) = oneshot::channel(); + // Bounded by block production - `ProvisionerMessage::RequestInherentData`. + sender.send_unbounded_message(DisputeCoordinatorMessage::QueryCandidateVotes( + disputes_to_query, + tx, + )); + + match rx.await { + Ok(v) => v, + Err(oneshot::Canceled) => { + gum::warn!(target: LOG_TARGET, "Unable to query candidate votes"); + Vec::new() + }, + } +} + +pub(crate) mod prioritized_selection; + +pub(crate) mod random_selection; diff --git a/node/core/provisioner/src/disputes/prioritized_selection/mod.rs b/node/core/provisioner/src/disputes/prioritized_selection/mod.rs new file mode 100644 index 000000000000..07426ef1a75b --- /dev/null +++ b/node/core/provisioner/src/disputes/prioritized_selection/mod.rs @@ -0,0 +1,464 @@ +// Copyright 2017-2022 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 . + +//! This module uses different approach for selecting dispute votes. It queries the Runtime +//! about the votes already known onchain and tries to select only relevant votes. Refer to +//! the documentation of `select_disputes` for more details about the actual implementation. + +use crate::{error::GetOnchainDisputesError, metrics, LOG_TARGET}; +use futures::channel::oneshot; +use polkadot_node_primitives::{dispute_is_inactive, CandidateVotes, DisputeStatus, Timestamp}; +use polkadot_node_subsystem::{ + errors::RuntimeApiError, + messages::{DisputeCoordinatorMessage, RuntimeApiMessage, RuntimeApiRequest}, + overseer, ActivatedLeaf, +}; +use polkadot_primitives::v2::{ + supermajority_threshold, CandidateHash, DisputeState, DisputeStatement, DisputeStatementSet, + Hash, MultiDisputeStatementSet, SessionIndex, ValidatorIndex, +}; +use std::{ + collections::{BTreeMap, HashMap}, + time::{SystemTime, UNIX_EPOCH}, +}; + +#[cfg(test)] +mod tests; + +/// The maximum number of disputes Provisioner will include in the inherent data. +/// Serves as a protection not to flood the Runtime with excessive data. +#[cfg(not(test))] +pub const MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME: usize = 200_000; +#[cfg(test)] +pub const MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME: usize = 200; + +/// Controls how much dispute votes to be fetched from the `dispute-coordinator` per iteration in +/// `fn vote_selection`. The purpose is to fetch the votes in batches until +/// `MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME` is reached. If all votes are fetched in single call +/// we might fetch votes which we never use. This will create unnecessary load on `dispute-coordinator`. +/// +/// This value should be less than `MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME`. Increase it in case +/// `provisioner` sends too many `QueryCandidateVotes` messages to `dispite-coordinator`. +#[cfg(not(test))] +const VOTES_SELECTION_BATCH_SIZE: usize = 1_100; +#[cfg(test)] +const VOTES_SELECTION_BATCH_SIZE: usize = 11; + +/// Implements the `select_disputes` function which selects dispute votes which should +/// be sent to the Runtime. +/// +/// # How the prioritization works +/// +/// Generally speaking disputes can be described as: +/// * Active vs Inactive +/// * Known vs Unknown onchain +/// * Offchain vs Onchain +/// * Concluded onchain vs Unconcluded onchain +/// +/// Provisioner fetches all disputes from `dispute-coordinator` and separates them in multiple partitions. +/// Please refer to `struct PartitionedDisputes` for details about the actual partitions. +/// Each partition has got a priority implicitly assigned to it and the disputes are selected based on this +/// priority (e.g. disputes in partition 1, then if there is space - disputes from partition 2 and so on). +/// +/// # Votes selection +/// +/// Besides the prioritization described above the votes in each partition are filtered too. Provisioner +/// fetches all onchain votes and filters them out from all partitions. As a result the Runtime receives +/// only fresh votes (votes it didn't know about). +/// +/// # How the onchain votes are fetched +/// +/// The logic outlined above relies on `RuntimeApiRequest::Disputes` message from the Runtime. The user +/// check the Runtime version before calling `select_disputes`. If the function is used with old runtime +/// an error is logged and the logic will continue with empty onchain votes `HashMap`. +pub async fn select_disputes( + sender: &mut Sender, + metrics: &metrics::Metrics, + leaf: &ActivatedLeaf, +) -> MultiDisputeStatementSet +where + Sender: overseer::ProvisionerSenderTrait, +{ + gum::trace!( + target: LOG_TARGET, + ?leaf, + "Selecting disputes for inherent data using prioritized selection" + ); + + // Fetch the onchain disputes. We'll do a prioritization based on them. + let onchain = match get_onchain_disputes(sender, leaf.hash.clone()).await { + Ok(r) => r, + Err(GetOnchainDisputesError::NotSupported(runtime_api_err, relay_parent)) => { + // Runtime version is checked before calling this method, so the error below should never happen! + gum::error!( + target: LOG_TARGET, + ?runtime_api_err, + ?relay_parent, + "Can't fetch onchain disputes, because ParachainHost runtime api version is old. Will continue with empty onchain disputes set.", + ); + HashMap::new() + }, + Err(GetOnchainDisputesError::Channel) => { + // This error usually means the node is shutting down. Log just in case. + gum::debug!( + target: LOG_TARGET, + "Channel error occurred while fetching onchain disputes. Will continue with empty onchain disputes set.", + ); + HashMap::new() + }, + Err(GetOnchainDisputesError::Execution(runtime_api_err, parent_hash)) => { + gum::warn!( + target: LOG_TARGET, + ?runtime_api_err, + ?parent_hash, + "Unexpected execution error occurred while fetching onchain votes. Will continue with empty onchain disputes set.", + ); + HashMap::new() + }, + }; + + let recent_disputes = request_disputes(sender).await; + gum::trace!( + target: LOG_TARGET, + ?leaf, + "Got {} recent disputes and {} onchain disputes.", + recent_disputes.len(), + onchain.len(), + ); + + let partitioned = partition_recent_disputes(recent_disputes, &onchain); + metrics.on_partition_recent_disputes(&partitioned); + + if partitioned.inactive_unknown_onchain.len() > 0 { + gum::warn!( + target: LOG_TARGET, + ?leaf, + "Got {} inactive unknown onchain disputes. This should not happen!", + partitioned.inactive_unknown_onchain.len() + ); + } + let result = vote_selection(sender, partitioned, &onchain).await; + + make_multi_dispute_statement_set(metrics, result) +} + +/// Selects dispute votes from `PartitionedDisputes` which should be sent to the runtime. Votes which +/// are already onchain are filtered out. Result should be sorted by `(SessionIndex, CandidateHash)` +/// which is enforced by the `BTreeMap`. This is a requirement from the runtime. +async fn vote_selection( + sender: &mut Sender, + partitioned: PartitionedDisputes, + onchain: &HashMap<(SessionIndex, CandidateHash), DisputeState>, +) -> BTreeMap<(SessionIndex, CandidateHash), CandidateVotes> +where + Sender: overseer::ProvisionerSenderTrait, +{ + // fetch in batches until there are enough votes + let mut disputes = partitioned.into_iter().collect::>(); + let mut total_votes_len = 0; + let mut result = BTreeMap::new(); + let mut request_votes_counter = 0; + while !disputes.is_empty() { + let batch_size = std::cmp::min(VOTES_SELECTION_BATCH_SIZE, disputes.len()); + let batch = Vec::from_iter(disputes.drain(0..batch_size)); + + // Filter votes which are already onchain + request_votes_counter += 1; + let votes = super::request_votes(sender, batch) + .await + .into_iter() + .map(|(session_index, candidate_hash, mut votes)| { + let onchain_state = + if let Some(onchain_state) = onchain.get(&(session_index, candidate_hash)) { + onchain_state + } else { + // onchain knows nothing about this dispute - add all votes + return (session_index, candidate_hash, votes) + }; + + votes.valid.retain(|validator_idx, (statement_kind, _)| { + is_vote_worth_to_keep( + validator_idx, + DisputeStatement::Valid(*statement_kind), + &onchain_state, + ) + }); + votes.invalid.retain(|validator_idx, (statement_kind, _)| { + is_vote_worth_to_keep( + validator_idx, + DisputeStatement::Invalid(*statement_kind), + &onchain_state, + ) + }); + (session_index, candidate_hash, votes) + }) + .collect::>(); + + // Check if votes are within the limit + for (session_index, candidate_hash, selected_votes) in votes { + let votes_len = selected_votes.valid.len() + selected_votes.invalid.len(); + if votes_len + total_votes_len > MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME { + // we are done - no more votes can be added + return result + } + result.insert((session_index, candidate_hash), selected_votes); + total_votes_len += votes_len + } + } + + gum::trace!( + target: LOG_TARGET, + ?request_votes_counter, + "vote_selection DisputeCoordinatorMessage::QueryCandidateVotes counter", + ); + + result +} + +/// Contains disputes by partitions. Check the field comments for further details. +#[derive(Default)] +pub(crate) struct PartitionedDisputes { + /// Concluded and inactive disputes which are completely unknown for the Runtime. + /// Hopefully this should never happen. + /// Will be sent to the Runtime with FIRST priority. + pub inactive_unknown_onchain: Vec<(SessionIndex, CandidateHash)>, + /// Disputes which are INACTIVE locally but they are unconcluded for the Runtime. + /// A dispute can have enough local vote to conclude and at the same time the + /// Runtime knows nothing about them at treats it as unconcluded. This discrepancy + /// should be treated with high priority. + /// Will be sent to the Runtime with SECOND priority. + pub inactive_unconcluded_onchain: Vec<(SessionIndex, CandidateHash)>, + /// Active disputes completely unknown onchain. + /// Will be sent to the Runtime with THIRD priority. + pub active_unknown_onchain: Vec<(SessionIndex, CandidateHash)>, + /// Active disputes unconcluded onchain. + /// Will be sent to the Runtime with FOURTH priority. + pub active_unconcluded_onchain: Vec<(SessionIndex, CandidateHash)>, + /// Active disputes concluded onchain. New votes are not that important for + /// this partition. + /// Will be sent to the Runtime with FIFTH priority. + pub active_concluded_onchain: Vec<(SessionIndex, CandidateHash)>, + /// Inactive disputes which has concluded onchain. These are not interesting and + /// won't be sent to the Runtime. + /// Will be DROPPED + pub inactive_concluded_onchain: Vec<(SessionIndex, CandidateHash)>, +} + +impl PartitionedDisputes { + fn new() -> PartitionedDisputes { + Default::default() + } + + fn into_iter(self) -> impl Iterator { + self.inactive_unknown_onchain + .into_iter() + .chain(self.inactive_unconcluded_onchain.into_iter()) + .chain(self.active_unknown_onchain.into_iter()) + .chain(self.active_unconcluded_onchain.into_iter()) + .chain(self.active_concluded_onchain.into_iter()) + // inactive_concluded_onchain is dropped on purpose + } +} + +fn secs_since_epoch() -> Timestamp { + match SystemTime::now().duration_since(UNIX_EPOCH) { + Ok(d) => d.as_secs(), + Err(e) => { + gum::warn!( + target: LOG_TARGET, + err = ?e, + "Error getting system time." + ); + 0 + }, + } +} + +fn concluded_onchain(onchain_state: &DisputeState) -> bool { + // Check if there are enough onchain votes for or against to conclude the dispute + let supermajority = supermajority_threshold(onchain_state.validators_for.len()); + + onchain_state.validators_for.count_ones() >= supermajority || + onchain_state.validators_against.count_ones() >= supermajority +} + +fn partition_recent_disputes( + recent: Vec<(SessionIndex, CandidateHash, DisputeStatus)>, + onchain: &HashMap<(SessionIndex, CandidateHash), DisputeState>, +) -> PartitionedDisputes { + let mut partitioned = PartitionedDisputes::new(); + + // Drop any duplicates + let unique_recent = recent + .into_iter() + .map(|(session_index, candidate_hash, dispute_state)| { + ((session_index, candidate_hash), dispute_state) + }) + .collect::>(); + + // Split recent disputes in ACTIVE and INACTIVE + let time_now = &secs_since_epoch(); + let (active, inactive): ( + Vec<(SessionIndex, CandidateHash, DisputeStatus)>, + Vec<(SessionIndex, CandidateHash, DisputeStatus)>, + ) = unique_recent + .into_iter() + .map(|((session_index, candidate_hash), dispute_state)| { + (session_index, candidate_hash, dispute_state) + }) + .partition(|(_, _, status)| !dispute_is_inactive(status, time_now)); + + // Split ACTIVE in three groups... + for (session_index, candidate_hash, _) in active { + match onchain.get(&(session_index, candidate_hash)) { + Some(d) => match concluded_onchain(d) { + true => partitioned.active_concluded_onchain.push((session_index, candidate_hash)), + false => + partitioned.active_unconcluded_onchain.push((session_index, candidate_hash)), + }, + None => partitioned.active_unknown_onchain.push((session_index, candidate_hash)), + }; + } + + // ... and INACTIVE in three more + for (session_index, candidate_hash, _) in inactive { + match onchain.get(&(session_index, candidate_hash)) { + Some(onchain_state) => + if concluded_onchain(onchain_state) { + partitioned.inactive_concluded_onchain.push((session_index, candidate_hash)); + } else { + partitioned.inactive_unconcluded_onchain.push((session_index, candidate_hash)); + }, + None => partitioned.inactive_unknown_onchain.push((session_index, candidate_hash)), + } + } + + partitioned +} + +/// Determines if a vote is worth to be kept, based on the onchain disputes +fn is_vote_worth_to_keep( + validator_index: &ValidatorIndex, + dispute_statement: DisputeStatement, + onchain_state: &DisputeState, +) -> bool { + let offchain_vote = match dispute_statement { + DisputeStatement::Valid(_) => true, + DisputeStatement::Invalid(_) => false, + }; + let in_validators_for = onchain_state + .validators_for + .get(validator_index.0 as usize) + .as_deref() + .copied() + .unwrap_or(false); + let in_validators_against = onchain_state + .validators_against + .get(validator_index.0 as usize) + .as_deref() + .copied() + .unwrap_or(false); + + if in_validators_for && in_validators_against { + // The validator has double voted and runtime knows about this. Ignore this vote. + return false + } + + if offchain_vote && in_validators_against || !offchain_vote && in_validators_for { + // offchain vote differs from the onchain vote + // we need this vote to punish the offending validator + return true + } + + // The vote is valid. Return true if it is not seen onchain. + !in_validators_for && !in_validators_against +} + +/// Request disputes identified by `CandidateHash` and the `SessionIndex`. +async fn request_disputes( + sender: &mut impl overseer::ProvisionerSenderTrait, +) -> Vec<(SessionIndex, CandidateHash, DisputeStatus)> { + let (tx, rx) = oneshot::channel(); + let msg = DisputeCoordinatorMessage::RecentDisputes(tx); + + // Bounded by block production - `ProvisionerMessage::RequestInherentData`. + sender.send_unbounded_message(msg); + + let recent_disputes = rx.await.unwrap_or_else(|err| { + gum::warn!(target: LOG_TARGET, err=?err, "Unable to gather recent disputes"); + Vec::new() + }); + recent_disputes +} + +// This function produces the return value for `pub fn select_disputes()` +fn make_multi_dispute_statement_set( + metrics: &metrics::Metrics, + dispute_candidate_votes: BTreeMap<(SessionIndex, CandidateHash), CandidateVotes>, +) -> MultiDisputeStatementSet { + // Transform all `CandidateVotes` into `MultiDisputeStatementSet`. + dispute_candidate_votes + .into_iter() + .map(|((session_index, candidate_hash), votes)| { + let valid_statements = votes + .valid + .into_iter() + .map(|(i, (s, sig))| (DisputeStatement::Valid(s), i, sig)); + + let invalid_statements = votes + .invalid + .into_iter() + .map(|(i, (s, sig))| (DisputeStatement::Invalid(s), i, sig)); + + metrics.inc_valid_statements_by(valid_statements.len()); + metrics.inc_invalid_statements_by(invalid_statements.len()); + metrics.inc_dispute_statement_sets_by(1); + + DisputeStatementSet { + candidate_hash, + session: session_index, + statements: valid_statements.chain(invalid_statements).collect(), + } + }) + .collect() +} + +/// Gets the on-chain disputes at a given block number and returns them as a `HashMap` so that searching in them is cheap. +pub async fn get_onchain_disputes( + sender: &mut Sender, + relay_parent: Hash, +) -> Result, GetOnchainDisputesError> +where + Sender: overseer::ProvisionerSenderTrait, +{ + gum::trace!(target: LOG_TARGET, ?relay_parent, "Fetching on-chain disputes"); + let (tx, rx) = oneshot::channel(); + sender + .send_message(RuntimeApiMessage::Request(relay_parent, RuntimeApiRequest::Disputes(tx))) + .await; + + rx.await + .map_err(|_| GetOnchainDisputesError::Channel) + .and_then(|res| { + res.map_err(|e| match e { + RuntimeApiError::Execution { .. } => + GetOnchainDisputesError::Execution(e, relay_parent), + RuntimeApiError::NotSupported { .. } => + GetOnchainDisputesError::NotSupported(e, relay_parent), + }) + }) + .map(|v| v.into_iter().map(|e| ((e.0, e.1), e.2)).collect()) +} diff --git a/node/core/provisioner/src/disputes/prioritized_selection/tests.rs b/node/core/provisioner/src/disputes/prioritized_selection/tests.rs new file mode 100644 index 000000000000..f76107dc65d4 --- /dev/null +++ b/node/core/provisioner/src/disputes/prioritized_selection/tests.rs @@ -0,0 +1,722 @@ +// Copyright 2017-2022 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 . + +use super::super::{ + super::{tests::common::test_harness, *}, + prioritized_selection::*, +}; +use bitvec::prelude::*; +use futures::channel::mpsc; +use polkadot_node_primitives::{CandidateVotes, DisputeStatus, ACTIVE_DURATION_SECS}; +use polkadot_node_subsystem::messages::{ + AllMessages, DisputeCoordinatorMessage, RuntimeApiMessage, RuntimeApiRequest, +}; +use polkadot_node_subsystem_test_helpers::TestSubsystemSender; +use polkadot_primitives::v2::{ + CandidateHash, DisputeState, InvalidDisputeStatementKind, SessionIndex, + ValidDisputeStatementKind, ValidatorSignature, +}; +use std::sync::Arc; +use test_helpers; + +// +// Unit tests for various functions +// +#[test] +fn should_keep_vote_behaves() { + let onchain_state = DisputeState { + validators_for: bitvec![u8, Lsb0; 1, 0, 1, 0, 1], + validators_against: bitvec![u8, Lsb0; 0, 1, 0, 0, 1], + start: 1, + concluded_at: None, + }; + + let local_valid_known = (ValidatorIndex(0), ValidDisputeStatementKind::Explicit); + let local_valid_unknown = (ValidatorIndex(3), ValidDisputeStatementKind::Explicit); + + let local_invalid_known = (ValidatorIndex(1), InvalidDisputeStatementKind::Explicit); + let local_invalid_unknown = (ValidatorIndex(3), InvalidDisputeStatementKind::Explicit); + + assert_eq!( + is_vote_worth_to_keep( + &local_valid_known.0, + DisputeStatement::Valid(local_valid_known.1), + &onchain_state + ), + false + ); + assert_eq!( + is_vote_worth_to_keep( + &local_valid_unknown.0, + DisputeStatement::Valid(local_valid_unknown.1), + &onchain_state + ), + true + ); + assert_eq!( + is_vote_worth_to_keep( + &local_invalid_known.0, + DisputeStatement::Invalid(local_invalid_known.1), + &onchain_state + ), + false + ); + assert_eq!( + is_vote_worth_to_keep( + &local_invalid_unknown.0, + DisputeStatement::Invalid(local_invalid_unknown.1), + &onchain_state + ), + true + ); + + //double voting - onchain knows + let local_double_vote_onchain_knows = + (ValidatorIndex(4), InvalidDisputeStatementKind::Explicit); + assert_eq!( + is_vote_worth_to_keep( + &local_double_vote_onchain_knows.0, + DisputeStatement::Invalid(local_double_vote_onchain_knows.1), + &onchain_state + ), + false + ); + + //double voting - onchain doesn't know + let local_double_vote_onchain_doesnt_knows = + (ValidatorIndex(0), InvalidDisputeStatementKind::Explicit); + assert_eq!( + is_vote_worth_to_keep( + &local_double_vote_onchain_doesnt_knows.0, + DisputeStatement::Invalid(local_double_vote_onchain_doesnt_knows.1), + &onchain_state + ), + true + ); + + // empty onchain state + let empty_onchain_state = DisputeState { + validators_for: BitVec::new(), + validators_against: BitVec::new(), + start: 1, + concluded_at: None, + }; + assert_eq!( + is_vote_worth_to_keep( + &local_double_vote_onchain_doesnt_knows.0, + DisputeStatement::Invalid(local_double_vote_onchain_doesnt_knows.1), + &empty_onchain_state + ), + true + ); +} + +#[test] +fn partitioning_happy_case() { + let mut input = Vec::<(SessionIndex, CandidateHash, DisputeStatus)>::new(); + let mut onchain = HashMap::<(u32, CandidateHash), DisputeState>::new(); + let time_now = secs_since_epoch(); + + // Create one dispute for each partition + let inactive_unknown_onchain = ( + 0, + CandidateHash(Hash::random()), + DisputeStatus::ConcludedFor(time_now - ACTIVE_DURATION_SECS * 2), + ); + input.push(inactive_unknown_onchain.clone()); + + let inactive_unconcluded_onchain = ( + 1, + CandidateHash(Hash::random()), + DisputeStatus::ConcludedFor(time_now - ACTIVE_DURATION_SECS * 2), + ); + input.push(inactive_unconcluded_onchain.clone()); + onchain.insert( + (inactive_unconcluded_onchain.0, inactive_unconcluded_onchain.1.clone()), + DisputeState { + validators_for: bitvec![u8, Lsb0; 1, 1, 1, 0, 0, 0, 0, 0, 0], + validators_against: bitvec![u8, Lsb0; 0, 0, 0, 0, 0, 0, 0, 0, 0], + start: 1, + concluded_at: None, + }, + ); + + let active_unknown_onchain = (2, CandidateHash(Hash::random()), DisputeStatus::Active); + input.push(active_unknown_onchain.clone()); + + let active_unconcluded_onchain = (3, CandidateHash(Hash::random()), DisputeStatus::Active); + input.push(active_unconcluded_onchain.clone()); + onchain.insert( + (active_unconcluded_onchain.0, active_unconcluded_onchain.1.clone()), + DisputeState { + validators_for: bitvec![u8, Lsb0; 1, 1, 1, 0, 0, 0, 0, 0, 0], + validators_against: bitvec![u8, Lsb0; 0, 0, 0, 0, 0, 0, 0, 0, 0], + start: 1, + concluded_at: None, + }, + ); + + let active_concluded_onchain = (4, CandidateHash(Hash::random()), DisputeStatus::Active); + input.push(active_concluded_onchain.clone()); + onchain.insert( + (active_concluded_onchain.0, active_concluded_onchain.1.clone()), + DisputeState { + validators_for: bitvec![u8, Lsb0; 1, 1, 1, 1, 1, 1, 1, 1, 0], + validators_against: bitvec![u8, Lsb0; 0, 0, 0, 0, 0, 0, 0, 0, 0], + start: 1, + concluded_at: Some(3), + }, + ); + + let inactive_concluded_onchain = ( + 5, + CandidateHash(Hash::random()), + DisputeStatus::ConcludedFor(time_now - ACTIVE_DURATION_SECS * 2), + ); + input.push(inactive_concluded_onchain.clone()); + onchain.insert( + (inactive_concluded_onchain.0, inactive_concluded_onchain.1.clone()), + DisputeState { + validators_for: bitvec![u8, Lsb0; 1, 1, 1, 1, 1, 1, 1, 0, 0], + validators_against: bitvec![u8, Lsb0; 0, 0, 0, 0, 0, 0, 0, 0, 0], + start: 1, + concluded_at: Some(3), + }, + ); + + let result = partition_recent_disputes(input, &onchain); + + // Check results + assert_eq!(result.inactive_unknown_onchain.len(), 1); + assert_eq!( + result.inactive_unknown_onchain.get(0).unwrap(), + &(inactive_unknown_onchain.0, inactive_unknown_onchain.1) + ); + + assert_eq!(result.inactive_unconcluded_onchain.len(), 1); + assert_eq!( + result.inactive_unconcluded_onchain.get(0).unwrap(), + &(inactive_unconcluded_onchain.0, inactive_unconcluded_onchain.1) + ); + + assert_eq!(result.active_unknown_onchain.len(), 1); + assert_eq!( + result.active_unknown_onchain.get(0).unwrap(), + &(active_unknown_onchain.0, active_unknown_onchain.1) + ); + + assert_eq!(result.active_unconcluded_onchain.len(), 1); + assert_eq!( + result.active_unconcluded_onchain.get(0).unwrap(), + &(active_unconcluded_onchain.0, active_unconcluded_onchain.1) + ); + + assert_eq!(result.active_concluded_onchain.len(), 1); + assert_eq!( + result.active_concluded_onchain.get(0).unwrap(), + &(active_concluded_onchain.0, active_concluded_onchain.1) + ); + + assert_eq!(result.inactive_concluded_onchain.len(), 1); + assert_eq!( + result.inactive_concluded_onchain.get(0).unwrap(), + &(inactive_concluded_onchain.0, inactive_concluded_onchain.1) + ); +} + +// This test verifies the double voting behavior. Currently we don't care if a supermajority is achieved with or +// without the 'help' of a double vote (a validator voting for and against at the same time). This makes the test +// a bit pointless but anyway I'm leaving it here to make this decision explicit and have the test code ready in +// case this behavior needs to be further tested in the future. +// Link to the PR with the discussions: https://github.com/paritytech/polkadot/pull/5567 +#[test] +fn partitioning_doubled_onchain_vote() { + let mut input = Vec::<(SessionIndex, CandidateHash, DisputeStatus)>::new(); + let mut onchain = HashMap::<(u32, CandidateHash), DisputeState>::new(); + + // Dispute A relies on a 'double onchain vote' to conclude. Validator with index 0 has voted both `for` and `against`. + // Despite that this dispute should be considered 'can conclude onchain'. + let dispute_a = (3, CandidateHash(Hash::random()), DisputeStatus::Active); + // Dispute B has supermajority + 1 votes, so the doubled onchain vote doesn't affect it. It should be considered + // as 'can conclude onchain'. + let dispute_b = (4, CandidateHash(Hash::random()), DisputeStatus::Active); + input.push(dispute_a.clone()); + input.push(dispute_b.clone()); + onchain.insert( + (dispute_a.0, dispute_a.1.clone()), + DisputeState { + validators_for: bitvec![u8, Lsb0; 1, 1, 1, 1, 1, 1, 1, 0, 0], + validators_against: bitvec![u8, Lsb0; 1, 0, 0, 0, 0, 0, 0, 0, 0], + start: 1, + concluded_at: None, + }, + ); + onchain.insert( + (dispute_b.0, dispute_b.1.clone()), + DisputeState { + validators_for: bitvec![u8, Lsb0; 1, 1, 1, 1, 1, 1, 1, 1, 0], + validators_against: bitvec![u8, Lsb0; 1, 0, 0, 0, 0, 0, 0, 0, 0], + start: 1, + concluded_at: None, + }, + ); + + let result = partition_recent_disputes(input, &onchain); + + assert_eq!(result.active_unconcluded_onchain.len(), 0); + assert_eq!(result.active_concluded_onchain.len(), 2); +} + +#[test] +fn partitioning_duplicated_dispute() { + let mut input = Vec::<(SessionIndex, CandidateHash, DisputeStatus)>::new(); + let mut onchain = HashMap::<(u32, CandidateHash), DisputeState>::new(); + + let some_dispute = (3, CandidateHash(Hash::random()), DisputeStatus::Active); + input.push(some_dispute.clone()); + input.push(some_dispute.clone()); + onchain.insert( + (some_dispute.0, some_dispute.1.clone()), + DisputeState { + validators_for: bitvec![u8, Lsb0; 1, 1, 1, 0, 0, 0, 0, 0, 0], + validators_against: bitvec![u8, Lsb0; 0, 0, 0, 0, 0, 0, 0, 0, 0], + start: 1, + concluded_at: None, + }, + ); + + let result = partition_recent_disputes(input, &onchain); + + assert_eq!(result.active_unconcluded_onchain.len(), 1); + assert_eq!( + result.active_unconcluded_onchain.get(0).unwrap(), + &(some_dispute.0, some_dispute.1) + ); +} + +// +// end-to-end tests for select_disputes() +// + +async fn mock_overseer( + mut receiver: mpsc::UnboundedReceiver, + disputes_db: &mut TestDisputes, + vote_queries_count: &mut usize, +) { + while let Some(from_job) = receiver.next().await { + match from_job { + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + _, + RuntimeApiRequest::Disputes(sender), + )) => { + let _ = sender.send(Ok(disputes_db + .onchain_disputes + .clone() + .into_iter() + .map(|(k, v)| (k.0, k.1, v)) + .collect::>())); + }, + AllMessages::RuntimeApi(_) => panic!("Unexpected RuntimeApi request"), + AllMessages::DisputeCoordinator(DisputeCoordinatorMessage::RecentDisputes(sender)) => { + let _ = sender.send(disputes_db.local_disputes.clone()); + }, + AllMessages::DisputeCoordinator(DisputeCoordinatorMessage::QueryCandidateVotes( + disputes, + sender, + )) => { + *vote_queries_count += 1; + let mut res = Vec::new(); + for d in disputes.iter() { + let v = disputes_db.votes_db.get(d).unwrap().clone(); + res.push((d.0, d.1, v)); + } + + let _ = sender.send(res); + }, + _ => panic!("Unexpected message: {:?}", from_job), + } + } +} + +fn leaf() -> ActivatedLeaf { + ActivatedLeaf { + hash: Hash::repeat_byte(0xAA), + number: 0xAA, + status: LeafStatus::Fresh, + span: Arc::new(jaeger::Span::Disabled), + } +} + +struct TestDisputes { + pub local_disputes: Vec<(SessionIndex, CandidateHash, DisputeStatus)>, + pub votes_db: HashMap<(SessionIndex, CandidateHash), CandidateVotes>, + pub onchain_disputes: HashMap<(u32, CandidateHash), DisputeState>, + validators_count: usize, +} + +impl TestDisputes { + pub fn new(validators_count: usize) -> TestDisputes { + TestDisputes { + local_disputes: Vec::<(SessionIndex, CandidateHash, DisputeStatus)>::new(), + votes_db: HashMap::<(SessionIndex, CandidateHash), CandidateVotes>::new(), + onchain_disputes: HashMap::<(u32, CandidateHash), DisputeState>::new(), + validators_count, + } + } + + // Offchain disputes are on node side + fn add_offchain_dispute( + &mut self, + dispute: (SessionIndex, CandidateHash, DisputeStatus), + local_votes_count: usize, + dummy_receipt: CandidateReceipt, + ) { + self.local_disputes.push(dispute.clone()); + self.votes_db.insert( + (dispute.0, dispute.1), + CandidateVotes { + candidate_receipt: dummy_receipt, + valid: TestDisputes::generate_local_votes( + ValidDisputeStatementKind::Explicit, + 0, + local_votes_count, + ), + invalid: BTreeMap::new(), + }, + ); + } + + fn add_onchain_dispute( + &mut self, + dispute: (SessionIndex, CandidateHash, DisputeStatus), + onchain_votes_count: usize, + ) { + let concluded_at = match dispute.2 { + DisputeStatus::Active | DisputeStatus::Confirmed => None, + DisputeStatus::ConcludedAgainst(_) | DisputeStatus::ConcludedFor(_) => Some(1), + }; + self.onchain_disputes.insert( + (dispute.0, dispute.1.clone()), + DisputeState { + validators_for: TestDisputes::generate_bitvec( + self.validators_count, + 0, + onchain_votes_count, + ), + validators_against: bitvec![u8, Lsb0; 0; self.validators_count], + start: 1, + concluded_at, + }, + ); + } + + pub fn add_unconfirmed_disputes_concluded_onchain( + &mut self, + dispute_count: usize, + ) -> (u32, usize) { + let local_votes_count = self.validators_count * 90 / 100; + let onchain_votes_count = self.validators_count * 80 / 100; + let session_idx = 0; + let lf = leaf(); + let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash.clone()); + for _ in 0..dispute_count { + let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::Active); + self.add_offchain_dispute(d.clone(), local_votes_count, dummy_receipt.clone()); + self.add_onchain_dispute(d, onchain_votes_count); + } + + (session_idx, (local_votes_count - onchain_votes_count) * dispute_count) + } + + pub fn add_unconfirmed_disputes_unconcluded_onchain( + &mut self, + dispute_count: usize, + ) -> (u32, usize) { + let local_votes_count = self.validators_count * 90 / 100; + let onchain_votes_count = self.validators_count * 40 / 100; + let session_idx = 1; + let lf = leaf(); + let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash.clone()); + for _ in 0..dispute_count { + let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::Active); + self.add_offchain_dispute(d.clone(), local_votes_count, dummy_receipt.clone()); + self.add_onchain_dispute(d, onchain_votes_count); + } + + (session_idx, (local_votes_count - onchain_votes_count) * dispute_count) + } + + pub fn add_unconfirmed_disputes_unknown_onchain( + &mut self, + dispute_count: usize, + ) -> (u32, usize) { + let local_votes_count = self.validators_count * 90 / 100; + let session_idx = 2; + let lf = leaf(); + let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash.clone()); + for _ in 0..dispute_count { + let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::Active); + self.add_offchain_dispute(d.clone(), local_votes_count, dummy_receipt.clone()); + } + (session_idx, local_votes_count * dispute_count) + } + + pub fn add_concluded_disputes_known_onchain(&mut self, dispute_count: usize) -> (u32, usize) { + let local_votes_count = self.validators_count * 90 / 100; + let onchain_votes_count = self.validators_count * 75 / 100; + let session_idx = 3; + let lf = leaf(); + let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash.clone()); + for _ in 0..dispute_count { + let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::ConcludedFor(0)); + self.add_offchain_dispute(d.clone(), local_votes_count, dummy_receipt.clone()); + self.add_onchain_dispute(d, onchain_votes_count); + } + (session_idx, (local_votes_count - onchain_votes_count) * dispute_count) + } + + pub fn add_concluded_disputes_unknown_onchain(&mut self, dispute_count: usize) -> (u32, usize) { + let local_votes_count = self.validators_count * 90 / 100; + let session_idx = 4; + let lf = leaf(); + let dummy_receipt = test_helpers::dummy_candidate_receipt(lf.hash.clone()); + for _ in 0..dispute_count { + let d = (session_idx, CandidateHash(Hash::random()), DisputeStatus::ConcludedFor(0)); + self.add_offchain_dispute(d.clone(), local_votes_count, dummy_receipt.clone()); + } + (session_idx, local_votes_count * dispute_count) + } + + fn generate_local_votes( + statement_kind: T, + start_idx: usize, + count: usize, + ) -> BTreeMap { + assert!(start_idx < count); + (start_idx..count) + .map(|idx| { + ( + ValidatorIndex(idx as u32), + (statement_kind.clone(), test_helpers::dummy_signature()), + ) + }) + .collect::>() + } + + fn generate_bitvec( + validator_count: usize, + start_idx: usize, + count: usize, + ) -> BitVec { + assert!(start_idx < count); + assert!(start_idx + count < validator_count); + let mut res = bitvec![u8, Lsb0; 0; validator_count]; + for idx in start_idx..count { + res.set(idx, true); + } + + res + } +} + +#[test] +fn normal_flow() { + const VALIDATOR_COUNT: usize = 10; + const DISPUTES_PER_BATCH: usize = 2; + const ACCEPTABLE_RUNTIME_VOTES_QUERIES_COUNT: usize = 1; + + let mut input = TestDisputes::new(VALIDATOR_COUNT); + + // active, concluded onchain + let (third_idx, third_votes) = + input.add_unconfirmed_disputes_concluded_onchain(DISPUTES_PER_BATCH); + + // active unconcluded onchain + let (first_idx, first_votes) = + input.add_unconfirmed_disputes_unconcluded_onchain(DISPUTES_PER_BATCH); + + //concluded disputes unknown onchain + let (fifth_idx, fifth_votes) = input.add_concluded_disputes_unknown_onchain(DISPUTES_PER_BATCH); + + // concluded disputes known onchain - these should be ignored + let (_, _) = input.add_concluded_disputes_known_onchain(DISPUTES_PER_BATCH); + + // active disputes unknown onchain + let (second_idx, second_votes) = + input.add_unconfirmed_disputes_unknown_onchain(DISPUTES_PER_BATCH); + + let metrics = metrics::Metrics::new_dummy(); + let mut vote_queries: usize = 0; + test_harness( + |r| mock_overseer(r, &mut input, &mut vote_queries), + |mut tx: TestSubsystemSender| async move { + let lf = leaf(); + let result = select_disputes(&mut tx, &metrics, &lf).await; + + assert!(!result.is_empty()); + + assert_eq!(result.len(), 4 * DISPUTES_PER_BATCH); + + // Naive checks that the result is partitioned correctly + let (first_batch, rest): (Vec, Vec) = + result.into_iter().partition(|d| d.session == first_idx); + assert_eq!(first_batch.len(), DISPUTES_PER_BATCH); + + let (second_batch, rest): (Vec, Vec) = + rest.into_iter().partition(|d| d.session == second_idx); + assert_eq!(second_batch.len(), DISPUTES_PER_BATCH); + + let (third_batch, rest): (Vec, Vec) = + rest.into_iter().partition(|d| d.session == third_idx); + assert_eq!(third_batch.len(), DISPUTES_PER_BATCH); + + let (fifth_batch, rest): (Vec, Vec) = + rest.into_iter().partition(|d| d.session == fifth_idx); + assert_eq!(fifth_batch.len(), DISPUTES_PER_BATCH); + + // Ensure there are no more disputes - fourth_batch should be dropped + assert_eq!(rest.len(), 0); + + assert_eq!( + first_batch.iter().map(|d| d.statements.len()).fold(0, |acc, v| acc + v), + first_votes + ); + assert_eq!( + second_batch.iter().map(|d| d.statements.len()).fold(0, |acc, v| acc + v), + second_votes + ); + assert_eq!( + third_batch.iter().map(|d| d.statements.len()).fold(0, |acc, v| acc + v), + third_votes + ); + assert_eq!( + fifth_batch.iter().map(|d| d.statements.len()).fold(0, |acc, v| acc + v), + fifth_votes + ); + }, + ); + assert!(vote_queries <= ACCEPTABLE_RUNTIME_VOTES_QUERIES_COUNT); +} + +#[test] +fn many_batches() { + const VALIDATOR_COUNT: usize = 10; + const DISPUTES_PER_PARTITION: usize = 10; + + // 10 disputes per partition * 4 partitions = 40 disputes + // BATCH_SIZE = 11 + // => There should be no more than 40 / 11 queries ( ~4 ) + const ACCEPTABLE_RUNTIME_VOTES_QUERIES_COUNT: usize = 4; + + let mut input = TestDisputes::new(VALIDATOR_COUNT); + + // active which can conclude onchain + input.add_unconfirmed_disputes_concluded_onchain(DISPUTES_PER_PARTITION); + + // active which can't conclude onchain + input.add_unconfirmed_disputes_unconcluded_onchain(DISPUTES_PER_PARTITION); + + //concluded disputes unknown onchain + input.add_concluded_disputes_unknown_onchain(DISPUTES_PER_PARTITION); + + // concluded disputes known onchain + input.add_concluded_disputes_known_onchain(DISPUTES_PER_PARTITION); + + // active disputes unknown onchain + input.add_unconfirmed_disputes_unknown_onchain(DISPUTES_PER_PARTITION); + + let metrics = metrics::Metrics::new_dummy(); + let mut vote_queries: usize = 0; + test_harness( + |r| mock_overseer(r, &mut input, &mut vote_queries), + |mut tx: TestSubsystemSender| async move { + let lf = leaf(); + let result = select_disputes(&mut tx, &metrics, &lf).await; + + assert!(!result.is_empty()); + + let vote_count = result.iter().map(|d| d.statements.len()).fold(0, |acc, v| acc + v); + + assert!( + MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME - VALIDATOR_COUNT <= vote_count && + vote_count <= MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME, + "vote_count: {}", + vote_count + ); + }, + ); + + assert!( + vote_queries <= ACCEPTABLE_RUNTIME_VOTES_QUERIES_COUNT, + "vote_queries: {} ACCEPTABLE_RUNTIME_VOTES_QUERIES_COUNT: {}", + vote_queries, + ACCEPTABLE_RUNTIME_VOTES_QUERIES_COUNT + ); +} + +#[test] +fn votes_above_limit() { + const VALIDATOR_COUNT: usize = 10; + const DISPUTES_PER_PARTITION: usize = 50; + const ACCEPTABLE_RUNTIME_VOTES_QUERIES_COUNT: usize = 4; + + let mut input = TestDisputes::new(VALIDATOR_COUNT); + + // active which can conclude onchain + let (_, second_votes) = + input.add_unconfirmed_disputes_concluded_onchain(DISPUTES_PER_PARTITION); + + // active which can't conclude onchain + let (_, first_votes) = + input.add_unconfirmed_disputes_unconcluded_onchain(DISPUTES_PER_PARTITION); + + //concluded disputes unknown onchain + let (_, third_votes) = input.add_concluded_disputes_unknown_onchain(DISPUTES_PER_PARTITION); + + assert!( + first_votes + second_votes + third_votes > 3 * MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME, + "Total relevant votes generated: {}", + first_votes + second_votes + third_votes + ); + + let metrics = metrics::Metrics::new_dummy(); + let mut vote_queries: usize = 0; + test_harness( + |r| mock_overseer(r, &mut input, &mut vote_queries), + |mut tx: TestSubsystemSender| async move { + let lf = leaf(); + let result = select_disputes(&mut tx, &metrics, &lf).await; + + assert!(!result.is_empty()); + + let vote_count = result.iter().map(|d| d.statements.len()).fold(0, |acc, v| acc + v); + + assert!( + MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME - VALIDATOR_COUNT <= vote_count && + vote_count <= MAX_DISPUTE_VOTES_FORWARDED_TO_RUNTIME, + "vote_count: {}", + vote_count + ); + }, + ); + + assert!( + vote_queries <= ACCEPTABLE_RUNTIME_VOTES_QUERIES_COUNT, + "vote_queries: {} ACCEPTABLE_RUNTIME_VOTES_QUERIES_COUNT: {}", + vote_queries, + ACCEPTABLE_RUNTIME_VOTES_QUERIES_COUNT + ); +} diff --git a/node/core/provisioner/src/disputes/random_selection/mod.rs b/node/core/provisioner/src/disputes/random_selection/mod.rs new file mode 100644 index 000000000000..a25d3445ac6e --- /dev/null +++ b/node/core/provisioner/src/disputes/random_selection/mod.rs @@ -0,0 +1,194 @@ +// Copyright 2017-2022 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 . + +//! This module selects all RECENT disputes, fetches the votes for them from dispute-coordinator and +//! returns them as `MultiDisputeStatementSet`. If the RECENT disputes are more than +//! `MAX_DISPUTES_FORWARDED_TO_RUNTIME` constant - the ACTIVE disputes plus a random selection of +//! RECENT disputes (up to `MAX_DISPUTES_FORWARDED_TO_RUNTIME`) are returned instead. +//! If the ACTIVE disputes are also above `MAX_DISPUTES_FORWARDED_TO_RUNTIME` limit - a random selection +//! of them is generated. + +use crate::{metrics, LOG_TARGET}; +use futures::channel::oneshot; +use polkadot_node_subsystem::{messages::DisputeCoordinatorMessage, overseer}; +use polkadot_primitives::v2::{ + CandidateHash, DisputeStatement, DisputeStatementSet, MultiDisputeStatementSet, SessionIndex, +}; +use std::collections::HashSet; + +/// The maximum number of disputes Provisioner will include in the inherent data. +/// Serves as a protection not to flood the Runtime with excessive data. +const MAX_DISPUTES_FORWARDED_TO_RUNTIME: usize = 1_000; + +#[derive(Debug)] +enum RequestType { + /// Query recent disputes, could be an excessive amount. + Recent, + /// Query the currently active and very recently concluded disputes. + Active, +} + +/// Request open disputes identified by `CandidateHash` and the `SessionIndex`. +async fn request_disputes( + sender: &mut impl overseer::ProvisionerSenderTrait, + active_or_recent: RequestType, +) -> Vec<(SessionIndex, CandidateHash)> { + let disputes = match active_or_recent { + RequestType::Recent => { + let (tx, rx) = oneshot::channel(); + let msg = DisputeCoordinatorMessage::RecentDisputes(tx); + sender.send_unbounded_message(msg); + let recent_disputes = match rx.await { + Ok(r) => r, + Err(oneshot::Canceled) => { + gum::warn!( + target: LOG_TARGET, + "Channel closed: unable to gather {:?} disputes", + active_or_recent + ); + Vec::new() + }, + }; + recent_disputes + .into_iter() + .map(|(sesion_idx, candodate_hash, _)| (sesion_idx, candodate_hash)) + .collect::>() + }, + RequestType::Active => { + let (tx, rx) = oneshot::channel(); + let msg = DisputeCoordinatorMessage::ActiveDisputes(tx); + sender.send_unbounded_message(msg); + let active_disputes = match rx.await { + Ok(r) => r, + Err(oneshot::Canceled) => { + gum::warn!( + target: LOG_TARGET, + "Unable to gather {:?} disputes", + active_or_recent + ); + Vec::new() + }, + }; + active_disputes + }, + }; + + disputes +} + +/// Extend `acc` by `n` random, picks of not-yet-present in `acc` items of `recent` without repetition and additions of recent. +fn extend_by_random_subset_without_repetition( + acc: &mut Vec<(SessionIndex, CandidateHash)>, + extension: Vec<(SessionIndex, CandidateHash)>, + n: usize, +) { + use rand::Rng; + + let lut = acc.iter().cloned().collect::>(); + + let mut unique_new = + extension.into_iter().filter(|recent| !lut.contains(recent)).collect::>(); + + // we can simply add all + if unique_new.len() <= n { + acc.extend(unique_new) + } else { + acc.reserve(n); + let mut rng = rand::thread_rng(); + for _ in 0..n { + let idx = rng.gen_range(0..unique_new.len()); + acc.push(unique_new.swap_remove(idx)); + } + } + // assure sorting stays candid according to session index + acc.sort_unstable_by(|a, b| a.0.cmp(&b.0)); +} + +pub async fn select_disputes( + sender: &mut Sender, + metrics: &metrics::Metrics, +) -> MultiDisputeStatementSet +where + Sender: overseer::ProvisionerSenderTrait, +{ + gum::trace!(target: LOG_TARGET, "Selecting disputes for inherent data using random selection"); + + // We use `RecentDisputes` instead of `ActiveDisputes` because redundancy is fine. + // It's heavier than `ActiveDisputes` but ensures that everything from the dispute + // window gets on-chain, unlike `ActiveDisputes`. + // In case of an overload condition, we limit ourselves to active disputes, and fill up to the + // upper bound of disputes to pass to wasm `fn create_inherent_data`. + // If the active ones are already exceeding the bounds, randomly select a subset. + let recent = request_disputes(sender, RequestType::Recent).await; + let disputes = if recent.len() > MAX_DISPUTES_FORWARDED_TO_RUNTIME { + gum::warn!( + target: LOG_TARGET, + "Recent disputes are excessive ({} > {}), reduce to active ones, and selected", + recent.len(), + MAX_DISPUTES_FORWARDED_TO_RUNTIME + ); + let mut active = request_disputes(sender, RequestType::Active).await; + let n_active = active.len(); + let active = if active.len() > MAX_DISPUTES_FORWARDED_TO_RUNTIME { + let mut picked = Vec::with_capacity(MAX_DISPUTES_FORWARDED_TO_RUNTIME); + extend_by_random_subset_without_repetition( + &mut picked, + active, + MAX_DISPUTES_FORWARDED_TO_RUNTIME, + ); + picked + } else { + extend_by_random_subset_without_repetition( + &mut active, + recent, + MAX_DISPUTES_FORWARDED_TO_RUNTIME.saturating_sub(n_active), + ); + active + }; + active + } else { + recent + }; + + // Load all votes for all disputes from the coordinator. + let dispute_candidate_votes = super::request_votes(sender, disputes).await; + + // Transform all `CandidateVotes` into `MultiDisputeStatementSet`. + dispute_candidate_votes + .into_iter() + .map(|(session_index, candidate_hash, votes)| { + let valid_statements = votes + .valid + .into_iter() + .map(|(i, (s, sig))| (DisputeStatement::Valid(s), i, sig)); + + let invalid_statements = votes + .invalid + .into_iter() + .map(|(i, (s, sig))| (DisputeStatement::Invalid(s), i, sig)); + + metrics.inc_valid_statements_by(valid_statements.len()); + metrics.inc_invalid_statements_by(invalid_statements.len()); + metrics.inc_dispute_statement_sets_by(1); + + DisputeStatementSet { + candidate_hash, + session: session_index, + statements: valid_statements.chain(invalid_statements).collect(), + } + }) + .collect() +} diff --git a/node/core/provisioner/src/error.rs b/node/core/provisioner/src/error.rs index 05e437854eac..9fb958c4f339 100644 --- a/node/core/provisioner/src/error.rs +++ b/node/core/provisioner/src/error.rs @@ -88,9 +88,7 @@ pub enum GetOnchainDisputesError { #[error("runtime execution error occurred while fetching onchain disputes for parent {1}")] Execution(#[source] RuntimeApiError, Hash), - #[error( - "runtime doesn't support RuntimeApiRequest::Disputes/RuntimeApiRequest::StagingDisputes for parent {1}" - )] + #[error("runtime doesn't support RuntimeApiRequest::Disputes for parent {1}")] NotSupported(#[source] RuntimeApiError, Hash), } diff --git a/node/core/provisioner/src/lib.rs b/node/core/provisioner/src/lib.rs index 0f3099c7df33..f669f9ddae2c 100644 --- a/node/core/provisioner/src/lib.rs +++ b/node/core/provisioner/src/lib.rs @@ -25,29 +25,27 @@ use futures::{ }; use futures_timer::Delay; -use polkadot_node_primitives::CandidateVotes; use polkadot_node_subsystem::{ jaeger, messages::{ - CandidateBackingMessage, ChainApiMessage, DisputeCoordinatorMessage, ProvisionableData, - ProvisionerInherentData, ProvisionerMessage, + CandidateBackingMessage, ChainApiMessage, ProvisionableData, ProvisionerInherentData, + ProvisionerMessage, RuntimeApiMessage, RuntimeApiRequest, }, overseer, ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, LeafStatus, OverseerSignal, - PerLeafSpan, SpawnedSubsystem, SubsystemError, + PerLeafSpan, RuntimeApiError, SpawnedSubsystem, SubsystemError, }; use polkadot_node_subsystem_util::{ request_availability_cores, request_persisted_validation_data, TimeoutExt, }; use polkadot_primitives::v2::{ - BackedCandidate, BlockNumber, CandidateHash, CandidateReceipt, CoreState, DisputeState, - DisputeStatement, DisputeStatementSet, Hash, MultiDisputeStatementSet, OccupiedCoreAssumption, - SessionIndex, SignedAvailabilityBitfield, ValidatorIndex, + BackedCandidate, BlockNumber, CandidateReceipt, CoreState, Hash, OccupiedCoreAssumption, + SignedAvailabilityBitfield, ValidatorIndex, }; -use std::collections::{BTreeMap, HashMap, HashSet}; +use std::collections::{BTreeMap, HashMap}; +mod disputes; mod error; mod metrics; -mod onchain_disputes; pub use self::metrics::*; use error::{Error, FatalResult}; @@ -62,6 +60,9 @@ const SEND_INHERENT_DATA_TIMEOUT: std::time::Duration = core::time::Duration::fr const LOG_TARGET: &str = "parachain::provisioner"; +const PRIORITIZED_SELECTION_RUNTIME_VERSION_REQUIREMENT: u32 = + RuntimeApiRequest::DISPUTES_RUNTIME_REQUIREMENT; + /// The provisioner subsystem. pub struct ProvisionerSubsystem { metrics: Metrics, @@ -270,7 +271,15 @@ async fn send_inherent_data_bg( match send_result.await { Err(err) => { - gum::warn!(target: LOG_TARGET, err = ?err, "failed to assemble or send inherent data"); + if let Error::CanceledBackedCandidates(_) = err { + gum::debug!( + target: LOG_TARGET, + err = ?err, + "Failed to assemble or send inherent data - block got likely obsoleted already." + ); + } else { + gum::warn!(target: LOG_TARGET, err = ?err, "failed to assemble or send inherent data"); + } metrics.on_inherent_data_request(Err(())); }, Ok(()) => { @@ -361,7 +370,18 @@ async fn send_inherent_data( relay_parent = ?leaf.hash, "Selecting disputes" ); - let disputes = select_disputes(from_job, metrics, leaf).await?; + + let disputes = match has_required_runtime( + from_job, + leaf.hash.clone(), + PRIORITIZED_SELECTION_RUNTIME_VERSION_REQUIREMENT, + ) + .await + { + true => disputes::prioritized_selection::select_disputes(from_job, metrics, leaf).await, + false => disputes::random_selection::select_disputes(from_job, metrics).await, + }; + gum::trace!( target: LOG_TARGET, relay_parent = ?leaf.hash, @@ -677,275 +697,55 @@ fn bitfields_indicate_availability( 3 * availability.count_ones() >= 2 * availability.len() } -#[derive(Debug)] -enum RequestType { - /// Query recent disputes, could be an excessive amount. - Recent, - /// Query the currently active and very recently concluded disputes. - Active, -} - -/// Request open disputes identified by `CandidateHash` and the `SessionIndex`. -async fn request_disputes( +// If we have to be absolutely precise here, this method gets the version of the `ParachainHost` api. +// For brevity we'll just call it 'runtime version'. +async fn has_required_runtime( sender: &mut impl overseer::ProvisionerSenderTrait, - active_or_recent: RequestType, -) -> Vec<(SessionIndex, CandidateHash)> { - let (tx, rx) = oneshot::channel(); - let msg = match active_or_recent { - RequestType::Recent => DisputeCoordinatorMessage::RecentDisputes(tx), - RequestType::Active => DisputeCoordinatorMessage::ActiveDisputes(tx), - }; - // Bounded by block production - `ProvisionerMessage::RequestInherentData`. - sender.send_unbounded_message(msg); - - let recent_disputes = match rx.await { - Ok(r) => r, - Err(oneshot::Canceled) => { - gum::warn!(target: LOG_TARGET, "Unable to gather {:?} disputes", active_or_recent); - Vec::new() - }, - }; - recent_disputes -} - -/// Request the relevant dispute statements for a set of disputes identified by `CandidateHash` and the `SessionIndex`. -async fn request_votes( - sender: &mut impl overseer::ProvisionerSenderTrait, - disputes_to_query: Vec<(SessionIndex, CandidateHash)>, -) -> Vec<(SessionIndex, CandidateHash, CandidateVotes)> { - // No need to send dummy request, if nothing to request: - if disputes_to_query.is_empty() { - gum::trace!(target: LOG_TARGET, "No disputes, nothing to request - returning empty `Vec`."); + relay_parent: Hash, + required_runtime_version: u32, +) -> bool { + gum::trace!(target: LOG_TARGET, ?relay_parent, "Fetching ParachainHost runtime api version"); - return Vec::new() - } let (tx, rx) = oneshot::channel(); - // Bounded by block production - `ProvisionerMessage::RequestInherentData`. - sender.send_unbounded_message(DisputeCoordinatorMessage::QueryCandidateVotes( - disputes_to_query, - tx, - )); + sender + .send_message(RuntimeApiMessage::Request(relay_parent, RuntimeApiRequest::Version(tx))) + .await; match rx.await { - Ok(v) => v, - Err(oneshot::Canceled) => { - gum::warn!(target: LOG_TARGET, "Unable to query candidate votes"); - Vec::new() + Result::Ok(Ok(runtime_version)) => { + gum::trace!( + target: LOG_TARGET, + ?relay_parent, + ?runtime_version, + ?required_runtime_version, + "Fetched ParachainHost runtime api version" + ); + runtime_version >= required_runtime_version }, - } -} - -/// Extend `acc` by `n` random, picks of not-yet-present in `acc` items of `recent` without repetition and additions of recent. -fn extend_by_random_subset_without_repetition( - acc: &mut Vec<(SessionIndex, CandidateHash)>, - extension: Vec<(SessionIndex, CandidateHash)>, - n: usize, -) { - use rand::Rng; - - let lut = acc.iter().cloned().collect::>(); - - let mut unique_new = - extension.into_iter().filter(|recent| !lut.contains(recent)).collect::>(); - - // we can simply add all - if unique_new.len() <= n { - acc.extend(unique_new) - } else { - acc.reserve(n); - let mut rng = rand::thread_rng(); - for _ in 0..n { - let idx = rng.gen_range(0..unique_new.len()); - acc.push(unique_new.swap_remove(idx)); - } - } - // assure sorting stays candid according to session index - acc.sort_unstable_by(|a, b| a.0.cmp(&b.0)); -} - -/// The maximum number of disputes Provisioner will include in the inherent data. -/// Serves as a protection not to flood the Runtime with excessive data. -const MAX_DISPUTES_FORWARDED_TO_RUNTIME: usize = 1_000; - -async fn select_disputes( - sender: &mut impl overseer::ProvisionerSenderTrait, - metrics: &metrics::Metrics, - _leaf: &ActivatedLeaf, -) -> Result { - // Helper lambda - // Gets the active disputes as input and partitions it in seen and unseen disputes by the Runtime - // Returns as much unseen disputes as possible and optionally some seen disputes up to `MAX_DISPUTES_FORWARDED_TO_RUNTIME` limit. - let generate_unseen_active_subset = - |active: Vec<(SessionIndex, CandidateHash)>, - onchain: HashMap<(SessionIndex, CandidateHash), DisputeState>| - -> Vec<(SessionIndex, CandidateHash)> { - let (seen_onchain, mut unseen_onchain): ( - Vec<(SessionIndex, CandidateHash)>, - Vec<(SessionIndex, CandidateHash)>, - ) = active.into_iter().partition(|d| onchain.contains_key(d)); - - if unseen_onchain.len() > MAX_DISPUTES_FORWARDED_TO_RUNTIME { - // Even unseen on-chain don't fit within the limit. Add as many as possible. - let mut unseen_subset = Vec::with_capacity(MAX_DISPUTES_FORWARDED_TO_RUNTIME); - extend_by_random_subset_without_repetition( - &mut unseen_subset, - unseen_onchain, - MAX_DISPUTES_FORWARDED_TO_RUNTIME, - ); - unseen_subset - } else { - // Add all unseen onchain disputes and as much of the seen ones as there is space. - let n_unseen_onchain = unseen_onchain.len(); - extend_by_random_subset_without_repetition( - &mut unseen_onchain, - seen_onchain, - MAX_DISPUTES_FORWARDED_TO_RUNTIME.saturating_sub(n_unseen_onchain), - ); - unseen_onchain - } - }; - - // Helper lambda - // Extends the active disputes with recent ones up to `MAX_DISPUTES_FORWARDED_TO_RUNTIME` limit. Unseen recent disputes are prioritised. - let generate_active_and_unseen_recent_subset = - |recent: Vec<(SessionIndex, CandidateHash)>, - mut active: Vec<(SessionIndex, CandidateHash)>, - onchain: HashMap<(SessionIndex, CandidateHash), DisputeState>| - -> Vec<(SessionIndex, CandidateHash)> { - let mut n_active = active.len(); - // All active disputes can be sent. Fill the rest of the space with recent ones. - // We assume there is not enough space for all recent disputes. So we prioritise the unseen ones. - let (seen_onchain, unseen_onchain): ( - Vec<(SessionIndex, CandidateHash)>, - Vec<(SessionIndex, CandidateHash)>, - ) = recent.into_iter().partition(|d| onchain.contains_key(d)); - - extend_by_random_subset_without_repetition( - &mut active, - unseen_onchain, - MAX_DISPUTES_FORWARDED_TO_RUNTIME.saturating_sub(n_active), + Result::Ok(Err(RuntimeApiError::Execution { source: error, .. })) => { + gum::trace!( + target: LOG_TARGET, + ?relay_parent, + ?error, + "Execution error while fetching ParachainHost runtime api version" ); - n_active = active.len(); - - if n_active < MAX_DISPUTES_FORWARDED_TO_RUNTIME { - // Looks like we can add some of the seen disputes too - extend_by_random_subset_without_repetition( - &mut active, - seen_onchain, - MAX_DISPUTES_FORWARDED_TO_RUNTIME.saturating_sub(n_active), - ); - } - active - }; - - gum::trace!( - target: LOG_TARGET, - relay_parent = ?_leaf.hash, - "Request recent disputes" - ); - - // We use `RecentDisputes` instead of `ActiveDisputes` because redundancy is fine. - // It's heavier than `ActiveDisputes` but ensures that everything from the dispute - // window gets on-chain, unlike `ActiveDisputes`. - // In case of an overload condition, we limit ourselves to active disputes, and fill up to the - // upper bound of disputes to pass to wasm `fn create_inherent_data`. - // If the active ones are already exceeding the bounds, randomly select a subset. - let recent = request_disputes(sender, RequestType::Recent).await; - - gum::trace!( - target: LOG_TARGET, - relay_paent = ?_leaf.hash, - "Received recent disputes" - ); - - gum::trace!( - target: LOG_TARGET, - relay_paent = ?_leaf.hash, - "Request on chain disputes" - ); - - // On chain disputes are fetched from the runtime. We want to prioritise the inclusion of unknown - // disputes in the inherent data. The call relies on staging Runtime API. If the staging API is not - // enabled in the binary an empty set is generated which doesn't affect the rest of the logic. - let onchain = match onchain_disputes::get_onchain_disputes(sender, _leaf.hash.clone()).await { - Ok(r) => r, - Err(e) => { - gum::debug!( + false + }, + Result::Ok(Err(RuntimeApiError::NotSupported { .. })) => { + gum::trace!( target: LOG_TARGET, - ?e, - "Can't fetch onchain disputes. Will continue with empty onchain disputes set.", + ?relay_parent, + "NotSupported error while fetching ParachainHost runtime api version" ); - HashMap::new() + false }, - }; - - gum::trace!( - target: LOG_TARGET, - relay_paent = ?_leaf.hash, - "Received on chain disputes" - ); - - gum::trace!( - target: LOG_TARGET, - relay_paent = ?_leaf.hash, - "Filtering disputes" - ); - - let disputes = if recent.len() > MAX_DISPUTES_FORWARDED_TO_RUNTIME { - gum::warn!( - target: LOG_TARGET, - "Recent disputes are excessive ({} > {}), reduce to active ones, and selected", - recent.len(), - MAX_DISPUTES_FORWARDED_TO_RUNTIME - ); - let active = request_disputes(sender, RequestType::Active).await; - if active.len() > MAX_DISPUTES_FORWARDED_TO_RUNTIME { - generate_unseen_active_subset(active, onchain) - } else { - generate_active_and_unseen_recent_subset(recent, active, onchain) - } - } else { - recent - }; - - gum::trace!( - target: LOG_TARGET, - relay_paent = ?_leaf.hash, - "Calling `request_votes`" - ); - - // Load all votes for all disputes from the coordinator. - let dispute_candidate_votes = request_votes(sender, disputes).await; - - gum::trace!( - target: LOG_TARGET, - relay_paent = ?_leaf.hash, - "Finished `request_votes`" - ); - - // Transform all `CandidateVotes` into `MultiDisputeStatementSet`. - Ok(dispute_candidate_votes - .into_iter() - .map(|(session_index, candidate_hash, votes)| { - let valid_statements = votes - .valid - .into_iter() - .map(|(i, (s, sig))| (DisputeStatement::Valid(s), i, sig)); - - let invalid_statements = votes - .invalid - .into_iter() - .map(|(i, (s, sig))| (DisputeStatement::Invalid(s), i, sig)); - - metrics.inc_valid_statements_by(valid_statements.len()); - metrics.inc_invalid_statements_by(invalid_statements.len()); - metrics.inc_dispute_statement_sets_by(1); - - DisputeStatementSet { - candidate_hash, - session: session_index, - statements: valid_statements.chain(invalid_statements).collect(), - } - }) - .collect()) + Result::Err(_) => { + gum::trace!( + target: LOG_TARGET, + ?relay_parent, + "Cancelled error while fetching ParachainHost runtime api version" + ); + false + }, + } } diff --git a/node/core/provisioner/src/metrics.rs b/node/core/provisioner/src/metrics.rs index 829293dfed53..8b6bb37284cb 100644 --- a/node/core/provisioner/src/metrics.rs +++ b/node/core/provisioner/src/metrics.rs @@ -14,13 +14,18 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . +use crate::disputes::prioritized_selection::PartitionedDisputes; use polkadot_node_subsystem_util::metrics::{self, prometheus}; #[derive(Clone)] struct MetricsInner { + /// Tracks successful/unsuccessful inherent data requests inherent_data_requests: prometheus::CounterVec, - request_inherent_data: prometheus::Histogram, - provisionable_data: prometheus::Histogram, + /// How much time the `RequestInherentData` processing takes + request_inherent_data_duration: prometheus::Histogram, + /// How much time `ProvisionableData` processing takes + provisionable_data_duration: prometheus::Histogram, + /// Bitfields array length in `ProvisionerInherentData` (the result for `RequestInherentData`) inherent_data_response_bitfields: prometheus::Histogram, /// The following metrics track how many disputes/votes the runtime will have to process. These will count @@ -28,6 +33,9 @@ struct MetricsInner { /// 4 hours on Polkadot. The metrics are updated only when the node authors a block, so values vary across nodes. inherent_data_dispute_statement_sets: prometheus::Counter, inherent_data_dispute_statements: prometheus::CounterVec, + + /// The disputes received from `disputes-coordinator` by partition + partitioned_disputes: prometheus::CounterVec, } /// Provisioner metrics. @@ -54,14 +62,16 @@ impl Metrics { pub(crate) fn time_request_inherent_data( &self, ) -> Option { - self.0.as_ref().map(|metrics| metrics.request_inherent_data.start_timer()) + self.0 + .as_ref() + .map(|metrics| metrics.request_inherent_data_duration.start_timer()) } /// Provide a timer for `provisionable_data` which observes on drop. pub(crate) fn time_provisionable_data( &self, ) -> Option { - self.0.as_ref().map(|metrics| metrics.provisionable_data.start_timer()) + self.0.as_ref().map(|metrics| metrics.provisionable_data_duration.start_timer()) } pub(crate) fn observe_inherent_data_bitfields_count(&self, bitfields_count: usize) { @@ -95,6 +105,44 @@ impl Metrics { .inc_by(disputes.try_into().unwrap_or(0)); } } + + pub(crate) fn on_partition_recent_disputes(&self, disputes: &PartitionedDisputes) { + if let Some(metrics) = &self.0 { + let PartitionedDisputes { + inactive_unknown_onchain, + inactive_unconcluded_onchain: inactive_unconcluded_known_onchain, + active_unknown_onchain, + active_unconcluded_onchain, + active_concluded_onchain, + inactive_concluded_onchain: inactive_concluded_known_onchain, + } = disputes; + + metrics + .partitioned_disputes + .with_label_values(&["inactive_unknown_onchain"]) + .inc_by(inactive_unknown_onchain.len().try_into().unwrap_or(0)); + metrics + .partitioned_disputes + .with_label_values(&["inactive_unconcluded_known_onchain"]) + .inc_by(inactive_unconcluded_known_onchain.len().try_into().unwrap_or(0)); + metrics + .partitioned_disputes + .with_label_values(&["active_unknown_onchain"]) + .inc_by(active_unknown_onchain.len().try_into().unwrap_or(0)); + metrics + .partitioned_disputes + .with_label_values(&["active_unconcluded_onchain"]) + .inc_by(active_unconcluded_onchain.len().try_into().unwrap_or(0)); + metrics + .partitioned_disputes + .with_label_values(&["active_concluded_onchain"]) + .inc_by(active_concluded_onchain.len().try_into().unwrap_or(0)); + metrics + .partitioned_disputes + .with_label_values(&["inactive_concluded_known_onchain"]) + .inc_by(inactive_concluded_known_onchain.len().try_into().unwrap_or(0)); + } + } } impl metrics::Metrics for Metrics { @@ -110,14 +158,14 @@ impl metrics::Metrics for Metrics { )?, registry, )?, - request_inherent_data: prometheus::register( + request_inherent_data_duration: prometheus::register( prometheus::Histogram::with_opts(prometheus::HistogramOpts::new( "polkadot_parachain_provisioner_request_inherent_data_time", "Time spent within `provisioner::request_inherent_data`", ))?, registry, )?, - provisionable_data: prometheus::register( + provisionable_data_duration: prometheus::register( prometheus::Histogram::with_opts(prometheus::HistogramOpts::new( "polkadot_parachain_provisioner_provisionable_data_time", "Time spent within `provisioner::provisionable_data`", @@ -150,6 +198,16 @@ impl metrics::Metrics for Metrics { )?, registry, )?, + partitioned_disputes: prometheus::register( + prometheus::CounterVec::new( + prometheus::Opts::new( + "polkadot_parachain_provisioner_partitioned_disputes", + "some fancy description", + ), + &["partition"], + )?, + ®istry, + )?, }; Ok(Metrics(Some(metrics))) } diff --git a/node/core/provisioner/src/onchain_disputes.rs b/node/core/provisioner/src/onchain_disputes.rs deleted file mode 100644 index 6c83d77fc9c9..000000000000 --- a/node/core/provisioner/src/onchain_disputes.rs +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2017-2022 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 . - -use crate::error::GetOnchainDisputesError; -use polkadot_node_subsystem::overseer; -use polkadot_primitives::v2::{CandidateHash, DisputeState, Hash, SessionIndex}; -use std::collections::HashMap; - -pub async fn get_onchain_disputes( - _sender: &mut Sender, - _relay_parent: Hash, -) -> Result, GetOnchainDisputesError> -where - Sender: overseer::ProvisionerSenderTrait, -{ - let _onchain = Result::< - HashMap<(SessionIndex, CandidateHash), DisputeState>, - GetOnchainDisputesError, - >::Ok(HashMap::new()); - #[cfg(feature = "staging-client")] - let _onchain = self::staging_impl::get_onchain_disputes(_sender, _relay_parent).await; - - _onchain -} - -// Merge this module with the outer (current one) when promoting to stable -#[cfg(feature = "staging-client")] -mod staging_impl { - use super::*; // remove this when promoting to stable - use crate::LOG_TARGET; - use futures::channel::oneshot; - use polkadot_node_subsystem::{ - errors::RuntimeApiError, - messages::{RuntimeApiMessage, RuntimeApiRequest}, - SubsystemSender, - }; - - /// Gets the on-chain disputes at a given block number and returns them as a `HashSet` so that searching in them is cheap. - pub async fn get_onchain_disputes( - sender: &mut Sender, - relay_parent: Hash, - ) -> Result, GetOnchainDisputesError> { - gum::trace!(target: LOG_TARGET, ?relay_parent, "Fetching on-chain disputes"); - let (tx, rx) = oneshot::channel(); - sender - .send_message( - RuntimeApiMessage::Request(relay_parent, RuntimeApiRequest::StagingDisputes(tx)) - .into(), - ) - .await; - - rx.await - .map_err(|_| GetOnchainDisputesError::Channel) - .and_then(|res| { - res.map_err(|e| match e { - RuntimeApiError::Execution { .. } => - GetOnchainDisputesError::Execution(e, relay_parent), - RuntimeApiError::NotSupported { .. } => - GetOnchainDisputesError::NotSupported(e, relay_parent), - }) - }) - .map(|v| v.into_iter().map(|e| ((e.0, e.1), e.2)).collect()) - } -} diff --git a/node/core/provisioner/src/tests.rs b/node/core/provisioner/src/tests.rs index d0ca425210ed..08eba8eabe80 100644 --- a/node/core/provisioner/src/tests.rs +++ b/node/core/provisioner/src/tests.rs @@ -195,7 +195,7 @@ mod select_availability_bitfields { } } -mod common { +pub(crate) mod common { use super::super::*; use futures::channel::mpsc; use polkadot_node_subsystem::messages::AllMessages; @@ -497,403 +497,3 @@ mod select_candidates { ) } } - -mod select_disputes { - use super::{super::*, common::test_harness}; - use futures::channel::mpsc; - use polkadot_node_subsystem::{ - messages::{AllMessages, DisputeCoordinatorMessage, RuntimeApiMessage, RuntimeApiRequest}, - RuntimeApiError, - }; - use polkadot_node_subsystem_test_helpers::TestSubsystemSender; - use polkadot_primitives::v2::DisputeState; - use std::sync::Arc; - use test_helpers; - - // Global Test Data - fn recent_disputes(len: usize) -> Vec<(SessionIndex, CandidateHash)> { - let mut res = Vec::with_capacity(len); - for _ in 0..len { - res.push((0, CandidateHash(Hash::random()))); - } - - res - } - - // same as recent_disputes() but with SessionIndex set to 1 - fn active_disputes(len: usize) -> Vec<(SessionIndex, CandidateHash)> { - let mut res = Vec::with_capacity(len); - for _ in 0..len { - res.push((1, CandidateHash(Hash::random()))); - } - - res - } - - fn leaf() -> ActivatedLeaf { - ActivatedLeaf { - hash: Hash::repeat_byte(0xAA), - number: 0xAA, - status: LeafStatus::Fresh, - span: Arc::new(jaeger::Span::Disabled), - } - } - - async fn mock_overseer( - leaf: ActivatedLeaf, - mut receiver: mpsc::UnboundedReceiver, - onchain_disputes: Result, RuntimeApiError>, - recent_disputes: Vec<(SessionIndex, CandidateHash)>, - active_disputes: Vec<(SessionIndex, CandidateHash)>, - ) { - while let Some(from_job) = receiver.next().await { - match from_job { - AllMessages::RuntimeApi(RuntimeApiMessage::Request( - _, - RuntimeApiRequest::StagingDisputes(sender), - )) => { - let _ = sender.send(onchain_disputes.clone()); - }, - AllMessages::RuntimeApi(_) => panic!("Unexpected RuntimeApi request"), - AllMessages::DisputeCoordinator(DisputeCoordinatorMessage::RecentDisputes( - sender, - )) => { - let _ = sender.send(recent_disputes.clone()); - }, - AllMessages::DisputeCoordinator(DisputeCoordinatorMessage::ActiveDisputes( - sender, - )) => { - let _ = sender.send(active_disputes.clone()); - }, - AllMessages::DisputeCoordinator( - DisputeCoordinatorMessage::QueryCandidateVotes(disputes, sender), - ) => { - let mut res = Vec::new(); - let v = CandidateVotes { - candidate_receipt: test_helpers::dummy_candidate_receipt(leaf.hash.clone()), - valid: BTreeMap::new(), - invalid: BTreeMap::new(), - }; - for r in disputes.iter() { - res.push((r.0, r.1, v.clone())); - } - - let _ = sender.send(res); - }, - _ => panic!("Unexpected message: {:?}", from_job), - } - } - } - - #[test] - fn recent_disputes_are_withing_onchain_limit() { - const RECENT_DISPUTES_SIZE: usize = 10; - let metrics = metrics::Metrics::new_dummy(); - let onchain_disputes = Ok(Vec::new()); - let active_disputes = Vec::new(); - let recent_disputes = recent_disputes(RECENT_DISPUTES_SIZE); - - let recent_disputes_overseer = recent_disputes.clone(); - test_harness( - |r| { - mock_overseer( - leaf(), - r, - onchain_disputes, - recent_disputes_overseer, - active_disputes, - ) - }, - |mut tx: TestSubsystemSender| async move { - let lf = leaf(); - let disputes = select_disputes(&mut tx, &metrics, &lf).await.unwrap(); - - assert!(!disputes.is_empty()); - - let result = disputes.iter().zip(recent_disputes.iter()); - // We should get all recent disputes. - for (d, r) in result { - assert_eq!(d.session, r.0); - assert_eq!(d.candidate_hash, r.1); - } - }, - ) - } - - #[test] - fn recent_disputes_are_too_much_but_active_are_within_limit() { - const RECENT_DISPUTES_SIZE: usize = MAX_DISPUTES_FORWARDED_TO_RUNTIME + 10; - const ACTIVE_DISPUTES_SIZE: usize = MAX_DISPUTES_FORWARDED_TO_RUNTIME; - let metrics = metrics::Metrics::new_dummy(); - let onchain_disputes = Ok(Vec::new()); - let recent_disputes = recent_disputes(RECENT_DISPUTES_SIZE); - let active_disputes = active_disputes(ACTIVE_DISPUTES_SIZE); - - let active_disputes_overseer = active_disputes.clone(); - test_harness( - |r| { - mock_overseer( - leaf(), - r, - onchain_disputes, - recent_disputes, - active_disputes_overseer, - ) - }, - |mut tx: TestSubsystemSender| async move { - let lf = leaf(); - let disputes = select_disputes(&mut tx, &metrics, &lf).await.unwrap(); - - assert!(!disputes.is_empty()); - - let result = disputes.iter().zip(active_disputes.iter()); - // We should get all active disputes. - for (d, r) in result { - assert_eq!(d.session, r.0); - assert_eq!(d.candidate_hash, r.1); - } - }, - ) - } - - #[test] - fn recent_disputes_are_too_much_but_active_are_less_than_the_limit() { - // In this case all active disputes + a random set of recent disputes should be returned - const RECENT_DISPUTES_SIZE: usize = MAX_DISPUTES_FORWARDED_TO_RUNTIME + 10; - const ACTIVE_DISPUTES_SIZE: usize = MAX_DISPUTES_FORWARDED_TO_RUNTIME - 10; - let metrics = metrics::Metrics::new_dummy(); - let onchain_disputes = Ok(Vec::new()); - let recent_disputes = recent_disputes(RECENT_DISPUTES_SIZE); - let active_disputes = active_disputes(ACTIVE_DISPUTES_SIZE); - - let active_disputes_overseer = active_disputes.clone(); - test_harness( - |r| { - mock_overseer( - leaf(), - r, - onchain_disputes, - recent_disputes, - active_disputes_overseer, - ) - }, - |mut tx: TestSubsystemSender| async move { - let lf = leaf(); - let disputes = select_disputes(&mut tx, &metrics, &lf).await.unwrap(); - - assert!(!disputes.is_empty()); - - // Recent disputes are generated with `SessionIndex` = 0 - let (res_recent, res_active): (Vec, Vec) = - disputes.into_iter().partition(|d| d.session == 0); - - // It should be good enough the count the number of active disputes and not compare them one by one. Checking the exact values is already covered by the previous tests. - assert_eq!(res_active.len(), active_disputes.len()); // We have got all active disputes - assert_eq!(res_active.len() + res_recent.len(), MAX_DISPUTES_FORWARDED_TO_RUNTIME); - // And some recent ones. - }, - ) - } - - //These tests rely on staging Runtime functions so they are separated and compiled conditionally. - #[cfg(feature = "staging-client")] - mod staging_tests { - use super::*; - - fn dummy_dispute_state() -> DisputeState { - DisputeState { - validators_for: BitVec::new(), - validators_against: BitVec::new(), - start: 0, - concluded_at: None, - } - } - - #[test] - fn recent_disputes_are_too_much_active_fits_test_recent_prioritisation() { - // In this case recent disputes are above `MAX_DISPUTES_FORWARDED_TO_RUNTIME` limit and the active ones are below it. - // The expected behaviour is to send all active disputes and extend the set with recent ones. During the extension the disputes unknown for the Runtime are added with priority. - const RECENT_DISPUTES_SIZE: usize = MAX_DISPUTES_FORWARDED_TO_RUNTIME + 10; - const ACTIVE_DISPUTES_SIZE: usize = MAX_DISPUTES_FORWARDED_TO_RUNTIME - 10; - const ONCHAIN_DISPUTE_SIZE: usize = RECENT_DISPUTES_SIZE - 9; - let metrics = metrics::Metrics::new_dummy(); - let recent_disputes = recent_disputes(RECENT_DISPUTES_SIZE); - let active_disputes = active_disputes(ACTIVE_DISPUTES_SIZE); - let onchain_disputes: Result< - Vec<(SessionIndex, CandidateHash, DisputeState)>, - RuntimeApiError, - > = Ok(Vec::from(&recent_disputes[0..ONCHAIN_DISPUTE_SIZE]) - .iter() - .map(|(session_index, candidate_hash)| { - (*session_index, candidate_hash.clone(), dummy_dispute_state()) - }) - .collect()); - let active_disputes_overseer = active_disputes.clone(); - let recent_disputes_overseer = recent_disputes.clone(); - test_harness( - |r| { - mock_overseer( - leaf(), - r, - onchain_disputes, - recent_disputes_overseer, - active_disputes_overseer, - ) - }, - |mut tx: TestSubsystemSender| async move { - let lf = leaf(); - let disputes = select_disputes(&mut tx, &metrics, &lf).await.unwrap(); - - assert!(!disputes.is_empty()); - - // Recent disputes are generated with `SessionIndex` = 0 - let (res_recent, res_active): ( - Vec, - Vec, - ) = disputes.into_iter().partition(|d| d.session == 0); - - // It should be good enough the count the number of the disputes and not compare them one by one as this was already covered in other tests. - assert_eq!(res_active.len(), active_disputes.len()); // We've got all active disputes. - assert_eq!( - res_recent.len(), - MAX_DISPUTES_FORWARDED_TO_RUNTIME - active_disputes.len() - ); // And some recent ones. - - // Check if the recent disputes were unknown for the Runtime. - let expected_recent_disputes = - Vec::from(&recent_disputes[ONCHAIN_DISPUTE_SIZE..]); - let res_recent_set: HashSet<(SessionIndex, CandidateHash)> = HashSet::from_iter( - res_recent.iter().map(|d| (d.session, d.candidate_hash)), - ); - - // Explicitly check that all unseen disputes are sent to the Runtime. - for d in &expected_recent_disputes { - assert_eq!(res_recent_set.contains(d), true); - } - }, - ) - } - - #[test] - fn active_disputes_are_too_much_test_active_prioritisation() { - // In this case the active disputes are above the `MAX_DISPUTES_FORWARDED_TO_RUNTIME` limit so the unseen ones should be prioritised. - const RECENT_DISPUTES_SIZE: usize = MAX_DISPUTES_FORWARDED_TO_RUNTIME + 10; - const ACTIVE_DISPUTES_SIZE: usize = MAX_DISPUTES_FORWARDED_TO_RUNTIME + 10; - const ONCHAIN_DISPUTE_SIZE: usize = ACTIVE_DISPUTES_SIZE - 9; - - let metrics = metrics::Metrics::new_dummy(); - let recent_disputes = recent_disputes(RECENT_DISPUTES_SIZE); - let active_disputes = active_disputes(ACTIVE_DISPUTES_SIZE); - let onchain_disputes: Result< - Vec<(SessionIndex, CandidateHash, DisputeState)>, - RuntimeApiError, - > = Ok(Vec::from(&active_disputes[0..ONCHAIN_DISPUTE_SIZE]) - .iter() - .map(|(session_index, candidate_hash)| { - (*session_index, candidate_hash.clone(), dummy_dispute_state()) - }) - .collect()); - let active_disputes_overseer = active_disputes.clone(); - let recent_disputes_overseer = recent_disputes.clone(); - test_harness( - |r| { - mock_overseer( - leaf(), - r, - onchain_disputes, - recent_disputes_overseer, - active_disputes_overseer, - ) - }, - |mut tx: TestSubsystemSender| async move { - let lf = leaf(); - let disputes = select_disputes(&mut tx, &metrics, &lf).await.unwrap(); - - assert!(!disputes.is_empty()); - - // Recent disputes are generated with `SessionIndex` = 0 - let (res_recent, res_active): ( - Vec, - Vec, - ) = disputes.into_iter().partition(|d| d.session == 0); - - // It should be good enough the count the number of the disputes and not compare them one by one - assert_eq!(res_recent.len(), 0); // We expect no recent disputes - assert_eq!(res_active.len(), MAX_DISPUTES_FORWARDED_TO_RUNTIME); - - let expected_active_disputes = - Vec::from(&active_disputes[ONCHAIN_DISPUTE_SIZE..]); - let res_active_set: HashSet<(SessionIndex, CandidateHash)> = HashSet::from_iter( - res_active.iter().map(|d| (d.session, d.candidate_hash)), - ); - - // Explicitly check that the unseen disputes are delivered to the Runtime. - for d in &expected_active_disputes { - assert_eq!(res_active_set.contains(d), true); - } - }, - ) - } - - #[test] - fn active_disputes_are_too_much_and_are_all_unseen() { - // In this case there are a lot of active disputes unseen by the Runtime. The focus of the test is to verify that in such cases known disputes are NOT sent to the Runtime. - const RECENT_DISPUTES_SIZE: usize = MAX_DISPUTES_FORWARDED_TO_RUNTIME + 10; - const ACTIVE_DISPUTES_SIZE: usize = MAX_DISPUTES_FORWARDED_TO_RUNTIME + 5; - const ONCHAIN_DISPUTE_SIZE: usize = 5; - - let metrics = metrics::Metrics::new_dummy(); - let recent_disputes = recent_disputes(RECENT_DISPUTES_SIZE); - let active_disputes = active_disputes(ACTIVE_DISPUTES_SIZE); - let onchain_disputes: Result< - Vec<(SessionIndex, CandidateHash, DisputeState)>, - RuntimeApiError, - > = Ok(Vec::from(&active_disputes[0..ONCHAIN_DISPUTE_SIZE]) - .iter() - .map(|(session_index, candidate_hash)| { - (*session_index, candidate_hash.clone(), dummy_dispute_state()) - }) - .collect()); - let active_disputes_overseer = active_disputes.clone(); - let recent_disputes_overseer = recent_disputes.clone(); - test_harness( - |r| { - mock_overseer( - leaf(), - r, - onchain_disputes, - recent_disputes_overseer, - active_disputes_overseer, - ) - }, - |mut tx: TestSubsystemSender| async move { - let lf = leaf(); - let disputes = select_disputes(&mut tx, &metrics, &lf).await.unwrap(); - assert!(!disputes.is_empty()); - - // Recent disputes are generated with `SessionIndex` = 0 - let (res_recent, res_active): ( - Vec, - Vec, - ) = disputes.into_iter().partition(|d| d.session == 0); - - // It should be good enough the count the number of the disputes and not compare them one by one - assert_eq!(res_recent.len(), 0); - assert_eq!(res_active.len(), MAX_DISPUTES_FORWARDED_TO_RUNTIME); - - // For sure we don't want to see any of this disputes in the result - let unexpected_active_disputes = - Vec::from(&active_disputes[0..ONCHAIN_DISPUTE_SIZE]); - let res_active_set: HashSet<(SessionIndex, CandidateHash)> = HashSet::from_iter( - res_active.iter().map(|d| (d.session, d.candidate_hash)), - ); - - // Verify that the result DOESN'T contain known disputes (because there is an excessive number of unknown onces). - for d in &unexpected_active_disputes { - assert_eq!(res_active_set.contains(d), false); - } - }, - ) - } - } -} diff --git a/node/core/pvf-checker/Cargo.toml b/node/core/pvf-checker/Cargo.toml index d4f7ec83d8ab..85749daaff50 100644 --- a/node/core/pvf-checker/Cargo.toml +++ b/node/core/pvf-checker/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-core-pvf-checker" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -15,14 +15,14 @@ polkadot-primitives = { path = "../../../primitives" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-overseer = { path = "../../overseer" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers"} test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures-timer = "3.0.2" diff --git a/node/core/pvf/Cargo.toml b/node/core/pvf/Cargo.toml index 01021da1f2f5..7ba85a9d141f 100644 --- a/node/core/pvf/Cargo.toml +++ b/node/core/pvf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-core-pvf" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -24,16 +24,16 @@ rayon = "1.5.1" parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } polkadot-parachain = { path = "../../../parachain" } polkadot-core-primitives = { path = "../../../core-primitives" } -polkadot-node-subsystem-util = { path = "../../subsystem-util"} -sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-executor-wasmtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-executor-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-wasm-interface = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +polkadot-node-metrics = { path = "../../metrics"} +sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-executor-wasmtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-executor-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-wasm-interface = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [dev-dependencies] adder = { package = "test-parachain-adder", path = "../../../parachain/test-parachains/adder" } diff --git a/node/core/pvf/src/host.rs b/node/core/pvf/src/host.rs index 36fd30d73fc1..77c9a29babf4 100644 --- a/node/core/pvf/src/host.rs +++ b/node/core/pvf/src/host.rs @@ -38,6 +38,16 @@ use std::{ time::{Duration, SystemTime}, }; +/// The time period after which the precheck preparation worker is considered unresponsive and will +/// be killed. +// NOTE: If you change this make sure to fix the buckets of `pvf_preparation_time` metric. +pub const PRECHECK_COMPILATION_TIMEOUT: Duration = Duration::from_secs(60); + +/// The time period after which the execute preparation worker is considered unresponsive and will +/// be killed. +// NOTE: If you change this make sure to fix the buckets of `pvf_preparation_time` metric. +pub const EXECUTE_COMPILATION_TIMEOUT: Duration = Duration::from_secs(180); + /// An alias to not spell the type for the oneshot sender for the PVF execution result. pub(crate) type ResultSender = oneshot::Sender>; @@ -51,10 +61,11 @@ pub struct ValidationHost { } impl ValidationHost { - /// Precheck PVF with the given code, i.e. verify that it compiles within a reasonable time limit. - /// The result of execution will be sent to the provided result sender. + /// Precheck PVF with the given code, i.e. verify that it compiles within a reasonable time + /// limit. This will prepare the PVF. The result of preparation will be sent to the provided + /// result sender. /// - /// This is async to accommodate the fact a possibility of back-pressure. In the vast majority of + /// This is async to accommodate the possibility of back-pressure. In the vast majority of /// situations this function should return immediately. /// /// Returns an error if the request cannot be sent to the validation host, i.e. if it shut down. @@ -72,7 +83,7 @@ impl ValidationHost { /// Execute PVF with the given code, execution timeout, parameters and priority. /// The result of execution will be sent to the provided result sender. /// - /// This is async to accommodate the fact a possibility of back-pressure. In the vast majority of + /// This is async to accommodate the possibility of back-pressure. In the vast majority of /// situations this function should return immediately. /// /// Returns an error if the request cannot be sent to the validation host, i.e. if it shut down. @@ -92,7 +103,7 @@ impl ValidationHost { /// Sends a signal to the validation host requesting to prepare a list of the given PVFs. /// - /// This is async to accommodate the fact a possibility of back-pressure. In the vast majority of + /// This is async to accommodate the possibility of back-pressure. In the vast majority of /// situations this function should return immediately. /// /// Returns an error if the request cannot be sent to the validation host, i.e. if it shut down. @@ -418,6 +429,9 @@ async fn handle_to_host( Ok(()) } +/// Handles PVF prechecking. +/// +/// This tries to prepare the PVF by compiling the WASM blob within a given timeout ([`PRECHECK_COMPILATION_TIMEOUT`]). async fn handle_precheck_pvf( artifacts: &mut Artifacts, prepare_queue: &mut mpsc::Sender, @@ -440,12 +454,24 @@ async fn handle_precheck_pvf( } } else { artifacts.insert_preparing(artifact_id, vec![result_sender]); - send_prepare(prepare_queue, prepare::ToQueue::Enqueue { priority: Priority::Normal, pvf }) - .await?; + send_prepare( + prepare_queue, + prepare::ToQueue::Enqueue { + priority: Priority::Normal, + pvf, + compilation_timeout: PRECHECK_COMPILATION_TIMEOUT, + }, + ) + .await?; } Ok(()) } +/// Handles PVF execution. +/// +/// This will first try to prepare the PVF, if a prepared artifact does not already exist. If there is already a +/// preparation job, we coalesce the two preparation jobs. When preparing for execution, we use a more lenient timeout +/// ([`EXECUTE_COMPILATION_TIMEOUT`]) than when prechecking. async fn handle_execute_pvf( cache_path: &Path, artifacts: &mut Artifacts, @@ -462,7 +488,7 @@ async fn handle_execute_pvf( if let Some(state) = artifacts.artifact_state_mut(&artifact_id) { match state { - ArtifactState::Prepared { ref mut last_time_needed } => { + ArtifactState::Prepared { last_time_needed } => { *last_time_needed = SystemTime::now(); send_execute( @@ -485,9 +511,17 @@ async fn handle_execute_pvf( } } else { // Artifact is unknown: register it and enqueue a job with the corresponding priority and - // + // PVF. artifacts.insert_preparing(artifact_id.clone(), Vec::new()); - send_prepare(prepare_queue, prepare::ToQueue::Enqueue { priority, pvf }).await?; + send_prepare( + prepare_queue, + prepare::ToQueue::Enqueue { + priority, + pvf, + compilation_timeout: EXECUTE_COMPILATION_TIMEOUT, + }, + ) + .await?; awaiting_prepare.add(artifact_id, execution_timeout, params, result_tx); } @@ -520,7 +554,11 @@ async fn handle_heads_up( send_prepare( prepare_queue, - prepare::ToQueue::Enqueue { priority: Priority::Normal, pvf: active_pvf }, + prepare::ToQueue::Enqueue { + priority: Priority::Normal, + pvf: active_pvf, + compilation_timeout: EXECUTE_COMPILATION_TIMEOUT, + }, ) .await?; } diff --git a/node/core/pvf/src/metrics.rs b/node/core/pvf/src/metrics.rs index 615dd084d2af..547ee65f3e9d 100644 --- a/node/core/pvf/src/metrics.rs +++ b/node/core/pvf/src/metrics.rs @@ -16,7 +16,7 @@ //! Prometheus metrics related to the validation host. -use polkadot_node_subsystem_util::metrics::{self, prometheus}; +use polkadot_node_metrics::metrics::{self, prometheus}; /// Validation host metrics. #[derive(Default, Clone)] @@ -155,7 +155,8 @@ impl metrics::Metrics for Metrics { "Time spent in preparing PVF artifacts in seconds", ) .buckets(vec![ - // This is synchronized with COMPILATION_TIMEOUT=60s constant found in + // This is synchronized with the PRECHECK_COMPILATION_TIMEOUT=60s + // and EXECUTE_COMPILATION_TIMEOUT=180s constants found in // src/prepare/worker.rs 0.1, 0.5, @@ -166,6 +167,7 @@ impl metrics::Metrics for Metrics { 20.0, 30.0, 60.0, + 180.0, ]), )?, registry, diff --git a/node/core/pvf/src/prepare/pool.rs b/node/core/pvf/src/prepare/pool.rs index 4902c4c7e3b3..fad6ed167614 100644 --- a/node/core/pvf/src/prepare/pool.rs +++ b/node/core/pvf/src/prepare/pool.rs @@ -61,7 +61,12 @@ pub enum ToPool { /// /// In either case, the worker is considered busy and no further `StartWork` messages should be /// sent until either `Concluded` or `Rip` message is received. - StartWork { worker: Worker, code: Arc>, artifact_path: PathBuf }, + StartWork { + worker: Worker, + code: Arc>, + artifact_path: PathBuf, + compilation_timeout: Duration, + }, } /// A message sent from pool to its client. @@ -205,7 +210,7 @@ fn handle_to_pool( metrics.prepare_worker().on_begin_spawn(); mux.push(spawn_worker_task(program_path.to_owned(), spawn_timeout).boxed()); }, - ToPool::StartWork { worker, code, artifact_path } => { + ToPool::StartWork { worker, code, artifact_path, compilation_timeout } => { if let Some(data) = spawned.get_mut(worker) { if let Some(idle) = data.idle.take() { let preparation_timer = metrics.time_preparation(); @@ -216,6 +221,7 @@ fn handle_to_pool( code, cache_path.to_owned(), artifact_path, + compilation_timeout, preparation_timer, ) .boxed(), @@ -263,9 +269,11 @@ async fn start_work_task( code: Arc>, cache_path: PathBuf, artifact_path: PathBuf, + compilation_timeout: Duration, _preparation_timer: Option, ) -> PoolEvent { - let outcome = worker::start_work(idle, code, &cache_path, artifact_path).await; + let outcome = + worker::start_work(idle, code, &cache_path, artifact_path, compilation_timeout).await; PoolEvent::StartWork(worker, outcome) } diff --git a/node/core/pvf/src/prepare/queue.rs b/node/core/pvf/src/prepare/queue.rs index 5aa1402916d6..a77b88e00345 100644 --- a/node/core/pvf/src/prepare/queue.rs +++ b/node/core/pvf/src/prepare/queue.rs @@ -21,7 +21,10 @@ use crate::{artifacts::ArtifactId, metrics::Metrics, PrepareResult, Priority, Pv use always_assert::{always, never}; use async_std::path::PathBuf; use futures::{channel::mpsc, stream::StreamExt as _, Future, SinkExt}; -use std::collections::{HashMap, VecDeque}; +use std::{ + collections::{HashMap, VecDeque}, + time::Duration, +}; /// A request to pool. #[derive(Debug)] @@ -30,7 +33,7 @@ pub enum ToQueue { /// /// Note that it is incorrect to enqueue the same PVF again without first receiving the /// [`FromQueue`] response. - Enqueue { priority: Priority, pvf: Pvf }, + Enqueue { priority: Priority, pvf: Pvf, compilation_timeout: Duration }, } /// A response from queue. @@ -76,6 +79,8 @@ struct JobData { /// The priority of this job. Can be bumped. priority: Priority, pvf: Pvf, + /// The timeout for the preparation job. + compilation_timeout: Duration, worker: Option, } @@ -91,7 +96,7 @@ impl WorkerData { } /// A queue structured like this is prone to starving, however, we don't care that much since we expect -/// there is going to be a limited number of critical jobs and we don't really care if background starve. +/// there is going to be a limited number of critical jobs and we don't really care if background starve. #[derive(Default)] struct Unscheduled { normal: VecDeque, @@ -203,18 +208,24 @@ impl Queue { async fn handle_to_queue(queue: &mut Queue, to_queue: ToQueue) -> Result<(), Fatal> { match to_queue { - ToQueue::Enqueue { priority, pvf } => { - handle_enqueue(queue, priority, pvf).await?; + ToQueue::Enqueue { priority, pvf, compilation_timeout } => { + handle_enqueue(queue, priority, pvf, compilation_timeout).await?; }, } Ok(()) } -async fn handle_enqueue(queue: &mut Queue, priority: Priority, pvf: Pvf) -> Result<(), Fatal> { +async fn handle_enqueue( + queue: &mut Queue, + priority: Priority, + pvf: Pvf, + compilation_timeout: Duration, +) -> Result<(), Fatal> { gum::debug!( target: LOG_TARGET, validation_code_hash = ?pvf.code_hash, ?priority, + ?compilation_timeout, "PVF is enqueued for preparation.", ); queue.metrics.prepare_enqueued(); @@ -225,7 +236,7 @@ async fn handle_enqueue(queue: &mut Queue, priority: Priority, pvf: Pvf) -> Resu "second Enqueue sent for a known artifact" ) { // This function is called in response to a `Enqueue` message; - // Precondtion for `Enqueue` is that it is sent only once for a PVF; + // Precondition for `Enqueue` is that it is sent only once for a PVF; // Thus this should always be `false`; // qed. gum::warn!( @@ -236,7 +247,7 @@ async fn handle_enqueue(queue: &mut Queue, priority: Priority, pvf: Pvf) -> Resu return Ok(()) } - let job = queue.jobs.insert(JobData { priority, pvf, worker: None }); + let job = queue.jobs.insert(JobData { priority, pvf, compilation_timeout, worker: None }); queue.artifact_id_to_job.insert(artifact_id, job); if let Some(available) = find_idle_worker(queue) { @@ -424,7 +435,12 @@ async fn assign(queue: &mut Queue, worker: Worker, job: Job) -> Result<(), Fatal send_pool( &mut queue.to_pool_tx, - pool::ToPool::StartWork { worker, code: job_data.pvf.code.clone(), artifact_path }, + pool::ToPool::StartWork { + worker, + code: job_data.pvf.code.clone(), + artifact_path, + compilation_timeout: job_data.compilation_timeout, + }, ) .await?; @@ -478,7 +494,7 @@ pub fn start( #[cfg(test)] mod tests { use super::*; - use crate::error::PrepareError; + use crate::{error::PrepareError, host::PRECHECK_COMPILATION_TIMEOUT}; use assert_matches::assert_matches; use futures::{future::BoxFuture, FutureExt}; use slotmap::SlotMap; @@ -571,7 +587,6 @@ mod tests { async fn poll_ensure_to_pool_is_empty(&mut self) { use futures_timer::Delay; - use std::time::Duration; let to_pool_rx = &mut self.to_pool_rx; run_until( @@ -594,7 +609,11 @@ mod tests { async fn properly_concludes() { let mut test = Test::new(2, 2); - test.send_queue(ToQueue::Enqueue { priority: Priority::Normal, pvf: pvf(1) }); + test.send_queue(ToQueue::Enqueue { + priority: Priority::Normal, + pvf: pvf(1), + compilation_timeout: PRECHECK_COMPILATION_TIMEOUT, + }); assert_eq!(test.poll_and_recv_to_pool().await, pool::ToPool::Spawn); let w = test.workers.insert(()); @@ -607,10 +626,12 @@ mod tests { #[async_std::test] async fn dont_spawn_over_soft_limit_unless_critical() { let mut test = Test::new(2, 3); + let compilation_timeout = PRECHECK_COMPILATION_TIMEOUT; - test.send_queue(ToQueue::Enqueue { priority: Priority::Normal, pvf: pvf(1) }); - test.send_queue(ToQueue::Enqueue { priority: Priority::Normal, pvf: pvf(2) }); - test.send_queue(ToQueue::Enqueue { priority: Priority::Normal, pvf: pvf(3) }); + let priority = Priority::Normal; + test.send_queue(ToQueue::Enqueue { priority, pvf: pvf(1), compilation_timeout }); + test.send_queue(ToQueue::Enqueue { priority, pvf: pvf(2), compilation_timeout }); + test.send_queue(ToQueue::Enqueue { priority, pvf: pvf(3), compilation_timeout }); // Receive only two spawns. assert_eq!(test.poll_and_recv_to_pool().await, pool::ToPool::Spawn); @@ -631,7 +652,11 @@ mod tests { assert_matches!(test.poll_and_recv_to_pool().await, pool::ToPool::StartWork { .. }); // Enqueue a critical job. - test.send_queue(ToQueue::Enqueue { priority: Priority::Critical, pvf: pvf(4) }); + test.send_queue(ToQueue::Enqueue { + priority: Priority::Critical, + pvf: pvf(4), + compilation_timeout, + }); // 2 out of 2 are working, but there is a critical job incoming. That means that spawning // another worker is warranted. @@ -641,15 +666,24 @@ mod tests { #[async_std::test] async fn cull_unwanted() { let mut test = Test::new(1, 2); + let compilation_timeout = PRECHECK_COMPILATION_TIMEOUT; - test.send_queue(ToQueue::Enqueue { priority: Priority::Normal, pvf: pvf(1) }); + test.send_queue(ToQueue::Enqueue { + priority: Priority::Normal, + pvf: pvf(1), + compilation_timeout, + }); assert_eq!(test.poll_and_recv_to_pool().await, pool::ToPool::Spawn); let w1 = test.workers.insert(()); test.send_from_pool(pool::FromPool::Spawned(w1)); assert_matches!(test.poll_and_recv_to_pool().await, pool::ToPool::StartWork { .. }); // Enqueue a critical job, which warrants spawning over the soft limit. - test.send_queue(ToQueue::Enqueue { priority: Priority::Critical, pvf: pvf(2) }); + test.send_queue(ToQueue::Enqueue { + priority: Priority::Critical, + pvf: pvf(2), + compilation_timeout, + }); assert_eq!(test.poll_and_recv_to_pool().await, pool::ToPool::Spawn); // However, before the new worker had a chance to spawn, the first worker finishes with its @@ -667,9 +701,10 @@ mod tests { async fn worker_mass_die_out_doesnt_stall_queue() { let mut test = Test::new(2, 2); - test.send_queue(ToQueue::Enqueue { priority: Priority::Normal, pvf: pvf(1) }); - test.send_queue(ToQueue::Enqueue { priority: Priority::Normal, pvf: pvf(2) }); - test.send_queue(ToQueue::Enqueue { priority: Priority::Normal, pvf: pvf(3) }); + let (priority, compilation_timeout) = (Priority::Normal, PRECHECK_COMPILATION_TIMEOUT); + test.send_queue(ToQueue::Enqueue { priority, pvf: pvf(1), compilation_timeout }); + test.send_queue(ToQueue::Enqueue { priority, pvf: pvf(2), compilation_timeout }); + test.send_queue(ToQueue::Enqueue { priority, pvf: pvf(3), compilation_timeout }); assert_eq!(test.poll_and_recv_to_pool().await, pool::ToPool::Spawn); assert_eq!(test.poll_and_recv_to_pool().await, pool::ToPool::Spawn); @@ -696,7 +731,11 @@ mod tests { async fn doesnt_resurrect_ripped_worker_if_no_work() { let mut test = Test::new(2, 2); - test.send_queue(ToQueue::Enqueue { priority: Priority::Normal, pvf: pvf(1) }); + test.send_queue(ToQueue::Enqueue { + priority: Priority::Normal, + pvf: pvf(1), + compilation_timeout: PRECHECK_COMPILATION_TIMEOUT, + }); assert_eq!(test.poll_and_recv_to_pool().await, pool::ToPool::Spawn); @@ -717,7 +756,11 @@ mod tests { async fn rip_for_start_work() { let mut test = Test::new(2, 2); - test.send_queue(ToQueue::Enqueue { priority: Priority::Normal, pvf: pvf(1) }); + test.send_queue(ToQueue::Enqueue { + priority: Priority::Normal, + pvf: pvf(1), + compilation_timeout: PRECHECK_COMPILATION_TIMEOUT, + }); assert_eq!(test.poll_and_recv_to_pool().await, pool::ToPool::Spawn); diff --git a/node/core/pvf/src/prepare/worker.rs b/node/core/pvf/src/prepare/worker.rs index a9124b3926c5..77570b47360b 100644 --- a/node/core/pvf/src/prepare/worker.rs +++ b/node/core/pvf/src/prepare/worker.rs @@ -32,10 +32,6 @@ use parity_scale_codec::{Decode, Encode}; use sp_core::hexdisplay::HexDisplay; use std::{panic, sync::Arc, time::Duration}; -/// The time period after which the preparation worker is considered unresponsive and will be killed. -// NOTE: If you change this make sure to fix the buckets of `pvf_preparation_time` metric. -const COMPILATION_TIMEOUT: Duration = Duration::from_secs(60); - /// Spawns a new worker with the given program path that acts as the worker and the spawn timeout. /// /// The program should be able to handle ` prepare-worker ` invocation. @@ -69,6 +65,7 @@ pub async fn start_work( code: Arc>, cache_path: &Path, artifact_path: PathBuf, + compilation_timeout: Duration, ) -> Outcome { let IdleWorker { mut stream, pid } = worker; @@ -103,7 +100,7 @@ pub async fn start_work( } let selected = - match async_std::future::timeout(COMPILATION_TIMEOUT, framed_recv(&mut stream)).await { + match async_std::future::timeout(compilation_timeout, framed_recv(&mut stream)).await { Ok(Ok(response_bytes)) => { // Received bytes from worker within the time limit. // By convention we expect encoded `PrepareResult`. diff --git a/node/core/runtime-api/Cargo.toml b/node/core/runtime-api/Cargo.toml index 749fcf97daa2..232d7741bc81 100644 --- a/node/core/runtime-api/Cargo.toml +++ b/node/core/runtime-api/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "polkadot-node-core-runtime-api" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] futures = "0.3.21" gum = { package = "tracing-gum", path = "../../gum" } -memory-lru = "0.1.0" -parity-util-mem = { version = "0.11.0", default-features = false } +memory-lru = "0.1.1" +parity-util-mem = { version = "0.12.0", default-features = false } -sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-primitives = { path = "../../../primitives" } polkadot-node-subsystem = { path = "../../subsystem" } @@ -18,10 +18,10 @@ polkadot-node-subsystem-types = { path = "../../subsystem-types" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } [dev-dependencies] -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures = { version = "0.3.21", features = ["thread-pool"] } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } polkadot-node-primitives = { path = "../../primitives" } diff --git a/node/core/runtime-api/src/cache.rs b/node/core/runtime-api/src/cache.rs index 6f5fdc5d4657..0fe9b74dc86d 100644 --- a/node/core/runtime-api/src/cache.rs +++ b/node/core/runtime-api/src/cache.rs @@ -463,5 +463,5 @@ pub(crate) enum RequestResult { SubmitPvfCheckStatement(Hash, PvfCheckStatement, ValidatorSignature, ()), ValidationCodeHash(Hash, ParaId, OccupiedCoreAssumption, Option), Version(Hash, u32), - StagingDisputes(Hash, Vec<(SessionIndex, CandidateHash, DisputeState)>), + Disputes(Hash, Vec<(SessionIndex, CandidateHash, DisputeState)>), } diff --git a/node/core/runtime-api/src/lib.rs b/node/core/runtime-api/src/lib.rs index a815b76a8d7c..36355b5759e6 100644 --- a/node/core/runtime-api/src/lib.rs +++ b/node/core/runtime-api/src/lib.rs @@ -153,7 +153,7 @@ where .cache_validation_code_hash((relay_parent, para_id, assumption), hash), Version(relay_parent, version) => self.requests_cache.cache_version(relay_parent, version), - StagingDisputes(relay_parent, disputes) => + Disputes(relay_parent, disputes) => self.requests_cache.cache_disputes(relay_parent, disputes), } } @@ -256,8 +256,8 @@ where Request::ValidationCodeHash(para, assumption, sender) => query!(validation_code_hash(para, assumption), sender) .map(|sender| Request::ValidationCodeHash(para, assumption, sender)), - Request::StagingDisputes(sender) => - query!(disputes(), sender).map(|sender| Request::StagingDisputes(sender)), + Request::Disputes(sender) => + query!(disputes(), sender).map(|sender| Request::Disputes(sender)), } } @@ -351,8 +351,9 @@ where let _timer = metrics.time_make_runtime_api_request(); macro_rules! query { - ($req_variant:ident, $api_name:ident ($($param:expr),*), ver = $version:literal, $sender:expr) => {{ + ($req_variant:ident, $api_name:ident ($($param:expr),*), ver = $version:expr, $sender:expr) => {{ let sender = $sender; + let version: u32 = $version; // enforce type for the version expression let runtime_version = client.api_version_parachain_host(relay_parent).await .unwrap_or_else(|e| { gum::warn!( @@ -370,7 +371,7 @@ where 0 }); - let res = if runtime_version >= $version { + let res = if runtime_version >= version { client.$api_name(relay_parent $(, $param.clone() )*).await .map_err(|e| RuntimeApiError::Execution { runtime_api_name: stringify!($api_name), @@ -499,7 +500,7 @@ where }, Request::ValidationCodeHash(para, assumption, sender) => query!(ValidationCodeHash, validation_code_hash(para, assumption), ver = 2, sender), - Request::StagingDisputes(sender) => - query!(StagingDisputes, staging_get_disputes(), ver = 2, sender), + Request::Disputes(sender) => + query!(Disputes, disputes(), ver = Request::DISPUTES_RUNTIME_REQUIREMENT, sender), } } diff --git a/node/core/runtime-api/src/tests.rs b/node/core/runtime-api/src/tests.rs index b1a1bba73769..2fab84179433 100644 --- a/node/core/runtime-api/src/tests.rs +++ b/node/core/runtime-api/src/tests.rs @@ -23,11 +23,11 @@ use polkadot_node_subsystem_test_helpers::make_subsystem_context; use polkadot_primitives::{ runtime_api::ParachainHost, v2::{ - AuthorityDiscoveryId, Block, BlockNumber, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Id as ParaId, - InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, - PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, - ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, + AuthorityDiscoveryId, Block, CandidateEvent, CommittedCandidateReceipt, CoreState, + GroupRotationInfo, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, + OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, + SessionIndex, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, + ValidatorSignature, }, }; use sp_api::ProvideRuntimeApi; @@ -196,14 +196,10 @@ sp_api::mock_impl_runtime_apis! { ) -> Option { self.validation_code_hash.get(¶).map(|c| c.clone()) } - - fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { - unimplemented!() - } } impl BabeApi for MockRuntimeApi { - fn configuration(&self) -> sp_consensus_babe::BabeGenesisConfiguration { + fn configuration(&self) -> sp_consensus_babe::BabeConfiguration { unimplemented!() } diff --git a/node/gum/Cargo.toml b/node/gum/Cargo.toml index 9768057c5d5c..c9338cd71a81 100644 --- a/node/gum/Cargo.toml +++ b/node/gum/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tracing-gum" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" description = "Stick logs together with the TraceID as provided by tempo" diff --git a/node/gum/proc-macro/Cargo.toml b/node/gum/proc-macro/Cargo.toml index 3b2866c6ad5e..7fa597f759fe 100644 --- a/node/gum/proc-macro/Cargo.toml +++ b/node/gum/proc-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tracing-gum-proc-macro" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" description = "Generate an overseer including builder pattern and message wrapper from a single annotated struct definition." @@ -14,7 +14,7 @@ proc-macro = true [dependencies] syn = { version = "1.0.95", features = ["full", "extra-traits"] } quote = "1.0.20" -proc-macro2 = "1.0.40" +proc-macro2 = "1.0.43" proc-macro-crate = "1.1.3" expander = "0.0.6" diff --git a/node/gum/src/tests.rs b/node/gum/src/tests.rs index 4b52147f2948..c4077c7615c7 100644 --- a/node/gum/src/tests.rs +++ b/node/gum/src/tests.rs @@ -32,7 +32,7 @@ fn plain() { fn wo_alias() { let a: i32 = 7; error!(target: "foo", - "Something something {}, {:?}, or maybe {}", + "Something something {}, {b:?}, or maybe {c}", a, b = Y::default(), c = a diff --git a/node/jaeger/Cargo.toml b/node/jaeger/Cargo.toml index 829df94d50a2..a4a20fb5374b 100644 --- a/node/jaeger/Cargo.toml +++ b/node/jaeger/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-jaeger" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" description = "Polkadot Jaeger primitives, but equally useful for Grafana/Tempo" @@ -12,8 +12,8 @@ lazy_static = "1.4" parking_lot = "0.12.0" polkadot-primitives = { path = "../../primitives" } polkadot-node-primitives = { path = "../primitives" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } thiserror = "1.0.31" log = "0.4.17" parity-scale-codec = { version = "3.1.5", default-features = false } diff --git a/node/malus/Cargo.toml b/node/malus/Cargo.toml index 7122d699c994..49271c4e7c4c 100644 --- a/node/malus/Cargo.toml +++ b/node/malus/Cargo.toml @@ -2,7 +2,7 @@ name = "polkadot-test-malus" description = "Misbehaving nodes for local testnets, system and Simnet tests." license = "GPL-3.0-only" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" readme = "README.md" @@ -23,22 +23,23 @@ polkadot-node-core-backing = { path = "../core/backing" } polkadot-node-primitives = { path = "../primitives" } polkadot-primitives = { path = "../../primitives" } polkadot-node-core-pvf = { path = "../core/pvf" } -parity-util-mem = { version = "0.11.0", default-features = false, features = ["jemalloc-global"] } +parity-util-mem = { version = "0.12.0", default-features = false, features = ["jemalloc-global"] } color-eyre = { version = "0.6.1", default-features = false } assert_matches = "1.5" -async-trait = "0.1.53" -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -clap = { version = "3.1", features = ["derive"] } +async-trait = "0.1.57" +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +clap = { version = "4.0.9", features = ["derive"] } futures = "0.3.21" futures-timer = "3.0.2" gum = { package = "tracing-gum", path = "../gum/" } erasure = { package = "polkadot-erasure-coding", path = "../../erasure-coding" } +rand = "0.8.5" [features] default = [] [dev-dependencies] polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures = { version = "0.3.21", features = ["thread-pool"] } diff --git a/node/malus/README.md b/node/malus/README.md index 4f71016d77ba..fb4bb0cd272f 100644 --- a/node/malus/README.md +++ b/node/malus/README.md @@ -13,8 +13,8 @@ The first argument determines the behavior strain. The currently supported are: To define integration tests create file in the toml format as used with [zombienet][zombienet] under `./integrationtests` describing the network to spawn and -also the `feature` file (with `.feature` extension ) using the format -defined in the [DSL doc](https://github.com/paritytech/zombienet/blob/main/docs/testing-dsl-definition.md). +also the `zndsl` file (with `.zndsl` extension ) using the format +defined in the [(DSL[(**D**omain **S**pecific **L**anguage)]) doc](https://paritytech.github.io/zombienet/cli/test-dsl-definition-spec.html). ## Usage @@ -37,7 +37,7 @@ gcloud container clusters get-credentials "parity-zombienet" --zone "europe-west # launching the actual test cd zombienet npm run build -node dist/cli.js test /node/malus/integrationtests/0001-dispute-valid-block.feature +node dist/cli.js test /node/malus/integrationtests/0001-dispute-valid-block.zndsl # Access logs (in google cloud storage) gsutil ls gs://zombienet-logs/zombie-/logs/ diff --git a/node/malus/integrationtests/0001-dispute-valid-block.feature b/node/malus/integrationtests/0001-dispute-valid-block.zndsl similarity index 99% rename from node/malus/integrationtests/0001-dispute-valid-block.feature rename to node/malus/integrationtests/0001-dispute-valid-block.zndsl index fe0c14c791e4..f778b0231ba9 100644 --- a/node/malus/integrationtests/0001-dispute-valid-block.feature +++ b/node/malus/integrationtests/0001-dispute-valid-block.zndsl @@ -6,7 +6,7 @@ Creds: config alice: is up bob: is up charlie: is up -david is up +dave: is up alice: reports node_roles is 4 bob: reports node_roles is 4 alice: reports sub_libp2p_is_major_syncing is 0 diff --git a/node/malus/src/malus.rs b/node/malus/src/malus.rs index dd9f1377f14a..bb466d4ba4de 100644 --- a/node/malus/src/malus.rs +++ b/node/malus/src/malus.rs @@ -18,7 +18,6 @@ use clap::Parser; use color_eyre::eyre; -use polkadot_cli::{Cli, RunCmd}; pub(crate) mod interceptor; pub(crate) mod shared; @@ -29,52 +28,66 @@ use variants::*; /// Define the different variants of behavior. #[derive(Debug, Parser)] -#[clap(about = "Malus - the nemesis of polkadot.", version)] -#[clap(rename_all = "kebab-case")] +#[command(about = "Malus - the nemesis of polkadot.", version, rename_all = "kebab-case")] enum NemesisVariant { /// Suggest a candidate with an invalid proof of validity. - SuggestGarbageCandidate(RunCmd), + SuggestGarbageCandidate(SuggestGarbageCandidateOptions), /// Back a candidate with a specifically crafted proof of validity. - BackGarbageCandidate(RunCmd), + BackGarbageCandidate(BackGarbageCandidateOptions), /// Delayed disputing of ancestors that are perfectly fine. DisputeAncestor(DisputeAncestorOptions), #[allow(missing_docs)] - #[clap(name = "prepare-worker", hide = true)] + #[command(name = "prepare-worker", hide = true)] PvfPrepareWorker(polkadot_cli::ValidationWorkerCommand), #[allow(missing_docs)] - #[clap(name = "execute-worker", hide = true)] + #[command(name = "execute-worker", hide = true)] PvfExecuteWorker(polkadot_cli::ValidationWorkerCommand), } #[derive(Debug, Parser)] #[allow(missing_docs)] struct MalusCli { - #[clap(subcommand)] + #[command(subcommand)] pub variant: NemesisVariant, /// Sets the minimum delay between the best and finalized block. pub finality_delay: Option, } -fn run_cmd(run: RunCmd) -> Cli { - Cli { subcommand: None, run } -} - impl MalusCli { /// Launch a malus node. fn launch(self) -> eyre::Result<()> { let finality_delay = self.finality_delay; match self.variant { - NemesisVariant::BackGarbageCandidate(cmd) => - polkadot_cli::run_node(run_cmd(cmd), BackGarbageCandidate, finality_delay)?, - NemesisVariant::SuggestGarbageCandidate(cmd) => - polkadot_cli::run_node(run_cmd(cmd), BackGarbageCandidateWrapper, finality_delay)?, - NemesisVariant::DisputeAncestor(opts) => polkadot_cli::run_node( - run_cmd(opts.clone().cmd), - DisputeValidCandidates::new(opts), - finality_delay, - )?, + NemesisVariant::BackGarbageCandidate(opts) => { + let BackGarbageCandidateOptions { percentage, cli } = opts; + + polkadot_cli::run_node(cli, BackGarbageCandidates { percentage }, finality_delay)? + }, + NemesisVariant::SuggestGarbageCandidate(opts) => { + let SuggestGarbageCandidateOptions { percentage, cli } = opts; + + polkadot_cli::run_node( + cli, + SuggestGarbageCandidates { percentage }, + finality_delay, + )? + }, + NemesisVariant::DisputeAncestor(opts) => { + let DisputeAncestorOptions { + fake_validation, + fake_validation_error, + percentage, + cli, + } = opts; + + polkadot_cli::run_node( + cli, + DisputeValidCandidates { fake_validation, fake_validation_error, percentage }, + finality_delay, + )? + }, NemesisVariant::PvfPrepareWorker(cmd) => { #[cfg(target_os = "android")] { @@ -126,7 +139,80 @@ mod tests { variant: NemesisVariant::DisputeAncestor(run), .. } => { - assert!(run.cmd.base.bob); + assert!(run.cli.run.base.bob); + }); + } + + #[test] + fn percentage_works_suggest_garbage() { + let cli = MalusCli::try_parse_from(IntoIterator::into_iter([ + "malus", + "suggest-garbage-candidate", + "--percentage", + "100", + "--bob", + ])) + .unwrap(); + assert_matches::assert_matches!(cli, MalusCli { + variant: NemesisVariant::SuggestGarbageCandidate(run), + .. + } => { + assert!(run.cli.run.base.bob); + }); + } + + #[test] + fn percentage_works_dispute_ancestor() { + let cli = MalusCli::try_parse_from(IntoIterator::into_iter([ + "malus", + "dispute-ancestor", + "--percentage", + "100", + "--bob", + ])) + .unwrap(); + assert_matches::assert_matches!(cli, MalusCli { + variant: NemesisVariant::DisputeAncestor(run), + .. + } => { + assert!(run.cli.run.base.bob); + }); + } + + #[test] + fn percentage_works_back_garbage() { + let cli = MalusCli::try_parse_from(IntoIterator::into_iter([ + "malus", + "back-garbage-candidate", + "--percentage", + "100", + "--bob", + ])) + .unwrap(); + assert_matches::assert_matches!(cli, MalusCli { + variant: NemesisVariant::BackGarbageCandidate(run), + .. + } => { + assert!(run.cli.run.base.bob); + }); + } + + #[test] + #[should_panic] + fn validate_range_for_percentage() { + let cli = MalusCli::try_parse_from(IntoIterator::into_iter([ + "malus", + "suggest-garbage-candidate", + "--percentage", + "101", + "--bob", + ])) + .unwrap(); + assert_matches::assert_matches!(cli, MalusCli { + variant: NemesisVariant::DisputeAncestor(run), + .. + } => { + assert!(run.cli.run.base.bob); }); } } diff --git a/node/malus/src/variants/back_garbage_candidate.rs b/node/malus/src/variants/back_garbage_candidate.rs index cf72776b5f28..b17b8bca5887 100644 --- a/node/malus/src/variants/back_garbage_candidate.rs +++ b/node/malus/src/variants/back_garbage_candidate.rs @@ -25,6 +25,7 @@ use polkadot_cli::{ OverseerConnector, OverseerGen, OverseerGenArgs, OverseerHandle, ParachainHost, ProvideRuntimeApi, }, + Cli, }; use polkadot_node_subsystem::SpawnGlue; use sp_core::traits::SpawnNamed; @@ -36,11 +37,27 @@ use crate::{ use std::sync::Arc; +#[derive(Debug, clap::Parser)] +#[clap(rename_all = "kebab-case")] +#[allow(missing_docs)] +pub struct BackGarbageCandidateOptions { + /// Determines the percentage of garbage candidates that should be backed. + /// Defaults to 100% of garbage candidates being backed. + #[clap(short, long, ignore_case = true, default_value_t = 100, value_parser = clap::value_parser!(u8).range(0..=100))] + pub percentage: u8, + + #[clap(flatten)] + pub cli: Cli, +} + /// Generates an overseer that replaces the candidate validation subsystem with our malicious /// variant. -pub(crate) struct BackGarbageCandidate; +pub(crate) struct BackGarbageCandidates { + /// The probability of behaving maliciously. + pub percentage: u8, +} -impl OverseerGen for BackGarbageCandidate { +impl OverseerGen for BackGarbageCandidates { fn generate<'a, Spawner, RuntimeClient>( &self, connector: OverseerConnector, @@ -55,6 +72,7 @@ impl OverseerGen for BackGarbageCandidate { let validation_filter = ReplaceValidationResult::new( FakeCandidateValidation::BackingAndApprovalValid, FakeCandidateValidationError::InvalidOutputs, + f64::from(self.percentage), SpawnGlue(spawner), ); diff --git a/node/malus/src/variants/common.rs b/node/malus/src/variants/common.rs index e112aa49f83e..610b43bc33a4 100644 --- a/node/malus/src/variants/common.rs +++ b/node/malus/src/variants/common.rs @@ -33,9 +33,10 @@ use polkadot_primitives::v2::{ }; use futures::channel::oneshot; +use rand::distributions::{Bernoulli, Distribution}; -#[derive(clap::ArgEnum, Clone, Copy, Debug, PartialEq)] -#[clap(rename_all = "kebab-case")] +#[derive(clap::ValueEnum, Clone, Copy, Debug, PartialEq)] +#[value(rename_all = "kebab-case")] #[non_exhaustive] pub enum FakeCandidateValidation { Disabled, @@ -48,8 +49,8 @@ pub enum FakeCandidateValidation { } /// Candidate invalidity details -#[derive(clap::ArgEnum, Clone, Copy, Debug, PartialEq)] -#[clap(rename_all = "kebab-case")] +#[derive(clap::ValueEnum, Clone, Copy, Debug, PartialEq)] +#[value(rename_all = "kebab-case")] pub enum FakeCandidateValidationError { /// Validation outputs check doesn't pass. InvalidOutputs, @@ -109,6 +110,7 @@ impl Into for FakeCandidateValidationError { pub struct ReplaceValidationResult { fake_validation: FakeCandidateValidation, fake_validation_error: FakeCandidateValidationError, + distribution: Bernoulli, spawner: Spawner, } @@ -119,9 +121,12 @@ where pub fn new( fake_validation: FakeCandidateValidation, fake_validation_error: FakeCandidateValidationError, + percentage: f64, spawner: Spawner, ) -> Self { - Self { fake_validation, fake_validation_error, spawner } + let distribution = Bernoulli::new(percentage / 100.0) + .expect("Invalid probability! Percentage must be in range [0..=100]."); + Self { fake_validation, fake_validation_error, distribution, spawner } } /// Creates and sends the validation response for a given candidate. Queries the runtime to obtain the validation data for the @@ -202,13 +207,14 @@ where { type Message = CandidateValidationMessage; - // Capture all candidate validation requests and depending on configuration fail them. + // Capture all (approval and backing) candidate validation requests and depending on configuration fail them. fn intercept_incoming( &self, subsystem_sender: &mut Sender, msg: FromOrchestra, ) -> Option> { match msg { + // Message sent by the approval voting subsystem FromOrchestra::Communication { msg: CandidateValidationMessage::ValidateFromExhaustive( @@ -236,28 +242,84 @@ where ), }) } - create_validation_response( - validation_data, - candidate_receipt.descriptor, - sender, - ); - None + // Create the fake response with probability `p` if the `PoV` is malicious, + // where 'p' defaults to 100% for suggest-garbage-candidate variant. + let behave_maliciously = self.distribution.sample(&mut rand::thread_rng()); + match behave_maliciously { + true => { + gum::info!( + target: MALUS, + ?behave_maliciously, + "😈 Creating malicious ValidationResult::Valid message with fake candidate commitments.", + ); + + create_validation_response( + validation_data, + candidate_receipt.descriptor, + sender, + ); + None + }, + false => { + // Behave normally with probability `(1-p)` for a malicious `PoV`. + gum::info!( + target: MALUS, + ?behave_maliciously, + "😈 Passing CandidateValidationMessage::ValidateFromExhaustive to the candidate validation subsystem.", + ); + + Some(FromOrchestra::Communication { + msg: CandidateValidationMessage::ValidateFromExhaustive( + validation_data, + validation_code, + candidate_receipt, + pov, + timeout, + sender, + ), + }) + }, + } }, FakeCandidateValidation::ApprovalInvalid | FakeCandidateValidation::BackingAndApprovalInvalid => { - let validation_result = - ValidationResult::Invalid(InvalidCandidate::InvalidOutputs); + // Set the validation result to invalid with probability `p` and trigger a dispute + let behave_maliciously = self.distribution.sample(&mut rand::thread_rng()); + match behave_maliciously { + true => { + let validation_result = + ValidationResult::Invalid(InvalidCandidate::InvalidOutputs); + + gum::info!( + target: MALUS, + ?behave_maliciously, + para_id = ?candidate_receipt.descriptor.para_id, + "😈 Maliciously sending invalid validation result: {:?}.", + &validation_result, + ); + + // We're not even checking the candidate, this makes us appear faster than honest validators. + sender.send(Ok(validation_result)).unwrap(); + None + }, + false => { + // Behave normally with probability `(1-p)` + gum::info!(target: MALUS, "😈 'Decided' to not act maliciously.",); - gum::debug!( - target: MALUS, - para_id = ?candidate_receipt.descriptor.para_id, - "ValidateFromExhaustive result: {:?}", - &validation_result - ); - // We're not even checking the candidate, this makes us appear faster than honest validators. - sender.send(Ok(validation_result)).unwrap(); - None + Some(FromOrchestra::Communication { + msg: CandidateValidationMessage::ValidateFromExhaustive( + validation_data, + validation_code, + candidate_receipt, + pov, + timeout, + sender, + ), + }) + }, + } }, + // Handle FakeCandidateValidation::Disabled _ => Some(FromOrchestra::Communication { msg: CandidateValidationMessage::ValidateFromExhaustive( validation_data, @@ -270,6 +332,7 @@ where }), } }, + // Behaviour related to the backing subsystem FromOrchestra::Communication { msg: CandidateValidationMessage::ValidateFromChainState( @@ -293,27 +356,68 @@ where ), }) } - self.send_validation_response( - candidate_receipt.descriptor, - subsystem_sender.clone(), - response_sender, - ); - None + // If the `PoV` is malicious, back the candidate with some probability `p`, + // where 'p' defaults to 100% for suggest-garbage-candidate variant. + let behave_maliciously = self.distribution.sample(&mut rand::thread_rng()); + match behave_maliciously { + true => { + gum::info!( + target: MALUS, + ?behave_maliciously, + "😈 Backing candidate with malicious PoV.", + ); + + self.send_validation_response( + candidate_receipt.descriptor, + subsystem_sender.clone(), + response_sender, + ); + None + }, + // If the `PoV` is malicious, we behave normally with some probability `(1-p)` + false => Some(FromOrchestra::Communication { + msg: CandidateValidationMessage::ValidateFromChainState( + candidate_receipt, + pov, + timeout, + response_sender, + ), + }), + } }, FakeCandidateValidation::BackingInvalid | FakeCandidateValidation::BackingAndApprovalInvalid => { - let validation_result = - ValidationResult::Invalid(self.fake_validation_error.clone().into()); - gum::debug!( - target: MALUS, - para_id = ?candidate_receipt.descriptor.para_id, - "ValidateFromChainState result: {:?}", - &validation_result - ); + // Maliciously set the validation result to invalid for a valid candidate with probability `p` + let behave_maliciously = self.distribution.sample(&mut rand::thread_rng()); + match behave_maliciously { + true => { + let validation_result = ValidationResult::Invalid( + self.fake_validation_error.clone().into(), + ); + gum::info!( + target: MALUS, + para_id = ?candidate_receipt.descriptor.para_id, + "😈 Maliciously sending invalid validation result: {:?}.", + &validation_result, + ); + // We're not even checking the candidate, this makes us appear faster than honest validators. + response_sender.send(Ok(validation_result)).unwrap(); + None + }, + // With some probability `(1-p)` we behave normally + false => { + gum::info!(target: MALUS, "😈 'Decided' to not act maliciously.",); - // We're not even checking the candidate, this makes us appear faster than honest validators. - response_sender.send(Ok(validation_result)).unwrap(); - None + Some(FromOrchestra::Communication { + msg: CandidateValidationMessage::ValidateFromChainState( + candidate_receipt, + pov, + timeout, + response_sender, + ), + }) + }, + } }, _ => Some(FromOrchestra::Communication { msg: CandidateValidationMessage::ValidateFromChainState( diff --git a/node/malus/src/variants/dispute_valid_candidates.rs b/node/malus/src/variants/dispute_valid_candidates.rs index 17ac070e619b..cea058023d6f 100644 --- a/node/malus/src/variants/dispute_valid_candidates.rs +++ b/node/malus/src/variants/dispute_valid_candidates.rs @@ -29,7 +29,7 @@ use polkadot_cli::{ OverseerConnector, OverseerGen, OverseerGenArgs, OverseerHandle, ParachainHost, ProvideRuntimeApi, }, - RunCmd, + Cli, }; use polkadot_node_subsystem::SpawnGlue; use sp_core::traits::SpawnNamed; @@ -40,34 +40,37 @@ use crate::{interceptor::*, variants::ReplaceValidationResult}; use std::sync::Arc; -#[derive(Clone, Debug, clap::Parser)] -#[clap(rename_all = "kebab-case")] +#[derive(Debug, clap::Parser)] +#[command(rename_all = "kebab-case")] #[allow(missing_docs)] pub struct DisputeAncestorOptions { /// Malicious candidate validation subsystem configuration. When enabled, node PVF execution is skipped /// during backing and/or approval and it's result can by specified by this option and `--fake-validation-error` /// for invalid candidate outcomes. - #[clap(long, arg_enum, ignore_case = true, default_value_t = FakeCandidateValidation::BackingAndApprovalInvalid)] + #[arg(long, value_enum, ignore_case = true, default_value_t = FakeCandidateValidation::BackingAndApprovalInvalid)] pub fake_validation: FakeCandidateValidation, /// Applies only when `--fake-validation` is configured to reject candidates as invalid. It allows /// to specify the exact error to return from the malicious candidate validation subsystem. - #[clap(long, arg_enum, ignore_case = true, default_value_t = FakeCandidateValidationError::InvalidOutputs)] + #[arg(long, value_enum, ignore_case = true, default_value_t = FakeCandidateValidationError::InvalidOutputs)] pub fake_validation_error: FakeCandidateValidationError, + /// Determines the percentage of candidates that should be disputed. Allows for fine-tuning + /// the intensity of the behavior of the malicious node. Value must be in the range [0..=100]. + #[clap(short, long, ignore_case = true, default_value_t = 100, value_parser = clap::value_parser!(u8).range(0..=100))] + pub percentage: u8, + #[clap(flatten)] - pub cmd: RunCmd, + pub cli: Cli, } pub(crate) struct DisputeValidCandidates { /// Fake validation config (applies to disputes as well). - opts: DisputeAncestorOptions, -} - -impl DisputeValidCandidates { - pub fn new(opts: DisputeAncestorOptions) -> Self { - Self { opts } - } + pub fake_validation: FakeCandidateValidation, + /// Fake validation error config. + pub fake_validation_error: FakeCandidateValidationError, + /// The probability of behaving maliciously. + pub percentage: u8, } impl OverseerGen for DisputeValidCandidates { @@ -83,8 +86,9 @@ impl OverseerGen for DisputeValidCandidates { { let spawner = args.spawner.clone(); let validation_filter = ReplaceValidationResult::new( - self.opts.fake_validation, - self.opts.fake_validation_error, + self.fake_validation, + self.fake_validation_error, + f64::from(self.percentage), SpawnGlue(spawner.clone()), ); diff --git a/node/malus/src/variants/mod.rs b/node/malus/src/variants/mod.rs index d57580fdf8d3..6f9a9359e025 100644 --- a/node/malus/src/variants/mod.rs +++ b/node/malus/src/variants/mod.rs @@ -22,8 +22,8 @@ mod dispute_valid_candidates; mod suggest_garbage_candidate; pub(crate) use self::{ - back_garbage_candidate::BackGarbageCandidate, + back_garbage_candidate::{BackGarbageCandidateOptions, BackGarbageCandidates}, dispute_valid_candidates::{DisputeAncestorOptions, DisputeValidCandidates}, - suggest_garbage_candidate::BackGarbageCandidateWrapper, + suggest_garbage_candidate::{SuggestGarbageCandidateOptions, SuggestGarbageCandidates}, }; pub(crate) use common::*; diff --git a/node/malus/src/variants/suggest_garbage_candidate.rs b/node/malus/src/variants/suggest_garbage_candidate.rs index b8aaaa18c10d..86b0c49e7125 100644 --- a/node/malus/src/variants/suggest_garbage_candidate.rs +++ b/node/malus/src/variants/suggest_garbage_candidate.rs @@ -29,14 +29,17 @@ use polkadot_cli::{ OverseerConnector, OverseerGen, OverseerGenArgs, OverseerHandle, ParachainHost, ProvideRuntimeApi, }, + Cli, }; use polkadot_node_core_candidate_validation::find_validation_data; use polkadot_node_primitives::{AvailableData, BlockData, PoV}; -use polkadot_primitives::v2::{CandidateDescriptor, CandidateHash}; +use polkadot_primitives::v2::CandidateDescriptor; use polkadot_node_subsystem_util::request_validators; use sp_core::traits::SpawnNamed; +use rand::distributions::{Bernoulli, Distribution}; + // Filter wrapping related types. use crate::{ interceptor::*, @@ -49,28 +52,16 @@ use crate::{ // Import extra types relevant to the particular // subsystem. -use polkadot_node_subsystem::{ - messages::{CandidateBackingMessage, CollatorProtocolMessage}, - SpawnGlue, -}; +use polkadot_node_subsystem::{messages::CandidateBackingMessage, SpawnGlue}; use polkadot_primitives::v2::CandidateReceipt; -use std::{ - collections::HashMap, - sync::{Arc, Mutex}, -}; - -struct Inner { - /// Maps malicious candidate hash to original candidate hash. - /// It is used to replace outgoing collator protocol seconded messages. - map: HashMap, -} +use std::sync::Arc; /// Replace outgoing approval messages with disputes. #[derive(Clone)] struct NoteCandidate { - inner: Arc>, spawner: Spawner, + percentage: f64, } impl MessageInterceptor for NoteCandidate @@ -80,7 +71,7 @@ where { type Message = CandidateBackingMessage; - /// Intercept incoming `Second` requests from the `collator-protocol` subsystem. We take + /// Intercept incoming `Second` requests from the `collator-protocol` subsystem. fn intercept_incoming( &self, subsystem_sender: &mut Sender, @@ -88,163 +79,174 @@ where ) -> Option> { match msg { FromOrchestra::Communication { - msg: CandidateBackingMessage::Second(relay_parent, candidate, _pov), + msg: CandidateBackingMessage::Second(relay_parent, ref candidate, ref _pov), } => { gum::debug!( target: MALUS, candidate_hash = ?candidate.hash(), ?relay_parent, - "Received request to second candidate" - ); - - let pov = PoV { block_data: BlockData(MALICIOUS_POV.into()) }; - - let (sender, receiver) = std::sync::mpsc::channel(); - let mut new_sender = subsystem_sender.clone(); - let _candidate = candidate.clone(); - self.spawner.spawn_blocking( - "malus-get-validation-data", - Some("malus"), - Box::pin(async move { - gum::trace!(target: MALUS, "Requesting validators"); - let n_validators = request_validators(relay_parent, &mut new_sender) - .await - .await - .unwrap() - .unwrap() - .len(); - gum::trace!(target: MALUS, "Validators {}", n_validators); - match find_validation_data(&mut new_sender, &_candidate.descriptor()).await - { - Ok(Some((validation_data, validation_code))) => { - sender - .send((validation_data, validation_code, n_validators)) - .expect("channel is still open"); - }, - _ => { - panic!("Unable to fetch validation data"); - }, - } - }), - ); - - let (validation_data, validation_code, n_validators) = receiver.recv().unwrap(); - - let validation_data_hash = validation_data.hash(); - let validation_code_hash = validation_code.hash(); - let validation_data_relay_parent_number = validation_data.relay_parent_number; - - gum::trace!( - target: MALUS, - candidate_hash = ?candidate.hash(), - ?relay_parent, - ?n_validators, - ?validation_data_hash, - ?validation_code_hash, - ?validation_data_relay_parent_number, - "Fetched validation data." + "Received request to second candidate", ); - let malicious_available_data = - AvailableData { pov: Arc::new(pov.clone()), validation_data }; - - let pov_hash = pov.hash(); - let erasure_root = { - let chunks = - erasure::obtain_chunks_v1(n_validators as usize, &malicious_available_data) - .unwrap(); - - let branches = erasure::branches(chunks.as_ref()); - branches.root() - }; - - let (collator_id, collator_signature) = { - use polkadot_primitives::v2::CollatorPair; - use sp_core::crypto::Pair; - - let collator_pair = CollatorPair::generate().0; - let signature_payload = polkadot_primitives::v2::collator_signature_payload( - &relay_parent, - &candidate.descriptor().para_id, - &validation_data_hash, - &pov_hash, - &validation_code_hash, + // Need to draw value from Bernoulli distribution with given probability of success defined by the clap parameter. + // Note that clap parameter must be f64 since this is expected by the Bernoulli::new() function. + // It must be converted from u8, due to the lack of support for the .range() call on u64 in the clap crate. + let distribution = Bernoulli::new(self.percentage / 100.0) + .expect("Invalid probability! Percentage must be in range [0..=100]."); + + // Draw a random boolean from the Bernoulli distribution with probability of true equal to `p`. + // We use `rand::thread_rng` as the source of randomness. + let generate_malicious_candidate = distribution.sample(&mut rand::thread_rng()); + + if generate_malicious_candidate == true { + gum::debug!(target: MALUS, "😈 Suggesting malicious candidate.",); + + let pov = PoV { block_data: BlockData(MALICIOUS_POV.into()) }; + + let (sender, receiver) = std::sync::mpsc::channel(); + let mut new_sender = subsystem_sender.clone(); + let _candidate = candidate.clone(); + self.spawner.spawn_blocking( + "malus-get-validation-data", + Some("malus"), + Box::pin(async move { + gum::trace!(target: MALUS, "Requesting validators"); + let n_validators = request_validators(relay_parent, &mut new_sender) + .await + .await + .unwrap() + .unwrap() + .len(); + gum::trace!(target: MALUS, "Validators {}", n_validators); + match find_validation_data(&mut new_sender, &_candidate.descriptor()) + .await + { + Ok(Some((validation_data, validation_code))) => { + sender + .send((validation_data, validation_code, n_validators)) + .expect("channel is still open"); + }, + _ => { + panic!("Unable to fetch validation data"); + }, + } + }), ); - (collator_pair.public(), collator_pair.sign(&signature_payload)) - }; - - let malicious_commitments = - create_fake_candidate_commitments(&malicious_available_data.validation_data); - - let malicious_candidate = CandidateReceipt { - descriptor: CandidateDescriptor { - para_id: candidate.descriptor().para_id, - relay_parent, - collator: collator_id, - persisted_validation_data_hash: validation_data_hash, - pov_hash, - erasure_root, - signature: collator_signature, - para_head: malicious_commitments.head_data.hash(), - validation_code_hash, - }, - commitments_hash: malicious_commitments.hash(), - }; - let malicious_candidate_hash = malicious_candidate.hash(); - - gum::debug!( - target: MALUS, - candidate_hash = ?candidate.hash(), - ?malicious_candidate_hash, - "Created malicious candidate" - ); - - // Map malicious candidate to the original one. We need this mapping to send back the correct seconded statement - // to the collators. - self.inner - .lock() - .expect("bad lock") - .map - .insert(malicious_candidate_hash, candidate.hash()); + let (validation_data, validation_code, n_validators) = receiver.recv().unwrap(); + + let validation_data_hash = validation_data.hash(); + let validation_code_hash = validation_code.hash(); + let validation_data_relay_parent_number = validation_data.relay_parent_number; + + gum::trace!( + target: MALUS, + candidate_hash = ?candidate.hash(), + ?relay_parent, + ?n_validators, + ?validation_data_hash, + ?validation_code_hash, + ?validation_data_relay_parent_number, + "Fetched validation data." + ); - let message = FromOrchestra::Communication { - msg: CandidateBackingMessage::Second(relay_parent, malicious_candidate, pov), - }; + let malicious_available_data = + AvailableData { pov: Arc::new(pov.clone()), validation_data }; + + let pov_hash = pov.hash(); + let erasure_root = { + let chunks = erasure::obtain_chunks_v1( + n_validators as usize, + &malicious_available_data, + ) + .unwrap(); + + let branches = erasure::branches(chunks.as_ref()); + branches.root() + }; + + let (collator_id, collator_signature) = { + use polkadot_primitives::v2::CollatorPair; + use sp_core::crypto::Pair; + + let collator_pair = CollatorPair::generate().0; + let signature_payload = polkadot_primitives::v2::collator_signature_payload( + &relay_parent, + &candidate.descriptor().para_id, + &validation_data_hash, + &pov_hash, + &validation_code_hash, + ); + + (collator_pair.public(), collator_pair.sign(&signature_payload)) + }; + + let malicious_commitments = create_fake_candidate_commitments( + &malicious_available_data.validation_data, + ); - Some(message) + let malicious_candidate = CandidateReceipt { + descriptor: CandidateDescriptor { + para_id: candidate.descriptor().para_id, + relay_parent, + collator: collator_id, + persisted_validation_data_hash: validation_data_hash, + pov_hash, + erasure_root, + signature: collator_signature, + para_head: malicious_commitments.head_data.hash(), + validation_code_hash, + }, + commitments_hash: malicious_commitments.hash(), + }; + let malicious_candidate_hash = malicious_candidate.hash(); + + let message = FromOrchestra::Communication { + msg: CandidateBackingMessage::Second( + relay_parent, + malicious_candidate, + pov, + ), + }; + + gum::info!( + target: MALUS, + candidate_hash = ?candidate.hash(), + "😈 Intercepted CandidateBackingMessage::Second and created malicious candidate with hash: {:?}", + &malicious_candidate_hash + ); + Some(message) + } else { + Some(msg) + } }, FromOrchestra::Communication { msg } => Some(FromOrchestra::Communication { msg }), FromOrchestra::Signal(signal) => Some(FromOrchestra::Signal(signal)), } } +} - fn intercept_outgoing( - &self, - msg: overseer::CandidateBackingOutgoingMessages, - ) -> Option { - let msg = match msg { - overseer::CandidateBackingOutgoingMessages::CollatorProtocolMessage( - CollatorProtocolMessage::Seconded(relay_parent, statement), - ) => { - // `parachain::collator-protocol: received an unexpected `CollationSeconded`: unknown statement statement=...` - // TODO: Fix this error. We get this on colaltors because `malicious backing` creates a candidate that gets backed/included. - // It is harmless for test parachain collators, but it will prevent cumulus based collators to make progress - // as they wait for the relay chain to confirm the seconding of the collation. - overseer::CandidateBackingOutgoingMessages::CollatorProtocolMessage( - CollatorProtocolMessage::Seconded(relay_parent, statement), - ) - }, - msg => msg, - }; - Some(msg) - } +#[derive(Debug, clap::Parser)] +#[clap(rename_all = "kebab-case")] +#[allow(missing_docs)] +pub struct SuggestGarbageCandidateOptions { + /// Determines the percentage of malicious candidates that are suggested by malus, + /// based on the total number of intercepted CandidateBacking + /// Must be in the range [0..=100]. + #[clap(short, long, ignore_case = true, default_value_t = 100, value_parser = clap::value_parser!(u8).range(0..=100))] + pub percentage: u8, + + #[clap(flatten)] + pub cli: Cli, } /// Garbage candidate implementation wrapper which implements `OverseerGen` glue. -pub(crate) struct BackGarbageCandidateWrapper; +pub(crate) struct SuggestGarbageCandidates { + /// The probability of behaving maliciously. + pub percentage: u8, +} -impl OverseerGen for BackGarbageCandidateWrapper { +impl OverseerGen for SuggestGarbageCandidates { fn generate<'a, Spawner, RuntimeClient>( &self, connector: OverseerConnector, @@ -255,14 +257,21 @@ impl OverseerGen for BackGarbageCandidateWrapper { RuntimeClient::Api: ParachainHost + BabeApi + AuthorityDiscoveryApi, Spawner: 'static + SpawnNamed + Clone + Unpin, { - let inner = Inner { map: std::collections::HashMap::new() }; - let inner_mut = Arc::new(Mutex::new(inner)); - let note_candidate = - NoteCandidate { inner: inner_mut.clone(), spawner: SpawnGlue(args.spawner.clone()) }; + gum::info!( + target: MALUS, + "😈 Started Malus node with a {:?} percent chance of behaving maliciously for a given candidate.", + &self.percentage, + ); + let note_candidate = NoteCandidate { + spawner: SpawnGlue(args.spawner.clone()), + percentage: f64::from(self.percentage), + }; + let fake_valid_probability = 100.0; let validation_filter = ReplaceValidationResult::new( FakeCandidateValidation::BackingAndApprovalValid, FakeCandidateValidationError::InvalidOutputs, + fake_valid_probability, SpawnGlue(args.spawner.clone()), ); diff --git a/node/metered-channel/Cargo.toml b/node/metered-channel/Cargo.toml deleted file mode 100644 index da95d0db8d6c..000000000000 --- a/node/metered-channel/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "prioritized-metered-channel" -version = "0.2.0" -authors = ["Parity Technologies "] -edition = "2021" -description = "Channels with built-in observability and message priorizitazion (coming soon™)" -repository = "https://github.com/paritytech/polkadot.git" -license = "MIT OR Apache-2.0" - -[dependencies] -futures = "0.3.21" -futures-timer = "3.0.2" -derive_more = "0.99" -tracing = "0.1.35" -thiserror = "1.0.31" -crossbeam-queue = "0.3.5" -nanorand = { version = "0.7.0", default-features = false, features = ["wyrand"] } -coarsetime = "^0.1.22" - -[dev-dependencies] -futures = { version = "0.3.21", features = ["thread-pool"] } -assert_matches = "1.5" -env_logger = "0.9" -log = "0.4" -tracing = { version = "0.1.35", features = ["log"] } diff --git a/node/metered-channel/src/bounded.rs b/node/metered-channel/src/bounded.rs deleted file mode 100644 index 4d3abffe729e..000000000000 --- a/node/metered-channel/src/bounded.rs +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright 2017-2021 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 . - -//! Metered variant of bounded mpsc channels to be able to extract metrics. - -use futures::{ - channel::mpsc, - sink::SinkExt, - stream::Stream, - task::{Context, Poll}, -}; - -use std::{pin::Pin, result}; - -use super::{measure_tof_check, CoarseInstant, MaybeTimeOfFlight, Meter}; - -/// Create a wrapped `mpsc::channel` pair of `MeteredSender` and `MeteredReceiver`. -pub fn channel(capacity: usize) -> (MeteredSender, MeteredReceiver) { - let (tx, rx) = mpsc::channel::>(capacity); - let shared_meter = Meter::default(); - let tx = MeteredSender { meter: shared_meter.clone(), inner: tx }; - let rx = MeteredReceiver { meter: shared_meter, inner: rx }; - (tx, rx) -} - -/// A receiver tracking the messages consumed by itself. -#[derive(Debug)] -pub struct MeteredReceiver { - // count currently contained messages - meter: Meter, - inner: mpsc::Receiver>, -} - -impl std::ops::Deref for MeteredReceiver { - type Target = mpsc::Receiver>; - fn deref(&self) -> &Self::Target { - &self.inner - } -} - -impl std::ops::DerefMut for MeteredReceiver { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.inner - } -} - -impl Stream for MeteredReceiver { - type Item = T; - fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - match mpsc::Receiver::poll_next(Pin::new(&mut self.inner), cx) { - Poll::Ready(maybe_value) => Poll::Ready(self.maybe_meter_tof(maybe_value)), - Poll::Pending => Poll::Pending, - } - } - - /// Don't rely on the unreliable size hint. - fn size_hint(&self) -> (usize, Option) { - self.inner.size_hint() - } -} - -impl MeteredReceiver { - fn maybe_meter_tof(&mut self, maybe_value: Option>) -> Option { - self.meter.note_received(); - maybe_value.map(|value| { - match value { - MaybeTimeOfFlight::::WithTimeOfFlight(value, tof_start) => { - // do not use `.elapsed()` of `std::time`, it may panic - // `coarsetime` does a saturating sub for all `CoarseInstant` substractions - let duration = tof_start.elapsed(); - self.meter.note_time_of_flight(duration); - value - }, - MaybeTimeOfFlight::::Bare(value) => value, - } - .into() - }) - } - - /// Get an updated accessor object for all metrics collected. - pub fn meter(&self) -> &Meter { - &self.meter - } - - /// Attempt to receive the next item. - pub fn try_next(&mut self) -> Result, mpsc::TryRecvError> { - match self.inner.try_next()? { - Some(value) => Ok(self.maybe_meter_tof(Some(value))), - None => Ok(None), - } - } -} - -impl futures::stream::FusedStream for MeteredReceiver { - fn is_terminated(&self) -> bool { - self.inner.is_terminated() - } -} - -/// The sender component, tracking the number of items -/// sent across it. -#[derive(Debug)] -pub struct MeteredSender { - meter: Meter, - inner: mpsc::Sender>, -} - -impl Clone for MeteredSender { - fn clone(&self) -> Self { - Self { meter: self.meter.clone(), inner: self.inner.clone() } - } -} - -impl std::ops::Deref for MeteredSender { - type Target = mpsc::Sender>; - fn deref(&self) -> &Self::Target { - &self.inner - } -} - -impl std::ops::DerefMut for MeteredSender { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.inner - } -} - -impl MeteredSender { - fn prepare_with_tof(&self, item: T) -> MaybeTimeOfFlight { - let previous = self.meter.note_sent(); - let item = if measure_tof_check(previous) { - MaybeTimeOfFlight::WithTimeOfFlight(item, CoarseInstant::now()) - } else { - MaybeTimeOfFlight::Bare(item) - }; - item - } - - /// Get an updated accessor object for all metrics collected. - pub fn meter(&self) -> &Meter { - &self.meter - } - - /// Send message, wait until capacity is available. - pub async fn send(&mut self, msg: T) -> result::Result<(), mpsc::SendError> - where - Self: Unpin, - { - match self.try_send(msg) { - Err(send_err) => { - if !send_err.is_full() { - return Err(send_err.into_send_error()) - } - - let msg = send_err.into_inner(); - self.meter.note_sent(); - let fut = self.inner.send(msg); - futures::pin_mut!(fut); - fut.await.map_err(|e| { - self.meter.retract_sent(); - e - }) - }, - _ => Ok(()), - } - } - - /// Attempt to send message or fail immediately. - pub fn try_send( - &mut self, - msg: T, - ) -> result::Result<(), mpsc::TrySendError>> { - let msg = self.prepare_with_tof(msg); - self.inner.try_send(msg).map_err(|e| { - if e.is_full() { - // Count bounded channel sends that block. - self.meter.note_blocked(); - } - self.meter.retract_sent(); - e - }) - } -} diff --git a/node/metered-channel/src/lib.rs b/node/metered-channel/src/lib.rs deleted file mode 100644 index 726d7163270c..000000000000 --- a/node/metered-channel/src/lib.rs +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2017-2021 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 . - -//! Metered variant of mpsc channels to be able to extract metrics. - -use std::sync::{ - atomic::{AtomicUsize, Ordering}, - Arc, -}; - -use derive_more::Display; - -mod bounded; -pub mod oneshot; -mod unbounded; - -pub use self::{bounded::*, unbounded::*}; - -pub use coarsetime::Duration as CoarseDuration; -use coarsetime::Instant as CoarseInstant; - -#[cfg(test)] -mod tests; - -/// A peek into the inner state of a meter. -#[derive(Debug, Clone)] -pub struct Meter { - // Number of sends on this channel. - sent: Arc, - // Number of receives on this channel. - received: Arc, - // Number of times senders blocked while sending messages to a subsystem. - blocked: Arc, - // Atomic ringbuffer of the last 50 time of flight values - tof: Arc>, -} - -impl std::default::Default for Meter { - fn default() -> Self { - Self { - sent: Arc::new(AtomicUsize::new(0)), - received: Arc::new(AtomicUsize::new(0)), - blocked: Arc::new(AtomicUsize::new(0)), - tof: Arc::new(crossbeam_queue::ArrayQueue::new(100)), - } - } -} - -/// A readout of sizes from the meter. Note that it is possible, due to asynchrony, for received -/// to be slightly higher than sent. -#[derive(Debug, Display, Clone, Default, PartialEq)] -#[display(fmt = "(sent={} received={})", sent, received)] -pub struct Readout { - /// The amount of messages sent on the channel, in aggregate. - pub sent: usize, - /// The amount of messages received on the channel, in aggregate. - pub received: usize, - /// How many times the caller blocked when sending messages. - pub blocked: usize, - /// Time of flight in micro seconds (us) - pub tof: Vec, -} - -impl Meter { - /// Count the number of items queued up inside the channel. - pub fn read(&self) -> Readout { - // when obtaining we don't care much about off by one - // accuracy - Readout { - sent: self.sent.load(Ordering::Relaxed), - received: self.received.load(Ordering::Relaxed), - blocked: self.blocked.load(Ordering::Relaxed), - tof: { - let mut acc = Vec::with_capacity(self.tof.len()); - while let Some(value) = self.tof.pop() { - acc.push(value) - } - acc - }, - } - } - - fn note_sent(&self) -> usize { - self.sent.fetch_add(1, Ordering::Relaxed) - } - - fn retract_sent(&self) { - self.sent.fetch_sub(1, Ordering::Relaxed); - } - - fn note_received(&self) { - self.received.fetch_add(1, Ordering::Relaxed); - } - - fn note_blocked(&self) { - self.blocked.fetch_add(1, Ordering::Relaxed); - } - - fn note_time_of_flight(&self, tof: CoarseDuration) { - let _ = self.tof.force_push(tof); - } -} - -/// Determine if this instance shall be measured -#[inline(always)] -fn measure_tof_check(nth: usize) -> bool { - if cfg!(test) { - // for tests, be deterministic and pick every second - nth & 0x01 == 0 - } else { - use nanorand::Rng; - let mut rng = nanorand::WyRand::new_seed(nth as u64); - let pick = rng.generate_range(1_usize..=1000); - // measure 5.3% - pick <= 53 - } -} - -/// Measure the time of flight between insertion and removal -/// of a single type `T` - -#[derive(Debug)] -pub enum MaybeTimeOfFlight { - Bare(T), - WithTimeOfFlight(T, CoarseInstant), -} - -impl From for MaybeTimeOfFlight { - fn from(value: T) -> Self { - Self::Bare(value) - } -} - -// Has some unexplicable conflict with a wildcard impl of std -impl MaybeTimeOfFlight { - /// Extract the inner `T` value. - pub fn into(self) -> T { - match self { - Self::Bare(value) => value, - Self::WithTimeOfFlight(value, _tof_start) => value, - } - } -} - -impl std::ops::Deref for MaybeTimeOfFlight { - type Target = T; - fn deref(&self) -> &Self::Target { - match self { - Self::Bare(ref value) => value, - Self::WithTimeOfFlight(ref value, _tof_start) => value, - } - } -} diff --git a/node/metered-channel/src/oneshot.rs b/node/metered-channel/src/oneshot.rs deleted file mode 100644 index 23cb548747b2..000000000000 --- a/node/metered-channel/src/oneshot.rs +++ /dev/null @@ -1,419 +0,0 @@ -// Copyright 2021 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 . - -//! Metered variant of oneshot channels to be able to extract delays caused by delayed responses. - -use std::{ - ops::Deref, - pin::Pin, - task::{Context, Poll}, -}; - -use futures::{ - channel::oneshot::{self, Canceled, Cancellation}, - future::{Fuse, FusedFuture}, - prelude::*, -}; -use futures_timer::Delay; - -use crate::{CoarseDuration, CoarseInstant}; - -/// Provides the reason for termination. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[repr(u8)] -pub enum Reason { - Completion = 1, - Cancellation = 2, - HardTimeout = 3, -} - -/// Obtained measurements by the `Receiver` side of the `MeteredOneshot`. -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct Measurements { - /// Duration between first poll and polling termination. - first_poll_till_end: CoarseDuration, - /// Duration starting with creation until polling termination. - creation_till_end: CoarseDuration, - /// Reason for resolving the future. - reason: Reason, -} - -impl Measurements { - /// Obtain the duration of a finished or canceled - /// `oneshot` channel. - pub fn duration_since_first_poll(&self) -> &CoarseDuration { - &self.first_poll_till_end - } - - /// Obtain the duration of a finished or canceled - /// `oneshot` channel. - pub fn duration_since_creation(&self) -> &CoarseDuration { - &self.creation_till_end - } - - /// Obtain the reason to the channel termination. - pub fn reason(&self) -> &Reason { - &self.reason - } -} - -/// Create a new pair of `OneshotMetered{Sender,Receiver}`. -pub fn channel( - name: &'static str, - soft_timeout: CoarseDuration, - hard_timeout: CoarseDuration, -) -> (MeteredSender, MeteredReceiver) { - let (tx, rx) = oneshot::channel(); - - ( - MeteredSender { inner: tx }, - MeteredReceiver { - name, - inner: rx, - soft_timeout, - hard_timeout, - soft_timeout_fut: None, - hard_timeout_fut: None, - first_poll_timestamp: None, - creation_timestamp: CoarseInstant::now(), - }, - ) -} - -#[allow(missing_docs)] -#[derive(thiserror::Error, Debug)] -pub enum Error { - #[error("Oneshot was canceled.")] - Canceled(#[source] Canceled, Measurements), - #[error("Oneshot did not receive a response within {}", CoarseDuration::as_f64(.0))] - HardTimeout(CoarseDuration, Measurements), -} - -impl Measurable for Error { - fn measurements(&self) -> Measurements { - match self { - Self::Canceled(_, measurements) => measurements.clone(), - Self::HardTimeout(_, measurements) => measurements.clone(), - } - } -} - -/// Oneshot sender, created by [`channel`]. -#[derive(Debug)] -pub struct MeteredSender { - inner: oneshot::Sender<(CoarseInstant, T)>, -} - -impl MeteredSender { - /// Send a value. - pub fn send(self, t: T) -> Result<(), T> { - let Self { inner } = self; - inner.send((CoarseInstant::now(), t)).map_err(|(_, t)| t) - } - - /// Poll if the thing is already canceled. - pub fn poll_canceled(&mut self, ctx: &mut Context<'_>) -> Poll<()> { - self.inner.poll_canceled(ctx) - } - - /// Access the cancellation object. - pub fn cancellation(&mut self) -> Cancellation<'_, (CoarseInstant, T)> { - self.inner.cancellation() - } - - /// Check the cancellation state. - pub fn is_canceled(&self) -> bool { - self.inner.is_canceled() - } - - /// Verify if the `receiver` is connected to the `sender` [`Self`]. - pub fn is_connected_to(&self, receiver: &MeteredReceiver) -> bool { - self.inner.is_connected_to(&receiver.inner) - } -} - -/// Oneshot receiver, created by [`channel`]. -#[derive(Debug)] -pub struct MeteredReceiver { - name: &'static str, - inner: oneshot::Receiver<(CoarseInstant, T)>, - /// Soft timeout, on expire a warning is printed. - soft_timeout_fut: Option>, - soft_timeout: CoarseDuration, - /// Hard timeout, terminating the sender. - hard_timeout_fut: Option, - hard_timeout: CoarseDuration, - /// The first time the receiver was polled. - first_poll_timestamp: Option, - creation_timestamp: CoarseInstant, -} - -impl MeteredReceiver { - pub fn close(&mut self) { - self.inner.close() - } - - /// Attempts to receive a message outside of the context of a task. - /// - /// A return value of `None` must be considered immediately stale (out of - /// date) unless [`close`](MeteredReceiver::close) has been called first. - /// - /// Returns an error if the sender was dropped. - pub fn try_recv(&mut self) -> Result>, Error> { - match self.inner.try_recv() { - Ok(Some((when, value))) => { - let measurements = self.create_measurement(when, Reason::Completion); - Ok(Some(OutputWithMeasurements { value, measurements })) - }, - Err(e) => { - let measurements = self.create_measurement( - self.first_poll_timestamp.unwrap_or_else(|| CoarseInstant::now()), - Reason::Cancellation, - ); - Err(Error::Canceled(e, measurements)) - }, - Ok(None) => Ok(None), - } - } - - /// Helper to create a measurement. - /// - /// `start` determines the first possible time where poll can resolve with `Ready`. - fn create_measurement(&self, start: CoarseInstant, reason: Reason) -> Measurements { - let end = CoarseInstant::now(); - Measurements { - // negative values are ok, if `send` was called before we poll for the first time. - first_poll_till_end: end - start, - creation_till_end: end - self.creation_timestamp, - reason, - } - } -} - -impl FusedFuture for MeteredReceiver { - fn is_terminated(&self) -> bool { - self.inner.is_terminated() - } -} - -impl Future for MeteredReceiver { - type Output = Result, Error>; - - fn poll( - mut self: Pin<&mut Self>, - ctx: &mut Context<'_>, - ) -> Poll, Error>> { - let first_poll_timestamp = - self.first_poll_timestamp.get_or_insert_with(|| CoarseInstant::now()).clone(); - - let soft_timeout = self.soft_timeout.clone().into(); - let soft_timeout = self - .soft_timeout_fut - .get_or_insert_with(move || Delay::new(soft_timeout).fuse()); - - if Pin::new(soft_timeout).poll(ctx).is_ready() { - tracing::warn!(target: "oneshot", "Oneshot `{name}` exceeded the soft threshold", name = &self.name); - } - - let hard_timeout = self.hard_timeout.clone().into(); - let hard_timeout = - self.hard_timeout_fut.get_or_insert_with(move || Delay::new(hard_timeout)); - - if Pin::new(hard_timeout).poll(ctx).is_ready() { - let measurements = self.create_measurement(first_poll_timestamp, Reason::HardTimeout); - return Poll::Ready(Err(Error::HardTimeout(self.hard_timeout.clone(), measurements))) - } - - match Pin::new(&mut self.inner).poll(ctx) { - Poll::Pending => Poll::Pending, - Poll::Ready(Err(e)) => { - let measurements = - self.create_measurement(first_poll_timestamp, Reason::Cancellation); - Poll::Ready(Err(Error::Canceled(e, measurements))) - }, - Poll::Ready(Ok((ref sent_at_timestamp, value))) => { - let measurements = - self.create_measurement(sent_at_timestamp.clone(), Reason::Completion); - Poll::Ready(Ok(OutputWithMeasurements:: { value, measurements })) - }, - } - } -} - -/// A dummy trait that allows implementing `measurements` for `Result<_,_>`. -pub trait Measurable { - /// Obtain a set of measurements represented by the `Measurements` type. - fn measurements(&self) -> Measurements; -} - -impl Measurable for Result, Error> { - fn measurements(&self) -> Measurements { - match self { - Err(err) => err.measurements(), - Ok(val) => val.measurements(), - } - } -} - -/// A wrapping type for the actual type `T` that is sent with the -/// oneshot yet allow to attach `Measurements` to it. -/// -/// Implements `AsRef` besides others for easier access to the inner, -/// wrapped type. -#[derive(Clone, Debug)] -pub struct OutputWithMeasurements { - value: T, - measurements: Measurements, -} - -impl Measurable for OutputWithMeasurements { - fn measurements(&self) -> Measurements { - self.measurements.clone() - } -} - -impl OutputWithMeasurements { - /// Converts the wrapper type into it's inner value. - /// - /// `trait Into` cannot be implemented due to conflicts. - pub fn into(self) -> T { - self.value - } -} - -impl AsRef for OutputWithMeasurements { - fn as_ref(&self) -> &T { - &self.value - } -} - -impl Deref for OutputWithMeasurements { - type Target = T; - - fn deref(&self) -> &Self::Target { - &self.value - } -} - -#[cfg(test)] -mod tests { - use assert_matches::assert_matches; - use futures::{executor::ThreadPool, task::SpawnExt}; - use std::time::Duration; - - use super::*; - - #[derive(Clone, PartialEq, Eq, Debug)] - struct DummyItem { - vals: [u8; 256], - } - - impl Default for DummyItem { - fn default() -> Self { - Self { vals: [0u8; 256] } - } - } - - fn test_launch(name: &'static str, gen_sender_test: S, gen_receiver_test: R) - where - S: Fn(MeteredSender) -> FS, - R: Fn(MeteredReceiver) -> FR, - FS: Future + Send + 'static, - FR: Future + Send + 'static, - { - let _ = env_logger::builder().is_test(true).filter_level(LevelFilter::Trace).try_init(); - - let pool = ThreadPool::new().unwrap(); - let (tx, rx) = channel(name, CoarseDuration::from_secs(1), CoarseDuration::from_secs(3)); - futures::executor::block_on(async move { - let handle_receiver = pool.spawn_with_handle(gen_receiver_test(rx)).unwrap(); - let handle_sender = pool.spawn_with_handle(gen_sender_test(tx)).unwrap(); - futures::future::select( - futures::future::join(handle_sender, handle_receiver), - Delay::new(Duration::from_secs(5)), - ) - .await; - }); - } - - use log::LevelFilter; - - #[test] - fn easy() { - test_launch( - "easy", - |tx| async move { - tx.send(DummyItem::default()).unwrap(); - }, - |rx| async move { - let x = rx.await.unwrap(); - let measurements = x.measurements(); - assert_eq!(x.as_ref(), &DummyItem::default()); - dbg!(measurements); - }, - ); - } - - #[test] - fn cancel_by_drop() { - test_launch( - "cancel_by_drop", - |tx| async move { - Delay::new(Duration::from_secs(2)).await; - drop(tx); - }, - |rx| async move { - let result = rx.await; - assert_matches!(result, Err(Error::Canceled(_, _))); - dbg!(result.measurements()); - }, - ); - } - - #[test] - fn starve_till_hard_timeout() { - test_launch( - "starve_till_timeout", - |tx| async move { - Delay::new(Duration::from_secs(4)).await; - let _ = tx.send(DummyItem::default()); - }, - |rx| async move { - let result = rx.await; - assert_matches!(&result, e @ &Err(Error::HardTimeout(_, _)) => { - println!("{:?}", e); - }); - dbg!(result.measurements()); - }, - ); - } - - #[test] - fn starve_till_soft_timeout_then_food() { - test_launch( - "starve_till_soft_timeout_then_food", - |tx| async move { - Delay::new(Duration::from_secs(2)).await; - let _ = tx.send(DummyItem::default()); - }, - |rx| async move { - let result = rx.await; - assert_matches!(result, Ok(_)); - dbg!(result.measurements()); - }, - ); - } -} diff --git a/node/metered-channel/src/tests.rs b/node/metered-channel/src/tests.rs deleted file mode 100644 index 6ea947eaa5be..000000000000 --- a/node/metered-channel/src/tests.rs +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2021 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 . - -use super::*; -use assert_matches::assert_matches; -use futures::{executor::block_on, StreamExt}; - -#[derive(Clone, Copy, Debug, Default)] -struct Msg { - val: u8, -} - -#[test] -fn try_send_try_next() { - block_on(async move { - let (mut tx, mut rx) = channel::(5); - let msg = Msg::default(); - assert_matches!(rx.meter().read(), Readout { sent: 0, received: 0, .. }); - tx.try_send(msg).unwrap(); - assert_matches!(tx.meter().read(), Readout { sent: 1, received: 0, .. }); - tx.try_send(msg).unwrap(); - tx.try_send(msg).unwrap(); - tx.try_send(msg).unwrap(); - assert_matches!(tx.meter().read(), Readout { sent: 4, received: 0, .. }); - rx.try_next().unwrap(); - assert_matches!(rx.meter().read(), Readout { sent: 4, received: 1, .. }); - rx.try_next().unwrap(); - rx.try_next().unwrap(); - assert_matches!(tx.meter().read(), Readout { sent: 4, received: 3, blocked: 0, tof } => { - // every second in test, consumed before - assert_eq!(dbg!(tof).len(), 1); - }); - rx.try_next().unwrap(); - assert_matches!(rx.meter().read(), Readout { sent: 4, received: 4, blocked: 0, tof } => { - // every second in test, consumed before - assert_eq!(dbg!(tof).len(), 0); - }); - assert!(rx.try_next().is_err()); - }); -} - -#[test] -fn with_tasks() { - let (ready, go) = futures::channel::oneshot::channel(); - - let (mut tx, mut rx) = channel::(5); - block_on(async move { - futures::join!( - async move { - let msg = Msg::default(); - assert_matches!(tx.meter().read(), Readout { sent: 0, received: 0, .. }); - tx.try_send(msg).unwrap(); - assert_matches!(tx.meter().read(), Readout { sent: 1, received: 0, .. }); - tx.try_send(msg).unwrap(); - tx.try_send(msg).unwrap(); - tx.try_send(msg).unwrap(); - ready.send(()).expect("Helper oneshot channel must work. qed"); - }, - async move { - go.await.expect("Helper oneshot channel must work. qed"); - assert_matches!(rx.meter().read(), Readout { sent: 4, received: 0, .. }); - rx.try_next().unwrap(); - assert_matches!(rx.meter().read(), Readout { sent: 4, received: 1, .. }); - rx.try_next().unwrap(); - rx.try_next().unwrap(); - assert_matches!(rx.meter().read(), Readout { sent: 4, received: 3, .. }); - rx.try_next().unwrap(); - assert_matches!(dbg!(rx.meter().read()), Readout { sent: 4, received: 4, .. }); - } - ) - }); -} - -use futures_timer::Delay; -use std::time::Duration; - -#[test] -fn stream_and_sink() { - let (mut tx, mut rx) = channel::(5); - - block_on(async move { - futures::join!( - async move { - for i in 0..15 { - println!("Sent #{} with a backlog of {} items", i + 1, tx.meter().read()); - let msg = Msg { val: i as u8 + 1u8 }; - tx.send(msg).await.unwrap(); - assert!(tx.meter().read().sent > 0usize); - Delay::new(Duration::from_millis(20)).await; - } - () - }, - async move { - while let Some(msg) = rx.next().await { - println!("rx'd one {} with {} backlogged", msg.val, rx.meter().read()); - Delay::new(Duration::from_millis(29)).await; - } - } - ) - }); -} - -#[test] -fn failed_send_does_not_inc_sent() { - let (mut bounded, _) = channel::(5); - let (unbounded, _) = unbounded::(); - - block_on(async move { - assert!(bounded.send(Msg::default()).await.is_err()); - assert!(bounded.try_send(Msg::default()).is_err()); - assert_matches!(bounded.meter().read(), Readout { sent: 0, received: 0, .. }); - - assert!(unbounded.unbounded_send(Msg::default()).is_err()); - assert_matches!(unbounded.meter().read(), Readout { sent: 0, received: 0, .. }); - }); -} - -#[test] -fn blocked_send_is_metered() { - let (mut bounded_sender, mut bounded_receiver) = channel::(1); - - block_on(async move { - assert!(bounded_sender.send(Msg::default()).await.is_ok()); - assert!(bounded_sender.send(Msg::default()).await.is_ok()); - assert!(bounded_sender.try_send(Msg::default()).is_err()); - - assert_matches!( - bounded_sender.meter().read(), - Readout { sent: 2, received: 0, blocked: 1, .. } - ); - bounded_receiver.try_next().unwrap(); - assert_matches!( - bounded_receiver.meter().read(), - Readout { sent: 2, received: 1, blocked: 1, .. } - ); - }); -} diff --git a/node/metered-channel/src/unbounded.rs b/node/metered-channel/src/unbounded.rs deleted file mode 100644 index 8ade941d6831..000000000000 --- a/node/metered-channel/src/unbounded.rs +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2017-2021 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 . - -//! Metered variant of unbounded mpsc channels to be able to extract metrics. - -use futures::{ - channel::mpsc, - stream::Stream, - task::{Context, Poll}, -}; - -use std::{pin::Pin, result}; - -use super::{measure_tof_check, CoarseInstant, MaybeTimeOfFlight, Meter}; - -/// Create a wrapped `mpsc::channel` pair of `MeteredSender` and `MeteredReceiver`. -pub fn unbounded() -> (UnboundedMeteredSender, UnboundedMeteredReceiver) { - let (tx, rx) = mpsc::unbounded::>(); - let shared_meter = Meter::default(); - let tx = UnboundedMeteredSender { meter: shared_meter.clone(), inner: tx }; - let rx = UnboundedMeteredReceiver { meter: shared_meter, inner: rx }; - (tx, rx) -} - -/// A receiver tracking the messages consumed by itself. -#[derive(Debug)] -pub struct UnboundedMeteredReceiver { - // count currently contained messages - meter: Meter, - inner: mpsc::UnboundedReceiver>, -} - -impl std::ops::Deref for UnboundedMeteredReceiver { - type Target = mpsc::UnboundedReceiver>; - fn deref(&self) -> &Self::Target { - &self.inner - } -} - -impl std::ops::DerefMut for UnboundedMeteredReceiver { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.inner - } -} - -impl Stream for UnboundedMeteredReceiver { - type Item = T; - fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - match mpsc::UnboundedReceiver::poll_next(Pin::new(&mut self.inner), cx) { - Poll::Ready(maybe_value) => Poll::Ready(self.maybe_meter_tof(maybe_value)), - Poll::Pending => Poll::Pending, - } - } - - /// Don't rely on the unreliable size hint. - fn size_hint(&self) -> (usize, Option) { - self.inner.size_hint() - } -} - -impl UnboundedMeteredReceiver { - fn maybe_meter_tof(&mut self, maybe_value: Option>) -> Option { - self.meter.note_received(); - maybe_value.map(|value| { - match value { - MaybeTimeOfFlight::::WithTimeOfFlight(value, tof_start) => { - // do not use `.elapsed()` of `std::time`, it may panic - // `coarsetime` does a saturating substractio for all `CoarseInstant`s - let duration = tof_start.elapsed(); - self.meter.note_time_of_flight(duration); - value - }, - MaybeTimeOfFlight::::Bare(value) => value, - } - .into() - }) - } - - /// Get an updated accessor object for all metrics collected. - pub fn meter(&self) -> &Meter { - &self.meter - } - - /// Attempt to receive the next item. - pub fn try_next(&mut self) -> Result, mpsc::TryRecvError> { - match self.inner.try_next()? { - Some(value) => Ok(self.maybe_meter_tof(Some(value))), - None => Ok(None), - } - } -} - -impl futures::stream::FusedStream for UnboundedMeteredReceiver { - fn is_terminated(&self) -> bool { - self.inner.is_terminated() - } -} - -/// The sender component, tracking the number of items -/// sent across it. -#[derive(Debug)] -pub struct UnboundedMeteredSender { - meter: Meter, - inner: mpsc::UnboundedSender>, -} - -impl Clone for UnboundedMeteredSender { - fn clone(&self) -> Self { - Self { meter: self.meter.clone(), inner: self.inner.clone() } - } -} - -impl std::ops::Deref for UnboundedMeteredSender { - type Target = mpsc::UnboundedSender>; - fn deref(&self) -> &Self::Target { - &self.inner - } -} - -impl std::ops::DerefMut for UnboundedMeteredSender { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.inner - } -} - -impl UnboundedMeteredSender { - fn prepare_with_tof(&self, item: T) -> MaybeTimeOfFlight { - let previous = self.meter.note_sent(); - let item = if measure_tof_check(previous) { - MaybeTimeOfFlight::WithTimeOfFlight(item, CoarseInstant::now()) - } else { - MaybeTimeOfFlight::Bare(item) - }; - item - } - - /// Get an updated accessor object for all metrics collected. - pub fn meter(&self) -> &Meter { - &self.meter - } - - /// Attempt to send message or fail immediately. - pub fn unbounded_send( - &self, - msg: T, - ) -> result::Result<(), mpsc::TrySendError>> { - let msg = self.prepare_with_tof(msg); - self.inner.unbounded_send(msg).map_err(|e| { - self.meter.retract_sent(); - e - }) - } -} diff --git a/node/metrics/Cargo.toml b/node/metrics/Cargo.toml index f87614aec6b5..589c9440b3b6 100644 --- a/node/metrics/Cargo.toml +++ b/node/metrics/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-metrics" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" description = "Subsystem metric helpers" @@ -10,14 +10,14 @@ futures = "0.3.21" futures-timer = "3.0.2" gum = { package = "tracing-gum", path = "../gum" } -metered = { package = "prioritized-metered-channel", path = "../metered-channel" , "version" = "0.2.0" } +metered = { package = "prioritized-metered-channel", version = "0.2.0" } # Both `sc-service` and `sc-cli` are required by runtime metrics `logger_hook()`. -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } -substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } codec = { package = "parity-scale-codec", version = "3.0.0" } primitives = { package = "polkadot-primitives", path = "../../primitives/" } bs58 = { version = "0.4.0", features = ["alloc"] } @@ -27,13 +27,13 @@ log = "0.4.17" assert_cmd = "2.0.4" nix = "0.24.1" tempfile = "3.2.0" -hyper = { version = "0.14.19", default-features = false, features = ["http1", "tcp"] } +hyper = { version = "0.14.20", default-features = false, features = ["http1", "tcp"] } tokio = "1.19.2" polkadot-test-service = { path = "../test/service", features=["runtime-metrics"]} -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } prometheus-parse = {version = "0.2.2"} [features] diff --git a/node/metrics/src/tests.rs b/node/metrics/src/tests.rs index 56e07d96280d..932cc7b68be7 100644 --- a/node/metrics/src/tests.rs +++ b/node/metrics/src/tests.rs @@ -92,16 +92,11 @@ async fn scrape_prometheus_metrics(metrics_uri: &str) -> HashMap { .expect("Scraper failed to parse Prometheus metrics") .samples .into_iter() - .map(|sample| { - ( - sample.metric.to_owned(), - match sample.value { - prometheus_parse::Value::Counter(value) => value as u64, - prometheus_parse::Value::Gauge(value) => value as u64, - prometheus_parse::Value::Untyped(value) => value as u64, - _ => unreachable!("unexpected metric type"), - }, - ) + .filter_map(|prometheus_parse::Sample { metric, value, .. }| match value { + prometheus_parse::Value::Counter(value) => Some((metric, value as u64)), + prometheus_parse::Value::Gauge(value) => Some((metric, value as u64)), + prometheus_parse::Value::Untyped(value) => Some((metric, value as u64)), + _ => None, }) .collect() } diff --git a/node/network/approval-distribution/Cargo.toml b/node/network/approval-distribution/Cargo.toml index 4187f1f6e48d..de6d13f551c7 100644 --- a/node/network/approval-distribution/Cargo.toml +++ b/node/network/approval-distribution/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-approval-distribution" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -16,11 +16,12 @@ futures = "0.3.21" gum = { package = "tracing-gum", path = "../../gum" } [dev-dependencies] -sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", features = ["std"] , branch = "polkadot-v0.9.28" } +sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", features = ["std"] , branch = "polkadot-v0.9.31" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } +polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } assert_matches = "1.4.0" schnorrkel = { version = "0.9.1", default-features = false } diff --git a/node/network/approval-distribution/src/lib.rs b/node/network/approval-distribution/src/lib.rs index f0cb4fc24ff8..5afae66ae818 100644 --- a/node/network/approval-distribution/src/lib.rs +++ b/node/network/approval-distribution/src/lib.rs @@ -343,9 +343,13 @@ impl State { }) }, NetworkBridgeEvent::NewGossipTopology(topology) => { - let session = topology.session; - self.handle_new_session_topology(ctx, session, SessionGridTopology::from(topology)) - .await; + self.handle_new_session_topology( + ctx, + topology.session, + topology.topology, + topology.local_index, + ) + .await; }, NetworkBridgeEvent::PeerViewChange(peer_id, view) => { self.handle_peer_view_change(ctx, metrics, peer_id, view, rng).await; @@ -500,8 +504,14 @@ impl State { ctx: &mut Context, session: SessionIndex, topology: SessionGridTopology, + local_index: Option, ) { - self.topologies.insert_topology(session, topology); + if local_index.is_none() { + // this subsystem only matters to validators. + return + } + + self.topologies.insert_topology(session, topology, local_index); let topology = self.topologies.get_topology(session).expect("just inserted above; qed"); adjust_required_routing_and_propagate( @@ -511,7 +521,9 @@ impl State { |block_entry| block_entry.session == session, |required_routing, local, validator_index| { if *required_routing == RequiredRouting::PendingTopology { - *required_routing = topology.required_routing_by_index(*validator_index, local); + *required_routing = topology + .local_grid_neighbors() + .required_routing_by_index(*validator_index, local); } }, ) @@ -861,7 +873,7 @@ impl State { let local = source == MessageSource::Local; let required_routing = topology.map_or(RequiredRouting::PendingTopology, |t| { - t.required_routing_by_index(validator_index, local) + t.local_grid_neighbors().required_routing_by_index(validator_index, local) }); let message_state = match entry.candidates.get_mut(claimed_candidate_index as usize) { @@ -902,7 +914,10 @@ impl State { return false } - if let Some(true) = topology.as_ref().map(|t| t.route_to_peer(required_routing, peer)) { + if let Some(true) = topology + .as_ref() + .map(|t| t.local_grid_neighbors().route_to_peer(required_routing, peer)) + { return true } @@ -1169,7 +1184,8 @@ impl State { // the assignment to all aware peers in the required routing _except_ the original // source of the assignment. Hence the `in_topology_check`. // 3. Any randomly selected peers have been sent the assignment already. - let in_topology = topology.map_or(false, |t| t.route_to_peer(required_routing, peer)); + let in_topology = topology + .map_or(false, |t| t.local_grid_neighbors().route_to_peer(required_routing, peer)); in_topology || knowledge.sent.contains(message_subject, MessageKind::Assignment) }; @@ -1301,9 +1317,9 @@ impl State { let required_routing = message_state.required_routing; let rng = &mut *rng; let mut peer_filter = move |peer_id| { - let in_topology = topology - .as_ref() - .map_or(false, |t| t.route_to_peer(required_routing, peer_id)); + let in_topology = topology.as_ref().map_or(false, |t| { + t.local_grid_neighbors().route_to_peer(required_routing, peer_id) + }); in_topology || { let route_random = random_routing.sample(total_peers, rng); if route_random { @@ -1564,7 +1580,10 @@ async fn adjust_required_routing_and_propagate; -fn dummy_signature() -> polkadot_primitives::v2::ValidatorSignature { - sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]) -} - fn test_harness>( mut state: State, test_fn: impl FnOnce(VirtualOverseer) -> T, @@ -122,33 +124,79 @@ fn make_gossip_topology( neighbors_x: &[usize], neighbors_y: &[usize], ) -> network_bridge_event::NewGossipTopology { - let mut t = network_bridge_event::NewGossipTopology { - session, - our_neighbors_x: HashMap::new(), - our_neighbors_y: HashMap::new(), + // This builds a grid topology which is a square matrix. + // The local validator occupies the top left-hand corner. + // The X peers occupy the same row and the Y peers occupy + // the same column. + + let local_index = 1; + + assert_eq!( + neighbors_x.len(), + neighbors_y.len(), + "mocking grid topology only implemented for squares", + ); + + let d = neighbors_x.len() + 1; + + let grid_size = d * d; + assert!(grid_size > 0); + assert!(all_peers.len() >= grid_size); + + let peer_info = |i: usize| TopologyPeerInfo { + peer_ids: vec![all_peers[i].0.clone()], + validator_index: ValidatorIndex::from(i as u32), + discovery_id: all_peers[i].1.clone(), }; - for &i in neighbors_x { - t.our_neighbors_x.insert( - all_peers[i].1.clone(), - network_bridge_event::TopologyPeerInfo { - peer_ids: vec![all_peers[i].0.clone()], - validator_index: ValidatorIndex::from(i as u32), - }, - ); + let mut canonical_shuffling: Vec<_> = (0..) + .filter(|i| local_index != *i) + .filter(|i| !neighbors_x.contains(i)) + .filter(|i| !neighbors_y.contains(i)) + .take(grid_size) + .map(peer_info) + .collect(); + + // filled with junk except for own. + let mut shuffled_indices = vec![d + 1; grid_size]; + shuffled_indices[local_index] = 0; + canonical_shuffling[0] = peer_info(local_index); + + for (x_pos, v) in neighbors_x.iter().enumerate() { + let pos = 1 + x_pos; + canonical_shuffling[pos] = peer_info(*v); } - for &i in neighbors_y { - t.our_neighbors_y.insert( - all_peers[i].1.clone(), - network_bridge_event::TopologyPeerInfo { - peer_ids: vec![all_peers[i].0.clone()], - validator_index: ValidatorIndex::from(i as u32), - }, - ); + for (y_pos, v) in neighbors_y.iter().enumerate() { + let pos = d * (1 + y_pos); + canonical_shuffling[pos] = peer_info(*v); } - t + let topology = SessionGridTopology::new(shuffled_indices, canonical_shuffling); + + // sanity check. + { + let g_n = topology + .compute_grid_neighbors_for(ValidatorIndex(local_index as _)) + .expect("topology just constructed with this validator index"); + + assert_eq!(g_n.validator_indices_x.len(), neighbors_x.len()); + assert_eq!(g_n.validator_indices_y.len(), neighbors_y.len()); + + for i in neighbors_x { + assert!(g_n.validator_indices_x.contains(&ValidatorIndex(*i as _))); + } + + for i in neighbors_y { + assert!(g_n.validator_indices_y.contains(&ValidatorIndex(*i as _))); + } + } + + network_bridge_event::NewGossipTopology { + session, + topology, + local_index: Some(ValidatorIndex(local_index as _)), + } } async fn setup_gossip_topology( @@ -174,7 +222,7 @@ async fn setup_peer_with_view( ApprovalDistributionMessage::NetworkBridgeUpdate(NetworkBridgeEvent::PeerConnected( peer_id.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), None, )), ) diff --git a/node/network/availability-distribution/Cargo.toml b/node/network/availability-distribution/Cargo.toml index 228adea806a0..886a22001225 100644 --- a/node/network/availability-distribution/Cargo.toml +++ b/node/network/availability-distribution/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-availability-distribution" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -14,20 +14,20 @@ polkadot-node-network-protocol = { path = "../../network/protocol" } polkadot-node-subsystem = { path = "../../subsystem" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-node-primitives = { path = "../../primitives" } -sp-core = { git = "https://github.com/paritytech/substrate", features = ["std"] , branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", features = ["std"] , branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } thiserror = "1.0.31" rand = "0.8.5" derive_more = "0.99.17" -lru = "0.7.7" +lru = "0.8.0" fatality = "0.0.6" [dev-dependencies] polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -sp-core = { git = "https://github.com/paritytech/substrate", features = ["std"] , branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", features = ["std"] , branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures-timer = "3.0.2" assert_matches = "1.4.0" polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } diff --git a/node/network/availability-distribution/src/lib.rs b/node/network/availability-distribution/src/lib.rs index 3faaa80ce835..7dceb5f80e6c 100644 --- a/node/network/availability-distribution/src/lib.rs +++ b/node/network/availability-distribution/src/lib.rs @@ -150,6 +150,7 @@ impl AvailabilityDistributionSubsystem { AvailabilityDistributionMessage::FetchPoV { relay_parent, from_validator, + para_id, candidate_hash, pov_hash, tx, @@ -161,6 +162,7 @@ impl AvailabilityDistributionSubsystem { &mut runtime, relay_parent, from_validator, + para_id, candidate_hash, pov_hash, tx, diff --git a/node/network/availability-distribution/src/pov_requester/mod.rs b/node/network/availability-distribution/src/pov_requester/mod.rs index 195c1748793c..f32a4bd4821d 100644 --- a/node/network/availability-distribution/src/pov_requester/mod.rs +++ b/node/network/availability-distribution/src/pov_requester/mod.rs @@ -30,7 +30,9 @@ use polkadot_node_subsystem::{ overseer, }; use polkadot_node_subsystem_util::runtime::RuntimeInfo; -use polkadot_primitives::v2::{AuthorityDiscoveryId, CandidateHash, Hash, ValidatorIndex}; +use polkadot_primitives::v2::{ + AuthorityDiscoveryId, CandidateHash, Hash, Id as ParaId, ValidatorIndex, +}; use crate::{ error::{Error, FatalError, JfyiError, Result}, @@ -45,6 +47,7 @@ pub async fn fetch_pov( runtime: &mut RuntimeInfo, parent: Hash, from_validator: ValidatorIndex, + para_id: ParaId, candidate_hash: CandidateHash, pov_hash: Hash, tx: oneshot::Sender, @@ -70,10 +73,12 @@ pub async fn fetch_pov( let span = jaeger::Span::new(candidate_hash, "fetch-pov") .with_validator_index(from_validator) - .with_relay_parent(parent); + .with_relay_parent(parent) + .with_para_id(para_id); ctx.spawn( "pov-fetcher", - fetch_pov_job(pov_hash, authority_id, pending_response.boxed(), span, tx, metrics).boxed(), + fetch_pov_job(para_id, pov_hash, authority_id, pending_response.boxed(), span, tx, metrics) + .boxed(), ) .map_err(|e| FatalError::SpawnTask(e))?; Ok(()) @@ -81,6 +86,7 @@ pub async fn fetch_pov( /// Future to be spawned for taking care of handling reception and sending of PoV. async fn fetch_pov_job( + para_id: ParaId, pov_hash: Hash, authority_id: AuthorityDiscoveryId, pending_response: BoxFuture<'static, std::result::Result>, @@ -89,7 +95,7 @@ async fn fetch_pov_job( metrics: Metrics, ) { if let Err(err) = do_fetch_pov(pov_hash, pending_response, span, tx, metrics).await { - gum::warn!(target: LOG_TARGET, ?err, ?pov_hash, ?authority_id, "fetch_pov_job"); + gum::warn!(target: LOG_TARGET, ?err, ?para_id, ?pov_hash, ?authority_id, "fetch_pov_job"); } } @@ -171,6 +177,7 @@ mod tests { &mut runtime, Hash::default(), ValidatorIndex(0), + ParaId::default(), CandidateHash::default(), pov_hash, tx, diff --git a/node/network/availability-distribution/src/requester/session_cache.rs b/node/network/availability-distribution/src/requester/session_cache.rs index 6d41d9301233..cf01e448b70b 100644 --- a/node/network/availability-distribution/src/requester/session_cache.rs +++ b/node/network/availability-distribution/src/requester/session_cache.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use std::collections::HashSet; +use std::{collections::HashSet, num::NonZeroUsize}; use lru::LruCache; use rand::{seq::SliceRandom, thread_rng}; @@ -85,7 +85,7 @@ impl SessionCache { pub fn new() -> Self { SessionCache { // We need to cache the current and the last session the most: - session_info_cache: LruCache::new(2), + session_info_cache: LruCache::new(NonZeroUsize::new(2).unwrap()), } } diff --git a/node/network/availability-recovery/Cargo.toml b/node/network/availability-recovery/Cargo.toml index 55ca8d3106ed..b9bcefc781ea 100644 --- a/node/network/availability-recovery/Cargo.toml +++ b/node/network/availability-recovery/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "polkadot-availability-recovery" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] futures = "0.3.21" -lru = "0.7.7" +lru = "0.8.0" rand = "0.8.5" fatality = "0.0.6" thiserror = "1.0.31" @@ -19,7 +19,7 @@ polkadot-node-subsystem = {path = "../../subsystem" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-node-network-protocol = { path = "../../network/protocol" } parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [dev-dependencies] assert_matches = "1.4.0" @@ -27,10 +27,10 @@ env_logger = "0.9.0" futures-timer = "3.0.2" log = "0.4.17" -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } diff --git a/node/network/availability-recovery/src/lib.rs b/node/network/availability-recovery/src/lib.rs index 92eefeaaeb79..a07f4e0baa52 100644 --- a/node/network/availability-recovery/src/lib.rs +++ b/node/network/availability-recovery/src/lib.rs @@ -20,6 +20,7 @@ use std::{ collections::{HashMap, VecDeque}, + num::NonZeroUsize, pin::Pin, time::Duration, }; @@ -77,7 +78,10 @@ const LOG_TARGET: &str = "parachain::availability-recovery"; const N_PARALLEL: usize = 50; // Size of the LRU cache where we keep recovered data. -const LRU_SIZE: usize = 16; +const LRU_SIZE: NonZeroUsize = match NonZeroUsize::new(16) { + Some(cap) => cap, + None => panic!("Availability-recovery cache size must be non-zero."), +}; const COST_INVALID_REQUEST: Rep = Rep::CostMajor("Peer sent unparsable request"); @@ -358,7 +362,7 @@ impl RequestChunksFromValidators { sender .send_message(NetworkBridgeTxMessage::SendRequests( requests, - IfDisconnected::ImmediateError, + IfDisconnected::TryConnect, )) .await; } @@ -376,49 +380,20 @@ impl RequestChunksFromValidators { self.total_received_responses += 1; match request_result { - Ok(Some(chunk)) => { - // Check merkle proofs of any received chunks. - - let validator_index = chunk.index; - - if let Ok(anticipated_hash) = - branch_hash(¶ms.erasure_root, chunk.proof(), chunk.index.0 as usize) - { - let erasure_chunk_hash = BlakeTwo256::hash(&chunk.chunk); - - if erasure_chunk_hash != anticipated_hash { - metrics.on_chunk_request_invalid(); - self.error_count += 1; - - gum::debug!( - target: LOG_TARGET, - candidate_hash = ?params.candidate_hash, - ?validator_index, - "Merkle proof mismatch", - ); - } else { - metrics.on_chunk_request_succeeded(); - - gum::trace!( - target: LOG_TARGET, - candidate_hash = ?params.candidate_hash, - ?validator_index, - "Received valid chunk.", - ); - self.received_chunks.insert(validator_index, chunk); - } - } else { - metrics.on_chunk_request_invalid(); - self.error_count += 1; - - gum::debug!( + Ok(Some(chunk)) => + if is_chunk_valid(params, &chunk) { + metrics.on_chunk_request_succeeded(); + gum::trace!( target: LOG_TARGET, candidate_hash = ?params.candidate_hash, - ?validator_index, - "Invalid Merkle proof", + validator_index = ?chunk.index, + "Received valid chunk", ); - } - }, + self.received_chunks.insert(chunk.index, chunk); + } else { + metrics.on_chunk_request_invalid(); + self.error_count += 1; + }, Ok(None) => { metrics.on_chunk_request_no_such_chunk(); self.error_count += 1; @@ -507,7 +482,20 @@ impl RequestChunksFromValidators { self.shuffling.retain(|i| !chunk_indices.contains(i)); for chunk in chunks { - self.received_chunks.insert(chunk.index, chunk); + if is_chunk_valid(params, &chunk) { + gum::trace!( + target: LOG_TARGET, + candidate_hash = ?params.candidate_hash, + validator_index = ?chunk.index, + "Found valid chunk on disk" + ); + self.received_chunks.insert(chunk.index, chunk); + } else { + gum::error!( + target: LOG_TARGET, + "Loaded invalid chunk from disk! Disk/Db corruption _very_ likely - please fix ASAP!" + ); + }; } }, Err(oneshot::Canceled) => { @@ -609,6 +597,35 @@ const fn is_unavailable( received_chunks + requesting_chunks + unrequested_validators < threshold } +/// Check validity of a chunk. +fn is_chunk_valid(params: &RecoveryParams, chunk: &ErasureChunk) -> bool { + let anticipated_hash = + match branch_hash(¶ms.erasure_root, chunk.proof(), chunk.index.0 as usize) { + Ok(hash) => hash, + Err(e) => { + gum::debug!( + target: LOG_TARGET, + candidate_hash = ?params.candidate_hash, + validator_index = ?chunk.index, + error = ?e, + "Invalid Merkle proof", + ); + return false + }, + }; + let erasure_chunk_hash = BlakeTwo256::hash(&chunk.chunk); + if anticipated_hash != erasure_chunk_hash { + gum::debug!( + target: LOG_TARGET, + candidate_hash = ?params.candidate_hash, + validator_index = ?chunk.index, + "Merkle proof mismatch" + ); + return false + } + true +} + /// Re-encode the data into erasure chunks in order to verify /// the root hash of the provided Merkle tree, which is built /// on-top of the encoded chunks. diff --git a/node/network/availability-recovery/src/tests.rs b/node/network/availability-recovery/src/tests.rs index 2cfed743bc5e..3e898088c7f9 100644 --- a/node/network/availability-recovery/src/tests.rs +++ b/node/network/availability-recovery/src/tests.rs @@ -189,6 +189,7 @@ struct TestState { available_data: AvailableData, chunks: Vec, + invalid_chunks: Vec, } impl TestState { @@ -273,6 +274,26 @@ impl TestState { ) } + async fn respond_to_query_all_request_invalid( + &self, + virtual_overseer: &mut VirtualOverseer, + send_chunk: impl Fn(usize) -> bool, + ) { + assert_matches!( + overseer_recv(virtual_overseer).await, + AllMessages::AvailabilityStore( + AvailabilityStoreMessage::QueryAllChunks(_, tx) + ) => { + let v = self.invalid_chunks.iter() + .filter(|c| send_chunk(c.index.0 as usize)) + .cloned() + .collect(); + + let _ = tx.send(v); + } + ) + } + async fn test_chunk_requests( &self, candidate_hash: CandidateHash, @@ -290,7 +311,7 @@ impl TestState { AllMessages::NetworkBridgeTx( NetworkBridgeTxMessage::SendRequests( requests, - IfDisconnected::ImmediateError, + _if_disconnected, ) ) => { for req in requests { @@ -454,6 +475,22 @@ impl Default for TestState { &available_data, |_, _| {}, ); + // Mess around: + let invalid_chunks = chunks + .iter() + .cloned() + .map(|mut chunk| { + if chunk.chunk.len() >= 2 && chunk.chunk[0] != chunk.chunk[1] { + chunk.chunk[0] = chunk.chunk[1]; + } else if chunk.chunk.len() >= 1 { + chunk.chunk[0] = !chunk.chunk[0]; + } else { + chunk.proof = Proof::dummy_proof(); + } + chunk + }) + .collect(); + debug_assert_ne!(chunks, invalid_chunks); candidate.descriptor.erasure_root = erasure_root; candidate.descriptor.relay_parent = Hash::repeat_byte(10); @@ -468,6 +505,7 @@ impl Default for TestState { persisted_validation_data, available_data, chunks, + invalid_chunks, } } } @@ -1284,6 +1322,57 @@ fn does_not_query_local_validator() { }); } +#[test] +fn invalid_local_chunk_is_ignored() { + let test_state = TestState::default(); + + test_harness_chunks_only(|mut virtual_overseer, req_cfg| async move { + overseer_signal( + &mut virtual_overseer, + OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(ActivatedLeaf { + hash: test_state.current.clone(), + number: 1, + status: LeafStatus::Fresh, + span: Arc::new(jaeger::Span::Disabled), + })), + ) + .await; + + let (tx, rx) = oneshot::channel(); + + overseer_send( + &mut virtual_overseer, + AvailabilityRecoveryMessage::RecoverAvailableData( + test_state.candidate.clone(), + test_state.session_index, + None, + tx, + ), + ) + .await; + + test_state.test_runtime_api(&mut virtual_overseer).await; + test_state.respond_to_available_data_query(&mut virtual_overseer, false).await; + test_state + .respond_to_query_all_request_invalid(&mut virtual_overseer, |i| i == 0) + .await; + + let candidate_hash = test_state.candidate.hash(); + + test_state + .test_chunk_requests( + candidate_hash, + &mut virtual_overseer, + test_state.threshold() - 1, + |i| if i == 0 { panic!("requested from local validator") } else { Has::Yes }, + ) + .await; + + assert_eq!(rx.await.unwrap().unwrap(), test_state.available_data); + (virtual_overseer, req_cfg) + }); +} + #[test] fn parallel_request_calculation_works_as_expected() { let num_validators = 100; diff --git a/node/network/bitfield-distribution/Cargo.toml b/node/network/bitfield-distribution/Cargo.toml index 2c3fc3a87540..0a26c57975c4 100644 --- a/node/network/bitfield-distribution/Cargo.toml +++ b/node/network/bitfield-distribution/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-availability-bitfield-distribution" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -16,10 +16,11 @@ rand = "0.8" [dev-dependencies] polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } maplit = "1.0.2" log = "0.4.17" env_logger = "0.9.0" diff --git a/node/network/bitfield-distribution/src/lib.rs b/node/network/bitfield-distribution/src/lib.rs index a0f82dc5ed1d..1b2167484b49 100644 --- a/node/network/bitfield-distribution/src/lib.rs +++ b/node/network/bitfield-distribution/src/lib.rs @@ -27,7 +27,7 @@ use futures::{channel::oneshot, FutureExt}; use polkadot_node_network_protocol::{ self as net_protocol, grid_topology::{ - RandomRouting, RequiredRouting, SessionBoundGridTopologyStorage, SessionGridTopology, + GridNeighbors, RandomRouting, RequiredRouting, SessionBoundGridTopologyStorage, }, v1 as protocol_v1, OurView, PeerId, UnifiedReputationChange as Rep, Versioned, View, }; @@ -327,7 +327,7 @@ async fn handle_bitfield_distribution( }; let msg = BitfieldGossipMessage { relay_parent, signed_availability }; - let topology = state.topologies.get_topology_or_fallback(session_idx); + let topology = state.topologies.get_topology_or_fallback(session_idx).local_grid_neighbors(); let required_routing = topology.required_routing_by_index(validator_index, true); relay_message( @@ -352,7 +352,7 @@ async fn handle_bitfield_distribution( async fn relay_message( ctx: &mut Context, job_data: &mut PerRelayParentData, - topology: &SessionGridTopology, + topology_neighbors: &GridNeighbors, peer_views: &mut HashMap, validator: ValidatorId, message: BitfieldGossipMessage, @@ -384,7 +384,7 @@ async fn relay_message( let message_needed = job_data.message_from_validator_needed_by_peer(&peer, &validator); if message_needed { - let in_topology = topology.route_to_peer(required_routing, &peer); + let in_topology = topology_neighbors.route_to_peer(required_routing, &peer); let need_routing = in_topology || { let route_random = random_routing.sample(total_peers, rng); if route_random { @@ -533,7 +533,8 @@ async fn process_incoming_peer_message( let topology = state .topologies - .get_topology_or_fallback(job_data.signing_context.session_index); + .get_topology_or_fallback(job_data.signing_context.session_index) + .local_grid_neighbors(); let required_routing = topology.required_routing_by_index(validator_index, false); metrics.on_bitfield_received(); @@ -579,14 +580,24 @@ async fn handle_network_msg( }, NetworkBridgeEvent::NewGossipTopology(gossip_topology) => { let session_index = gossip_topology.session; - let new_topology = SessionGridTopology::from(gossip_topology); - let newly_added = new_topology.peers_diff(&new_topology); - state.topologies.update_topology(session_index, new_topology); + let new_topology = gossip_topology.topology; + let prev_neighbors = + state.topologies.get_current_topology().local_grid_neighbors().clone(); + + state.topologies.update_topology( + session_index, + new_topology, + gossip_topology.local_index, + ); + let current_topology = state.topologies.get_current_topology(); + + let newly_added = current_topology.local_grid_neighbors().peers_diff(&prev_neighbors); + gum::debug!( target: LOG_TARGET, ?session_index, - "New gossip topology received {} unseen peers", - newly_added.len() + newly_added_peers = ?newly_added.len(), + "New gossip topology received", ); for new_peer in newly_added { @@ -651,7 +662,7 @@ async fn handle_peer_view_change( .cloned() .collect::>(); - let topology = state.topologies.get_current_topology(); + let topology = state.topologies.get_current_topology().local_grid_neighbors(); let is_gossip_peer = topology.route_to_peer(RequiredRouting::GridXY, &origin); let lucky = is_gossip_peer || util::gen_ratio_rng( diff --git a/node/network/bitfield-distribution/src/tests.rs b/node/network/bitfield-distribution/src/tests.rs index 6509db3ba660..5eb610fe8508 100644 --- a/node/network/bitfield-distribution/src/tests.rs +++ b/node/network/bitfield-distribution/src/tests.rs @@ -20,7 +20,10 @@ use bitvec::bitvec; use futures::executor; use maplit::hashmap; use polkadot_node_network_protocol::{ - grid_topology::SessionBoundGridTopologyStorage, our_view, view, ObservedRole, + grid_topology::{SessionBoundGridTopologyStorage, SessionGridTopology, TopologyPeerInfo}, + our_view, + peer_set::ValidationVersion, + view, ObservedRole, }; use polkadot_node_subsystem::{ jaeger, @@ -31,6 +34,7 @@ use polkadot_node_subsystem_util::TimeoutExt; use polkadot_primitives::v2::{AvailabilityBitfield, Signed, ValidatorIndex}; use rand_chacha::ChaCha12Rng; use sp_application_crypto::AppKey; +use sp_authority_discovery::AuthorityPair as AuthorityDiscoveryPair; use sp_core::Pair as PairT; use sp_keyring::Sr25519Keyring; use sp_keystore::{testing::KeyStore, SyncCryptoStore, SyncCryptoStorePtr}; @@ -60,10 +64,11 @@ fn prewarmed_state( peers: Vec, ) -> ProtocolState { let relay_parent = known_message.relay_parent.clone(); - let mut topology: SessionGridTopology = Default::default(); - topology.peers_x = peers.iter().cloned().collect(); let mut topologies = SessionBoundGridTopologyStorage::default(); - topologies.update_topology(0_u32, topology); + topologies.update_topology(0_u32, SessionGridTopology::new(Vec::new(), Vec::new()), None); + topologies.get_current_topology_mut().local_grid_neighbors_mut().peers_x = + peers.iter().cloned().collect(); + ProtocolState { per_relay_parent: hashmap! { relay_parent.clone() => @@ -455,10 +460,9 @@ fn do_not_relay_message_twice() { let mut rng = dummy_rng(); executor::block_on(async move { - let gossip_peers = SessionGridTopology { - peers_x: HashSet::from_iter(vec![peer_a.clone(), peer_b.clone()].into_iter()), - ..Default::default() - }; + let mut gossip_peers = GridNeighbors::empty(); + gossip_peers.peers_x = HashSet::from_iter(vec![peer_a.clone(), peer_b.clone()].into_iter()); + relay_message( &mut ctx, state.per_relay_parent.get_mut(&hash).unwrap(), @@ -568,7 +572,12 @@ fn changing_view() { &mut ctx, &mut state, &Default::default(), - NetworkBridgeEvent::PeerConnected(peer_b.clone(), ObservedRole::Full, 1, None), + NetworkBridgeEvent::PeerConnected( + peer_b.clone(), + ObservedRole::Full, + ValidationVersion::V1.into(), + None + ), &mut rng, )); @@ -774,33 +783,43 @@ fn topology_test() { .try_init(); let hash: Hash = [0; 32].into(); - let peers_x = (0..25).map(|_| PeerId::random()).collect::>(); - let peers_y = (0..25).map(|_| PeerId::random()).collect::>(); - - // ensure all unique - assert_eq!( - peers_x.iter().chain(peers_y.iter()).collect::>().len(), - peers_x.len() + peers_y.len() - ); // validator 0 key pair let (mut state, signing_context, keystore, validator) = state_with_view(our_view![hash], hash); - // Create a simple grid - let mut topology: SessionGridTopology = Default::default(); - topology.peers_x = peers_x.iter().cloned().collect::>(); - topology.validator_indices_x = peers_x + // Create a simple grid without any shuffling. We occupy position 1. + let topology_peer_info: Vec<_> = (0..49) + .map(|i| TopologyPeerInfo { + peer_ids: vec![PeerId::random()], + validator_index: ValidatorIndex(i as _), + discovery_id: AuthorityDiscoveryPair::generate().0.public(), + }) + .collect(); + + let topology = SessionGridTopology::new((0usize..49).collect(), topology_peer_info.clone()); + state.topologies.update_topology(0_u32, topology, Some(ValidatorIndex(1))); + + let peers_x: Vec<_> = [0, 2, 3, 4, 5, 6] .iter() - .enumerate() - .map(|(idx, _)| ValidatorIndex(idx as u32)) - .collect::>(); - topology.peers_y = peers_y.iter().cloned().collect::>(); - topology.validator_indices_y = peers_y + .cloned() + .map(|i| topology_peer_info[i].peer_ids[0].clone()) + .collect(); + + let peers_y: Vec<_> = [8, 15, 22, 29, 36, 43] .iter() - .enumerate() - .map(|(idx, _)| ValidatorIndex((idx + peers_x.len()) as u32)) - .collect::>(); - state.topologies.update_topology(0_u32, topology); + .cloned() + .map(|i| topology_peer_info[i].peer_ids[0].clone()) + .collect(); + + { + let t = state.topologies.get_current_topology().local_grid_neighbors(); + for p_x in &peers_x { + assert!(t.peers_x.contains(p_x)); + } + for p_y in &peers_y { + assert!(t.peers_y.contains(p_y)); + } + } // create a signed message by validator 0 let payload = AvailabilityBitfield(bitvec![u8, bitvec::order::Lsb0; 1u8; 32]); @@ -854,7 +873,7 @@ fn topology_test() { AllMessages::NetworkBridgeTx( NetworkBridgeTxMessage::SendValidationMessage(peers, send_msg), ) => { - let topology = state.topologies.get_current_topology(); + let topology = state.topologies.get_current_topology().local_grid_neighbors(); // It should send message to all peers in y direction and to 4 random peers in x direction assert_eq!(peers_y.len() + 4, peers.len()); assert!(topology.peers_y.iter().all(|peer| peers.contains(&peer))); diff --git a/node/network/bridge/Cargo.toml b/node/network/bridge/Cargo.toml index 7aadf2377f6b..7802a83e2747 100644 --- a/node/network/bridge/Cargo.toml +++ b/node/network/bridge/Cargo.toml @@ -1,19 +1,19 @@ [package] name = "polkadot-network-bridge" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] always-assert = "0.1" -async-trait = "0.1.53" +async-trait = "0.1.57" futures = "0.3.21" gum = { package = "tracing-gum", path = "../../gum" } polkadot-primitives = { path = "../../../primitives" } parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-node-subsystem = {path = "../../subsystem" } polkadot-overseer = { path = "../../overseer" } polkadot-node-network-protocol = { path = "../protocol" } @@ -26,7 +26,7 @@ thiserror = "1" [dev-dependencies] assert_matches = "1.4.0" polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures-timer = "3" polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } diff --git a/node/network/bridge/src/lib.rs b/node/network/bridge/src/lib.rs index d599ae25d9c1..77d106d25f7b 100644 --- a/node/network/bridge/src/lib.rs +++ b/node/network/bridge/src/lib.rs @@ -28,7 +28,8 @@ use parking_lot::Mutex; use sp_consensus::SyncOracle; use polkadot_node_network_protocol::{ - peer_set::PeerSet, PeerId, ProtocolVersion, UnifiedReputationChange as Rep, View, + peer_set::{PeerSet, ProtocolVersion}, + PeerId, UnifiedReputationChange as Rep, View, }; /// Peer set info for network initialization. diff --git a/node/network/bridge/src/metrics.rs b/node/network/bridge/src/metrics.rs index 0224c4960ac9..52b3629a66ad 100644 --- a/node/network/bridge/src/metrics.rs +++ b/node/network/bridge/src/metrics.rs @@ -23,7 +23,7 @@ pub struct Metrics(pub(crate) Option); fn peer_set_label(peer_set: PeerSet, version: ProtocolVersion) -> &'static str { // Higher level code is meant to protect against this ever happening. - peer_set.get_protocol_name_static(version).unwrap_or("") + peer_set.get_protocol_label(version).unwrap_or("") } #[allow(missing_docs)] @@ -98,7 +98,7 @@ impl Metrics { self.0.as_ref().map(|metrics| { metrics .desired_peer_count - .with_label_values(&[peer_set.get_default_protocol_name()]) + .with_label_values(&[peer_set.get_label()]) .set(size as u64) }); } diff --git a/node/network/bridge/src/network.rs b/node/network/bridge/src/network.rs index 00a950f35c54..9b326cbbfb38 100644 --- a/node/network/bridge/src/network.rs +++ b/node/network/bridge/src/network.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use std::{borrow::Cow, collections::HashSet, sync::Arc}; +use std::{collections::HashSet, sync::Arc}; use async_trait::async_trait; use futures::{prelude::*, stream::BoxStream}; @@ -22,17 +22,19 @@ use futures::{prelude::*, stream::BoxStream}; use parity_scale_codec::Encode; use sc_network::{ - config::parse_addr, multiaddr::Multiaddr, Event as NetworkEvent, IfDisconnected, - NetworkService, OutboundFailure, RequestFailure, + multiaddr::Multiaddr, Event as NetworkEvent, IfDisconnected, NetworkService, OutboundFailure, + RequestFailure, }; -use sc_network_common::service::{ - NetworkEventStream, NetworkNotification, NetworkPeers, NetworkRequest, +use sc_network_common::{ + config::parse_addr, + protocol::ProtocolName, + service::{NetworkEventStream, NetworkNotification, NetworkPeers, NetworkRequest}, }; use polkadot_node_network_protocol::{ - peer_set::PeerSet, + peer_set::{PeerSet, PeerSetProtocolNames, ProtocolVersion}, request_response::{OutgoingRequest, Recipient, ReqProtocolNames, Requests}, - PeerId, ProtocolVersion, UnifiedReputationChange as Rep, + PeerId, UnifiedReputationChange as Rep, }; use polkadot_primitives::v2::{AuthorityDiscoveryId, Block, Hash}; @@ -51,6 +53,7 @@ pub(crate) fn send_message( mut peers: Vec, peer_set: PeerSet, version: ProtocolVersion, + protocol_names: &PeerSetProtocolNames, message: M, metrics: &super::Metrics, ) where @@ -66,11 +69,13 @@ pub(crate) fn send_message( // list. The message payload can be quite large. If the underlying // network used `Bytes` this would not be necessary. let last_peer = peers.pop(); + // optimization: generate the protocol name once. + let protocol_name = protocol_names.get_name(peer_set, version); peers.into_iter().for_each(|peer| { - net.write_notification(peer, peer_set, message.clone()); + net.write_notification(peer, protocol_name.clone(), message.clone()); }); if let Some(peer) = last_peer { - net.write_notification(peer, peer_set, message); + net.write_notification(peer, protocol_name, message); } } @@ -88,12 +93,12 @@ pub trait Network: Clone + Send + 'static { /// Note that `out_peers` setting has no effect on this. async fn set_reserved_peers( &mut self, - protocol: Cow<'static, str>, + protocol: ProtocolName, multiaddresses: HashSet, ) -> Result<(), String>; /// Removes the peers for the protocol's peer set (both reserved and non-reserved). - async fn remove_from_peers_set(&mut self, protocol: Cow<'static, str>, peers: Vec); + async fn remove_from_peers_set(&mut self, protocol: ProtocolName, peers: Vec); /// Send a request to a remote peer. async fn start_request( @@ -107,11 +112,11 @@ pub trait Network: Clone + Send + 'static { /// Report a given peer as either beneficial (+) or costly (-) according to the given scalar. fn report_peer(&self, who: PeerId, cost_benefit: Rep); - /// Disconnect a given peer from the peer set specified without harming reputation. - fn disconnect_peer(&self, who: PeerId, peer_set: PeerSet); + /// Disconnect a given peer from the protocol specified without harming reputation. + fn disconnect_peer(&self, who: PeerId, protocol: ProtocolName); - /// Write a notification to a peer on the given peer-set's protocol. - fn write_notification(&self, who: PeerId, peer_set: PeerSet, message: Vec); + /// Write a notification to a peer on the given protocol. + fn write_notification(&self, who: PeerId, protocol: ProtocolName, message: Vec); } #[async_trait] @@ -122,13 +127,13 @@ impl Network for Arc> { async fn set_reserved_peers( &mut self, - protocol: Cow<'static, str>, + protocol: ProtocolName, multiaddresses: HashSet, ) -> Result<(), String> { NetworkService::set_reserved_peers(&**self, protocol, multiaddresses) } - async fn remove_from_peers_set(&mut self, protocol: Cow<'static, str>, peers: Vec) { + async fn remove_from_peers_set(&mut self, protocol: ProtocolName, peers: Vec) { NetworkService::remove_peers_from_reserved_set(&**self, protocol, peers); } @@ -136,17 +141,12 @@ impl Network for Arc> { NetworkService::report_peer(&**self, who, cost_benefit.into_base_rep()); } - fn disconnect_peer(&self, who: PeerId, peer_set: PeerSet) { - NetworkService::disconnect_peer(&**self, who, peer_set.into_default_protocol_name()); + fn disconnect_peer(&self, who: PeerId, protocol: ProtocolName) { + NetworkService::disconnect_peer(&**self, who, protocol); } - fn write_notification(&self, who: PeerId, peer_set: PeerSet, message: Vec) { - NetworkService::write_notification( - &**self, - who, - peer_set.into_default_protocol_name(), - message, - ); + fn write_notification(&self, who: PeerId, protocol: ProtocolName, message: Vec) { + NetworkService::write_notification(&**self, who, protocol, message); } async fn start_request( diff --git a/node/network/bridge/src/rx/mod.rs b/node/network/bridge/src/rx/mod.rs index f135b006f114..a08596cd15ac 100644 --- a/node/network/bridge/src/rx/mod.rs +++ b/node/network/bridge/src/rx/mod.rs @@ -27,18 +27,20 @@ use sp_consensus::SyncOracle; use polkadot_node_network_protocol::{ self as net_protocol, - peer_set::{PeerSet, PerPeerSet}, - v1 as protocol_v1, ObservedRole, OurView, PeerId, ProtocolVersion, - UnifiedReputationChange as Rep, View, + grid_topology::{SessionGridTopology, TopologyPeerInfo}, + peer_set::{ + CollationVersion, PeerSet, PeerSetProtocolNames, PerPeerSet, ProtocolVersion, + ValidationVersion, + }, + v1 as protocol_v1, ObservedRole, OurView, PeerId, UnifiedReputationChange as Rep, View, }; use polkadot_node_subsystem::{ errors::SubsystemError, messages::{ - network_bridge_event::{NewGossipTopology, TopologyPeerInfo}, - ApprovalDistributionMessage, BitfieldDistributionMessage, CollatorProtocolMessage, - GossipSupportMessage, NetworkBridgeEvent, NetworkBridgeRxMessage, - StatementDistributionMessage, + network_bridge_event::NewGossipTopology, ApprovalDistributionMessage, + BitfieldDistributionMessage, CollatorProtocolMessage, GossipSupportMessage, + NetworkBridgeEvent, NetworkBridgeRxMessage, StatementDistributionMessage, }, overseer, ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, SpawnedSubsystem, }; @@ -80,6 +82,7 @@ pub struct NetworkBridgeRx { sync_oracle: Box, shared: Shared, metrics: Metrics, + peerset_protocol_names: PeerSetProtocolNames, } impl NetworkBridgeRx { @@ -92,9 +95,17 @@ impl NetworkBridgeRx { authority_discovery_service: AD, sync_oracle: Box, metrics: Metrics, + peerset_protocol_names: PeerSetProtocolNames, ) -> Self { let shared = Shared::default(); - Self { network_service, authority_discovery_service, sync_oracle, shared, metrics } + Self { + network_service, + authority_discovery_service, + sync_oracle, + shared, + metrics, + peerset_protocol_names, + } } } @@ -118,28 +129,6 @@ where } } -async fn update_gossip_peers_1d( - ads: &mut AD, - neighbors: N, -) -> HashMap -where - AD: validator_discovery::AuthorityDiscovery, - N: IntoIterator, - N::IntoIter: std::iter::ExactSizeIterator, -{ - let neighbors = neighbors.into_iter(); - let mut peers = HashMap::with_capacity(neighbors.len()); - for (authority, validator_index) in neighbors { - let addr = get_peer_id_by_authority_id(ads, authority.clone()).await; - - if let Some(peer_id) = addr { - peers.insert(authority, TopologyPeerInfo { peer_ids: vec![peer_id], validator_index }); - } - } - - peers -} - async fn handle_network_messages( mut sender: impl overseer::NetworkBridgeRxSenderTrait, mut network_service: impl Network, @@ -147,6 +136,7 @@ async fn handle_network_messages( mut authority_discovery_service: AD, metrics: Metrics, shared: Shared, + peerset_protocol_names: PeerSetProtocolNames, ) -> Result<(), Error> where AD: validator_discovery::AuthorityDiscovery + Send, @@ -166,13 +156,14 @@ where }) => { let role = ObservedRole::from(role); let (peer_set, version) = { - let (peer_set, version) = match PeerSet::try_from_protocol_name(&protocol) { - None => continue, - Some(p) => p, - }; + let (peer_set, version) = + match peerset_protocol_names.try_get_protocol(&protocol) { + None => continue, + Some(p) => p, + }; if let Some(fallback) = negotiated_fallback { - match PeerSet::try_from_protocol_name(&fallback) { + match peerset_protocol_names.try_get_protocol(&fallback) { None => { gum::debug!( target: LOG_TARGET, @@ -210,7 +201,7 @@ where target: LOG_TARGET, action = "PeerConnected", peer_set = ?peer_set, - version, + version = %version, peer = ?peer, role = ?role ); @@ -245,7 +236,7 @@ where NetworkBridgeEvent::PeerConnected( peer.clone(), role, - 1, + version, maybe_authority, ), NetworkBridgeEvent::PeerViewChange(peer.clone(), View::default()), @@ -259,6 +250,7 @@ where vec![peer], PeerSet::Validation, version, + &peerset_protocol_names, WireMessage::::ViewUpdate(local_view), &metrics, ); @@ -269,7 +261,7 @@ where NetworkBridgeEvent::PeerConnected( peer.clone(), role, - 1, + version, maybe_authority, ), NetworkBridgeEvent::PeerViewChange(peer.clone(), View::default()), @@ -283,6 +275,7 @@ where vec![peer], PeerSet::Collation, version, + &peerset_protocol_names, WireMessage::::ViewUpdate(local_view), &metrics, ); @@ -290,7 +283,7 @@ where } }, Some(NetworkEvent::NotificationStreamClosed { remote: peer, protocol }) => { - let (peer_set, version) = match PeerSet::try_from_protocol_name(&protocol) { + let (peer_set, version) = match peerset_protocol_names.try_get_protocol(&protocol) { None => continue, Some(peer_set) => peer_set, }; @@ -317,7 +310,7 @@ where w }; - if was_connected && version == peer_set.get_default_version() { + if was_connected && version == peer_set.get_main_version() { match peer_set { PeerSet::Validation => dispatch_validation_event_to_all( @@ -355,7 +348,8 @@ where .filter_map(|(protocol, msg_bytes)| { // version doesn't matter because we always receive on the 'correct' // protocol name, not the negotiated fallback. - let (peer_set, _version) = PeerSet::try_from_protocol_name(protocol)?; + let (peer_set, _version) = + peerset_protocol_names.try_get_protocol(protocol)?; if peer_set == PeerSet::Validation { if expected_versions[PeerSet::Validation].is_none() { return Some(Err(UNCONNECTED_PEERSET_COST)) @@ -384,7 +378,8 @@ where .filter_map(|(protocol, msg_bytes)| { // version doesn't matter because we always receive on the 'correct' // protocol name, not the negotiated fallback. - let (peer_set, _version) = PeerSet::try_from_protocol_name(protocol)?; + let (peer_set, _version) = + peerset_protocol_names.try_get_protocol(protocol)?; if peer_set == PeerSet::Collation { if expected_versions[PeerSet::Collation].is_none() { @@ -422,7 +417,9 @@ where if !v_messages.is_empty() { let (events, reports) = - if expected_versions[PeerSet::Validation] == Some(1) { + if expected_versions[PeerSet::Validation] == + Some(ValidationVersion::V1.into()) + { handle_v1_peer_messages::( remote.clone(), PeerSet::Validation, @@ -453,7 +450,9 @@ where if !c_messages.is_empty() { let (events, reports) = - if expected_versions[PeerSet::Collation] == Some(1) { + if expected_versions[PeerSet::Collation] == + Some(CollationVersion::V1.into()) + { handle_v1_peer_messages::( remote.clone(), PeerSet::Collation, @@ -486,6 +485,26 @@ where } } +async fn flesh_out_topology_peers(ads: &mut AD, neighbors: N) -> Vec +where + AD: validator_discovery::AuthorityDiscovery, + N: IntoIterator, + N::IntoIter: std::iter::ExactSizeIterator, +{ + let neighbors = neighbors.into_iter(); + let mut peers = Vec::with_capacity(neighbors.len()); + for (discovery_id, validator_index) in neighbors { + let addr = get_peer_id_by_authority_id(ads, discovery_id.clone()).await; + peers.push(TopologyPeerInfo { + peer_ids: addr.into_iter().collect(), + validator_index, + discovery_id, + }); + } + + peers +} + #[overseer::contextbounds(NetworkBridgeRx, prefix = self::overseer)] async fn run_incoming_orchestra_signals( mut ctx: Context, @@ -494,6 +513,7 @@ async fn run_incoming_orchestra_signals( shared: Shared, sync_oracle: Box, metrics: Metrics, + peerset_protocol_names: PeerSetProtocolNames, ) -> Result<(), Error> where N: Network, @@ -510,29 +530,28 @@ where msg: NetworkBridgeRxMessage::NewGossipTopology { session, - our_neighbors_x, - our_neighbors_y, + local_index, + canonical_shuffling, + shuffled_indices, }, } => { gum::debug!( target: LOG_TARGET, action = "NewGossipTopology", - neighbors_x = our_neighbors_x.len(), - neighbors_y = our_neighbors_y.len(), + ?session, + ?local_index, "Gossip topology has changed", ); - let gossip_peers_x = - update_gossip_peers_1d(&mut authority_discovery_service, our_neighbors_x).await; - - let gossip_peers_y = - update_gossip_peers_1d(&mut authority_discovery_service, our_neighbors_y).await; + let topology_peers = + flesh_out_topology_peers(&mut authority_discovery_service, canonical_shuffling) + .await; dispatch_validation_event_to_all_unbounded( NetworkBridgeEvent::NewGossipTopology(NewGossipTopology { session, - our_neighbors_x: gossip_peers_x, - our_neighbors_y: gossip_peers_y, + topology: SessionGridTopology::new(shuffled_indices, topology_peers), + local_index, }), ctx.sender(), ); @@ -574,6 +593,7 @@ where &shared, finalized_number, &metrics, + &peerset_protocol_names, ); } } @@ -619,6 +639,7 @@ where metrics, sync_oracle, shared, + peerset_protocol_names, } = bridge; let (task, network_event_handler) = handle_network_messages( @@ -628,6 +649,7 @@ where authority_discovery_service.clone(), metrics.clone(), shared.clone(), + peerset_protocol_names.clone(), ) .remote_handle(); @@ -641,6 +663,7 @@ where shared, sync_oracle, metrics, + peerset_protocol_names, ); futures::pin_mut!(orchestra_signal_handler); @@ -667,6 +690,7 @@ fn update_our_view( shared: &Shared, finalized_number: BlockNumber, metrics: &Metrics, + peerset_protocol_names: &PeerSetProtocolNames, ) where Net: Network, { @@ -700,11 +724,18 @@ fn update_our_view( send_validation_message_v1( net, validation_peers, + peerset_protocol_names, WireMessage::ViewUpdate(new_view.clone()), metrics, ); - send_collation_message_v1(net, collation_peers, WireMessage::ViewUpdate(new_view), metrics); + send_collation_message_v1( + net, + collation_peers, + peerset_protocol_names, + WireMessage::ViewUpdate(new_view), + metrics, + ); let our_view = OurView::new( live_heads.iter().take(MAX_VIEW_HEADS).cloned().map(|a| (a.hash, a.span)), @@ -778,19 +809,37 @@ fn handle_v1_peer_messages>( fn send_validation_message_v1( net: &mut impl Network, peers: Vec, + peerset_protocol_names: &PeerSetProtocolNames, message: WireMessage, metrics: &Metrics, ) { - send_message(net, peers, PeerSet::Validation, 1, message, metrics); + send_message( + net, + peers, + PeerSet::Validation, + ValidationVersion::V1.into(), + peerset_protocol_names, + message, + metrics, + ); } fn send_collation_message_v1( net: &mut impl Network, peers: Vec, + peerset_protocol_names: &PeerSetProtocolNames, message: WireMessage, metrics: &Metrics, ) { - send_message(net, peers, PeerSet::Collation, 1, message, metrics) + send_message( + net, + peers, + PeerSet::Collation, + CollationVersion::V1.into(), + peerset_protocol_names, + message, + metrics, + ); } async fn dispatch_validation_event_to_all( diff --git a/node/network/bridge/src/rx/tests.rs b/node/network/bridge/src/rx/tests.rs index ad1d8392d30c..d4353c0342a5 100644 --- a/node/network/bridge/src/rx/tests.rs +++ b/node/network/bridge/src/rx/tests.rs @@ -23,14 +23,14 @@ use assert_matches::assert_matches; use async_trait::async_trait; use parking_lot::Mutex; use std::{ - borrow::Cow, collections::HashSet, sync::atomic::{AtomicBool, Ordering}, }; -use sc_network::{Event as NetworkEvent, IfDisconnected}; +use sc_network::{Event as NetworkEvent, IfDisconnected, ProtocolName}; use polkadot_node_network_protocol::{ + peer_set::PeerSetProtocolNames, request_response::{outgoing::Requests, ReqProtocolNames}, view, ObservedRole, Versioned, }; @@ -46,7 +46,7 @@ use polkadot_node_subsystem_test_helpers::{ SingleItemSink, SingleItemStream, TestSubsystemContextHandle, }; use polkadot_node_subsystem_util::metered; -use polkadot_primitives::v2::AuthorityDiscoveryId; +use polkadot_primitives::v2::{AuthorityDiscoveryId, Hash}; use sc_network::Multiaddr; use sp_keyring::Sr25519Keyring; @@ -68,6 +68,7 @@ pub enum NetworkAction { struct TestNetwork { net_events: Arc>>>, action_tx: Arc>>, + protocol_names: Arc, } #[derive(Clone, Debug)] @@ -78,9 +79,12 @@ struct TestAuthorityDiscovery; struct TestNetworkHandle { action_rx: metered::UnboundedMeteredReceiver, net_tx: SingleItemSink, + protocol_names: PeerSetProtocolNames, } -fn new_test_network() -> (TestNetwork, TestNetworkHandle, TestAuthorityDiscovery) { +fn new_test_network( + protocol_names: PeerSetProtocolNames, +) -> (TestNetwork, TestNetworkHandle, TestAuthorityDiscovery) { let (net_tx, net_rx) = polkadot_node_subsystem_test_helpers::single_item_sink(); let (action_tx, action_rx) = metered::unbounded(); @@ -88,8 +92,9 @@ fn new_test_network() -> (TestNetwork, TestNetworkHandle, TestAuthorityDiscovery TestNetwork { net_events: Arc::new(Mutex::new(Some(net_rx))), action_tx: Arc::new(Mutex::new(action_tx)), + protocol_names: Arc::new(protocol_names.clone()), }, - TestNetworkHandle { action_rx, net_tx }, + TestNetworkHandle { action_rx, net_tx, protocol_names }, TestAuthorityDiscovery, ) } @@ -106,13 +111,13 @@ impl Network for TestNetwork { async fn set_reserved_peers( &mut self, - _protocol: Cow<'static, str>, + _protocol: ProtocolName, _: HashSet, ) -> Result<(), String> { Ok(()) } - async fn remove_from_peers_set(&mut self, _protocol: Cow<'static, str>, _: Vec) {} + async fn remove_from_peers_set(&mut self, _protocol: ProtocolName, _: Vec) {} async fn start_request( &self, @@ -130,14 +135,20 @@ impl Network for TestNetwork { .unwrap(); } - fn disconnect_peer(&self, who: PeerId, peer_set: PeerSet) { + fn disconnect_peer(&self, who: PeerId, protocol: ProtocolName) { + let (peer_set, version) = self.protocol_names.try_get_protocol(&protocol).unwrap(); + assert_eq!(version, peer_set.get_main_version()); + self.action_tx .lock() .unbounded_send(NetworkAction::DisconnectPeer(who, peer_set)) .unwrap(); } - fn write_notification(&self, who: PeerId, peer_set: PeerSet, message: Vec) { + fn write_notification(&self, who: PeerId, protocol: ProtocolName, message: Vec) { + let (peer_set, version) = self.protocol_names.try_get_protocol(&protocol).unwrap(); + assert_eq!(version, peer_set.get_main_version()); + self.action_tx .lock() .unbounded_send(NetworkAction::WriteNotification(who, peer_set, message)) @@ -181,7 +192,7 @@ impl TestNetworkHandle { async fn connect_peer(&mut self, peer: PeerId, peer_set: PeerSet, role: ObservedRole) { self.send_network_event(NetworkEvent::NotificationStreamOpened { remote: peer, - protocol: peer_set.into_default_protocol_name(), + protocol: self.protocol_names.get_main_name(peer_set), negotiated_fallback: None, role: role.into(), }) @@ -191,7 +202,7 @@ impl TestNetworkHandle { async fn disconnect_peer(&mut self, peer: PeerId, peer_set: PeerSet) { self.send_network_event(NetworkEvent::NotificationStreamClosed { remote: peer, - protocol: peer_set.into_default_protocol_name(), + protocol: self.protocol_names.get_main_name(peer_set), }) .await; } @@ -199,7 +210,7 @@ impl TestNetworkHandle { async fn peer_message(&mut self, peer: PeerId, peer_set: PeerSet, message: Vec) { self.send_network_event(NetworkEvent::NotificationsReceived { remote: peer, - messages: vec![(peer_set.into_default_protocol_name(), message.into())], + messages: vec![(self.protocol_names.get_main_name(peer_set), message.into())], }) .await; } @@ -285,8 +296,12 @@ fn test_harness>( sync_oracle: Box, test: impl FnOnce(TestHarness) -> T, ) { + let genesis_hash = Hash::repeat_byte(0xff); + let fork_id = None; + let peerset_protocol_names = PeerSetProtocolNames::new(genesis_hash, fork_id); + let pool = sp_core::testing::TaskExecutor::new(); - let (mut network, network_handle, discovery) = new_test_network(); + let (mut network, network_handle, discovery) = new_test_network(peerset_protocol_names.clone()); let (context, virtual_overseer) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool); let network_stream = network.event_stream(); @@ -297,6 +312,7 @@ fn test_harness>( metrics: Metrics(None), sync_oracle, shared: Shared::default(), + peerset_protocol_names, }; let network_bridge = run_network_in(bridge, context, network_stream) @@ -656,7 +672,12 @@ fn peer_view_updates_sent_via_overseer() { // bridge will inform about all connected peers. { assert_sends_validation_event_to_all( - NetworkBridgeEvent::PeerConnected(peer.clone(), ObservedRole::Full, 1, None), + NetworkBridgeEvent::PeerConnected( + peer.clone(), + ObservedRole::Full, + ValidationVersion::V1.into(), + None, + ), &mut virtual_overseer, ) .await; @@ -699,7 +720,12 @@ fn peer_messages_sent_via_overseer() { // bridge will inform about all connected peers. { assert_sends_validation_event_to_all( - NetworkBridgeEvent::PeerConnected(peer.clone(), ObservedRole::Full, 1, None), + NetworkBridgeEvent::PeerConnected( + peer.clone(), + ObservedRole::Full, + ValidationVersion::V1.into(), + None, + ), &mut virtual_overseer, ) .await; @@ -769,7 +795,12 @@ fn peer_disconnect_from_just_one_peerset() { // bridge will inform about all connected peers. { assert_sends_validation_event_to_all( - NetworkBridgeEvent::PeerConnected(peer.clone(), ObservedRole::Full, 1, None), + NetworkBridgeEvent::PeerConnected( + peer.clone(), + ObservedRole::Full, + ValidationVersion::V1.into(), + None, + ), &mut virtual_overseer, ) .await; @@ -783,7 +814,12 @@ fn peer_disconnect_from_just_one_peerset() { { assert_sends_collation_event_to_all( - NetworkBridgeEvent::PeerConnected(peer.clone(), ObservedRole::Full, 1, None), + NetworkBridgeEvent::PeerConnected( + peer.clone(), + ObservedRole::Full, + ValidationVersion::V1.into(), + None, + ), &mut virtual_overseer, ) .await; @@ -852,7 +888,12 @@ fn relays_collation_protocol_messages() { // bridge will inform about all connected peers. { assert_sends_validation_event_to_all( - NetworkBridgeEvent::PeerConnected(peer_a.clone(), ObservedRole::Full, 1, None), + NetworkBridgeEvent::PeerConnected( + peer_a.clone(), + ObservedRole::Full, + ValidationVersion::V1.into(), + None, + ), &mut virtual_overseer, ) .await; @@ -866,7 +907,12 @@ fn relays_collation_protocol_messages() { { assert_sends_collation_event_to_all( - NetworkBridgeEvent::PeerConnected(peer_b.clone(), ObservedRole::Full, 1, None), + NetworkBridgeEvent::PeerConnected( + peer_b.clone(), + ObservedRole::Full, + ValidationVersion::V1.into(), + None, + ), &mut virtual_overseer, ) .await; @@ -945,7 +991,12 @@ fn different_views_on_different_peer_sets() { // bridge will inform about all connected peers. { assert_sends_validation_event_to_all( - NetworkBridgeEvent::PeerConnected(peer.clone(), ObservedRole::Full, 1, None), + NetworkBridgeEvent::PeerConnected( + peer.clone(), + ObservedRole::Full, + ValidationVersion::V1.into(), + None, + ), &mut virtual_overseer, ) .await; @@ -959,7 +1010,12 @@ fn different_views_on_different_peer_sets() { { assert_sends_collation_event_to_all( - NetworkBridgeEvent::PeerConnected(peer.clone(), ObservedRole::Full, 1, None), + NetworkBridgeEvent::PeerConnected( + peer.clone(), + ObservedRole::Full, + ValidationVersion::V1.into(), + None, + ), &mut virtual_overseer, ) .await; diff --git a/node/network/bridge/src/tx/mod.rs b/node/network/bridge/src/tx/mod.rs index ac34cf315cec..47f095fdf273 100644 --- a/node/network/bridge/src/tx/mod.rs +++ b/node/network/bridge/src/tx/mod.rs @@ -18,7 +18,9 @@ use super::*; use polkadot_node_network_protocol::{ - peer_set::PeerSet, request_response::ReqProtocolNames, v1 as protocol_v1, PeerId, Versioned, + peer_set::{CollationVersion, PeerSet, PeerSetProtocolNames, ValidationVersion}, + request_response::ReqProtocolNames, + v1 as protocol_v1, PeerId, Versioned, }; use polkadot_node_subsystem::{ @@ -53,6 +55,7 @@ pub struct NetworkBridgeTx { authority_discovery_service: AD, metrics: Metrics, req_protocol_names: ReqProtocolNames, + peerset_protocol_names: PeerSetProtocolNames, } impl NetworkBridgeTx { @@ -65,8 +68,15 @@ impl NetworkBridgeTx { authority_discovery_service: AD, metrics: Metrics, req_protocol_names: ReqProtocolNames, + peerset_protocol_names: PeerSetProtocolNames, ) -> Self { - Self { network_service, authority_discovery_service, metrics, req_protocol_names } + Self { + network_service, + authority_discovery_service, + metrics, + req_protocol_names, + peerset_protocol_names, + } } } @@ -91,12 +101,14 @@ async fn handle_subsystem_messages( mut authority_discovery_service: AD, metrics: Metrics, req_protocol_names: ReqProtocolNames, + peerset_protocol_names: PeerSetProtocolNames, ) -> Result<(), Error> where N: Network, AD: validator_discovery::AuthorityDiscovery + Clone, { - let mut validator_discovery = validator_discovery::Service::::new(); + let mut validator_discovery = + validator_discovery::Service::::new(peerset_protocol_names.clone()); loop { match ctx.recv().fuse().await? { @@ -112,6 +124,7 @@ where msg, &metrics, &req_protocol_names, + &peerset_protocol_names, ) .await; }, @@ -128,6 +141,7 @@ async fn handle_incoming_subsystem_communication( msg: NetworkBridgeTxMessage, metrics: &Metrics, req_protocol_names: &ReqProtocolNames, + peerset_protocol_names: &PeerSetProtocolNames, ) -> (N, AD) where N: Network, @@ -150,7 +164,9 @@ where peer_set = ?peer_set, ); - network_service.disconnect_peer(peer, peer_set); + // [`NetworkService`] keeps track of the protocols by their main name. + let protocol = peerset_protocol_names.get_main_name(peer_set); + network_service.disconnect_peer(peer, protocol); }, NetworkBridgeTxMessage::SendValidationMessage(peers, msg) => { gum::trace!( @@ -163,6 +179,7 @@ where Versioned::V1(msg) => send_validation_message_v1( &mut network_service, peers, + peerset_protocol_names, WireMessage::ProtocolMessage(msg), &metrics, ), @@ -180,6 +197,7 @@ where Versioned::V1(msg) => send_validation_message_v1( &mut network_service, peers, + peerset_protocol_names, WireMessage::ProtocolMessage(msg), &metrics, ), @@ -197,6 +215,7 @@ where Versioned::V1(msg) => send_collation_message_v1( &mut network_service, peers, + peerset_protocol_names, WireMessage::ProtocolMessage(msg), &metrics, ), @@ -214,6 +233,7 @@ where Versioned::V1(msg) => send_collation_message_v1( &mut network_service, peers, + peerset_protocol_names, WireMessage::ProtocolMessage(msg), &metrics, ), @@ -296,6 +316,7 @@ where authority_discovery_service, metrics, req_protocol_names, + peerset_protocol_names, } = bridge; handle_subsystem_messages( @@ -304,6 +325,7 @@ where authority_discovery_service, metrics, req_protocol_names, + peerset_protocol_names, ) .await?; @@ -313,17 +335,35 @@ where fn send_validation_message_v1( net: &mut impl Network, peers: Vec, + protocol_names: &PeerSetProtocolNames, message: WireMessage, metrics: &Metrics, ) { - send_message(net, peers, PeerSet::Validation, 1, message, metrics); + send_message( + net, + peers, + PeerSet::Validation, + ValidationVersion::V1.into(), + protocol_names, + message, + metrics, + ); } fn send_collation_message_v1( net: &mut impl Network, peers: Vec, + protocol_names: &PeerSetProtocolNames, message: WireMessage, metrics: &Metrics, ) { - send_message(net, peers, PeerSet::Collation, 1, message, metrics) + send_message( + net, + peers, + PeerSet::Collation, + CollationVersion::V1.into(), + protocol_names, + message, + metrics, + ); } diff --git a/node/network/bridge/src/tx/tests.rs b/node/network/bridge/src/tx/tests.rs index d5b6d3ca67ab..c001457d592b 100644 --- a/node/network/bridge/src/tx/tests.rs +++ b/node/network/bridge/src/tx/tests.rs @@ -20,11 +20,12 @@ use polkadot_node_subsystem_util::TimeoutExt; use async_trait::async_trait; use parking_lot::Mutex; -use std::{borrow::Cow, collections::HashSet}; +use std::collections::HashSet; -use sc_network::{Event as NetworkEvent, IfDisconnected}; +use sc_network::{Event as NetworkEvent, IfDisconnected, ProtocolName}; use polkadot_node_network_protocol::{ + peer_set::PeerSetProtocolNames, request_response::{outgoing::Requests, ReqProtocolNames}, ObservedRole, Versioned, }; @@ -55,6 +56,7 @@ pub enum NetworkAction { struct TestNetwork { net_events: Arc>>>, action_tx: Arc>>, + peerset_protocol_names: Arc, } #[derive(Clone, Debug)] @@ -65,9 +67,12 @@ struct TestAuthorityDiscovery; struct TestNetworkHandle { action_rx: metered::UnboundedMeteredReceiver, net_tx: metered::MeteredSender, + peerset_protocol_names: PeerSetProtocolNames, } -fn new_test_network() -> (TestNetwork, TestNetworkHandle, TestAuthorityDiscovery) { +fn new_test_network( + peerset_protocol_names: PeerSetProtocolNames, +) -> (TestNetwork, TestNetworkHandle, TestAuthorityDiscovery) { let (net_tx, net_rx) = metered::channel(10); let (action_tx, action_rx) = metered::unbounded(); @@ -75,8 +80,9 @@ fn new_test_network() -> (TestNetwork, TestNetworkHandle, TestAuthorityDiscovery TestNetwork { net_events: Arc::new(Mutex::new(Some(net_rx))), action_tx: Arc::new(Mutex::new(action_tx)), + peerset_protocol_names: Arc::new(peerset_protocol_names.clone()), }, - TestNetworkHandle { action_rx, net_tx }, + TestNetworkHandle { action_rx, net_tx, peerset_protocol_names }, TestAuthorityDiscovery, ) } @@ -93,13 +99,13 @@ impl Network for TestNetwork { async fn set_reserved_peers( &mut self, - _protocol: Cow<'static, str>, + _protocol: ProtocolName, _: HashSet, ) -> Result<(), String> { Ok(()) } - async fn remove_from_peers_set(&mut self, _protocol: Cow<'static, str>, _: Vec) {} + async fn remove_from_peers_set(&mut self, _protocol: ProtocolName, _: Vec) {} async fn start_request( &self, @@ -117,14 +123,20 @@ impl Network for TestNetwork { .unwrap(); } - fn disconnect_peer(&self, who: PeerId, peer_set: PeerSet) { + fn disconnect_peer(&self, who: PeerId, protocol: ProtocolName) { + let (peer_set, version) = self.peerset_protocol_names.try_get_protocol(&protocol).unwrap(); + assert_eq!(version, peer_set.get_main_version()); + self.action_tx .lock() .unbounded_send(NetworkAction::DisconnectPeer(who, peer_set)) .unwrap(); } - fn write_notification(&self, who: PeerId, peer_set: PeerSet, message: Vec) { + fn write_notification(&self, who: PeerId, protocol: ProtocolName, message: Vec) { + let (peer_set, version) = self.peerset_protocol_names.try_get_protocol(&protocol).unwrap(); + assert_eq!(version, peer_set.get_main_version()); + self.action_tx .lock() .unbounded_send(NetworkAction::WriteNotification(who, peer_set, message)) @@ -158,7 +170,7 @@ impl TestNetworkHandle { async fn connect_peer(&mut self, peer: PeerId, peer_set: PeerSet, role: ObservedRole) { self.send_network_event(NetworkEvent::NotificationStreamOpened { remote: peer, - protocol: peer_set.into_default_protocol_name(), + protocol: self.peerset_protocol_names.get_main_name(peer_set), negotiated_fallback: None, role: role.into(), }) @@ -178,16 +190,24 @@ struct TestHarness { } fn test_harness>(test: impl FnOnce(TestHarness) -> T) { + let genesis_hash = Hash::repeat_byte(0xff); + let fork_id = None; + let req_protocol_names = ReqProtocolNames::new(genesis_hash, fork_id); + let peerset_protocol_names = PeerSetProtocolNames::new(genesis_hash, fork_id); + let pool = sp_core::testing::TaskExecutor::new(); - let (network, network_handle, discovery) = new_test_network(); + let (network, network_handle, discovery) = new_test_network(peerset_protocol_names.clone()); let (context, virtual_overseer) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool); - let genesis_hash = Hash::repeat_byte(0xff); - let protocol_names = ReqProtocolNames::new(genesis_hash, None); - - let bridge_out = NetworkBridgeTx::new(network, discovery, Metrics(None), protocol_names); + let bridge_out = NetworkBridgeTx::new( + network, + discovery, + Metrics(None), + req_protocol_names, + peerset_protocol_names, + ); let network_bridge_out_fut = run_network_out(bridge_out, context) .map_err(|e| panic!("bridge-out subsystem execution failed {:?}", e)) diff --git a/node/network/bridge/src/validator_discovery.rs b/node/network/bridge/src/validator_discovery.rs index 9c90200aa06a..f7cb805428b5 100644 --- a/node/network/bridge/src/validator_discovery.rs +++ b/node/network/bridge/src/validator_discovery.rs @@ -27,7 +27,7 @@ use sc_network::multiaddr::{self, Multiaddr}; pub use polkadot_node_network_protocol::authority_discovery::AuthorityDiscovery; use polkadot_node_network_protocol::{ - peer_set::{PeerSet, PerPeerSet}, + peer_set::{PeerSet, PeerSetProtocolNames, PerPeerSet}, PeerId, }; use polkadot_primitives::v2::AuthorityDiscoveryId; @@ -36,6 +36,7 @@ const LOG_TARGET: &str = "parachain::validator-discovery"; pub(super) struct Service { state: PerPeerSet, + peerset_protocol_names: PeerSetProtocolNames, // PhantomData used to make the struct generic instead of having generic methods _phantom: PhantomData<(N, AD)>, } @@ -46,8 +47,8 @@ struct StatePerPeerSet { } impl Service { - pub fn new() -> Self { - Self { state: Default::default(), _phantom: PhantomData } + pub fn new(peerset_protocol_names: PeerSetProtocolNames) -> Self { + Self { state: Default::default(), peerset_protocol_names, _phantom: PhantomData } } /// Connect to already resolved addresses. @@ -76,20 +77,26 @@ impl Service { // ask the network to connect to these nodes and not disconnect // from them until removed from the set // - // for peer-set management, the default should be used regardless of + // for peer-set management, the main protocol name should be used regardless of // the negotiated version. if let Err(e) = network_service - .set_reserved_peers(peer_set.into_default_protocol_name(), newly_requested) + .set_reserved_peers( + self.peerset_protocol_names.get_main_name(peer_set), + newly_requested, + ) .await { gum::warn!(target: LOG_TARGET, err = ?e, "AuthorityDiscoveryService returned an invalid multiaddress"); } // the addresses are known to be valid // - // for peer-set management, the default should be used regardless of + // for peer-set management, the main protocol name should be used regardless of // the negotiated version. let _ = network_service - .remove_from_peers_set(peer_set.into_default_protocol_name(), peers_to_remove) + .remove_from_peers_set( + self.peerset_protocol_names.get_main_name(peer_set), + peers_to_remove, + ) .await; network_service @@ -166,15 +173,17 @@ mod tests { request_response::{outgoing::Requests, ReqProtocolNames}, PeerId, }; - use sc_network::{Event as NetworkEvent, IfDisconnected}; + use polkadot_primitives::v2::Hash; + use sc_network::{Event as NetworkEvent, IfDisconnected, ProtocolName}; use sp_keyring::Sr25519Keyring; - use std::{ - borrow::Cow, - collections::{HashMap, HashSet}, - }; + use std::collections::{HashMap, HashSet}; fn new_service() -> Service { - Service::new() + let genesis_hash = Hash::repeat_byte(0xff); + let fork_id = None; + let protocol_names = PeerSetProtocolNames::new(genesis_hash, fork_id); + + Service::new(protocol_names) } fn new_network() -> (TestNetwork, TestAuthorityDiscovery) { @@ -220,18 +229,14 @@ mod tests { async fn set_reserved_peers( &mut self, - _protocol: Cow<'static, str>, + _protocol: ProtocolName, multiaddresses: HashSet, ) -> Result<(), String> { self.peers_set = extract_peer_ids(multiaddresses.into_iter()); Ok(()) } - async fn remove_from_peers_set( - &mut self, - _protocol: Cow<'static, str>, - peers: Vec, - ) { + async fn remove_from_peers_set(&mut self, _protocol: ProtocolName, peers: Vec) { self.peers_set.retain(|elem| !peers.contains(elem)); } @@ -248,11 +253,11 @@ mod tests { panic!() } - fn disconnect_peer(&self, _: PeerId, _: PeerSet) { + fn disconnect_peer(&self, _: PeerId, _: ProtocolName) { panic!() } - fn write_notification(&self, _: PeerId, _: PeerSet, _: Vec) { + fn write_notification(&self, _: PeerId, _: ProtocolName, _: Vec) { panic!() } } diff --git a/node/network/collator-protocol/Cargo.toml b/node/network/collator-protocol/Cargo.toml index 74c2a1442677..141d28af869f 100644 --- a/node/network/collator-protocol/Cargo.toml +++ b/node/network/collator-protocol/Cargo.toml @@ -1,18 +1,19 @@ [package] name = "polkadot-collator-protocol" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] always-assert = "0.1.2" +bitvec = { version = "1.0.1", default-features = false, features = ["alloc"] } futures = "0.3.21" futures-timer = "3" gum = { package = "tracing-gum", path = "../../gum" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-primitives = { path = "../../../primitives" } polkadot-node-network-protocol = { path = "../../network/protocol" } @@ -27,9 +28,9 @@ log = "0.4.17" env_logger = "0.9.0" assert_matches = "1.4.0" -sp-core = { git = "https://github.com/paritytech/substrate", features = ["std"] , branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", features = ["std"] , branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } parity-scale-codec = { version = "3.1.5", features = ["std"] } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } diff --git a/node/network/collator-protocol/src/collator_side/metrics.rs b/node/network/collator-protocol/src/collator_side/metrics.rs new file mode 100644 index 000000000000..85e00406b9ba --- /dev/null +++ b/node/network/collator-protocol/src/collator_side/metrics.rs @@ -0,0 +1,123 @@ +// Copyright 2017-2022 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 . + +use polkadot_node_subsystem_util::metrics::{self, prometheus}; + +#[derive(Clone, Default)] +pub struct Metrics(Option); + +impl Metrics { + pub fn on_advertisment_made(&self) { + if let Some(metrics) = &self.0 { + metrics.advertisements_made.inc(); + } + } + + pub fn on_collation_sent_requested(&self) { + if let Some(metrics) = &self.0 { + metrics.collations_send_requested.inc(); + } + } + + pub fn on_collation_sent(&self) { + if let Some(metrics) = &self.0 { + metrics.collations_sent.inc(); + } + } + + /// Provide a timer for `process_msg` which observes on drop. + pub fn time_process_msg(&self) -> Option { + self.0.as_ref().map(|metrics| metrics.process_msg.start_timer()) + } + + /// Provide a timer for `distribute_collation` which observes on drop. + pub fn time_collation_distribution( + &self, + label: &'static str, + ) -> Option { + self.0.as_ref().map(|metrics| { + metrics.collation_distribution_time.with_label_values(&[label]).start_timer() + }) + } +} + +#[derive(Clone)] +struct MetricsInner { + advertisements_made: prometheus::Counter, + collations_sent: prometheus::Counter, + collations_send_requested: prometheus::Counter, + process_msg: prometheus::Histogram, + collation_distribution_time: prometheus::HistogramVec, +} + +impl metrics::Metrics for Metrics { + fn try_register( + registry: &prometheus::Registry, + ) -> std::result::Result { + let metrics = MetricsInner { + advertisements_made: prometheus::register( + prometheus::Counter::new( + "polkadot_parachain_collation_advertisements_made_total", + "A number of collation advertisements sent to validators.", + )?, + registry, + )?, + collations_send_requested: prometheus::register( + prometheus::Counter::new( + "polkadot_parachain_collations_sent_requested_total", + "A number of collations requested to be sent to validators.", + )?, + registry, + )?, + collations_sent: prometheus::register( + prometheus::Counter::new( + "polkadot_parachain_collations_sent_total", + "A number of collations sent to validators.", + )?, + registry, + )?, + process_msg: prometheus::register( + prometheus::Histogram::with_opts( + prometheus::HistogramOpts::new( + "polkadot_parachain_collator_protocol_collator_process_msg", + "Time spent within `collator_protocol_collator::process_msg`", + ) + .buckets(vec![ + 0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.15, 0.25, 0.35, 0.5, 0.75, + 1.0, + ]), + )?, + registry, + )?, + collation_distribution_time: prometheus::register( + prometheus::HistogramVec::new( + prometheus::HistogramOpts::new( + "polkadot_parachain_collator_protocol_collator_distribution_time", + "Time spent within `collator_protocol_collator::distribute_collation`", + ) + .buckets(vec![ + 0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.15, 0.25, 0.35, 0.5, 0.75, + 1.0, + ]), + &["state"], + )?, + registry, + )?, + }; + + Ok(Metrics(Some(metrics))) + } +} diff --git a/node/network/collator-protocol/src/collator_side/mod.rs b/node/network/collator-protocol/src/collator_side/mod.rs index c1a20a2a670b..4f2eea2ca747 100644 --- a/node/network/collator-protocol/src/collator_side/mod.rs +++ b/node/network/collator-protocol/src/collator_side/mod.rs @@ -17,7 +17,7 @@ use std::{ collections::{HashMap, HashSet, VecDeque}, pin::Pin, - time::Duration, + time::{Duration, Instant}, }; use futures::{ @@ -44,19 +44,25 @@ use polkadot_node_subsystem::{ overseer, FromOrchestra, OverseerSignal, PerLeafSpan, }; use polkadot_node_subsystem_util::{ - metrics::{self, prometheus}, runtime::{get_availability_cores, get_group_rotation_info, RuntimeInfo}, TimeoutExt, }; use polkadot_primitives::v2::{ AuthorityDiscoveryId, CandidateHash, CandidateReceipt, CollatorPair, CoreIndex, CoreState, - Hash, Id as ParaId, + GroupIndex, Hash, Id as ParaId, SessionIndex, }; use super::LOG_TARGET; use crate::error::{log_error, Error, FatalError, Result}; use fatality::Split; +mod metrics; +mod validators_buffer; + +use validators_buffer::{ValidatorGroupsBuffer, VALIDATORS_BUFFER_CAPACITY}; + +pub use metrics::Metrics; + #[cfg(test)] mod tests; @@ -73,111 +79,16 @@ const COST_APPARENT_FLOOD: Rep = /// For considerations on this value, see: https://github.com/paritytech/polkadot/issues/4386 const MAX_UNSHARED_UPLOAD_TIME: Duration = Duration::from_millis(150); -#[derive(Clone, Default)] -pub struct Metrics(Option); - -impl Metrics { - fn on_advertisment_made(&self) { - if let Some(metrics) = &self.0 { - metrics.advertisements_made.inc(); - } - } - - fn on_collation_sent_requested(&self) { - if let Some(metrics) = &self.0 { - metrics.collations_send_requested.inc(); - } - } - - fn on_collation_sent(&self) { - if let Some(metrics) = &self.0 { - metrics.collations_sent.inc(); - } - } - - /// Provide a timer for `process_msg` which observes on drop. - fn time_process_msg(&self) -> Option { - self.0.as_ref().map(|metrics| metrics.process_msg.start_timer()) - } - - /// Provide a timer for `distribute_collation` which observes on drop. - fn time_collation_distribution( - &self, - label: &'static str, - ) -> Option { - self.0.as_ref().map(|metrics| { - metrics.collation_distribution_time.with_label_values(&[label]).start_timer() - }) - } -} - -#[derive(Clone)] -struct MetricsInner { - advertisements_made: prometheus::Counter, - collations_sent: prometheus::Counter, - collations_send_requested: prometheus::Counter, - process_msg: prometheus::Histogram, - collation_distribution_time: prometheus::HistogramVec, -} +/// Ensure that collator issues a connection request at least once every this many seconds. +/// Usually it's done when advertising new collation. However, if the core stays occupied or +/// it's not our turn to produce a candidate, it's important to disconnect from previous +/// peers. +/// +/// Validators are obtained from [`ValidatorGroupsBuffer::validators_to_connect`]. +const RECONNECT_TIMEOUT: Duration = Duration::from_secs(12); -impl metrics::Metrics for Metrics { - fn try_register( - registry: &prometheus::Registry, - ) -> std::result::Result { - let metrics = MetricsInner { - advertisements_made: prometheus::register( - prometheus::Counter::new( - "polkadot_parachain_collation_advertisements_made_total", - "A number of collation advertisements sent to validators.", - )?, - registry, - )?, - collations_send_requested: prometheus::register( - prometheus::Counter::new( - "polkadot_parachain_collations_sent_requested_total", - "A number of collations requested to be sent to validators.", - )?, - registry, - )?, - collations_sent: prometheus::register( - prometheus::Counter::new( - "polkadot_parachain_collations_sent_total", - "A number of collations sent to validators.", - )?, - registry, - )?, - process_msg: prometheus::register( - prometheus::Histogram::with_opts( - prometheus::HistogramOpts::new( - "polkadot_parachain_collator_protocol_collator_process_msg", - "Time spent within `collator_protocol_collator::process_msg`", - ) - .buckets(vec![ - 0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.15, 0.25, 0.35, 0.5, 0.75, - 1.0, - ]), - )?, - registry, - )?, - collation_distribution_time: prometheus::register( - prometheus::HistogramVec::new( - prometheus::HistogramOpts::new( - "polkadot_parachain_collator_protocol_collator_distribution_time", - "Time spent within `collator_protocol_collator::distribute_collation`", - ) - .buckets(vec![ - 0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.15, 0.25, 0.35, 0.5, 0.75, - 1.0, - ]), - &["state"], - )?, - registry, - )?, - }; - - Ok(Metrics(Some(metrics))) - } -} +/// How often to check for reconnect timeout. +const RECONNECT_POLL: Duration = Duration::from_secs(1); /// Info about validators we are currently connected to. /// @@ -269,8 +180,14 @@ struct WaitingCollationFetches { waiting_peers: HashSet, } +struct CollationSendResult { + relay_parent: Hash, + peer_id: PeerId, + timed_out: bool, +} + type ActiveCollationFetches = - FuturesUnordered + Send + 'static>>>; + FuturesUnordered + Send + 'static>>>; struct State { /// Our network peer id. @@ -308,6 +225,13 @@ struct State { /// by `PeerConnected` events. peer_ids: HashMap>, + /// Tracks which validators we want to stay connected to. + validator_groups_buf: ValidatorGroupsBuffer, + + /// Timestamp of the last connection request to a non-empty list of validators, + /// `None` otherwise. + last_connected_at: Option, + /// Metrics. metrics: Metrics, @@ -339,6 +263,8 @@ impl State { collation_result_senders: Default::default(), our_validators_groups: Default::default(), peer_ids: Default::default(), + validator_groups_buf: ValidatorGroupsBuffer::with_capacity(VALIDATORS_BUFFER_CAPACITY), + last_connected_at: None, waiting_collation_fetches: Default::default(), active_collation_fetches: Default::default(), } @@ -373,6 +299,7 @@ async fn distribute_collation( result_sender: Option>, ) -> Result<()> { let relay_parent = receipt.descriptor.relay_parent; + let candidate_hash = receipt.hash(); // This collation is not in the active-leaves set. if !state.view.contains(&relay_parent) { @@ -412,10 +339,10 @@ async fn distribute_collation( }; // Determine the group on that core. - let current_validators = + let GroupValidators { validators, session_index, group_index } = determine_our_validators(ctx, runtime, our_core, num_cores, relay_parent).await?; - if current_validators.validators.is_empty() { + if validators.is_empty() { gum::warn!( target: LOG_TARGET, core = ?our_core, @@ -425,24 +352,36 @@ async fn distribute_collation( return Ok(()) } + // It's important to insert new collation bits **before** + // issuing a connection request. + // + // If a validator managed to fetch all the relevant collations + // but still assigned to our core, we keep the connection alive. + state.validator_groups_buf.note_collation_advertised( + relay_parent, + session_index, + group_index, + &validators, + ); + gum::debug!( target: LOG_TARGET, para_id = %id, relay_parent = %relay_parent, - candidate_hash = ?receipt.hash(), + ?candidate_hash, pov_hash = ?pov.hash(), core = ?our_core, - ?current_validators, + current_validators = ?validators, "Accepted collation, connecting to validators." ); - // Issue a discovery request for the validators of the current group: - connect_to_validators(ctx, current_validators.validators.into_iter().collect()).await; + // Update a set of connected validators if necessary. + state.last_connected_at = connect_to_validators(ctx, &state.validator_groups_buf).await; state.our_validators_groups.insert(relay_parent, ValidatorGroup::new()); if let Some(result_sender) = result_sender { - state.collation_result_senders.insert(receipt.hash(), result_sender); + state.collation_result_senders.insert(candidate_hash, result_sender); } state @@ -483,6 +422,9 @@ async fn determine_core( struct GroupValidators { /// The validators of above group (their discovery keys). validators: Vec, + + session_index: SessionIndex, + group_index: GroupIndex, } /// Figure out current group of validators assigned to the para being collated on. @@ -516,7 +458,11 @@ async fn determine_our_validators( let current_validators = current_validators.iter().map(|i| validators[i.0 as usize].clone()).collect(); - let current_validators = GroupValidators { validators: current_validators }; + let current_validators = GroupValidators { + validators: current_validators, + session_index, + group_index: current_group_index, + }; Ok(current_validators) } @@ -541,13 +487,19 @@ async fn declare(ctx: &mut Context, state: &mut State, peer: PeerId) { } } -/// Issue a connection request to a set of validators and -/// revoke the previous connection request. +/// Updates a set of connected validators based on their advertisement-bits +/// in a validators buffer. +/// +/// Returns current timestamp if the connection request was non-empty, `None` +/// otherwise. #[overseer::contextbounds(CollatorProtocol, prefix = self::overseer)] async fn connect_to_validators( ctx: &mut Context, - validator_ids: Vec, -) { + validator_groups_buf: &ValidatorGroupsBuffer, +) -> Option { + let validator_ids = validator_groups_buf.validators_to_connect(); + let is_disconnect = validator_ids.is_empty(); + // ignore address resolution failure // will reissue a new request on new collation let (failed, _) = oneshot::channel(); @@ -557,6 +509,8 @@ async fn connect_to_validators( failed, }) .await; + + (!is_disconnect).then_some(Instant::now()) } /// Advertise collation to the given `peer`. @@ -715,15 +669,9 @@ async fn send_collation( state.active_collation_fetches.push( async move { let r = rx.timeout(MAX_UNSHARED_UPLOAD_TIME).await; - if r.is_none() { - gum::debug!( - target: LOG_TARGET, - ?relay_parent, - ?peer_id, - "Sending collation to validator timed out, carrying on with next validator." - ); - } - (relay_parent, peer_id) + let timed_out = r.is_none(); + + CollationSendResult { relay_parent, peer_id, timed_out } } .boxed(), ); @@ -986,6 +934,7 @@ async fn handle_our_view_change(state: &mut State, view: OurView) -> Result<()> state.our_validators_groups.remove(removed); state.span_per_relay_parent.remove(removed); state.waiting_collation_fetches.remove(removed); + state.validator_groups_buf.remove_relay_parent(removed); } state.view = view; @@ -1007,6 +956,9 @@ pub(crate) async fn run( let mut state = State::new(local_peer_id, collator_pair, metrics); let mut runtime = RuntimeInfo::new(None); + let reconnect_stream = super::tick_stream(RECONNECT_POLL); + pin_mut!(reconnect_stream); + loop { let recv_req = req_receiver.recv(|| vec![COST_INVALID_REQUEST]).fuse(); pin_mut!(recv_req); @@ -1022,7 +974,25 @@ pub(crate) async fn run( FromOrchestra::Signal(BlockFinalized(..)) => {} FromOrchestra::Signal(Conclude) => return Ok(()), }, - (relay_parent, peer_id) = state.active_collation_fetches.select_next_some() => { + CollationSendResult { + relay_parent, + peer_id, + timed_out, + } = state.active_collation_fetches.select_next_some() => { + if timed_out { + gum::debug!( + target: LOG_TARGET, + ?relay_parent, + ?peer_id, + "Sending collation to validator timed out, carrying on with next validator", + ); + } else { + for authority_id in state.peer_ids.get(&peer_id).into_iter().flatten() { + // Timeout not hit, this peer is no longer interested in this relay parent. + state.validator_groups_buf.reset_validator_interest(relay_parent, authority_id); + } + } + let next = if let Some(waiting) = state.waiting_collation_fetches.get_mut(&relay_parent) { waiting.waiting_peers.remove(&peer_id); if let Some(next) = waiting.waiting.pop_front() { @@ -1042,7 +1012,29 @@ pub(crate) async fn run( send_collation(&mut state, next, receipt, pov).await; } - } + }, + _ = reconnect_stream.next() => { + let now = Instant::now(); + if state + .last_connected_at + .map_or(false, |timestamp| now - timestamp > RECONNECT_TIMEOUT) + { + // Remove all advertisements from the buffer if the timeout was hit. + // Usually, it shouldn't be necessary as leaves get deactivated, rather + // serves as a safeguard against finality lags. + state.validator_groups_buf.clear_advertisements(); + // Returns `None` if connection request is empty. + state.last_connected_at = + connect_to_validators(&mut ctx, &state.validator_groups_buf).await; + + gum::debug!( + target: LOG_TARGET, + timeout = ?RECONNECT_TIMEOUT, + "Timeout hit, sent a connection request. Disconnected from all validators = {}", + state.last_connected_at.is_none(), + ); + } + }, in_req = recv_req => { match in_req { Ok(req) => { diff --git a/node/network/collator-protocol/src/collator_side/tests.rs b/node/network/collator-protocol/src/collator_side/tests.rs index f81e738e16a4..c20a2d6c97a5 100644 --- a/node/network/collator-protocol/src/collator_side/tests.rs +++ b/node/network/collator-protocol/src/collator_side/tests.rs @@ -31,6 +31,7 @@ use sp_runtime::traits::AppVerify; use polkadot_node_network_protocol::{ our_view, + peer_set::CollationVersion, request_response::{IncomingRequest, ReqProtocolNames}, view, }; @@ -55,7 +56,7 @@ struct TestState { group_rotation_info: GroupRotationInfo, validator_peer_id: Vec, relay_parent: Hash, - availability_core: CoreState, + availability_cores: Vec, local_peer_id: PeerId, collator_pair: CollatorPair, session_index: SessionIndex, @@ -87,14 +88,15 @@ impl Default for TestState { let validator_peer_id = std::iter::repeat_with(|| PeerId::random()).take(discovery_keys.len()).collect(); - let validator_groups = vec![vec![2, 0, 4], vec![3, 2, 4]] + let validator_groups = vec![vec![2, 0, 4], vec![1, 3]] .into_iter() .map(|g| g.into_iter().map(ValidatorIndex).collect()) .collect(); let group_rotation_info = GroupRotationInfo { session_start_block: 0, group_rotation_frequency: 100, now: 1 }; - let availability_core = CoreState::Scheduled(ScheduledCore { para_id, collator: None }); + let availability_cores = + vec![CoreState::Scheduled(ScheduledCore { para_id, collator: None }), CoreState::Free]; let relay_parent = Hash::random(); @@ -121,7 +123,7 @@ impl Default for TestState { group_rotation_info, validator_peer_id, relay_parent, - availability_core, + availability_cores, local_peer_id, collator_pair, session_index: 1, @@ -131,7 +133,9 @@ impl Default for TestState { impl TestState { fn current_group_validator_indices(&self) -> &[ValidatorIndex] { - &self.session_info.validator_groups[0] + let core_num = self.availability_cores.len(); + let GroupIndex(group_idx) = self.group_rotation_info.group_for_core(CoreIndex(0), core_num); + &self.session_info.validator_groups[group_idx as usize] } fn current_session_index(&self) -> SessionIndex { @@ -332,7 +336,7 @@ async fn distribute_collation( RuntimeApiRequest::AvailabilityCores(tx) )) => { assert_eq!(relay_parent, test_state.relay_parent); - tx.send(Ok(vec![test_state.availability_core.clone()])).unwrap(); + tx.send(Ok(test_state.availability_cores.clone())).unwrap(); } ); @@ -399,7 +403,7 @@ async fn connect_peer( CollatorProtocolMessage::NetworkBridgeUpdate(NetworkBridgeEvent::PeerConnected( peer.clone(), polkadot_node_network_protocol::ObservedRole::Authority, - 1, + CollationVersion::V1.into(), authority_id.map(|v| HashSet::from([v])), )), ) @@ -986,3 +990,104 @@ where test_harness }); } + +#[test] +fn connect_to_buffered_groups() { + let mut test_state = TestState::default(); + let local_peer_id = test_state.local_peer_id.clone(); + let collator_pair = test_state.collator_pair.clone(); + + test_harness(local_peer_id, collator_pair, |test_harness| async move { + let mut virtual_overseer = test_harness.virtual_overseer; + let mut req_cfg = test_harness.req_cfg; + + setup_system(&mut virtual_overseer, &test_state).await; + + let group_a = test_state.current_group_validator_authority_ids(); + let peers_a = test_state.current_group_validator_peer_ids(); + assert!(group_a.len() > 1); + + distribute_collation(&mut virtual_overseer, &test_state, false).await; + + assert_matches!( + overseer_recv(&mut virtual_overseer).await, + AllMessages::NetworkBridgeTx( + NetworkBridgeTxMessage::ConnectToValidators { validator_ids, .. } + ) => { + assert_eq!(group_a, validator_ids); + } + ); + + let head_a = test_state.relay_parent; + + for (val, peer) in group_a.iter().zip(&peers_a) { + connect_peer(&mut virtual_overseer, peer.clone(), Some(val.clone())).await; + } + + for peer_id in &peers_a { + expect_declare_msg(&mut virtual_overseer, &test_state, peer_id).await; + } + + // Update views. + for peed_id in &peers_a { + send_peer_view_change(&mut virtual_overseer, peed_id, vec![head_a]).await; + expect_advertise_collation_msg(&mut virtual_overseer, peed_id, head_a).await; + } + + let peer = peers_a[0]; + // Peer from the group fetches the collation. + let (pending_response, rx) = oneshot::channel(); + req_cfg + .inbound_queue + .as_mut() + .unwrap() + .send(RawIncomingRequest { + peer, + payload: CollationFetchingRequest { + relay_parent: head_a, + para_id: test_state.para_id, + } + .encode(), + pending_response, + }) + .await + .unwrap(); + assert_matches!( + rx.await, + Ok(full_response) => { + let CollationFetchingResponse::Collation(..): CollationFetchingResponse = + CollationFetchingResponse::decode( + &mut full_response.result.expect("We should have a proper answer").as_ref(), + ) + .expect("Decoding should work"); + } + ); + + test_state.advance_to_new_round(&mut virtual_overseer, true).await; + test_state.group_rotation_info = test_state.group_rotation_info.bump_rotation(); + + let head_b = test_state.relay_parent; + let group_b = test_state.current_group_validator_authority_ids(); + assert_ne!(head_a, head_b); + assert_ne!(group_a, group_b); + + distribute_collation(&mut virtual_overseer, &test_state, false).await; + + // Should be connected to both groups except for the validator that fetched advertised + // collation. + assert_matches!( + overseer_recv(&mut virtual_overseer).await, + AllMessages::NetworkBridgeTx( + NetworkBridgeTxMessage::ConnectToValidators { validator_ids, .. } + ) => { + assert!(!validator_ids.contains(&group_a[0])); + + for validator in group_a[1..].iter().chain(&group_b) { + assert!(validator_ids.contains(validator)); + } + } + ); + + TestHarness { virtual_overseer, req_cfg } + }); +} diff --git a/node/network/collator-protocol/src/collator_side/validators_buffer.rs b/node/network/collator-protocol/src/collator_side/validators_buffer.rs new file mode 100644 index 000000000000..5bb31c72d6c5 --- /dev/null +++ b/node/network/collator-protocol/src/collator_side/validators_buffer.rs @@ -0,0 +1,317 @@ +// Copyright 2017-2022 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 . + +//! Validator groups buffer for connection managements. +//! +//! Solves 2 problems: +//! 1. A collator may want to stay connected to multiple groups on rotation boundaries. +//! 2. It's important to disconnect from validator when there're no collations to be fetched. +//! +//! We keep a simple FIFO buffer of N validator groups and a bitvec for each advertisement, +//! 1 indicating we want to be connected to i-th validator in a buffer, 0 otherwise. +//! +//! The bit is set to 1 for the whole **group** whenever it's inserted into the buffer. Given a relay +//! parent, one can reset a bit back to 0 for particular **validator**. For example, if a collation +//! was fetched or some timeout has been hit. +//! +//! The bitwise OR over known advertisements gives us validators indices for connection request. + +use std::{ + collections::{HashMap, VecDeque}, + num::NonZeroUsize, + ops::Range, +}; + +use bitvec::{bitvec, vec::BitVec}; + +use polkadot_primitives::v2::{AuthorityDiscoveryId, GroupIndex, Hash, SessionIndex}; + +/// The ring buffer stores at most this many unique validator groups. +/// +/// This value should be chosen in way that all groups assigned to our para +/// in the view can fit into the buffer. +pub const VALIDATORS_BUFFER_CAPACITY: NonZeroUsize = match NonZeroUsize::new(3) { + Some(cap) => cap, + None => panic!("buffer capacity must be non-zero"), +}; + +/// Unique identifier of a validators group. +#[derive(Debug)] +struct ValidatorsGroupInfo { + /// Number of validators in the group. + len: usize, + session_index: SessionIndex, + group_index: GroupIndex, +} + +/// Ring buffer of validator groups. +/// +/// Tracks which peers we want to be connected to with respect to advertised collations. +#[derive(Debug)] +pub struct ValidatorGroupsBuffer { + /// Validator groups identifiers we **had** advertisements for. + group_infos: VecDeque, + /// Continuous buffer of validators discovery keys. + validators: VecDeque, + /// Mapping from relay-parent to bit-vectors with bits for all `validators`. + /// Invariants kept: All bit-vectors are guaranteed to have the same size. + should_be_connected: HashMap, + /// Buffer capacity, limits the number of **groups** tracked. + cap: NonZeroUsize, +} + +impl ValidatorGroupsBuffer { + /// Creates a new buffer with a non-zero capacity. + pub fn with_capacity(cap: NonZeroUsize) -> Self { + Self { + group_infos: VecDeque::new(), + validators: VecDeque::new(), + should_be_connected: HashMap::new(), + cap, + } + } + + /// Returns discovery ids of validators we have at least one advertised-but-not-fetched + /// collation for. + pub fn validators_to_connect(&self) -> Vec { + let validators_num = self.validators.len(); + let bits = self + .should_be_connected + .values() + .fold(bitvec![0; validators_num], |acc, next| acc | next); + + self.validators + .iter() + .enumerate() + .filter_map(|(idx, authority_id)| bits[idx].then_some(authority_id.clone())) + .collect() + } + + /// Note a new advertisement, marking that we want to be connected to validators + /// from this group. + /// + /// If max capacity is reached and the group is new, drops validators from the back + /// of the buffer. + pub fn note_collation_advertised( + &mut self, + relay_parent: Hash, + session_index: SessionIndex, + group_index: GroupIndex, + validators: &[AuthorityDiscoveryId], + ) { + if validators.is_empty() { + return + } + + match self.group_infos.iter().enumerate().find(|(_, group)| { + group.session_index == session_index && group.group_index == group_index + }) { + Some((idx, group)) => { + let group_start_idx = self.group_lengths_iter().take(idx).sum(); + self.set_bits(relay_parent, group_start_idx..(group_start_idx + group.len)); + }, + None => self.push(relay_parent, session_index, group_index, validators), + } + } + + /// Note that a validator is no longer interested in a given relay parent. + pub fn reset_validator_interest( + &mut self, + relay_parent: Hash, + authority_id: &AuthorityDiscoveryId, + ) { + let bits = match self.should_be_connected.get_mut(&relay_parent) { + Some(bits) => bits, + None => return, + }; + + for (idx, auth_id) in self.validators.iter().enumerate() { + if auth_id == authority_id { + bits.set(idx, false); + } + } + } + + /// Remove relay parent from the buffer. + /// + /// The buffer will no longer track which validators are interested in a corresponding + /// advertisement. + pub fn remove_relay_parent(&mut self, relay_parent: &Hash) { + self.should_be_connected.remove(relay_parent); + } + + /// Removes all advertisements from the buffer. + pub fn clear_advertisements(&mut self) { + self.should_be_connected.clear(); + } + + /// Pushes a new group to the buffer along with advertisement, setting all validators + /// bits to 1. + /// + /// If the buffer is full, drops group from the tail. + fn push( + &mut self, + relay_parent: Hash, + session_index: SessionIndex, + group_index: GroupIndex, + validators: &[AuthorityDiscoveryId], + ) { + let new_group_info = + ValidatorsGroupInfo { len: validators.len(), session_index, group_index }; + + let buf = &mut self.group_infos; + let cap = self.cap.get(); + + if buf.len() >= cap { + let pruned_group = buf.pop_front().expect("buf is not empty; qed"); + self.validators.drain(..pruned_group.len); + + self.should_be_connected.values_mut().for_each(|bits| { + bits.as_mut_bitslice().shift_left(pruned_group.len); + }); + } + + self.validators.extend(validators.iter().cloned()); + buf.push_back(new_group_info); + let buf_len = buf.len(); + let group_start_idx = self.group_lengths_iter().take(buf_len - 1).sum(); + + let new_len = self.validators.len(); + self.should_be_connected + .values_mut() + .for_each(|bits| bits.resize(new_len, false)); + self.set_bits(relay_parent, group_start_idx..(group_start_idx + validators.len())); + } + + /// Sets advertisement bits to 1 in a given range (usually corresponding to some group). + /// If the relay parent is unknown, inserts 0-initialized bitvec first. + /// + /// The range must be ensured to be within bounds. + fn set_bits(&mut self, relay_parent: Hash, range: Range) { + let bits = self + .should_be_connected + .entry(relay_parent) + .or_insert_with(|| bitvec![0; self.validators.len()]); + + bits[range].fill(true); + } + + /// Returns iterator over numbers of validators in groups. + /// + /// Useful for getting an index of the first validator in i-th group. + fn group_lengths_iter(&self) -> impl Iterator + '_ { + self.group_infos.iter().map(|group| group.len) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use sp_keyring::Sr25519Keyring; + + #[test] + fn one_capacity_buffer() { + let cap = NonZeroUsize::new(1).unwrap(); + let mut buf = ValidatorGroupsBuffer::with_capacity(cap); + + let hash_a = Hash::repeat_byte(0x1); + let hash_b = Hash::repeat_byte(0x2); + + let validators: Vec<_> = [ + Sr25519Keyring::Alice, + Sr25519Keyring::Bob, + Sr25519Keyring::Charlie, + Sr25519Keyring::Dave, + Sr25519Keyring::Ferdie, + ] + .into_iter() + .map(|key| AuthorityDiscoveryId::from(key.public())) + .collect(); + + assert!(buf.validators_to_connect().is_empty()); + + buf.note_collation_advertised(hash_a, 0, GroupIndex(0), &validators[..2]); + assert_eq!(buf.validators_to_connect(), validators[..2].to_vec()); + + buf.reset_validator_interest(hash_a, &validators[1]); + assert_eq!(buf.validators_to_connect(), vec![validators[0].clone()]); + + buf.note_collation_advertised(hash_b, 0, GroupIndex(1), &validators[2..]); + assert_eq!(buf.validators_to_connect(), validators[2..].to_vec()); + + for validator in &validators[2..] { + buf.reset_validator_interest(hash_b, validator); + } + assert!(buf.validators_to_connect().is_empty()); + } + + #[test] + fn buffer_works() { + let cap = NonZeroUsize::new(3).unwrap(); + let mut buf = ValidatorGroupsBuffer::with_capacity(cap); + + let hashes: Vec<_> = (0..5).map(Hash::repeat_byte).collect(); + + let validators: Vec<_> = [ + Sr25519Keyring::Alice, + Sr25519Keyring::Bob, + Sr25519Keyring::Charlie, + Sr25519Keyring::Dave, + Sr25519Keyring::Ferdie, + ] + .into_iter() + .map(|key| AuthorityDiscoveryId::from(key.public())) + .collect(); + + buf.note_collation_advertised(hashes[0], 0, GroupIndex(0), &validators[..2]); + buf.note_collation_advertised(hashes[1], 0, GroupIndex(0), &validators[..2]); + buf.note_collation_advertised(hashes[2], 0, GroupIndex(1), &validators[2..4]); + buf.note_collation_advertised(hashes[2], 0, GroupIndex(1), &validators[2..4]); + + assert_eq!(buf.validators_to_connect(), validators[..4].to_vec()); + + for validator in &validators[2..4] { + buf.reset_validator_interest(hashes[2], validator); + } + + buf.reset_validator_interest(hashes[1], &validators[0]); + assert_eq!(buf.validators_to_connect(), validators[..2].to_vec()); + + buf.reset_validator_interest(hashes[0], &validators[0]); + assert_eq!(buf.validators_to_connect(), vec![validators[1].clone()]); + + buf.note_collation_advertised(hashes[3], 0, GroupIndex(1), &validators[2..4]); + buf.note_collation_advertised( + hashes[4], + 0, + GroupIndex(2), + std::slice::from_ref(&validators[4]), + ); + + buf.reset_validator_interest(hashes[3], &validators[2]); + buf.note_collation_advertised( + hashes[4], + 0, + GroupIndex(3), + std::slice::from_ref(&validators[0]), + ); + + assert_eq!( + buf.validators_to_connect(), + vec![validators[3].clone(), validators[4].clone(), validators[0].clone()] + ); + } +} diff --git a/node/network/collator-protocol/src/lib.rs b/node/network/collator-protocol/src/lib.rs index 66659e4b5bee..b71acc127c88 100644 --- a/node/network/collator-protocol/src/lib.rs +++ b/node/network/collator-protocol/src/lib.rs @@ -21,9 +21,12 @@ #![deny(unused_crate_dependencies)] #![recursion_limit = "256"] -use std::time::Duration; +use std::time::{Duration, Instant}; -use futures::{FutureExt, TryFutureExt}; +use futures::{ + stream::{FusedStream, StreamExt}, + FutureExt, TryFutureExt, +}; use sp_keystore::SyncCryptoStorePtr; @@ -134,3 +137,23 @@ async fn modify_reputation( sender.send_message(NetworkBridgeTxMessage::ReportPeer(peer, rep)).await; } + +/// Wait until tick and return the timestamp for the following one. +async fn wait_until_next_tick(last_poll: Instant, period: Duration) -> Instant { + let now = Instant::now(); + let next_poll = last_poll + period; + + if next_poll > now { + futures_timer::Delay::new(next_poll - now).await + } + + Instant::now() +} + +/// Returns an infinite stream that yields with an interval of `period`. +fn tick_stream(period: Duration) -> impl FusedStream { + futures::stream::unfold(Instant::now(), move |next_check| async move { + Some(((), wait_until_next_tick(next_check, period).await)) + }) + .fuse() +} diff --git a/node/network/collator-protocol/src/validator_side/mod.rs b/node/network/collator-protocol/src/validator_side/mod.rs index 997ad62a9804..b2b3dc4824b5 100644 --- a/node/network/collator-protocol/src/validator_side/mod.rs +++ b/node/network/collator-protocol/src/validator_side/mod.rs @@ -19,7 +19,7 @@ use futures::{ channel::oneshot, future::{BoxFuture, Fuse, FusedFuture}, select, - stream::{FusedStream, FuturesUnordered}, + stream::FuturesUnordered, FutureExt, StreamExt, }; use futures_timer::Delay; @@ -57,7 +57,7 @@ use polkadot_primitives::v2::{CandidateReceipt, CollatorId, Hash, Id as ParaId}; use crate::error::Result; -use super::{modify_reputation, LOG_TARGET}; +use super::{modify_reputation, tick_stream, LOG_TARGET}; #[cfg(test)] mod tests; @@ -85,19 +85,23 @@ const BENEFIT_NOTIFY_GOOD: Rep = /// to finish on time. /// /// There is debug logging output, so we can adjust this value based on production results. +#[cfg(not(test))] const MAX_UNSHARED_DOWNLOAD_TIME: Duration = Duration::from_millis(400); // How often to check all peers with activity. #[cfg(not(test))] const ACTIVITY_POLL: Duration = Duration::from_secs(1); +#[cfg(test)] +const MAX_UNSHARED_DOWNLOAD_TIME: Duration = Duration::from_millis(100); + #[cfg(test)] const ACTIVITY_POLL: Duration = Duration::from_millis(10); // How often to poll collation responses. // This is a hack that should be removed in a refactoring. // See https://github.com/paritytech/polkadot/issues/4182 -const CHECK_COLLATIONS_POLL: Duration = Duration::from_millis(5); +const CHECK_COLLATIONS_POLL: Duration = Duration::from_millis(50); #[derive(Clone, Default)] pub struct Metrics(Option); @@ -730,7 +734,7 @@ async fn handle_peer_view_change(state: &mut State, peer_id: PeerId, view: View) peer_data.update_view(view); state .requested_collations - .retain(|pc, _| pc.peer_id != peer_id || !peer_data.has_advertised(&pc.relay_parent)); + .retain(|pc, _| pc.peer_id != peer_id || peer_data.has_advertised(&pc.relay_parent)); Ok(()) } @@ -1167,25 +1171,6 @@ async fn process_msg( } } -// wait until next inactivity check. returns the instant for the following check. -async fn wait_until_next_check(last_poll: Instant) -> Instant { - let now = Instant::now(); - let next_poll = last_poll + ACTIVITY_POLL; - - if next_poll > now { - Delay::new(next_poll - now).await - } - - Instant::now() -} - -fn infinite_stream(every: Duration) -> impl FusedStream { - futures::stream::unfold(Instant::now() + every, |next_check| async move { - Some(((), wait_until_next_check(next_check).await)) - }) - .fuse() -} - /// The main run loop. #[overseer::contextbounds(CollatorProtocol, prefix = self::overseer)] pub(crate) async fn run( @@ -1196,10 +1181,10 @@ pub(crate) async fn run( ) -> std::result::Result<(), crate::error::FatalError> { let mut state = State { metrics, ..Default::default() }; - let next_inactivity_stream = infinite_stream(ACTIVITY_POLL); + let next_inactivity_stream = tick_stream(ACTIVITY_POLL); futures::pin_mut!(next_inactivity_stream); - let check_collations_stream = infinite_stream(CHECK_COLLATIONS_POLL); + let check_collations_stream = tick_stream(CHECK_COLLATIONS_POLL); futures::pin_mut!(check_collations_stream); loop { diff --git a/node/network/collator-protocol/src/validator_side/tests.rs b/node/network/collator-protocol/src/validator_side/tests.rs index cfb8b967bb34..ae8644cea521 100644 --- a/node/network/collator-protocol/src/validator_side/tests.rs +++ b/node/network/collator-protocol/src/validator_side/tests.rs @@ -20,10 +20,11 @@ use futures::{executor, future, Future}; use sp_core::{crypto::Pair, Encode}; use sp_keyring::Sr25519Keyring; use sp_keystore::{testing::KeyStore as TestKeyStore, SyncCryptoStore}; -use std::{iter, sync::Arc, time::Duration}; +use std::{iter, sync::Arc, task::Poll, time::Duration}; use polkadot_node_network_protocol::{ our_view, + peer_set::CollationVersion, request_response::{Requests, ResponseSender}, ObservedRole, }; @@ -306,7 +307,7 @@ async fn connect_and_declare_collator( CollatorProtocolMessage::NetworkBridgeUpdate(NetworkBridgeEvent::PeerConnected( peer.clone(), ObservedRole::Full, - 1, + CollationVersion::V1.into(), None, )), ) @@ -458,7 +459,7 @@ fn collator_authentication_verification_works() { CollatorProtocolMessage::NetworkBridgeUpdate(NetworkBridgeEvent::PeerConnected( peer_b, ObservedRole::Full, - 1, + CollationVersion::V1.into(), None, )), ) @@ -492,17 +493,11 @@ fn collator_authentication_verification_works() { }); } -// A test scenario that takes the following steps -// - Two collators connect, declare themselves and advertise a collation relevant to -// our view. -// - Collation protocol should request one PoV. -// - Collation protocol should disconnect both collators after having received the collation. -// - The same collators plus an additional collator connect again and send `PoV`s for a different relay parent. -// - Collation protocol will request one PoV, but we will cancel it. -// - Collation protocol should request the second PoV which does not succeed in time. -// - Collation protocol should request third PoV. +/// Tests that a validator fetches only one collation at any moment of time +/// per relay parent and ignores other advertisements once a candidate gets +/// seconded. #[test] -fn fetch_collations_works() { +fn fetch_one_collation_at_a_time() { let test_state = TestState::default(); test_harness(|test_harness| async move { @@ -574,22 +569,38 @@ fn fetch_collations_works() { ) .await; - overseer_send( - &mut virtual_overseer, - CollatorProtocolMessage::NetworkBridgeUpdate(NetworkBridgeEvent::PeerDisconnected( - peer_b.clone(), - )), - ) - .await; + // Ensure the subsystem is polled. + test_helpers::Yield::new().await; + + // Second collation is not requested since there's already seconded one. + assert_matches!(futures::poll!(virtual_overseer.recv().boxed()), Poll::Pending); + + virtual_overseer + }) +} + +/// Tests that a validator starts fetching next queued collations on [`MAX_UNSHARED_DOWNLOAD_TIME`] +/// timeout and in case of an error. +#[test] +fn fetches_next_collation() { + let test_state = TestState::default(); + + test_harness(|test_harness| async move { + let TestHarness { mut virtual_overseer } = test_harness; + + let second = Hash::random(); overseer_send( &mut virtual_overseer, - CollatorProtocolMessage::NetworkBridgeUpdate(NetworkBridgeEvent::PeerDisconnected( - peer_c.clone(), + CollatorProtocolMessage::NetworkBridgeUpdate(NetworkBridgeEvent::OurViewChange( + our_view![test_state.relay_parent, second], )), ) .await; + respond_to_core_info_queries(&mut virtual_overseer, &test_state).await; + respond_to_core_info_queries(&mut virtual_overseer, &test_state).await; + let peer_b = PeerId::random(); let peer_c = PeerId::random(); let peer_d = PeerId::random(); @@ -946,7 +957,7 @@ fn disconnect_if_no_declare() { CollatorProtocolMessage::NetworkBridgeUpdate(NetworkBridgeEvent::PeerConnected( peer_b.clone(), ObservedRole::Full, - 1, + CollationVersion::V1.into(), None, )), ) @@ -984,7 +995,7 @@ fn disconnect_if_wrong_declare() { CollatorProtocolMessage::NetworkBridgeUpdate(NetworkBridgeEvent::PeerConnected( peer_b.clone(), ObservedRole::Full, - 1, + CollationVersion::V1.into(), None, )), ) diff --git a/node/network/dispute-distribution/Cargo.toml b/node/network/dispute-distribution/Cargo.toml index 72701b916a66..270d73529334 100644 --- a/node/network/dispute-distribution/Cargo.toml +++ b/node/network/dispute-distribution/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "polkadot-dispute-distribution" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] futures = "0.3.21" +futures-timer = "3.0.2" gum = { package = "tracing-gum", path = "../../gum" } derive_more = "0.99.17" parity-scale-codec = { version = "3.1.5", features = ["std"] } @@ -15,19 +16,20 @@ polkadot-node-subsystem = {path = "../../subsystem" } polkadot-node-network-protocol = { path = "../../network/protocol" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-node-primitives = { path = "../../primitives" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } thiserror = "1.0.31" fatality = "0.0.6" -lru = "0.7.7" +lru = "0.8.0" +indexmap = "1.9.1" [dev-dependencies] -async-trait = "0.1.53" +async-trait = "0.1.57" polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures-timer = "3.0.2" assert_matches = "1.4.0" lazy_static = "1.4.0" diff --git a/node/network/dispute-distribution/src/lib.rs b/node/network/dispute-distribution/src/lib.rs index aefd66e0ae79..f109d5e6a40e 100644 --- a/node/network/dispute-distribution/src/lib.rs +++ b/node/network/dispute-distribution/src/lib.rs @@ -24,6 +24,8 @@ //! The sender is responsible for getting our vote out, see [`sender`]. The receiver handles //! incoming [`DisputeRequest`]s and offers spam protection, see [`receiver`]. +use std::{num::NonZeroUsize, time::Duration}; + use futures::{channel::mpsc, FutureExt, StreamExt, TryFutureExt}; use polkadot_node_network_protocol::authority_discovery::AuthorityDiscovery; @@ -64,16 +66,19 @@ use self::sender::{DisputeSender, TaskFinish}; /// via a dedicated channel and forwarding them to the dispute coordinator via /// `DisputeCoordinatorMessage::ImportStatements`. Being the interface to the network and untrusted /// nodes, the reality is not that simple of course. Before importing statements the receiver will -/// make sure as good as it can to filter out malicious/unwanted/spammy requests. For this it does -/// the following: +/// batch up imports as well as possible for efficient imports while maintaining timely dispute +/// resolution and handling of spamming validators: /// /// - Drop all messages from non validator nodes, for this it requires the [`AuthorityDiscovery`] /// service. -/// - Drop messages from a node, if we are already importing a message from that node (flood). -/// - Drop messages from nodes, that provided us messages where the statement import failed. +/// - Drop messages from a node, if it sends at a too high rate. +/// - Filter out duplicate messages (over some period of time). /// - Drop any obviously invalid votes (invalid signatures for example). /// - Ban peers whose votes were deemed invalid. /// +/// In general dispute-distribution works on limiting the work the dispute-coordinator will have to +/// do, while at the same time making it aware of new disputes as fast as possible. +/// /// For successfully imported votes, we will confirm the receipt of the message back to the sender. /// This way a received confirmation guarantees, that the vote has been stored to disk by the /// receiver. @@ -93,6 +98,20 @@ pub use metrics::Metrics; const LOG_TARGET: &'static str = "parachain::dispute-distribution"; +/// Rate limit on the `receiver` side. +/// +/// If messages from one peer come in at a higher rate than every `RECEIVE_RATE_LIMIT` on average, we +/// start dropping messages from that peer to enforce that limit. +pub const RECEIVE_RATE_LIMIT: Duration = Duration::from_millis(100); + +/// Rate limit on the `sender` side. +/// +/// In order to not hit the `RECEIVE_RATE_LIMIT` on the receiving side, we limit out sending rate as +/// well. +/// +/// We add 50ms extra, just to have some save margin to the `RECEIVE_RATE_LIMIT`. +pub const SEND_RATE_LIMIT: Duration = RECEIVE_RATE_LIMIT.saturating_add(Duration::from_millis(50)); + /// The dispute distribution subsystem. pub struct DisputeDistributionSubsystem { /// Easy and efficient runtime access for this subsystem. @@ -145,7 +164,8 @@ where ) -> Self { let runtime = RuntimeInfo::new_with_config(runtime::Config { keystore: Some(keystore), - session_cache_lru_size: DISPUTE_WINDOW.get() as usize, + session_cache_lru_size: NonZeroUsize::new(DISPUTE_WINDOW.get() as usize) + .expect("Dispute window can not be 0; qed"), }); let (tx, sender_rx) = mpsc::channel(1); let disputes_sender = DisputeSender::new(tx, metrics.clone()); @@ -172,6 +192,12 @@ where ctx.spawn("disputes-receiver", receiver.run().boxed()) .map_err(FatalError::SpawnTask)?; + // Process messages for sending side. + // + // Note: We want the sender to be rate limited and we are currently taking advantage of the + // fact that the root task of this subsystem is only concerned with sending: Functions of + // `DisputeSender` might back pressure if the rate limit is hit, which will slow down this + // loop. If this fact ever changes, we will likely need another task. loop { let message = MuxedMessage::receive(&mut ctx, &mut self.sender_rx).await; match message { @@ -247,9 +273,10 @@ impl MuxedMessage { // ends. let from_overseer = ctx.recv().fuse(); futures::pin_mut!(from_overseer, from_sender); - futures::select!( - msg = from_overseer => MuxedMessage::Subsystem(msg.map_err(FatalError::SubsystemReceive)), + // We select biased to make sure we finish up loose ends, before starting new work. + futures::select_biased!( msg = from_sender.next() => MuxedMessage::Sender(msg), + msg = from_overseer => MuxedMessage::Subsystem(msg.map_err(FatalError::SubsystemReceive)), ) } } diff --git a/node/network/dispute-distribution/src/metrics.rs b/node/network/dispute-distribution/src/metrics.rs index 3f717bd105c3..aa2feeaad3a0 100644 --- a/node/network/dispute-distribution/src/metrics.rs +++ b/node/network/dispute-distribution/src/metrics.rs @@ -72,9 +72,12 @@ impl Metrics { } /// Statements have been imported. - pub fn on_imported(&self, label: &'static str) { + pub fn on_imported(&self, label: &'static str, num_requests: usize) { if let Some(metrics) = &self.0 { - metrics.imported_requests.with_label_values(&[label]).inc() + metrics + .imported_requests + .with_label_values(&[label]) + .inc_by(num_requests as u64) } } diff --git a/node/network/dispute-distribution/src/receiver/batches/batch.rs b/node/network/dispute-distribution/src/receiver/batches/batch.rs new file mode 100644 index 000000000000..eebed25ed790 --- /dev/null +++ b/node/network/dispute-distribution/src/receiver/batches/batch.rs @@ -0,0 +1,209 @@ +// Copyright 2022 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 . + +use std::{collections::HashMap, time::Instant}; + +use gum::CandidateHash; +use polkadot_node_network_protocol::{ + request_response::{incoming::OutgoingResponseSender, v1::DisputeRequest}, + PeerId, +}; +use polkadot_node_primitives::SignedDisputeStatement; +use polkadot_primitives::v2::{CandidateReceipt, ValidatorIndex}; + +use crate::receiver::{BATCH_COLLECTING_INTERVAL, MIN_KEEP_BATCH_ALIVE_VOTES}; + +use super::MAX_BATCH_LIFETIME; + +/// A batch of votes to be imported into the `dispute-coordinator`. +/// +/// Vote imports are way more efficient when performed in batches, hence we batch together incoming +/// votes until the rate of incoming votes falls below a threshold, then we import into the dispute +/// coordinator. +/// +/// A `Batch` keeps track of the votes to be imported and the current incoming rate, on rate update +/// it will "flush" in case the incoming rate dropped too low, preparing the import. +pub struct Batch { + /// The actual candidate this batch is concerned with. + candidate_receipt: CandidateReceipt, + + /// Cache of `CandidateHash` (candidate_receipt.hash()). + candidate_hash: CandidateHash, + + /// All valid votes received in this batch so far. + /// + /// We differentiate between valid and invalid votes, so we can detect (and drop) duplicates, + /// while still allowing validators to equivocate. + /// + /// Detecting and rejecting duplicates is crucial in order to effectively enforce + /// `MIN_KEEP_BATCH_ALIVE_VOTES` per `BATCH_COLLECTING_INTERVAL`. If we would count duplicates + /// here, the mechanism would be broken. + valid_votes: HashMap, + + /// All invalid votes received in this batch so far. + invalid_votes: HashMap, + + /// How many votes have been batched since the last tick/creation. + votes_batched_since_last_tick: u32, + + /// Expiry time for the batch. + /// + /// By this time the latest this batch will get flushed. + best_before: Instant, + + /// Requesters waiting for a response. + requesters: Vec<(PeerId, OutgoingResponseSender)>, +} + +/// Result of checking a batch every `BATCH_COLLECTING_INTERVAL`. +pub(super) enum TickResult { + /// Batch is still alive, please call `tick` again at the given `Instant`. + Alive(Batch, Instant), + /// Batch is done, ready for import! + Done(PreparedImport), +} + +/// Ready for import. +pub struct PreparedImport { + pub candidate_receipt: CandidateReceipt, + pub statements: Vec<(SignedDisputeStatement, ValidatorIndex)>, + /// Information about original requesters. + pub requesters: Vec<(PeerId, OutgoingResponseSender)>, +} + +impl From for PreparedImport { + fn from(batch: Batch) -> Self { + let Batch { + candidate_receipt, + valid_votes, + invalid_votes, + requesters: pending_responses, + .. + } = batch; + + let statements = valid_votes + .into_iter() + .chain(invalid_votes.into_iter()) + .map(|(index, statement)| (statement, index)) + .collect(); + + Self { candidate_receipt, statements, requesters: pending_responses } + } +} + +impl Batch { + /// Create a new empty batch based on the given `CandidateReceipt`. + /// + /// To create a `Batch` use Batches::find_batch`. + /// + /// Arguments: + /// + /// * `candidate_receipt` - The candidate this batch is meant to track votes for. + /// * `now` - current time stamp for calculating the first tick. + /// + /// Returns: A batch and the first `Instant` you are supposed to call `tick`. + pub(super) fn new(candidate_receipt: CandidateReceipt, now: Instant) -> (Self, Instant) { + let s = Self { + candidate_hash: candidate_receipt.hash(), + candidate_receipt, + valid_votes: HashMap::new(), + invalid_votes: HashMap::new(), + votes_batched_since_last_tick: 0, + best_before: Instant::now() + MAX_BATCH_LIFETIME, + requesters: Vec::new(), + }; + let next_tick = s.calculate_next_tick(now); + (s, next_tick) + } + + /// Receipt of the candidate this batch is batching votes for. + pub fn candidate_receipt(&self) -> &CandidateReceipt { + &self.candidate_receipt + } + + /// Add votes from a validator into the batch. + /// + /// The statements are supposed to be the valid and invalid statements received in a + /// `DisputeRequest`. + /// + /// The given `pending_response` is the corresponding response sender for responding to `peer`. + /// If at least one of the votes is new as far as this batch is concerned we record the + /// pending_response, for later use. In case both votes are known already, we return the + /// response sender as an `Err` value. + pub fn add_votes( + &mut self, + valid_vote: (SignedDisputeStatement, ValidatorIndex), + invalid_vote: (SignedDisputeStatement, ValidatorIndex), + peer: PeerId, + pending_response: OutgoingResponseSender, + ) -> Result<(), OutgoingResponseSender> { + debug_assert!(valid_vote.0.candidate_hash() == invalid_vote.0.candidate_hash()); + debug_assert!(valid_vote.0.candidate_hash() == &self.candidate_hash); + + let mut duplicate = true; + + if self.valid_votes.insert(valid_vote.1, valid_vote.0).is_none() { + self.votes_batched_since_last_tick += 1; + duplicate = false; + } + if self.invalid_votes.insert(invalid_vote.1, invalid_vote.0).is_none() { + self.votes_batched_since_last_tick += 1; + duplicate = false; + } + + if duplicate { + Err(pending_response) + } else { + self.requesters.push((peer, pending_response)); + Ok(()) + } + } + + /// Check batch for liveness. + /// + /// This function is supposed to be called at instants given at construction and as returned as + /// part of `TickResult`. + pub(super) fn tick(mut self, now: Instant) -> TickResult { + if self.votes_batched_since_last_tick >= MIN_KEEP_BATCH_ALIVE_VOTES && + now < self.best_before + { + // Still good: + let next_tick = self.calculate_next_tick(now); + // Reset counter: + self.votes_batched_since_last_tick = 0; + TickResult::Alive(self, next_tick) + } else { + TickResult::Done(PreparedImport::from(self)) + } + } + + /// Calculate when the next tick should happen. + /// + /// This will usually return `now + BATCH_COLLECTING_INTERVAL`, except if the lifetime of this batch + /// would exceed `MAX_BATCH_LIFETIME`. + /// + /// # Arguments + /// + /// * `now` - The current time. + fn calculate_next_tick(&self, now: Instant) -> Instant { + let next_tick = now + BATCH_COLLECTING_INTERVAL; + if next_tick < self.best_before { + next_tick + } else { + self.best_before + } + } +} diff --git a/node/network/dispute-distribution/src/receiver/batches/mod.rs b/node/network/dispute-distribution/src/receiver/batches/mod.rs new file mode 100644 index 000000000000..b343b55e0b04 --- /dev/null +++ b/node/network/dispute-distribution/src/receiver/batches/mod.rs @@ -0,0 +1,170 @@ +// Copyright 2022 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 . + +use std::{ + collections::{hash_map, HashMap}, + time::{Duration, Instant}, +}; + +use futures::future::pending; + +use polkadot_node_network_protocol::request_response::DISPUTE_REQUEST_TIMEOUT; +use polkadot_primitives::v2::{CandidateHash, CandidateReceipt}; + +use crate::{ + receiver::batches::{batch::TickResult, waiting_queue::PendingWake}, + LOG_TARGET, +}; + +pub use self::batch::{Batch, PreparedImport}; +use self::waiting_queue::WaitingQueue; + +use super::{ + error::{JfyiError, JfyiResult}, + BATCH_COLLECTING_INTERVAL, +}; + +/// A single batch (per candidate) as managed by `Batches`. +mod batch; + +/// Queue events in time and wait for them to become ready. +mod waiting_queue; + +/// Safe-guard in case votes trickle in real slow. +/// +/// If the batch life time exceeded the time the sender is willing to wait for a confirmation, we +/// would trigger pointless re-sends. +const MAX_BATCH_LIFETIME: Duration = DISPUTE_REQUEST_TIMEOUT.saturating_sub(Duration::from_secs(2)); + +/// Limit the number of batches that can be alive at any given time. +/// +/// Reasoning for this number, see guide. +pub const MAX_BATCHES: usize = 1000; + +/// Manage batches. +/// +/// - Batches can be found via `find_batch()` in order to add votes to them/check they exist. +/// - Batches can be checked for being ready for flushing in order to import contained votes. +pub struct Batches { + /// The batches we manage. + /// + /// Kept invariants: + /// For each entry in `batches`, there exists an entry in `waiting_queue` as well - we wait on + /// all batches! + batches: HashMap, + /// Waiting queue for waiting for batches to become ready for `tick`. + /// + /// Kept invariants by `Batches`: + /// For each entry in the `waiting_queue` there exists a corresponding entry in `batches`. + waiting_queue: WaitingQueue, +} + +/// A found batch is either really found or got created so it can be found. +pub enum FoundBatch<'a> { + /// Batch just got created. + Created(&'a mut Batch), + /// Batch already existed. + Found(&'a mut Batch), +} + +impl Batches { + /// Create new empty `Batches`. + pub fn new() -> Self { + debug_assert!( + MAX_BATCH_LIFETIME > BATCH_COLLECTING_INTERVAL, + "Unexpectedly low `MAX_BATCH_LIFETIME`, please check parameters." + ); + Self { batches: HashMap::new(), waiting_queue: WaitingQueue::new() } + } + + /// Find a particular batch. + /// + /// That is either find it, or we create it as reflected by the result `FoundBatch`. + pub fn find_batch( + &mut self, + candidate_hash: CandidateHash, + candidate_receipt: CandidateReceipt, + ) -> JfyiResult { + if self.batches.len() >= MAX_BATCHES { + return Err(JfyiError::MaxBatchLimitReached) + } + debug_assert!(candidate_hash == candidate_receipt.hash()); + let result = match self.batches.entry(candidate_hash) { + hash_map::Entry::Vacant(vacant) => { + let now = Instant::now(); + let (created, ready_at) = Batch::new(candidate_receipt, now); + let pending_wake = PendingWake { payload: candidate_hash, ready_at }; + self.waiting_queue.push(pending_wake); + FoundBatch::Created(vacant.insert(created)) + }, + hash_map::Entry::Occupied(occupied) => FoundBatch::Found(occupied.into_mut()), + }; + Ok(result) + } + + /// Wait for the next `tick` to check for ready batches. + /// + /// This function blocks (returns `Poll::Pending`) until at least one batch can be + /// checked for readiness meaning that `BATCH_COLLECTING_INTERVAL` has passed since the last + /// check for that batch or it reached end of life. + /// + /// If this `Batches` instance is empty (does not actually contain any batches), then this + /// function will always return `Poll::Pending`. + /// + /// Returns: A `Vec` of all `PreparedImport`s from batches that became ready. + pub async fn check_batches(&mut self) -> Vec { + let now = Instant::now(); + + let mut imports = Vec::new(); + + // Wait for at least one batch to become ready: + self.waiting_queue.wait_ready(now).await; + + // Process all ready entries: + while let Some(wake) = self.waiting_queue.pop_ready(now) { + let batch = self.batches.remove(&wake.payload); + debug_assert!( + batch.is_some(), + "Entries referenced in `waiting_queue` are supposed to exist!" + ); + let batch = match batch { + None => return pending().await, + Some(batch) => batch, + }; + match batch.tick(now) { + TickResult::Done(import) => { + gum::trace!( + target: LOG_TARGET, + candidate_hash = ?wake.payload, + "Batch became ready." + ); + imports.push(import); + }, + TickResult::Alive(old_batch, next_tick) => { + gum::trace!( + target: LOG_TARGET, + candidate_hash = ?wake.payload, + "Batch found to be still alive on check." + ); + let pending_wake = PendingWake { payload: wake.payload, ready_at: next_tick }; + self.waiting_queue.push(pending_wake); + self.batches.insert(wake.payload, old_batch); + }, + } + } + imports + } +} diff --git a/node/network/dispute-distribution/src/receiver/batches/waiting_queue.rs b/node/network/dispute-distribution/src/receiver/batches/waiting_queue.rs new file mode 100644 index 000000000000..995dc74d358f --- /dev/null +++ b/node/network/dispute-distribution/src/receiver/batches/waiting_queue.rs @@ -0,0 +1,204 @@ +// Copyright 2022 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 . + +use std::{cmp::Ordering, collections::BinaryHeap, time::Instant}; + +use futures::future::pending; +use futures_timer::Delay; + +/// Wait asynchronously for given `Instant`s one after the other. +/// +/// `PendingWake`s can be inserted and `WaitingQueue` makes `wait_ready()` to always wait for the +/// next `Instant` in the queue. +pub struct WaitingQueue { + /// All pending wakes we are supposed to wait on in order. + pending_wakes: BinaryHeap>, + /// Wait for next `PendingWake`. + timer: Option, +} + +/// Represents some event waiting to be processed at `ready_at`. +/// +/// This is an event in `WaitingQueue`. It provides an `Ord` instance, that sorts descending with +/// regard to `Instant` (so we get a `min-heap` with the earliest `Instant` at the top). +#[derive(Eq, PartialEq)] +pub struct PendingWake { + pub payload: Payload, + pub ready_at: Instant, +} + +impl WaitingQueue { + /// Get a new empty `WaitingQueue`. + /// + /// If you call `pop` on this queue immediately, it will always return `Poll::Pending`. + pub fn new() -> Self { + Self { pending_wakes: BinaryHeap::new(), timer: None } + } + + /// Push a `PendingWake`. + /// + /// The next call to `wait_ready` will make sure to wake soon enough to process that new event in a + /// timely manner. + pub fn push(&mut self, wake: PendingWake) { + self.pending_wakes.push(wake); + // Reset timer as it is potentially obsolete now: + self.timer = None; + } + + /// Pop the next ready item. + /// + /// This function does not wait, if nothing is ready right now as determined by the passed + /// `now` time stamp, this function simply returns `None`. + pub fn pop_ready(&mut self, now: Instant) -> Option> { + let is_ready = self.pending_wakes.peek().map_or(false, |p| p.ready_at <= now); + if is_ready { + Some(self.pending_wakes.pop().expect("We just peeked. qed.")) + } else { + None + } + } + + /// Don't pop, just wait until something is ready. + /// + /// Once this function returns `Poll::Ready(())` `pop_ready()` will return `Some`, if passed + /// the same `Instant`. + /// + /// Whether ready or not is determined based on the passed time stamp `now` which should be the + /// current time as returned by `Instant::now()` + /// + /// This function waits asynchronously for an item to become ready. If there is no more item, + /// this call will wait forever (return Poll::Pending without scheduling a wake). + pub async fn wait_ready(&mut self, now: Instant) { + if let Some(timer) = &mut self.timer { + // Previous timer was not done yet. + timer.await + } + + let next_waiting = self.pending_wakes.peek(); + let is_ready = next_waiting.map_or(false, |p| p.ready_at <= now); + if is_ready { + return + } + + self.timer = next_waiting.map(|p| Delay::new(p.ready_at.duration_since(now))); + match &mut self.timer { + None => return pending().await, + Some(timer) => timer.await, + } + } +} + +impl PartialOrd> for PendingWake { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for PendingWake { + fn cmp(&self, other: &Self) -> Ordering { + // Reverse order for min-heap: + match other.ready_at.cmp(&self.ready_at) { + Ordering::Equal => other.payload.cmp(&self.payload), + o => o, + } + } +} +#[cfg(test)] +mod tests { + use std::{ + task::Poll, + time::{Duration, Instant}, + }; + + use assert_matches::assert_matches; + use futures::{future::poll_fn, pin_mut, Future}; + + use crate::LOG_TARGET; + + use super::{PendingWake, WaitingQueue}; + + #[test] + fn wait_ready_waits_for_earliest_event_always() { + sp_tracing::try_init_simple(); + let mut queue = WaitingQueue::new(); + let now = Instant::now(); + let start = now; + queue.push(PendingWake { payload: 1u32, ready_at: now + Duration::from_millis(3) }); + // Push another one in order: + queue.push(PendingWake { payload: 2u32, ready_at: now + Duration::from_millis(5) }); + // Push one out of order: + queue.push(PendingWake { payload: 0u32, ready_at: now + Duration::from_millis(1) }); + // Push another one at same timestamp (should become ready at the same time) + queue.push(PendingWake { payload: 10u32, ready_at: now + Duration::from_millis(1) }); + + futures::executor::block_on(async move { + // No time passed yet - nothing should be ready. + assert!(queue.pop_ready(now).is_none(), "No time has passed, nothing should be ready"); + + // Receive them in order at expected times: + queue.wait_ready(now).await; + gum::trace!(target: LOG_TARGET, "After first wait."); + + let now = start + Duration::from_millis(1); + assert!(Instant::now() - start >= Duration::from_millis(1)); + assert_eq!(queue.pop_ready(now).map(|p| p.payload), Some(0u32)); + // One more should be ready: + assert_eq!(queue.pop_ready(now).map(|p| p.payload), Some(10u32)); + assert!(queue.pop_ready(now).is_none(), "No more entry expected to be ready."); + + queue.wait_ready(now).await; + gum::trace!(target: LOG_TARGET, "After second wait."); + let now = start + Duration::from_millis(3); + assert!(Instant::now() - start >= Duration::from_millis(3)); + assert_eq!(queue.pop_ready(now).map(|p| p.payload), Some(1u32)); + assert!(queue.pop_ready(now).is_none(), "No more entry expected to be ready."); + + // Push in between wait: + poll_fn(|cx| { + let fut = queue.wait_ready(now); + pin_mut!(fut); + assert_matches!(fut.poll(cx), Poll::Pending); + Poll::Ready(()) + }) + .await; + queue.push(PendingWake { payload: 3u32, ready_at: start + Duration::from_millis(4) }); + + queue.wait_ready(now).await; + // Newly pushed element should have become ready: + gum::trace!(target: LOG_TARGET, "After third wait."); + let now = start + Duration::from_millis(4); + assert!(Instant::now() - start >= Duration::from_millis(4)); + assert_eq!(queue.pop_ready(now).map(|p| p.payload), Some(3u32)); + assert!(queue.pop_ready(now).is_none(), "No more entry expected to be ready."); + + queue.wait_ready(now).await; + gum::trace!(target: LOG_TARGET, "After fourth wait."); + let now = start + Duration::from_millis(5); + assert!(Instant::now() - start >= Duration::from_millis(5)); + assert_eq!(queue.pop_ready(now).map(|p| p.payload), Some(2u32)); + assert!(queue.pop_ready(now).is_none(), "No more entry expected to be ready."); + + // queue empty - should wait forever now: + poll_fn(|cx| { + let fut = queue.wait_ready(now); + pin_mut!(fut); + assert_matches!(fut.poll(cx), Poll::Pending); + Poll::Ready(()) + }) + .await; + }); + } +} diff --git a/node/network/dispute-distribution/src/receiver/error.rs b/node/network/dispute-distribution/src/receiver/error.rs index ce578cc8e0f9..4477335440d0 100644 --- a/node/network/dispute-distribution/src/receiver/error.rs +++ b/node/network/dispute-distribution/src/receiver/error.rs @@ -19,8 +19,10 @@ use fatality::Nested; +use gum::CandidateHash; use polkadot_node_network_protocol::{request_response::incoming, PeerId}; use polkadot_node_subsystem_util::runtime; +use polkadot_primitives::v2::AuthorityDiscoveryId; use crate::LOG_TARGET; @@ -35,8 +37,8 @@ pub enum Error { #[error("Retrieving next incoming request failed.")] IncomingRequest(#[from] incoming::Error), - #[error("Sending back response to peer {0} failed.")] - SendResponse(PeerId), + #[error("Sending back response to peers {0:#?} failed.")] + SendResponses(Vec), #[error("Changing peer's ({0}) reputation failed.")] SetPeerReputation(PeerId), @@ -44,16 +46,29 @@ pub enum Error { #[error("Dispute request with invalid signatures, from peer {0}.")] InvalidSignature(PeerId), - #[error("Import of dispute got canceled for peer {0} - import failed for some reason.")] - ImportCanceled(PeerId), + #[error("Received votes from peer {0} have been completely redundant.")] + RedundantMessage(PeerId), + + #[error("Import of dispute got canceled for candidate {0} - import failed for some reason.")] + ImportCanceled(CandidateHash), #[error("Peer {0} attempted to participate in dispute and is not a validator.")] NotAValidator(PeerId), + + #[error("Force flush for batch that could not be found attempted, candidate hash: {0}")] + ForceFlushBatchDoesNotExist(CandidateHash), + + // Should never happen in practice: + #[error("We needed to drop messages, because we reached limit on concurrent batches.")] + MaxBatchLimitReached, + + #[error("Authority {0} sent messages at a too high rate.")] + AuthorityFlooding(AuthorityDiscoveryId), } pub type Result = std::result::Result; -pub type JfyiErrorResult = std::result::Result; +pub type JfyiResult = std::result::Result; /// Utility for eating top level errors and log them. /// diff --git a/node/network/dispute-distribution/src/receiver/mod.rs b/node/network/dispute-distribution/src/receiver/mod.rs index 9193947e78d1..158c66e20655 100644 --- a/node/network/dispute-distribution/src/receiver/mod.rs +++ b/node/network/dispute-distribution/src/receiver/mod.rs @@ -15,20 +15,21 @@ // along with Polkadot. If not, see . use std::{ - collections::HashSet, + num::NonZeroUsize, pin::Pin, task::{Context, Poll}, + time::Duration, }; use futures::{ channel::oneshot, - future::{poll_fn, BoxFuture}, + future::poll_fn, pin_mut, - stream::{FusedStream, FuturesUnordered, StreamExt}, - Future, FutureExt, Stream, + stream::{FuturesUnordered, StreamExt}, + Future, }; -use lru::LruCache; +use gum::CandidateHash; use polkadot_node_network_protocol::{ authority_discovery::AuthorityDiscovery, request_response::{ @@ -51,20 +52,47 @@ use crate::{ }; mod error; -use self::error::{log_error, JfyiError, JfyiErrorResult, Result}; + +/// Rate limiting queues for incoming requests by peers. +mod peer_queues; + +/// Batch imports together. +mod batches; + +use self::{ + batches::{Batches, FoundBatch, PreparedImport}, + error::{log_error, JfyiError, JfyiResult, Result}, + peer_queues::PeerQueues, +}; const COST_INVALID_REQUEST: Rep = Rep::CostMajor("Received message could not be decoded."); const COST_INVALID_SIGNATURE: Rep = Rep::Malicious("Signatures were invalid."); -const COST_INVALID_CANDIDATE: Rep = Rep::Malicious("Reported candidate was not available."); +const COST_INVALID_IMPORT: Rep = + Rep::Malicious("Import was deemed invalid by dispute-coordinator."); const COST_NOT_A_VALIDATOR: Rep = Rep::CostMajor("Reporting peer was not a validator."); +/// Mildly punish peers exceeding their rate limit. +/// +/// For honest peers this should rarely happen, but if it happens we would not want to disconnect +/// too quickly. Minor cost should suffice for disconnecting any real flooder. +const COST_APPARENT_FLOOD: Rep = Rep::CostMinor("Peer exceeded the rate limit."); -/// How many statement imports we want to issue in parallel: -pub const MAX_PARALLEL_IMPORTS: usize = 10; +/// How many votes must have arrived in the last `BATCH_COLLECTING_INTERVAL` +/// +/// in order for a batch to stay alive and not get flushed/imported to the dispute-coordinator. +/// +/// This ensures a timely import of batches. +#[cfg(not(test))] +pub const MIN_KEEP_BATCH_ALIVE_VOTES: u32 = 10; +#[cfg(test)] +pub const MIN_KEEP_BATCH_ALIVE_VOTES: u32 = 2; -/// State for handling incoming `DisputeRequest` messages. +/// Time we allow to pass for new votes to trickle in. /// -/// This is supposed to run as its own task in order to easily impose back pressure on the incoming -/// request channel and at the same time to drop flood messages as fast as possible. +/// See `MIN_KEEP_BATCH_ALIVE_VOTES` above. +/// Should be greater or equal to `RECEIVE_RATE_LIMIT` (there is no point in checking any faster). +pub const BATCH_COLLECTING_INTERVAL: Duration = Duration::from_millis(500); + +/// State for handling incoming `DisputeRequest` messages. pub struct DisputesReceiver { /// Access to session information. runtime: RuntimeInfo, @@ -75,18 +103,17 @@ pub struct DisputesReceiver { /// Channel to retrieve incoming requests from. receiver: IncomingRequestReceiver, + /// Rate limiting queue for each peer (only authorities). + peer_queues: PeerQueues, + + /// Currently active batches of imports per candidate. + batches: Batches, + /// Authority discovery service: authority_discovery: AD, - /// Imports currently being processed. - pending_imports: PendingImports, - - /// We keep record of the last banned peers. - /// - /// This is needed because once we ban a peer, we will very likely still have pending requests - /// in the incoming channel - we should not waste time recovering availability for those, as we - /// already know the peer is malicious. - banned_peers: LruCache, + /// Imports currently being processed by the `dispute-coordinator`. + pending_imports: FuturesUnordered, /// Log received requests. metrics: Metrics, @@ -100,36 +127,24 @@ enum MuxedMessage { /// /// - We need to make sure responses are actually sent (therefore we need to await futures /// promptly). - /// - We need to update `banned_peers` accordingly to the result. - ConfirmedImport(JfyiErrorResult<(PeerId, ImportStatementsResult)>), + /// - We need to punish peers whose import got rejected. + ConfirmedImport(ImportResult), /// A new request has arrived and should be handled. NewRequest(IncomingRequest), -} -impl MuxedMessage { - async fn receive( - pending_imports: &mut PendingImports, - pending_requests: &mut IncomingRequestReceiver, - ) -> Result { - poll_fn(|ctx| { - let next_req = pending_requests.recv(|| vec![COST_INVALID_REQUEST]); - pin_mut!(next_req); - if let Poll::Ready(r) = next_req.poll(ctx) { - return match r { - Err(e) => Poll::Ready(Err(incoming::Error::from(e).into())), - Ok(v) => Poll::Ready(Ok(Self::NewRequest(v))), - } - } - // In case of Ready(None) return `Pending` below - we want to wait for the next request - // in that case. - if let Poll::Ready(Some(v)) = pending_imports.poll_next_unpin(ctx) { - return Poll::Ready(Ok(Self::ConfirmedImport(v))) - } - Poll::Pending - }) - .await - } + /// Rate limit timer hit - is is time to process one row of messages. + /// + /// This is the result of calling `self.peer_queues.pop_reqs()`. + WakePeerQueuesPopReqs(Vec>), + + /// It is time to check batches. + /// + /// Every `BATCH_COLLECTING_INTERVAL` we check whether less than `MIN_KEEP_BATCH_ALIVE_VOTES` + /// new votes arrived, if so the batch is ready for import. + /// + /// This is the result of calling `self.batches.check_batches()`. + WakeCheckBatches(Vec), } impl DisputesReceiver @@ -146,17 +161,17 @@ where ) -> Self { let runtime = RuntimeInfo::new_with_config(runtime::Config { keystore: None, - session_cache_lru_size: DISPUTE_WINDOW.get() as usize, + session_cache_lru_size: NonZeroUsize::new(DISPUTE_WINDOW.get() as usize) + .expect("Dispute window can not be 0; qed"), }); Self { runtime, sender, receiver, + peer_queues: PeerQueues::new(), + batches: Batches::new(), authority_discovery, - pending_imports: PendingImports::new(), - // Size of MAX_PARALLEL_IMPORTS ensures we are going to immediately get rid of any - // malicious requests still pending in the incoming queue. - banned_peers: LruCache::new(MAX_PARALLEL_IMPORTS), + pending_imports: FuturesUnordered::new(), metrics, } } @@ -180,60 +195,132 @@ where } } - /// Actual work happening here. + /// Actual work happening here in three phases: + /// + /// 1. Receive and queue incoming messages until the rate limit timer hits. + /// 2. Do import/batching for the head of all queues. + /// 3. Check and flush any ready batches. async fn run_inner(&mut self) -> Result<()> { - let msg = MuxedMessage::receive(&mut self.pending_imports, &mut self.receiver).await?; + let msg = self.receive_message().await?; - let incoming = match msg { - // We need to clean up futures, to make sure responses are sent: - MuxedMessage::ConfirmedImport(m_bad) => { - self.ban_bad_peer(m_bad)?; - return Ok(()) + match msg { + MuxedMessage::NewRequest(req) => { + // Phase 1: + self.metrics.on_received_request(); + self.dispatch_to_queues(req).await?; }, - MuxedMessage::NewRequest(req) => req, - }; + MuxedMessage::WakePeerQueuesPopReqs(reqs) => { + // Phase 2: + for req in reqs { + // No early return - we cannot cancel imports of one peer, because the import of + // another failed: + match log_error(self.start_import_or_batch(req).await) { + Ok(()) => {}, + Err(fatal) => return Err(fatal.into()), + } + } + }, + MuxedMessage::WakeCheckBatches(ready_imports) => { + // Phase 3: + self.import_ready_batches(ready_imports).await; + }, + MuxedMessage::ConfirmedImport(import_result) => { + self.update_imported_requests_metrics(&import_result); + // Confirm imports to requesters/punish them on invalid imports: + send_responses_to_requesters(import_result).await?; + }, + } + + Ok(()) + } + + /// Receive one `MuxedMessage`. + /// + /// + /// Dispatching events to messages as they happen. + async fn receive_message(&mut self) -> Result { + poll_fn(|ctx| { + // In case of Ready(None), we want to wait for pending requests: + if let Poll::Ready(Some(v)) = self.pending_imports.poll_next_unpin(ctx) { + return Poll::Ready(Ok(MuxedMessage::ConfirmedImport(v?))) + } + + let rate_limited = self.peer_queues.pop_reqs(); + pin_mut!(rate_limited); + // We poll rate_limit before batches, so we don't unnecessarily delay importing to + // batches. + if let Poll::Ready(reqs) = rate_limited.poll(ctx) { + return Poll::Ready(Ok(MuxedMessage::WakePeerQueuesPopReqs(reqs))) + } - self.metrics.on_received_request(); + let ready_batches = self.batches.check_batches(); + pin_mut!(ready_batches); + if let Poll::Ready(ready_batches) = ready_batches.poll(ctx) { + return Poll::Ready(Ok(MuxedMessage::WakeCheckBatches(ready_batches))) + } - let peer = incoming.peer; + let next_req = self.receiver.recv(|| vec![COST_INVALID_REQUEST]); + pin_mut!(next_req); + if let Poll::Ready(r) = next_req.poll(ctx) { + return match r { + Err(e) => Poll::Ready(Err(incoming::Error::from(e).into())), + Ok(v) => Poll::Ready(Ok(MuxedMessage::NewRequest(v))), + } + } + Poll::Pending + }) + .await + } - // Only accept messages from validators: - if self.authority_discovery.get_authority_ids_by_peer_id(peer).await.is_none() { - incoming - .send_outgoing_response(OutgoingResponse { + /// Process incoming requests. + /// + /// - Check sender is authority + /// - Dispatch message to corresponding queue in `peer_queues`. + /// - If queue is full, drop message and change reputation of sender. + async fn dispatch_to_queues(&mut self, req: IncomingRequest) -> JfyiResult<()> { + let peer = req.peer; + // Only accept messages from validators, in case there are multiple `AuthorityId`s, we + // just take the first one. On session boundaries this might allow validators to double + // their rate limit for a short period of time, which seems acceptable. + let authority_id = match self + .authority_discovery + .get_authority_ids_by_peer_id(peer) + .await + .and_then(|s| s.into_iter().next()) + { + None => { + req.send_outgoing_response(OutgoingResponse { result: Err(()), reputation_changes: vec![COST_NOT_A_VALIDATOR], sent_feedback: None, }) - .map_err(|_| JfyiError::SendResponse(peer))?; - - return Err(JfyiError::NotAValidator(peer).into()) - } - - // Immediately drop requests from peers that already have requests in flight or have - // been banned recently (flood protection): - if self.pending_imports.peer_is_pending(&peer) || self.banned_peers.contains(&peer) { - gum::trace!( - target: LOG_TARGET, - ?peer, - "Dropping message from peer (banned/pending import)" - ); - return Ok(()) - } + .map_err(|_| JfyiError::SendResponses(vec![peer]))?; + return Err(JfyiError::NotAValidator(peer).into()) + }, + Some(auth_id) => auth_id, + }; - // Wait for a free slot: - if self.pending_imports.len() >= MAX_PARALLEL_IMPORTS as usize { - // Wait for one to finish: - let r = self.pending_imports.next().await; - self.ban_bad_peer(r.expect("pending_imports.len() is greater 0. qed."))?; + // Queue request: + if let Err((authority_id, req)) = self.peer_queues.push_req(authority_id, req) { + req.send_outgoing_response(OutgoingResponse { + result: Err(()), + reputation_changes: vec![COST_APPARENT_FLOOD], + sent_feedback: None, + }) + .map_err(|_| JfyiError::SendResponses(vec![peer]))?; + return Err(JfyiError::AuthorityFlooding(authority_id)) } - - // All good - initiate import. - self.start_import(incoming).await + Ok(()) } - /// Start importing votes for the given request. - async fn start_import(&mut self, incoming: IncomingRequest) -> Result<()> { + /// Start importing votes for the given request or batch. + /// + /// Signature check and in case we already have an existing batch we import to that batch, + /// otherwise import to `dispute-coordinator` directly and open a batch. + async fn start_import_or_batch( + &mut self, + incoming: IncomingRequest, + ) -> Result<()> { let IncomingRequest { peer, payload, pending_response } = incoming; let info = self @@ -263,128 +350,172 @@ where Ok(votes) => votes, }; - let (pending_confirmation, confirmation_rx) = oneshot::channel(); - self.sender - .send_message(DisputeCoordinatorMessage::ImportStatements { - candidate_receipt, - session: valid_vote.0.session_index(), - statements: vec![valid_vote, invalid_vote], - pending_confirmation: Some(pending_confirmation), - }) - .await; + let candidate_hash = *valid_vote.0.candidate_hash(); + + match self.batches.find_batch(candidate_hash, candidate_receipt)? { + FoundBatch::Created(batch) => { + // There was no entry yet - start import immediately: + gum::trace!( + target: LOG_TARGET, + ?candidate_hash, + ?peer, + "No batch yet - triggering immediate import" + ); + let import = PreparedImport { + candidate_receipt: batch.candidate_receipt().clone(), + statements: vec![valid_vote, invalid_vote], + requesters: vec![(peer, pending_response)], + }; + self.start_import(import).await; + }, + FoundBatch::Found(batch) => { + gum::trace!(target: LOG_TARGET, ?candidate_hash, "Batch exists - batching request"); + let batch_result = + batch.add_votes(valid_vote, invalid_vote, peer, pending_response); + + if let Err(pending_response) = batch_result { + // We don't expect honest peers to send redundant votes within a single batch, + // as the timeout for retry is much higher. Still we don't want to punish the + // node as it might not be the node's fault. Some other (malicious) node could have been + // faster sending the same votes in order to harm the reputation of that honest + // node. Given that we already have a rate limit, if a validator chooses to + // waste available rate with redundant votes - so be it. The actual dispute + // resolution is unaffected. + gum::debug!( + target: LOG_TARGET, + ?peer, + "Peer sent completely redundant votes within a single batch - that looks fishy!", + ); + pending_response + .send_outgoing_response(OutgoingResponse { + // While we have seen duplicate votes, we cannot confirm as we don't + // know yet whether the batch is going to be confirmed, so we assume + // the worst. We don't want to push the pending response to the batch + // either as that would be unbounded, only limited by the rate limit. + result: Err(()), + reputation_changes: Vec::new(), + sent_feedback: None, + }) + .map_err(|_| JfyiError::SendResponses(vec![peer]))?; + return Err(From::from(JfyiError::RedundantMessage(peer))) + } + }, + } - self.pending_imports.push(peer, confirmation_rx, pending_response); Ok(()) } - /// Await an import and ban any misbehaving peers. - /// - /// In addition we report import metrics. - fn ban_bad_peer( - &mut self, - result: JfyiErrorResult<(PeerId, ImportStatementsResult)>, - ) -> JfyiErrorResult<()> { - match result? { - (_, ImportStatementsResult::ValidImport) => { - self.metrics.on_imported(SUCCEEDED); - }, - (bad_peer, ImportStatementsResult::InvalidImport) => { - self.metrics.on_imported(FAILED); - self.banned_peers.put(bad_peer, ()); - }, + /// Trigger import into the dispute-coordinator of ready batches (`PreparedImport`s). + async fn import_ready_batches(&mut self, ready_imports: Vec) { + for import in ready_imports { + self.start_import(import).await; } - Ok(()) } -} -/// Manage pending imports in a way that preserves invariants. -struct PendingImports { - /// Futures in flight. - futures: - FuturesUnordered)>>, - /// Peers whose requests are currently in flight. - peers: HashSet, -} + /// Start import and add response receiver to `pending_imports`. + async fn start_import(&mut self, import: PreparedImport) { + let PreparedImport { candidate_receipt, statements, requesters } = import; + let (session_index, candidate_hash) = match statements.iter().next() { + None => { + gum::debug!( + target: LOG_TARGET, + candidate_hash = ?candidate_receipt.hash(), + "Not importing empty batch" + ); + return + }, + Some(vote) => (vote.0.session_index(), vote.0.candidate_hash().clone()), + }; -impl PendingImports { - pub fn new() -> Self { - Self { futures: FuturesUnordered::new(), peers: HashSet::new() } - } + let (pending_confirmation, confirmation_rx) = oneshot::channel(); + self.sender + .send_message(DisputeCoordinatorMessage::ImportStatements { + candidate_receipt, + session: session_index, + statements, + pending_confirmation: Some(pending_confirmation), + }) + .await; - pub fn push( - &mut self, - peer: PeerId, - handled: oneshot::Receiver, - pending_response: OutgoingResponseSender, - ) { - self.peers.insert(peer); - self.futures.push( - async move { - let r = respond_to_request(peer, handled, pending_response).await; - (peer, r) - } - .boxed(), - ) - } + let pending = + PendingImport { candidate_hash, requesters, pending_response: confirmation_rx }; - /// Returns the number of contained futures. - pub fn len(&self) -> usize { - self.futures.len() + self.pending_imports.push(pending); } - /// Check whether a peer has a pending import. - pub fn peer_is_pending(&self, peer: &PeerId) -> bool { - self.peers.contains(peer) + fn update_imported_requests_metrics(&self, result: &ImportResult) { + let label = match result.result { + ImportStatementsResult::ValidImport => SUCCEEDED, + ImportStatementsResult::InvalidImport => FAILED, + }; + self.metrics.on_imported(label, result.requesters.len()); } } -impl Stream for PendingImports { - type Item = JfyiErrorResult<(PeerId, ImportStatementsResult)>; - fn poll_next(mut self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll> { - match Pin::new(&mut self.futures).poll_next(ctx) { - Poll::Pending => Poll::Pending, - Poll::Ready(None) => Poll::Ready(None), - Poll::Ready(Some((peer, result))) => { - self.peers.remove(&peer); - Poll::Ready(Some(result.map(|r| (peer, r)))) - }, - } - } -} -impl FusedStream for PendingImports { - fn is_terminated(&self) -> bool { - self.futures.is_terminated() - } -} +async fn send_responses_to_requesters(import_result: ImportResult) -> JfyiResult<()> { + let ImportResult { requesters, result } = import_result; -// Future for `PendingImports` -// -// - Wait for import -// - Punish peer -// - Deliver result -async fn respond_to_request( - peer: PeerId, - handled: oneshot::Receiver, - pending_response: OutgoingResponseSender, -) -> JfyiErrorResult { - let result = handled.await.map_err(|_| JfyiError::ImportCanceled(peer))?; - - let response = match result { - ImportStatementsResult::ValidImport => OutgoingResponse { + let mk_response = match result { + ImportStatementsResult::ValidImport => || OutgoingResponse { result: Ok(DisputeResponse::Confirmed), reputation_changes: Vec::new(), sent_feedback: None, }, - ImportStatementsResult::InvalidImport => OutgoingResponse { + ImportStatementsResult::InvalidImport => || OutgoingResponse { result: Err(()), - reputation_changes: vec![COST_INVALID_CANDIDATE], + reputation_changes: vec![COST_INVALID_IMPORT], sent_feedback: None, }, }; - pending_response - .send_outgoing_response(response) - .map_err(|_| JfyiError::SendResponse(peer))?; + let mut sending_failed_for = Vec::new(); + for (peer, pending_response) in requesters { + if let Err(()) = pending_response.send_outgoing_response(mk_response()) { + sending_failed_for.push(peer); + } + } + + if !sending_failed_for.is_empty() { + Err(JfyiError::SendResponses(sending_failed_for)) + } else { + Ok(()) + } +} - Ok(result) +/// A future that resolves into an `ImportResult` when ready. +/// +/// This future is used on `dispute-coordinator` import messages for the oneshot response receiver +/// to: +/// - Keep track of concerned `CandidateHash` for reporting errors. +/// - Keep track of requesting peers so we can confirm the import/punish them on invalid imports. +struct PendingImport { + candidate_hash: CandidateHash, + requesters: Vec<(PeerId, OutgoingResponseSender)>, + pending_response: oneshot::Receiver, +} + +/// A `PendingImport` becomes an `ImportResult` once done. +struct ImportResult { + /// Requesters of that import. + requesters: Vec<(PeerId, OutgoingResponseSender)>, + /// Actual result of the import. + result: ImportStatementsResult, +} + +impl PendingImport { + async fn wait_for_result(&mut self) -> JfyiResult { + let result = (&mut self.pending_response) + .await + .map_err(|_| JfyiError::ImportCanceled(self.candidate_hash))?; + Ok(ImportResult { requesters: std::mem::take(&mut self.requesters), result }) + } +} + +impl Future for PendingImport { + type Output = JfyiResult; + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + let fut = self.wait_for_result(); + pin_mut!(fut); + fut.poll(cx) + } } diff --git a/node/network/dispute-distribution/src/receiver/peer_queues.rs b/node/network/dispute-distribution/src/receiver/peer_queues.rs new file mode 100644 index 000000000000..138b59c3f867 --- /dev/null +++ b/node/network/dispute-distribution/src/receiver/peer_queues.rs @@ -0,0 +1,141 @@ +// Copyright 2022 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 . + +use std::collections::{hash_map::Entry, HashMap, VecDeque}; + +use futures::future::pending; +use futures_timer::Delay; +use polkadot_node_network_protocol::request_response::{v1::DisputeRequest, IncomingRequest}; +use polkadot_primitives::v2::AuthorityDiscoveryId; + +use crate::RECEIVE_RATE_LIMIT; + +/// How many messages we are willing to queue per peer (validator). +/// +/// The larger this value is, the larger bursts are allowed to be without us dropping messages. On +/// the flip side this gets allocated per validator, so for a size of 10 this will result +/// in `10_000 * size_of(IncomingRequest)` in the worst case. +/// +/// `PEER_QUEUE_CAPACITY` must not be 0 for obvious reasons. +#[cfg(not(test))] +pub const PEER_QUEUE_CAPACITY: usize = 10; +#[cfg(test)] +pub const PEER_QUEUE_CAPACITY: usize = 2; + +/// Queues for messages from authority peers for rate limiting. +/// +/// Invariants ensured: +/// +/// 1. No queue will ever have more than `PEER_QUEUE_CAPACITY` elements. +/// 2. There are no empty queues. Whenever a queue gets empty, it is removed. This way checking +/// whether there are any messages queued is cheap. +/// 3. As long as not empty, `pop_reqs` will, if called in sequence, not return `Ready` more often +/// than once for every `RECEIVE_RATE_LIMIT`, but it will always return Ready eventually. +/// 4. If empty `pop_reqs` will never return `Ready`, but will always be `Pending`. +pub struct PeerQueues { + /// Actual queues. + queues: HashMap>>, + + /// Delay timer for establishing the rate limit. + rate_limit_timer: Option, +} + +impl PeerQueues { + /// New empty `PeerQueues`. + pub fn new() -> Self { + Self { queues: HashMap::new(), rate_limit_timer: None } + } + + /// Push an incoming request for a given authority. + /// + /// Returns: `Ok(())` if succeeded, `Err((args))` if capacity is reached. + pub fn push_req( + &mut self, + peer: AuthorityDiscoveryId, + req: IncomingRequest, + ) -> Result<(), (AuthorityDiscoveryId, IncomingRequest)> { + let queue = match self.queues.entry(peer) { + Entry::Vacant(vacant) => vacant.insert(VecDeque::new()), + Entry::Occupied(occupied) => { + if occupied.get().len() >= PEER_QUEUE_CAPACITY { + return Err((occupied.key().clone(), req)) + } + occupied.into_mut() + }, + }; + queue.push_back(req); + + // We have at least one element to process - rate limit `timer` needs to exist now: + self.ensure_timer(); + Ok(()) + } + + /// Pop all heads and return them for processing. + /// + /// This gets one message from each peer that has sent at least one. + /// + /// This function is rate limited, if called in sequence it will not return more often than + /// every `RECEIVE_RATE_LIMIT`. + /// + /// NOTE: If empty this function will not return `Ready` at all, but will always be `Pending`. + pub async fn pop_reqs(&mut self) -> Vec> { + self.wait_for_timer().await; + + let mut heads = Vec::with_capacity(self.queues.len()); + let old_queues = std::mem::replace(&mut self.queues, HashMap::new()); + for (k, mut queue) in old_queues.into_iter() { + let front = queue.pop_front(); + debug_assert!(front.is_some(), "Invariant that queues are never empty is broken."); + + if let Some(front) = front { + heads.push(front); + } + if !queue.is_empty() { + self.queues.insert(k, queue); + } + } + + if !self.is_empty() { + // Still not empty - we should get woken at some point. + self.ensure_timer(); + } + + heads + } + + /// Whether or not all queues are empty. + pub fn is_empty(&self) -> bool { + self.queues.is_empty() + } + + /// Ensure there is an active `timer`. + /// + /// Checks whether one exists and if not creates one. + fn ensure_timer(&mut self) -> &mut Delay { + self.rate_limit_timer.get_or_insert(Delay::new(RECEIVE_RATE_LIMIT)) + } + + /// Wait for `timer` if it exists, or be `Pending` forever. + /// + /// Afterwards it gets set back to `None`. + async fn wait_for_timer(&mut self) { + match self.rate_limit_timer.as_mut() { + None => pending().await, + Some(timer) => timer.await, + } + self.rate_limit_timer = None; + } +} diff --git a/node/network/dispute-distribution/src/sender/mod.rs b/node/network/dispute-distribution/src/sender/mod.rs index 5312528b413e..09b902173ede 100644 --- a/node/network/dispute-distribution/src/sender/mod.rs +++ b/node/network/dispute-distribution/src/sender/mod.rs @@ -14,10 +14,21 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use std::collections::{hash_map::Entry, HashMap, HashSet}; - -use futures::channel::{mpsc, oneshot}; - +use std::{ + collections::{HashMap, HashSet}, + pin::Pin, + task::Poll, + time::Duration, +}; + +use futures::{ + channel::{mpsc, oneshot}, + future::poll_fn, + Future, +}; + +use futures_timer::Delay; +use indexmap::{map::Entry, IndexMap}; use polkadot_node_network_protocol::request_response::v1::DisputeRequest; use polkadot_node_primitives::{CandidateVotes, DisputeMessage, SignedDisputeStatement}; use polkadot_node_subsystem::{messages::DisputeCoordinatorMessage, overseer, ActiveLeavesUpdate}; @@ -28,22 +39,27 @@ use polkadot_primitives::v2::{CandidateHash, DisputeStatement, Hash, SessionInde /// /// It is going to spawn real tasks as it sees fit for getting the votes of the particular dispute /// out. +/// +/// As we assume disputes have a priority, we start sending for disputes in the order +/// `start_sender` got called. mod send_task; use send_task::SendTask; pub use send_task::TaskFinish; -/// Error and [`Result`] type for sender +/// Error and [`Result`] type for sender. mod error; pub use error::{Error, FatalError, JfyiError, Result}; use self::error::JfyiErrorResult; -use crate::{Metrics, LOG_TARGET}; +use crate::{Metrics, LOG_TARGET, SEND_RATE_LIMIT}; /// The `DisputeSender` keeps track of all ongoing disputes we need to send statements out. /// /// For each dispute a `SendTask` is responsible for sending to the concerned validators for that /// particular dispute. The `DisputeSender` keeps track of those tasks, informs them about new /// sessions/validator sets and cleans them up when they become obsolete. +/// +/// The unit of work for the `DisputeSender` is a dispute, represented by `SendTask`s. pub struct DisputeSender { /// All heads we currently consider active. active_heads: Vec, @@ -54,11 +70,16 @@ pub struct DisputeSender { active_sessions: HashMap, /// All ongoing dispute sendings this subsystem is aware of. - disputes: HashMap, + /// + /// Using an `IndexMap` so items can be iterated in the order of insertion. + disputes: IndexMap, /// Sender to be cloned for `SendTask`s. tx: mpsc::Sender, + /// Future for delaying too frequent creation of dispute sending tasks. + rate_limit: RateLimit, + /// Metrics for reporting stats about sent requests. metrics: Metrics, } @@ -70,19 +91,25 @@ impl DisputeSender { Self { active_heads: Vec::new(), active_sessions: HashMap::new(), - disputes: HashMap::new(), + disputes: IndexMap::new(), tx, + rate_limit: RateLimit::new(), metrics, } } /// Create a `SendTask` for a particular new dispute. + /// + /// This function is rate-limited by `SEND_RATE_LIMIT`. It will block if called too frequently + /// in order to maintain the limit. pub async fn start_sender( &mut self, ctx: &mut Context, runtime: &mut RuntimeInfo, msg: DisputeMessage, ) -> Result<()> { + self.rate_limit.limit().await; + let req: DisputeRequest = msg.into(); let candidate_hash = req.0.candidate_receipt.hash(); match self.disputes.entry(candidate_hash) { @@ -112,6 +139,8 @@ impl DisputeSender { /// - Get new authorities to send messages to. /// - Get rid of obsolete tasks and disputes. /// - Get dispute sending started in case we missed one for some reason (e.g. on node startup) + /// + /// This function ensures the `SEND_RATE_LIMIT`, therefore it might block. pub async fn update_leaves( &mut self, ctx: &mut Context, @@ -134,21 +163,38 @@ impl DisputeSender { let active_disputes: HashSet<_> = active_disputes.into_iter().map(|(_, c)| c).collect(); - // Cleanup obsolete senders: + // Cleanup obsolete senders (retain keeps order of remaining elements): self.disputes .retain(|candidate_hash, _| active_disputes.contains(candidate_hash)); + // Iterates in order of insertion: + let mut should_rate_limit = true; for dispute in self.disputes.values_mut() { if have_new_sessions || dispute.has_failed_sends() { - dispute + if should_rate_limit { + self.rate_limit.limit().await; + } + let sends_happened = dispute .refresh_sends(ctx, runtime, &self.active_sessions, &self.metrics) .await?; + // Only rate limit if we actually sent something out _and_ it was not just because + // of errors on previous sends. + // + // Reasoning: It would not be acceptable to slow down the whole subsystem, just + // because of a few bad peers having problems. It is actually better to risk + // running into their rate limit in that case and accept a minor reputation change. + should_rate_limit = sends_happened && have_new_sessions; } } - // This should only be non-empty on startup, but if not - we got you covered: + // This should only be non-empty on startup, but if not - we got you covered. + // + // Initial order will not be maintained in that case, but that should be fine as disputes + // recovered at startup will be relatively "old" anyway and we assume that no more than a + // third of the validators will go offline at any point in time anyway. for dispute in unknown_disputes { - self.start_send_for_dispute(ctx, runtime, dispute).await? + self.rate_limit.limit().await; + self.start_send_for_dispute(ctx, runtime, dispute).await?; } Ok(()) } @@ -317,6 +363,46 @@ impl DisputeSender { } } +/// Rate limiting logic. +/// +/// Suitable for the sending side. +struct RateLimit { + limit: Delay, +} + +impl RateLimit { + /// Create new `RateLimit` that is immediately ready. + fn new() -> Self { + // Start with an empty duration, as there has not been any previous call. + Self { limit: Delay::new(Duration::new(0, 0)) } + } + + /// Initialized with actual `SEND_RATE_LIMIT` duration. + fn new_limit() -> Self { + Self { limit: Delay::new(SEND_RATE_LIMIT) } + } + + /// Wait until ready and prepare for next call. + async fn limit(&mut self) { + // Wait for rate limit and add some logging: + poll_fn(|cx| { + let old_limit = Pin::new(&mut self.limit); + match old_limit.poll(cx) { + Poll::Pending => { + gum::debug!( + target: LOG_TARGET, + "Sending rate limit hit, slowing down requests" + ); + Poll::Pending + }, + Poll::Ready(()) => Poll::Ready(()), + } + }) + .await; + *self = Self::new_limit(); + } +} + /// Retrieve the currently active sessions. /// /// List is all indices of all active sessions together with the head that was used for the query. diff --git a/node/network/dispute-distribution/src/sender/send_task.rs b/node/network/dispute-distribution/src/sender/send_task.rs index a2b8cdcf7441..89b5c099bde9 100644 --- a/node/network/dispute-distribution/src/sender/send_task.rs +++ b/node/network/dispute-distribution/src/sender/send_task.rs @@ -42,13 +42,15 @@ use crate::{ /// Delivery status for a particular dispute. /// /// Keeps track of all the validators that have to be reached for a dispute. +/// +/// The unit of work for a `SendTask` is an authority/validator. pub struct SendTask { - /// The request we are supposed to get out to all parachain validators of the dispute's session + /// The request we are supposed to get out to all `parachain` validators of the dispute's session /// and to all current authorities. request: DisputeRequest, /// The set of authorities we need to send our messages to. This set will change at session - /// boundaries. It will always be at least the parachain validators of the session where the + /// boundaries. It will always be at least the `parachain` validators of the session where the /// dispute happened and the authorities of the current sessions as determined by active heads. deliveries: HashMap, @@ -100,6 +102,10 @@ impl TaskResult { #[overseer::contextbounds(DisputeDistribution, prefix = self::overseer)] impl SendTask { /// Initiates sending a dispute message to peers. + /// + /// Creation of new `SendTask`s is subject to rate limiting. As each `SendTask` will trigger + /// sending a message to each validator, hence for employing a per-peer rate limit, we need to + /// limit the construction of new `SendTask`s. pub async fn new( ctx: &mut Context, runtime: &mut RuntimeInfo, @@ -118,15 +124,22 @@ impl SendTask { /// /// This function is called at construction and should also be called whenever a session change /// happens and on a regular basis to ensure we are retrying failed attempts. + /// + /// This might resend to validators and is thus subject to any rate limiting we might want. + /// Calls to this function for different instances should be rate limited according to + /// `SEND_RATE_LIMIT`. + /// + /// Returns: `True` if this call resulted in new requests. pub async fn refresh_sends( &mut self, ctx: &mut Context, runtime: &mut RuntimeInfo, active_sessions: &HashMap, metrics: &Metrics, - ) -> Result<()> { + ) -> Result { let new_authorities = self.get_relevant_validators(ctx, runtime, active_sessions).await?; + // Note this will also contain all authorities for which sending failed previously: let add_authorities = new_authorities .iter() .filter(|a| !self.deliveries.contains_key(a)) @@ -141,12 +154,14 @@ impl SendTask { send_requests(ctx, self.tx.clone(), add_authorities, self.request.clone(), metrics) .await?; + let was_empty = new_statuses.is_empty(); + self.has_failed_sends = false; self.deliveries.extend(new_statuses.into_iter()); - Ok(()) + Ok(!was_empty) } - /// Whether any sends have failed since the last refreshed. + /// Whether any sends have failed since the last refresh. pub fn has_failed_sends(&self) -> bool { self.has_failed_sends } @@ -193,9 +208,8 @@ impl SendTask { /// Determine all validators that should receive the given dispute requests. /// - /// This is all parachain validators of the session the candidate occurred and all authorities + /// This is all `parachain` validators of the session the candidate occurred and all authorities /// of all currently active sessions, determined by currently active heads. - async fn get_relevant_validators( &self, ctx: &mut Context, @@ -293,7 +307,7 @@ async fn wait_response_task( gum::debug!( target: LOG_TARGET, %err, - "Failed to notify susystem about dispute sending result." + "Failed to notify subsystem about dispute sending result." ); } } diff --git a/node/network/dispute-distribution/src/tests/mock.rs b/node/network/dispute-distribution/src/tests/mock.rs index 08428d5852cc..aa2a4485d480 100644 --- a/node/network/dispute-distribution/src/tests/mock.rs +++ b/node/network/dispute-distribution/src/tests/mock.rs @@ -20,6 +20,7 @@ use std::{ collections::{HashMap, HashSet}, sync::Arc, + time::Instant, }; use async_trait::async_trait; @@ -38,6 +39,8 @@ use polkadot_primitives::v2::{ }; use polkadot_primitives_test_helpers::dummy_candidate_descriptor; +use crate::LOG_TARGET; + pub const MOCK_SESSION_INDEX: SessionIndex = 1; pub const MOCK_NEXT_SESSION_INDEX: SessionIndex = 2; pub const MOCK_VALIDATORS: [Sr25519Keyring; 6] = [ @@ -54,6 +57,8 @@ pub const MOCK_AUTHORITIES_NEXT_SESSION: [Sr25519Keyring; 2] = pub const FERDIE_INDEX: ValidatorIndex = ValidatorIndex(0); pub const ALICE_INDEX: ValidatorIndex = ValidatorIndex(1); +pub const BOB_INDEX: ValidatorIndex = ValidatorIndex(2); +pub const CHARLIE_INDEX: ValidatorIndex = ValidatorIndex(3); lazy_static! { @@ -148,12 +153,22 @@ pub async fn make_dispute_message( invalid_validator: ValidatorIndex, ) -> DisputeMessage { let candidate_hash = candidate.hash(); + let before_request = Instant::now(); let valid_vote = make_explicit_signed(MOCK_VALIDATORS[valid_validator.0 as usize], candidate_hash, true) .await; + gum::trace!( + "Passed time for valid vote: {:#?}", + Instant::now().saturating_duration_since(before_request) + ); + let before_request = Instant::now(); let invalid_vote = make_explicit_signed(MOCK_VALIDATORS[invalid_validator.0 as usize], candidate_hash, false) .await; + gum::trace!( + "Passed time for invald vote: {:#?}", + Instant::now().saturating_duration_since(before_request) + ); DisputeMessage::from_signed_statements( valid_vote, valid_validator, @@ -206,10 +221,15 @@ impl AuthorityDiscovery for MockAuthorityDiscovery { ) -> Option> { for (a, p) in self.peer_ids.iter() { if p == &peer_id { - return Some(HashSet::from([MOCK_VALIDATORS_DISCOVERY_KEYS - .get(&a) - .unwrap() - .clone()])) + let result = + HashSet::from([MOCK_VALIDATORS_DISCOVERY_KEYS.get(&a).unwrap().clone()]); + gum::trace!( + target: LOG_TARGET, + %peer_id, + ?result, + "Returning authority ids for peer id" + ); + return Some(result) } } diff --git a/node/network/dispute-distribution/src/tests/mod.rs b/node/network/dispute-distribution/src/tests/mod.rs index 8ef8286ea197..56cdd467fd62 100644 --- a/node/network/dispute-distribution/src/tests/mod.rs +++ b/node/network/dispute-distribution/src/tests/mod.rs @@ -17,12 +17,17 @@ //! Subsystem unit tests -use std::{collections::HashSet, sync::Arc, task::Poll, time::Duration}; +use std::{ + collections::HashSet, + sync::Arc, + task::Poll, + time::{Duration, Instant}, +}; use assert_matches::assert_matches; use futures::{ channel::{mpsc, oneshot}, - future::poll_fn, + future::{poll_fn, ready}, pin_mut, Future, SinkExt, }; use futures_timer::Delay; @@ -52,7 +57,7 @@ use polkadot_node_subsystem_test_helpers::{ mock::make_ferdie_keystore, subsystem_test_harness, TestSubsystemContextHandle, }; use polkadot_primitives::v2::{ - AuthorityDiscoveryId, CandidateHash, Hash, SessionIndex, SessionInfo, + AuthorityDiscoveryId, CandidateHash, CandidateReceipt, Hash, SessionIndex, SessionInfo, }; use self::mock::{ @@ -60,7 +65,11 @@ use self::mock::{ MOCK_AUTHORITY_DISCOVERY, MOCK_NEXT_SESSION_INDEX, MOCK_NEXT_SESSION_INFO, MOCK_SESSION_INDEX, MOCK_SESSION_INFO, }; -use crate::{DisputeDistributionSubsystem, Metrics, LOG_TARGET}; +use crate::{ + receiver::BATCH_COLLECTING_INTERVAL, + tests::mock::{BOB_INDEX, CHARLIE_INDEX}, + DisputeDistributionSubsystem, Metrics, LOG_TARGET, SEND_RATE_LIMIT, +}; /// Useful mock providers. pub mod mock; @@ -72,49 +81,108 @@ fn send_dispute_sends_dispute() { let relay_parent = Hash::random(); let candidate = make_candidate_receipt(relay_parent); - let message = make_dispute_message(candidate.clone(), ALICE_INDEX, FERDIE_INDEX).await; - handle - .send(FromOrchestra::Communication { - msg: DisputeDistributionMessage::SendDispute(message.clone()), - }) - .await; + send_dispute(&mut handle, candidate, true).await; + conclude(&mut handle).await; + }; + test_harness(test); +} + +#[test] +fn send_honors_rate_limit() { + sp_tracing::try_init_simple(); + let test = |mut handle: TestSubsystemContextHandle, _req_cfg| async move { + let _ = handle_subsystem_startup(&mut handle, None).await; + + let relay_parent = Hash::random(); + let candidate = make_candidate_receipt(relay_parent); + let before_request = Instant::now(); + send_dispute(&mut handle, candidate, true).await; + // First send should not be rate limited: + gum::trace!("Passed time: {:#?}", Instant::now().saturating_duration_since(before_request)); + // This test would likely be flaky on CI: + //assert!(Instant::now().saturating_duration_since(before_request) < SEND_RATE_LIMIT); + + let relay_parent = Hash::random(); + let candidate = make_candidate_receipt(relay_parent); + send_dispute(&mut handle, candidate, false).await; + // Second send should be rate limited: + gum::trace!( + "Passed time for send_dispute: {:#?}", + Instant::now().saturating_duration_since(before_request) + ); + assert!(Instant::now() - before_request >= SEND_RATE_LIMIT); + conclude(&mut handle).await; + }; + test_harness(test); +} + +/// Helper for sending a new dispute to dispute-distribution sender and handling resulting messages. +async fn send_dispute( + handle: &mut TestSubsystemContextHandle, + candidate: CandidateReceipt, + needs_session_info: bool, +) { + let before_request = Instant::now(); + let message = make_dispute_message(candidate.clone(), ALICE_INDEX, FERDIE_INDEX).await; + gum::trace!( + "Passed time for making message: {:#?}", + Instant::now().saturating_duration_since(before_request) + ); + let before_request = Instant::now(); + handle + .send(FromOrchestra::Communication { + msg: DisputeDistributionMessage::SendDispute(message.clone()), + }) + .await; + gum::trace!( + "Passed time for sending message: {:#?}", + Instant::now().saturating_duration_since(before_request) + ); + if needs_session_info { // Requests needed session info: assert_matches!( - handle.recv().await, - AllMessages::RuntimeApi( - RuntimeApiMessage::Request( - hash, - RuntimeApiRequest::SessionInfo(session_index, tx) + handle.recv().await, + AllMessages::RuntimeApi( + RuntimeApiMessage::Request( + hash, + RuntimeApiRequest::SessionInfo(session_index, tx) ) ) => { - assert_eq!(session_index, MOCK_SESSION_INDEX); - assert_eq!( - hash, - message.candidate_receipt().descriptor.relay_parent + assert_eq!(session_index, MOCK_SESSION_INDEX); + assert_eq!( + hash, + message.candidate_receipt().descriptor.relay_parent ); - tx.send(Ok(Some(MOCK_SESSION_INFO.clone()))).expect("Receiver should stay alive."); - } + tx.send(Ok(Some(MOCK_SESSION_INFO.clone()))).expect("Receiver should stay alive."); + } ); + } - let expected_receivers = { - let info = &MOCK_SESSION_INFO; - info.discovery_keys - .clone() - .into_iter() - .filter(|a| a != &Sr25519Keyring::Ferdie.public().into()) - .collect() - // All validators are also authorities in the first session, so we are - // done here. - }; - check_sent_requests(&mut handle, expected_receivers, true).await; - - conclude(&mut handle).await; + let expected_receivers = { + let info = &MOCK_SESSION_INFO; + info.discovery_keys + .clone() + .into_iter() + .filter(|a| a != &Sr25519Keyring::Ferdie.public().into()) + .collect() + // All validators are also authorities in the first session, so we are + // done here. }; - test_harness(test); + check_sent_requests(handle, expected_receivers, true).await; } +// Things to test: +// x Request triggers import +// x Subsequent imports get batched +// x Batch gets flushed. +// x Batch gets renewed. +// x Non authority requests get dropped. +// x Sending rate limit is honored. +// x Receiving rate limit is honored. +// x Duplicate requests on batch are dropped + #[test] -fn received_request_triggers_import() { +fn received_non_authorities_are_dropped() { let test = |mut handle: TestSubsystemContextHandle, mut req_cfg: RequestResponseConfig| async move { let req_tx = req_cfg.inbound_queue.as_mut().unwrap(); @@ -140,110 +208,271 @@ fn received_request_triggers_import() { assert_eq!(reputation_changes.len(), 1); } ); + conclude(&mut handle).await; + }; + test_harness(test); +} + +#[test] +fn received_request_triggers_import() { + let test = |mut handle: TestSubsystemContextHandle, + mut req_cfg: RequestResponseConfig| async move { + let req_tx = req_cfg.inbound_queue.as_mut().unwrap(); + let _ = handle_subsystem_startup(&mut handle, None).await; + + let relay_parent = Hash::random(); + let candidate = make_candidate_receipt(relay_parent); + let message = make_dispute_message(candidate.clone(), ALICE_INDEX, FERDIE_INDEX).await; - // Nested valid and invalid import. - // - // Nested requests from same peer should get dropped. For the invalid request even - // subsequent requests should get dropped. nested_network_dispute_request( &mut handle, req_tx, MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Alice), message.clone().into(), - ImportStatementsResult::InvalidImport, + ImportStatementsResult::ValidImport, true, - move |handle, req_tx, message| { - nested_network_dispute_request( - handle, - req_tx, - MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Bob), - message.clone().into(), - ImportStatementsResult::ValidImport, - false, - move |_, req_tx, message| async move { - // Another request from Alice should get dropped (request already in - // flight): - { - let rx_response = send_network_dispute_request( - req_tx, - MOCK_AUTHORITY_DISCOVERY - .get_peer_id_by_authority(Sr25519Keyring::Alice), - message.clone(), - ) - .await; - - assert_matches!( - rx_response.await, - Err(err) => { - gum::trace!( - target: LOG_TARGET, - ?err, - "Request got dropped - other request already in flight" - ); - } - ); - } - // Another request from Bob should get dropped (request already in - // flight): - { - let rx_response = send_network_dispute_request( - req_tx, - MOCK_AUTHORITY_DISCOVERY - .get_peer_id_by_authority(Sr25519Keyring::Bob), - message.clone(), - ) - .await; - - assert_matches!( - rx_response.await, - Err(err) => { - gum::trace!( - target: LOG_TARGET, - ?err, - "Request got dropped - other request already in flight" - ); - } - ); - } - }, - ) - }, + move |_handle, _req_tx, _message| ready(()), ) .await; - // Subsequent sends from Alice should fail (peer is banned): - { - let rx_response = send_network_dispute_request( - req_tx, - MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Alice), - message.clone().into(), - ) - .await; + gum::trace!(target: LOG_TARGET, "Concluding."); + conclude(&mut handle).await; + }; + test_harness(test); +} + +#[test] +fn batching_works() { + let test = |mut handle: TestSubsystemContextHandle, + mut req_cfg: RequestResponseConfig| async move { + let req_tx = req_cfg.inbound_queue.as_mut().unwrap(); + let _ = handle_subsystem_startup(&mut handle, None).await; + + let relay_parent = Hash::random(); + let candidate = make_candidate_receipt(relay_parent); + let message = make_dispute_message(candidate.clone(), ALICE_INDEX, FERDIE_INDEX).await; + + // Initial request should get forwarded immediately: + nested_network_dispute_request( + &mut handle, + req_tx, + MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Alice), + message.clone().into(), + ImportStatementsResult::ValidImport, + true, + move |_handle, _req_tx, _message| ready(()), + ) + .await; + let mut rx_responses = Vec::new(); + + let message = make_dispute_message(candidate.clone(), BOB_INDEX, FERDIE_INDEX).await; + let peer = MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Bob); + rx_responses.push(send_network_dispute_request(req_tx, peer, message.clone().into()).await); + + let message = make_dispute_message(candidate.clone(), CHARLIE_INDEX, FERDIE_INDEX).await; + let peer = MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Charlie); + rx_responses.push(send_network_dispute_request(req_tx, peer, message.clone().into()).await); + gum::trace!("Imported 3 votes into batch"); + + Delay::new(BATCH_COLLECTING_INTERVAL).await; + gum::trace!("Batch should still be alive"); + // Batch should still be alive (2 new votes): + // Let's import two more votes, but fully duplicates - should not extend batch live. + gum::trace!("Importing duplicate votes"); + let mut rx_responses_duplicate = Vec::new(); + let message = make_dispute_message(candidate.clone(), BOB_INDEX, FERDIE_INDEX).await; + let peer = MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Bob); + rx_responses_duplicate + .push(send_network_dispute_request(req_tx, peer, message.clone().into()).await); + + let message = make_dispute_message(candidate.clone(), CHARLIE_INDEX, FERDIE_INDEX).await; + let peer = MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Charlie); + rx_responses_duplicate + .push(send_network_dispute_request(req_tx, peer, message.clone().into()).await); + + for rx_response in rx_responses_duplicate { assert_matches!( rx_response.await, - Err(err) => { + Ok(resp) => { + let sc_network::config::OutgoingResponse { + result, + reputation_changes, + sent_feedback: _, + } = resp; gum::trace!( target: LOG_TARGET, - ?err, - "Request got dropped - peer is banned." + ?reputation_changes, + "Received reputation changes." + ); + // We don't punish on that. + assert_eq!(reputation_changes.len(), 0); + + assert_matches!(result, Err(())); + } + ); + } + + Delay::new(BATCH_COLLECTING_INTERVAL).await; + gum::trace!("Batch should be ready now (only duplicates have been added)"); + + let pending_confirmation = assert_matches!( + handle.recv().await, + AllMessages::DisputeCoordinator( + DisputeCoordinatorMessage::ImportStatements { + candidate_receipt: _, + session, + statements, + pending_confirmation: Some(pending_confirmation), + } + ) => { + assert_eq!(session, MOCK_SESSION_INDEX); + assert_eq!(statements.len(), 3); + pending_confirmation + } + ); + pending_confirmation.send(ImportStatementsResult::ValidImport).unwrap(); + + for rx_response in rx_responses { + assert_matches!( + rx_response.await, + Ok(resp) => { + let sc_network::config::OutgoingResponse { + result, + reputation_changes: _, + sent_feedback, + } = resp; + + let result = result.unwrap(); + let decoded = + ::decode(&mut result.as_slice()).unwrap(); + + assert!(decoded == DisputeResponse::Confirmed); + if let Some(sent_feedback) = sent_feedback { + sent_feedback.send(()).unwrap(); + } + gum::trace!( + target: LOG_TARGET, + "Valid import happened." ); + } ); } - // But should work fine for Bob: + gum::trace!(target: LOG_TARGET, "Concluding."); + conclude(&mut handle).await; + }; + test_harness(test); +} + +#[test] +fn receive_rate_limit_is_enforced() { + let test = |mut handle: TestSubsystemContextHandle, + mut req_cfg: RequestResponseConfig| async move { + let req_tx = req_cfg.inbound_queue.as_mut().unwrap(); + let _ = handle_subsystem_startup(&mut handle, None).await; + + let relay_parent = Hash::random(); + let candidate = make_candidate_receipt(relay_parent); + let message = make_dispute_message(candidate.clone(), ALICE_INDEX, FERDIE_INDEX).await; + + // Initial request should get forwarded immediately: nested_network_dispute_request( &mut handle, req_tx, - MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Bob), + MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Alice), message.clone().into(), ImportStatementsResult::ValidImport, - false, - |_, _, _| async {}, + true, + move |_handle, _req_tx, _message| ready(()), ) .await; + let mut rx_responses = Vec::new(); + + let peer = MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Bob); + + let message = make_dispute_message(candidate.clone(), BOB_INDEX, FERDIE_INDEX).await; + rx_responses.push(send_network_dispute_request(req_tx, peer, message.clone().into()).await); + + let message = make_dispute_message(candidate.clone(), CHARLIE_INDEX, FERDIE_INDEX).await; + rx_responses.push(send_network_dispute_request(req_tx, peer, message.clone().into()).await); + + gum::trace!("Import one too much:"); + + let message = make_dispute_message(candidate.clone(), CHARLIE_INDEX, ALICE_INDEX).await; + let rx_response_flood = + send_network_dispute_request(req_tx, peer, message.clone().into()).await; + + assert_matches!( + rx_response_flood.await, + Ok(resp) => { + let sc_network::config::OutgoingResponse { + result: _, + reputation_changes, + sent_feedback: _, + } = resp; + gum::trace!( + target: LOG_TARGET, + ?reputation_changes, + "Received reputation changes." + ); + // Received punishment for flood: + assert_eq!(reputation_changes.len(), 1); + } + ); + gum::trace!("Need to wait 2 patch intervals:"); + Delay::new(BATCH_COLLECTING_INTERVAL).await; + Delay::new(BATCH_COLLECTING_INTERVAL).await; + + gum::trace!("Batch should be ready now"); + + let pending_confirmation = assert_matches!( + handle.recv().await, + AllMessages::DisputeCoordinator( + DisputeCoordinatorMessage::ImportStatements { + candidate_receipt: _, + session, + statements, + pending_confirmation: Some(pending_confirmation), + } + ) => { + assert_eq!(session, MOCK_SESSION_INDEX); + // Only 3 as fourth was flood: + assert_eq!(statements.len(), 3); + pending_confirmation + } + ); + pending_confirmation.send(ImportStatementsResult::ValidImport).unwrap(); + + for rx_response in rx_responses { + assert_matches!( + rx_response.await, + Ok(resp) => { + let sc_network::config::OutgoingResponse { + result, + reputation_changes: _, + sent_feedback, + } = resp; + + let result = result.unwrap(); + let decoded = + ::decode(&mut result.as_slice()).unwrap(); + + assert!(decoded == DisputeResponse::Confirmed); + if let Some(sent_feedback) = sent_feedback { + sent_feedback.send(()).unwrap(); + } + gum::trace!( + target: LOG_TARGET, + "Valid import happened." + ); + + } + ); + } + gum::trace!(target: LOG_TARGET, "Concluding."); conclude(&mut handle).await; }; diff --git a/node/network/gossip-support/Cargo.toml b/node/network/gossip-support/Cargo.toml index 6cdc87d0051c..d8c8a633cab3 100644 --- a/node/network/gossip-support/Cargo.toml +++ b/node/network/gossip-support/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "polkadot-gossip-support" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-node-network-protocol = { path = "../protocol" } polkadot-node-subsystem = { path = "../../subsystem" } @@ -22,13 +22,13 @@ rand_chacha = { version = "0.3.1", default-features = false } gum = { package = "tracing-gum", path = "../../gum" } [dev-dependencies] -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } assert_matches = "1.4.0" -async-trait = "0.1.53" +async-trait = "0.1.57" lazy_static = "1.4.0" diff --git a/node/network/gossip-support/src/lib.rs b/node/network/gossip-support/src/lib.rs index df90914b6f58..36459f9c8dab 100644 --- a/node/network/gossip-support/src/lib.rs +++ b/node/network/gossip-support/src/lib.rs @@ -249,11 +249,15 @@ where let mut connections = authorities_past_present_future(sender, leaf).await?; // Remove all of our locally controlled validator indices so we don't connect to ourself. - // If we control none of them, don't issue connection requests - we're outside - // of the 'clique' of recent validators. - if remove_all_controlled(&self.keystore, &mut connections).await != 0 { - self.issue_connection_request(sender, connections).await; - } + let connections = + if remove_all_controlled(&self.keystore, &mut connections).await != 0 { + connections + } else { + // If we control none of them, issue an empty connection request + // to clean up all connections. + Vec::new() + }; + self.issue_connection_request(sender, connections).await; } if is_new_session { @@ -353,7 +357,7 @@ where // issue another request for the same session // if at least a third of the authorities were not resolved. - if 3 * failures >= num { + if num != 0 && 3 * failures >= num { let timestamp = Instant::now(); match self.failure_start { None => self.failure_start = Some(timestamp), @@ -521,73 +525,37 @@ async fn update_gossip_topology( sp_core::blake2_256(&subject) }; - // shuffle the indices - let mut rng: ChaCha20Rng = SeedableRng::from_seed(random_seed); - let len = authorities.len(); - let mut indices: Vec = (0..len).collect(); - indices.shuffle(&mut rng); - let our_shuffled_position = indices - .iter() - .position(|i| *i == our_index) - .expect("our_index < len; indices contains it; qed"); - - let neighbors = matrix_neighbors(our_shuffled_position, len); - let row_neighbors = neighbors - .row_neighbors - .map(|i| indices[i]) - .map(|i| (authorities[i].clone(), ValidatorIndex::from(i as u32))) - .collect(); - - let column_neighbors = neighbors - .column_neighbors - .map(|i| indices[i]) - .map(|i| (authorities[i].clone(), ValidatorIndex::from(i as u32))) - .collect(); + // shuffle the validators and create the index mapping + let (shuffled_indices, canonical_shuffling) = { + let mut rng: ChaCha20Rng = SeedableRng::from_seed(random_seed); + let len = authorities.len(); + let mut shuffled_indices = vec![0; len]; + let mut canonical_shuffling: Vec<_> = authorities + .iter() + .enumerate() + .map(|(i, a)| (a.clone(), ValidatorIndex(i as _))) + .collect(); + + canonical_shuffling.shuffle(&mut rng); + for (i, (_, validator_index)) in canonical_shuffling.iter().enumerate() { + shuffled_indices[validator_index.0 as usize] = i; + } + + (shuffled_indices, canonical_shuffling) + }; sender .send_message(NetworkBridgeRxMessage::NewGossipTopology { session: session_index, - our_neighbors_x: row_neighbors, - our_neighbors_y: column_neighbors, + local_index: Some(ValidatorIndex(our_index as _)), + canonical_shuffling, + shuffled_indices, }) .await; Ok(()) } -struct MatrixNeighbors { - row_neighbors: R, - column_neighbors: C, -} - -/// Compute our row and column neighbors in a matrix -fn matrix_neighbors( - our_index: usize, - len: usize, -) -> MatrixNeighbors, impl Iterator> { - assert!(our_index < len, "our_index is computed using `enumerate`; qed"); - - // e.g. for size 11 the matrix would be - // - // 0 1 2 - // 3 4 5 - // 6 7 8 - // 9 10 - // - // and for index 10, the neighbors would be 1, 4, 7, 9 - - let sqrt = (len as f64).sqrt() as usize; - let our_row = our_index / sqrt; - let our_column = our_index % sqrt; - let row_neighbors = our_row * sqrt..std::cmp::min(our_row * sqrt + sqrt, len); - let column_neighbors = (our_column..len).step_by(sqrt); - - MatrixNeighbors { - row_neighbors: row_neighbors.filter(move |i| *i != our_index), - column_neighbors: column_neighbors.filter(move |i| *i != our_index), - } -} - #[overseer::subsystem(GossipSupport, error = SubsystemError, prefix = self::overseer)] impl GossipSupport where diff --git a/node/network/gossip-support/src/tests.rs b/node/network/gossip-support/src/tests.rs index 831f0aa94342..79f2a9a6db42 100644 --- a/node/network/gossip-support/src/tests.rs +++ b/node/network/gossip-support/src/tests.rs @@ -29,6 +29,7 @@ use sp_consensus_babe::{AllowedSlots, BabeEpochConfiguration, Epoch as BabeEpoch use sp_core::crypto::Pair as PairT; use sp_keyring::Sr25519Keyring; +use polkadot_node_network_protocol::grid_topology::{SessionGridTopology, TopologyPeerInfo}; use polkadot_node_subsystem::{ jaeger, messages::{AllMessages, RuntimeApiMessage, RuntimeApiRequest}, @@ -73,13 +74,15 @@ lazy_static! { // [1 3] // [0 ] - static ref ROW_NEIGHBORS: Vec<(AuthorityDiscoveryId, ValidatorIndex)> = vec![ - (Sr25519Keyring::Charlie.public().into(), ValidatorIndex::from(2)), + static ref EXPECTED_SHUFFLING: Vec = vec![6, 4, 0, 5, 2, 3, 1]; + + static ref ROW_NEIGHBORS: Vec = vec![ + ValidatorIndex::from(2), ]; - static ref COLUMN_NEIGHBORS: Vec<(AuthorityDiscoveryId, ValidatorIndex)> = vec![ - (Sr25519Keyring::Two.public().into(), ValidatorIndex::from(5)), - (Sr25519Keyring::Eve.public().into(), ValidatorIndex::from(3)), + static ref COLUMN_NEIGHBORS: Vec = vec![ + ValidatorIndex::from(3), + ValidatorIndex::from(5), ]; } @@ -257,12 +260,31 @@ async fn test_neighbors(overseer: &mut VirtualOverseer, expected_session: Sessio overseer_recv(overseer).await, AllMessages::NetworkBridgeRx(NetworkBridgeRxMessage::NewGossipTopology { session: got_session, - our_neighbors_x, - our_neighbors_y, + local_index, + canonical_shuffling, + shuffled_indices, }) => { assert_eq!(expected_session, got_session); - let mut got_row: Vec<_> = our_neighbors_x.into_iter().collect(); - let mut got_column: Vec<_> = our_neighbors_y.into_iter().collect(); + assert_eq!(local_index, Some(ValidatorIndex(6))); + assert_eq!(shuffled_indices, EXPECTED_SHUFFLING.clone()); + + let grid_topology = SessionGridTopology::new( + shuffled_indices, + canonical_shuffling.into_iter() + .map(|(a, v)| TopologyPeerInfo { + validator_index: v, + discovery_id: a, + peer_ids: Vec::new(), + }) + .collect(), + ); + + let grid_neighbors = grid_topology + .compute_grid_neighbors_for(local_index.unwrap()) + .unwrap(); + + let mut got_row: Vec<_> = grid_neighbors.validator_indices_x.into_iter().collect(); + let mut got_column: Vec<_> = grid_neighbors.validator_indices_y.into_iter().collect(); got_row.sort(); got_column.sort(); assert_eq!(got_row, ROW_NEIGHBORS.clone()); @@ -475,6 +497,64 @@ fn issues_connection_request_to_past_present_future() { }); } +#[test] +fn disconnect_when_not_in_past_present_future() { + sp_tracing::try_init_simple(); + let hash = Hash::repeat_byte(0xAA); + test_harness(make_subsystem(), |mut virtual_overseer| async move { + let overseer = &mut virtual_overseer; + overseer_signal_active_leaves(overseer, hash).await; + assert_matches!( + overseer_recv(overseer).await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + relay_parent, + RuntimeApiRequest::SessionIndexForChild(tx), + )) => { + assert_eq!(relay_parent, hash); + tx.send(Ok(1)).unwrap(); + } + ); + + assert_matches!( + overseer_recv(overseer).await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + relay_parent, + RuntimeApiRequest::SessionInfo(s, tx), + )) => { + assert_eq!(relay_parent, hash); + assert_eq!(s, 1); + let mut heute_leider_nicht = make_session_info(); + heute_leider_nicht.discovery_keys = AUTHORITIES_WITHOUT_US.clone(); + tx.send(Ok(Some(heute_leider_nicht))).unwrap(); + } + ); + + assert_matches!( + overseer_recv(overseer).await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + relay_parent, + RuntimeApiRequest::Authorities(tx), + )) => { + assert_eq!(relay_parent, hash); + tx.send(Ok(AUTHORITIES_WITHOUT_US.clone())).unwrap(); + } + ); + + assert_matches!( + overseer_recv(overseer).await, + AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::ConnectToResolvedValidators { + validator_addrs, + peer_set, + }) => { + assert!(validator_addrs.is_empty()); + assert_eq!(peer_set, PeerSet::Validation); + } + ); + + virtual_overseer + }); +} + #[test] fn test_log_output() { sp_tracing::try_init_simple(); @@ -636,26 +716,3 @@ fn issues_a_connection_request_when_last_request_was_mostly_unresolved() { assert_eq!(state.last_session_index, Some(1)); assert!(state.last_failure.is_none()); } - -#[test] -fn test_matrix_neighbors() { - for (our_index, len, expected_row, expected_column) in vec![ - (0usize, 1usize, vec![], vec![]), - (1, 2, vec![], vec![0usize]), - (0, 9, vec![1, 2], vec![3, 6]), - (9, 10, vec![], vec![0, 3, 6]), - (10, 11, vec![9], vec![1, 4, 7]), - (7, 11, vec![6, 8], vec![1, 4, 10]), - ] - .into_iter() - { - let matrix = matrix_neighbors(our_index, len); - let mut row_result: Vec<_> = matrix.row_neighbors.collect(); - let mut column_result: Vec<_> = matrix.column_neighbors.collect(); - row_result.sort(); - column_result.sort(); - - assert_eq!(row_result, expected_row); - assert_eq!(column_result, expected_column); - } -} diff --git a/node/network/protocol/Cargo.toml b/node/network/protocol/Cargo.toml index a956b524af73..85c9cf2bd86c 100644 --- a/node/network/protocol/Cargo.toml +++ b/node/network/protocol/Cargo.toml @@ -1,19 +1,20 @@ [package] name = "polkadot-node-network-protocol" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" description = "Primitives types for the Node-side" [dependencies] -async-trait = "0.1.53" +async-trait = "0.1.57" hex = "0.4.3" polkadot-primitives = { path = "../../../primitives" } polkadot-node-primitives = { path = "../../primitives" } polkadot-node-jaeger = { path = "../../jaeger" } parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } strum = { version = "0.24", features = ["derive"] } futures = "0.3.21" thiserror = "1.0.31" diff --git a/node/network/protocol/src/grid_topology.rs b/node/network/protocol/src/grid_topology.rs index 73de9cfc25b1..100ef66957bd 100644 --- a/node/network/protocol/src/grid_topology.rs +++ b/node/network/protocol/src/grid_topology.rs @@ -30,7 +30,7 @@ //! use crate::PeerId; -use polkadot_primitives::v2::{SessionIndex, ValidatorIndex}; +use polkadot_primitives::v2::{AuthorityDiscoveryId, SessionIndex, ValidatorIndex}; use rand::{CryptoRng, Rng}; use std::{ collections::{hash_map, HashMap, HashSet}, @@ -48,9 +48,106 @@ pub const DEFAULT_RANDOM_SAMPLE_RATE: usize = crate::MIN_GOSSIP_PEERS; /// The number of peers to randomly propagate messages to. pub const DEFAULT_RANDOM_CIRCULATION: usize = 4; -/// Topology representation -#[derive(Default, Clone, Debug)] +/// Information about a peer in the gossip topology for a session. +#[derive(Debug, Clone, PartialEq)] +pub struct TopologyPeerInfo { + /// The validator's known peer IDs. + pub peer_ids: Vec, + /// The index of the validator in the discovery keys of the corresponding + /// `SessionInfo`. This can extend _beyond_ the set of active parachain validators. + pub validator_index: ValidatorIndex, + /// The authority discovery public key of the validator in the corresponding + /// `SessionInfo`. + pub discovery_id: AuthorityDiscoveryId, +} + +/// Topology representation for a session. +#[derive(Default, Clone, Debug, PartialEq)] pub struct SessionGridTopology { + /// An array mapping validator indices to their indices in the + /// shuffling itself. This has the same size as the number of validators + /// in the session. + shuffled_indices: Vec, + /// The canonical shuffling of validators for the session. + canonical_shuffling: Vec, +} + +impl SessionGridTopology { + /// Create a new session grid topology. + pub fn new(shuffled_indices: Vec, canonical_shuffling: Vec) -> Self { + SessionGridTopology { shuffled_indices, canonical_shuffling } + } + + /// Produces the outgoing routing logic for a particular peer. + /// + /// Returns `None` if the validator index is out of bounds. + pub fn compute_grid_neighbors_for(&self, v: ValidatorIndex) -> Option { + if self.shuffled_indices.len() != self.canonical_shuffling.len() { + return None + } + let shuffled_val_index = *self.shuffled_indices.get(v.0 as usize)?; + + let neighbors = matrix_neighbors(shuffled_val_index, self.shuffled_indices.len())?; + + let mut grid_subset = GridNeighbors::empty(); + for r_n in neighbors.row_neighbors { + let n = &self.canonical_shuffling[r_n]; + grid_subset.validator_indices_x.insert(n.validator_index); + for p in &n.peer_ids { + grid_subset.peers_x.insert(p.clone()); + } + } + + for c_n in neighbors.column_neighbors { + let n = &self.canonical_shuffling[c_n]; + grid_subset.validator_indices_y.insert(n.validator_index); + for p in &n.peer_ids { + grid_subset.peers_y.insert(p.clone()); + } + } + + Some(grid_subset) + } +} + +struct MatrixNeighbors { + row_neighbors: R, + column_neighbors: C, +} + +/// Compute the row and column neighbors of `val_index` in a matrix +fn matrix_neighbors( + val_index: usize, + len: usize, +) -> Option, impl Iterator>> { + if val_index >= len { + return None + } + + // e.g. for size 11 the matrix would be + // + // 0 1 2 + // 3 4 5 + // 6 7 8 + // 9 10 + // + // and for index 10, the neighbors would be 1, 4, 7, 9 + + let sqrt = (len as f64).sqrt() as usize; + let our_row = val_index / sqrt; + let our_column = val_index % sqrt; + let row_neighbors = our_row * sqrt..std::cmp::min(our_row * sqrt + sqrt, len); + let column_neighbors = (our_column..len).step_by(sqrt); + + Some(MatrixNeighbors { + row_neighbors: row_neighbors.filter(move |i| *i != val_index), + column_neighbors: column_neighbors.filter(move |i| *i != val_index), + }) +} + +/// Information about the grid neighbors for a particular node in the topology. +#[derive(Debug, Clone, PartialEq)] +pub struct GridNeighbors { /// Represent peers in the X axis pub peers_x: HashSet, /// Represent validators in the X axis @@ -61,7 +158,18 @@ pub struct SessionGridTopology { pub validator_indices_y: HashSet, } -impl SessionGridTopology { +impl GridNeighbors { + /// Utility function for creating an empty set of grid neighbors. + /// Useful for testing. + pub fn empty() -> Self { + GridNeighbors { + peers_x: HashSet::new(), + validator_indices_x: HashSet::new(), + peers_y: HashSet::new(), + validator_indices_y: HashSet::new(), + } + } + /// Given the originator of a message as a validator index, indicates the part of the topology /// we're meant to send the message to. pub fn required_routing_by_index( @@ -123,7 +231,7 @@ impl SessionGridTopology { } /// Returns the difference between this and the `other` topology as a vector of peers - pub fn peers_diff(&self, other: &SessionGridTopology) -> Vec { + pub fn peers_diff(&self, other: &Self) -> Vec { self.peers_x .iter() .chain(self.peers_y.iter()) @@ -138,15 +246,39 @@ impl SessionGridTopology { } } +/// An entry tracking a session grid topology and some cached local neighbors. +#[derive(Debug)] +pub struct SessionGridTopologyEntry { + topology: SessionGridTopology, + local_neighbors: GridNeighbors, +} + +impl SessionGridTopologyEntry { + /// Access the local grid neighbors. + pub fn local_grid_neighbors(&self) -> &GridNeighbors { + &self.local_neighbors + } + + /// Access the local grid neighbors mutably. + pub fn local_grid_neighbors_mut(&mut self) -> &mut GridNeighbors { + &mut self.local_neighbors + } + + /// Access the underlying topology. + pub fn get(&self) -> &SessionGridTopology { + &self.topology + } +} + /// A set of topologies indexed by session #[derive(Default)] pub struct SessionGridTopologies { - inner: HashMap, usize)>, + inner: HashMap, usize)>, } impl SessionGridTopologies { /// Returns a topology for the specific session index - pub fn get_topology(&self, session: SessionIndex) -> Option<&SessionGridTopology> { + pub fn get_topology(&self, session: SessionIndex) -> Option<&SessionGridTopologyEntry> { self.inner.get(&session).and_then(|val| val.0.as_ref()) } @@ -166,63 +298,112 @@ impl SessionGridTopologies { } /// Insert a new topology, no-op if already present. - pub fn insert_topology(&mut self, session: SessionIndex, topology: SessionGridTopology) { + pub fn insert_topology( + &mut self, + session: SessionIndex, + topology: SessionGridTopology, + local_index: Option, + ) { let entry = self.inner.entry(session).or_insert((None, 0)); if entry.0.is_none() { - entry.0 = Some(topology); + let local_neighbors = local_index + .and_then(|l| topology.compute_grid_neighbors_for(l)) + .unwrap_or_else(GridNeighbors::empty); + + entry.0 = Some(SessionGridTopologyEntry { topology, local_neighbors }); } } } /// A simple storage for a topology and the corresponding session index -#[derive(Default, Debug)] -pub struct GridTopologySessionBound { - topology: SessionGridTopology, +#[derive(Debug)] +struct GridTopologySessionBound { + entry: SessionGridTopologyEntry, session_index: SessionIndex, } /// A storage for the current and maybe previous topology -#[derive(Default, Debug)] +#[derive(Debug)] pub struct SessionBoundGridTopologyStorage { current_topology: GridTopologySessionBound, prev_topology: Option, } +impl Default for SessionBoundGridTopologyStorage { + fn default() -> Self { + // having this struct be `Default` is objectively stupid + // but used in a few places + SessionBoundGridTopologyStorage { + current_topology: GridTopologySessionBound { + // session 0 is valid so we should use the upper bound + // as the default instead of the lower bound. + session_index: SessionIndex::max_value(), + entry: SessionGridTopologyEntry { + topology: SessionGridTopology { + shuffled_indices: Vec::new(), + canonical_shuffling: Vec::new(), + }, + local_neighbors: GridNeighbors::empty(), + }, + }, + prev_topology: None, + } + } +} + impl SessionBoundGridTopologyStorage { /// Return a grid topology based on the session index: /// If we need a previous session and it is registered in the storage, then return that session. /// Otherwise, return a current session to have some grid topology in any case - pub fn get_topology_or_fallback(&self, idx: SessionIndex) -> &SessionGridTopology { - self.get_topology(idx).unwrap_or(&self.current_topology.topology) + pub fn get_topology_or_fallback(&self, idx: SessionIndex) -> &SessionGridTopologyEntry { + self.get_topology(idx).unwrap_or(&self.current_topology.entry) } /// Return the grid topology for the specific session index, if no such a session is stored /// returns `None`. - pub fn get_topology(&self, idx: SessionIndex) -> Option<&SessionGridTopology> { + pub fn get_topology(&self, idx: SessionIndex) -> Option<&SessionGridTopologyEntry> { if let Some(prev_topology) = &self.prev_topology { if idx == prev_topology.session_index { - return Some(&prev_topology.topology) + return Some(&prev_topology.entry) } } if self.current_topology.session_index == idx { - return Some(&self.current_topology.topology) + return Some(&self.current_topology.entry) } None } /// Update the current topology preserving the previous one - pub fn update_topology(&mut self, session_index: SessionIndex, topology: SessionGridTopology) { + pub fn update_topology( + &mut self, + session_index: SessionIndex, + topology: SessionGridTopology, + local_index: Option, + ) { + let local_neighbors = local_index + .and_then(|l| topology.compute_grid_neighbors_for(l)) + .unwrap_or_else(GridNeighbors::empty); + let old_current = std::mem::replace( &mut self.current_topology, - GridTopologySessionBound { topology, session_index }, + GridTopologySessionBound { + entry: SessionGridTopologyEntry { topology, local_neighbors }, + session_index, + }, ); self.prev_topology.replace(old_current); } /// Returns a current grid topology - pub fn get_current_topology(&self) -> &SessionGridTopology { - &self.current_topology.topology + pub fn get_current_topology(&self) -> &SessionGridTopologyEntry { + &self.current_topology.entry + } + + /// Access the current grid topology mutably. Dangerous and intended + /// to be used in tests. + pub fn get_current_topology_mut(&mut self) -> &mut SessionGridTopologyEntry { + &mut self.current_topology.entry } } @@ -365,4 +546,27 @@ mod tests { let mut random_routing = RandomRouting { target: 10, sent: 0, sample_rate: 10 }; assert_eq!(run_random_routing(&mut random_routing, &mut rng, 10, 100), 10); } + + #[test] + fn test_matrix_neighbors() { + for (our_index, len, expected_row, expected_column) in vec![ + (0usize, 1usize, vec![], vec![]), + (1, 2, vec![], vec![0usize]), + (0, 9, vec![1, 2], vec![3, 6]), + (9, 10, vec![], vec![0, 3, 6]), + (10, 11, vec![9], vec![1, 4, 7]), + (7, 11, vec![6, 8], vec![1, 4, 10]), + ] + .into_iter() + { + let matrix = matrix_neighbors(our_index, len).unwrap(); + let mut row_result: Vec<_> = matrix.row_neighbors.collect(); + let mut column_result: Vec<_> = matrix.column_neighbors.collect(); + row_result.sort(); + column_result.sort(); + + assert_eq!(row_result, expected_row); + assert_eq!(column_result, expected_column); + } + } } diff --git a/node/network/protocol/src/lib.rs b/node/network/protocol/src/lib.rs index 78727ae67e83..169d916ce6f9 100644 --- a/node/network/protocol/src/lib.rs +++ b/node/network/protocol/src/lib.rs @@ -43,8 +43,6 @@ pub mod authority_discovery; /// Grid topology support module pub mod grid_topology; -/// A version of the protocol. -pub type ProtocolVersion = u32; /// The minimum amount of peers to send gossip messages to. pub const MIN_GOSSIP_PEERS: usize = 25; diff --git a/node/network/protocol/src/peer_set.rs b/node/network/protocol/src/peer_set.rs index 400b36e3d4c5..d9d2925e594d 100644 --- a/node/network/protocol/src/peer_set.rs +++ b/node/network/protocol/src/peer_set.rs @@ -16,23 +16,27 @@ //! All peersets and protocols used for parachains. -use super::ProtocolVersion; -use sc_network::config::{NonDefaultSetConfig, SetConfig}; +use derive_more::Display; +use polkadot_primitives::v2::Hash; +use sc_network_common::{ + config::{NonDefaultSetConfig, SetConfig}, + protocol::ProtocolName, +}; use std::{ - borrow::Cow, + collections::{hash_map::Entry, HashMap}, ops::{Index, IndexMut}, }; use strum::{EnumIter, IntoEnumIterator}; -// Only supported protocol versions should be defined here. -const VALIDATION_PROTOCOL_V1: &str = "/polkadot/validation/1"; -const COLLATION_PROTOCOL_V1: &str = "/polkadot/collation/1"; +/// The legacy protocol names. Only supported on version = 1. +const LEGACY_VALIDATION_PROTOCOL_V1: &str = "/polkadot/validation/1"; +const LEGACY_COLLATION_PROTOCOL_V1: &str = "/polkadot/collation/1"; -/// The default validation protocol version. -pub const DEFAULT_VALIDATION_PROTOCOL_VERSION: ProtocolVersion = 1; +/// The legacy protocol version. Is always 1 for both validation & collation. +const LEGACY_PROTOCOL_VERSION_V1: u32 = 1; -/// The default collation protocol version. -pub const DEFAULT_COLLATION_PROTOCOL_VERSION: ProtocolVersion = 1; +/// Max notification size is currently constant. +const MAX_NOTIFICATION_SIZE: u64 = 100 * 1024; /// The peer-sets and thus the protocols which are used for the network. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EnumIter)] @@ -60,19 +64,24 @@ impl PeerSet { /// /// Those should be used in the network configuration to register the protocols with the /// network service. - pub fn get_info(self, is_authority: IsAuthority) -> NonDefaultSetConfig { - let version = self.get_default_version(); - let protocol = self - .into_protocol_name(version) - .expect("default version always has protocol name; qed"); - let max_notification_size = 100 * 1024; + pub fn get_info( + self, + is_authority: IsAuthority, + peerset_protocol_names: &PeerSetProtocolNames, + ) -> NonDefaultSetConfig { + // Networking layer relies on `get_main_name()` being the main name of the protocol + // for peersets and connection management. + let protocol = peerset_protocol_names.get_main_name(self); + let fallback_names = PeerSetProtocolNames::get_fallback_names(self); + let max_notification_size = self.get_max_notification_size(is_authority); match self { PeerSet::Validation => NonDefaultSetConfig { notifications_protocol: protocol, - fallback_names: Vec::new(), + fallback_names, max_notification_size, - set_config: sc_network::config::SetConfig { + handshake: None, + set_config: sc_network_common::config::SetConfig { // we allow full nodes to connect to validators for gossip // to ensure any `MIN_GOSSIP_PEERS` always include reserved peers // we limit the amount of non-reserved slots to be less @@ -80,73 +89,70 @@ impl PeerSet { in_peers: super::MIN_GOSSIP_PEERS as u32 / 2 - 1, out_peers: super::MIN_GOSSIP_PEERS as u32 / 2 - 1, reserved_nodes: Vec::new(), - non_reserved_mode: sc_network::config::NonReservedPeerMode::Accept, + non_reserved_mode: sc_network_common::config::NonReservedPeerMode::Accept, }, }, PeerSet::Collation => NonDefaultSetConfig { notifications_protocol: protocol, - fallback_names: Vec::new(), + fallback_names, max_notification_size, + handshake: None, set_config: SetConfig { // Non-authority nodes don't need to accept incoming connections on this peer set: in_peers: if is_authority == IsAuthority::Yes { 100 } else { 0 }, out_peers: 0, reserved_nodes: Vec::new(), non_reserved_mode: if is_authority == IsAuthority::Yes { - sc_network::config::NonReservedPeerMode::Accept + sc_network_common::config::NonReservedPeerMode::Accept } else { - sc_network::config::NonReservedPeerMode::Deny + sc_network_common::config::NonReservedPeerMode::Deny }, }, }, } } - /// Get the default protocol version for this peer set. - pub const fn get_default_version(self) -> ProtocolVersion { + /// Get the main protocol version for this peer set. + /// + /// Networking layer relies on `get_main_version()` being the version + /// of the main protocol name reported by [`PeerSetProtocolNames::get_main_name()`]. + pub fn get_main_version(self) -> ProtocolVersion { match self { - PeerSet::Validation => DEFAULT_VALIDATION_PROTOCOL_VERSION, - PeerSet::Collation => DEFAULT_COLLATION_PROTOCOL_VERSION, + PeerSet::Validation => ValidationVersion::V1.into(), + PeerSet::Collation => CollationVersion::V1.into(), } } - /// Get the default protocol name as a static str. - pub const fn get_default_protocol_name(self) -> &'static str { - match self { - PeerSet::Validation => VALIDATION_PROTOCOL_V1, - PeerSet::Collation => COLLATION_PROTOCOL_V1, - } + /// Get the max notification size for this peer set. + pub fn get_max_notification_size(self, _: IsAuthority) -> u64 { + MAX_NOTIFICATION_SIZE } - /// Get the protocol name associated with each peer set - /// and the given version, if any, as static str. - pub const fn get_protocol_name_static(self, version: ProtocolVersion) -> Option<&'static str> { - match (self, version) { - (PeerSet::Validation, 1) => Some(VALIDATION_PROTOCOL_V1), - (PeerSet::Collation, 1) => Some(COLLATION_PROTOCOL_V1), - _ => None, + /// Get the peer set label for metrics reporting. + pub fn get_label(self) -> &'static str { + match self { + PeerSet::Validation => "validation", + PeerSet::Collation => "collation", } } - /// Get the protocol name associated with each peer set as understood by Substrate. - pub fn into_default_protocol_name(self) -> Cow<'static, str> { - self.get_default_protocol_name().into() - } - - /// Convert a peer set and the given version into a protocol name, if any, - /// as understood by Substrate. - pub fn into_protocol_name(self, version: ProtocolVersion) -> Option> { - self.get_protocol_name_static(version).map(|n| n.into()) - } - - /// Try parsing a protocol name into a peer set and protocol version. - /// - /// This only succeeds on supported versions. - pub fn try_from_protocol_name(name: &Cow<'static, str>) -> Option<(PeerSet, ProtocolVersion)> { - match name { - n if n == VALIDATION_PROTOCOL_V1 => Some((PeerSet::Validation, 1)), - n if n == COLLATION_PROTOCOL_V1 => Some((PeerSet::Collation, 1)), - _ => None, + /// Get the protocol label for metrics reporting. + pub fn get_protocol_label(self, version: ProtocolVersion) -> Option<&'static str> { + // Unfortunately, labels must be static strings, so we must manually cover them + // for all protocol versions here. + match self { + PeerSet::Validation => + if version == ValidationVersion::V1.into() { + Some("validation/1") + } else { + None + }, + PeerSet::Collation => + if version == CollationVersion::V1.into() { + Some("collation/1") + } else { + None + }, } } } @@ -181,6 +187,353 @@ impl IndexMut for PerPeerSet { /// /// Should be used during network configuration (added to [`NetworkConfiguration::extra_sets`]) /// or shortly after startup to register the protocols with the network service. -pub fn peer_sets_info(is_authority: IsAuthority) -> Vec { - PeerSet::iter().map(|s| s.get_info(is_authority)).collect() +pub fn peer_sets_info( + is_authority: IsAuthority, + peerset_protocol_names: &PeerSetProtocolNames, +) -> Vec { + PeerSet::iter() + .map(|s| s.get_info(is_authority, &peerset_protocol_names)) + .collect() +} + +/// A generic version of the protocol. This struct must not be created directly. +#[derive(Debug, Clone, Copy, Display, PartialEq, Eq, Hash)] +pub struct ProtocolVersion(u32); + +impl From for u32 { + fn from(version: ProtocolVersion) -> u32 { + version.0 + } +} + +/// Supported validation protocol versions. Only versions defined here must be used in the codebase. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EnumIter)] +pub enum ValidationVersion { + /// The first version. + V1 = 1, +} + +/// Supported collation protocol versions. Only versions defined here must be used in the codebase. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EnumIter)] +pub enum CollationVersion { + /// The first version. + V1 = 1, +} + +impl From for ProtocolVersion { + fn from(version: ValidationVersion) -> ProtocolVersion { + ProtocolVersion(version as u32) + } +} + +impl From for ProtocolVersion { + fn from(version: CollationVersion) -> ProtocolVersion { + ProtocolVersion(version as u32) + } +} + +/// On the wire protocol name to [`PeerSet`] mapping. +#[derive(Clone)] +pub struct PeerSetProtocolNames { + protocols: HashMap, + names: HashMap<(PeerSet, ProtocolVersion), ProtocolName>, +} + +impl PeerSetProtocolNames { + /// Construct [`PeerSetProtocols`] using `genesis_hash` and `fork_id`. + pub fn new(genesis_hash: Hash, fork_id: Option<&str>) -> Self { + let mut protocols = HashMap::new(); + let mut names = HashMap::new(); + for protocol in PeerSet::iter() { + match protocol { + PeerSet::Validation => + for version in ValidationVersion::iter() { + Self::register_main_protocol( + &mut protocols, + &mut names, + protocol, + version.into(), + &genesis_hash, + fork_id, + ); + }, + PeerSet::Collation => + for version in CollationVersion::iter() { + Self::register_main_protocol( + &mut protocols, + &mut names, + protocol, + version.into(), + &genesis_hash, + fork_id, + ); + }, + } + Self::register_legacy_protocol(&mut protocols, protocol); + } + Self { protocols, names } + } + + /// Helper function to register main protocol. + fn register_main_protocol( + protocols: &mut HashMap, + names: &mut HashMap<(PeerSet, ProtocolVersion), ProtocolName>, + protocol: PeerSet, + version: ProtocolVersion, + genesis_hash: &Hash, + fork_id: Option<&str>, + ) { + let protocol_name = Self::generate_name(genesis_hash, fork_id, protocol, version); + names.insert((protocol, version), protocol_name.clone()); + Self::insert_protocol_or_panic(protocols, protocol_name, protocol, version); + } + + /// Helper function to register legacy protocol. + fn register_legacy_protocol( + protocols: &mut HashMap, + protocol: PeerSet, + ) { + Self::insert_protocol_or_panic( + protocols, + Self::get_legacy_name(protocol), + protocol, + ProtocolVersion(LEGACY_PROTOCOL_VERSION_V1), + ) + } + + /// Helper function to make sure no protocols have the same name. + fn insert_protocol_or_panic( + protocols: &mut HashMap, + name: ProtocolName, + protocol: PeerSet, + version: ProtocolVersion, + ) { + match protocols.entry(name) { + Entry::Vacant(entry) => { + entry.insert((protocol, version)); + }, + Entry::Occupied(entry) => { + panic!( + "Protocol {:?} (version {}) has the same on-the-wire name as protocol {:?} (version {}): `{}`.", + protocol, + version, + entry.get().0, + entry.get().1, + entry.key(), + ); + }, + } + } + + /// Lookup the protocol using its on the wire name. + pub fn try_get_protocol(&self, name: &ProtocolName) -> Option<(PeerSet, ProtocolVersion)> { + self.protocols.get(name).map(ToOwned::to_owned) + } + + /// Get the main protocol name. It's used by the networking for keeping track + /// of peersets and connections. + pub fn get_main_name(&self, protocol: PeerSet) -> ProtocolName { + self.get_name(protocol, protocol.get_main_version()) + } + + /// Get the protocol name for specific version. + pub fn get_name(&self, protocol: PeerSet, version: ProtocolVersion) -> ProtocolName { + self.names + .get(&(protocol, version)) + .expect("Protocols & versions are specified via enums defined above, and they are all registered in `new()`; qed") + .clone() + } + + /// The protocol name of this protocol based on `genesis_hash` and `fork_id`. + fn generate_name( + genesis_hash: &Hash, + fork_id: Option<&str>, + protocol: PeerSet, + version: ProtocolVersion, + ) -> ProtocolName { + let prefix = if let Some(fork_id) = fork_id { + format!("/{}/{}", hex::encode(genesis_hash), fork_id) + } else { + format!("/{}", hex::encode(genesis_hash)) + }; + + let short_name = match protocol { + PeerSet::Validation => "validation", + PeerSet::Collation => "collation", + }; + + format!("{}/{}/{}", prefix, short_name, version).into() + } + + /// Get the legacy protocol name, only `LEGACY_PROTOCOL_VERSION` = 1 is supported. + fn get_legacy_name(protocol: PeerSet) -> ProtocolName { + match protocol { + PeerSet::Validation => LEGACY_VALIDATION_PROTOCOL_V1, + PeerSet::Collation => LEGACY_COLLATION_PROTOCOL_V1, + } + .into() + } + + /// Get the protocol fallback names. Currently only holds the legacy name + /// for `LEGACY_PROTOCOL_VERSION` = 1. + fn get_fallback_names(protocol: PeerSet) -> Vec { + std::iter::once(Self::get_legacy_name(protocol)).collect() + } +} + +#[cfg(test)] +mod tests { + use super::{ + CollationVersion, Hash, PeerSet, PeerSetProtocolNames, ProtocolVersion, ValidationVersion, + }; + use strum::IntoEnumIterator; + + struct TestVersion(u32); + + impl From for ProtocolVersion { + fn from(version: TestVersion) -> ProtocolVersion { + ProtocolVersion(version.0) + } + } + + #[test] + fn protocol_names_are_correctly_generated() { + let genesis_hash = Hash::from([ + 122, 200, 116, 29, 232, 183, 20, 109, 138, 86, 23, 253, 70, 41, 20, 85, 127, 230, 60, + 38, 90, 127, 28, 16, 231, 218, 227, 40, 88, 238, 187, 128, + ]); + let name = PeerSetProtocolNames::generate_name( + &genesis_hash, + None, + PeerSet::Validation, + TestVersion(3).into(), + ); + let expected = + "/7ac8741de8b7146d8a5617fd462914557fe63c265a7f1c10e7dae32858eebb80/validation/3"; + assert_eq!(name, expected.into()); + + let name = PeerSetProtocolNames::generate_name( + &genesis_hash, + None, + PeerSet::Collation, + TestVersion(5).into(), + ); + let expected = + "/7ac8741de8b7146d8a5617fd462914557fe63c265a7f1c10e7dae32858eebb80/collation/5"; + assert_eq!(name, expected.into()); + + let fork_id = Some("test-fork"); + let name = PeerSetProtocolNames::generate_name( + &genesis_hash, + fork_id, + PeerSet::Validation, + TestVersion(7).into(), + ); + let expected = + "/7ac8741de8b7146d8a5617fd462914557fe63c265a7f1c10e7dae32858eebb80/test-fork/validation/7"; + assert_eq!(name, expected.into()); + + let name = PeerSetProtocolNames::generate_name( + &genesis_hash, + fork_id, + PeerSet::Collation, + TestVersion(11).into(), + ); + let expected = + "/7ac8741de8b7146d8a5617fd462914557fe63c265a7f1c10e7dae32858eebb80/test-fork/collation/11"; + assert_eq!(name, expected.into()); + } + + #[test] + fn all_protocol_names_are_known() { + let genesis_hash = Hash::from([ + 122, 200, 116, 29, 232, 183, 20, 109, 138, 86, 23, 253, 70, 41, 20, 85, 127, 230, 60, + 38, 90, 127, 28, 16, 231, 218, 227, 40, 88, 238, 187, 128, + ]); + let protocol_names = PeerSetProtocolNames::new(genesis_hash, None); + + let validation_main = + "/7ac8741de8b7146d8a5617fd462914557fe63c265a7f1c10e7dae32858eebb80/validation/1"; + assert_eq!( + protocol_names.try_get_protocol(&validation_main.into()), + Some((PeerSet::Validation, TestVersion(1).into())), + ); + + let validation_legacy = "/polkadot/validation/1"; + assert_eq!( + protocol_names.try_get_protocol(&validation_legacy.into()), + Some((PeerSet::Validation, TestVersion(1).into())), + ); + + let collation_main = + "/7ac8741de8b7146d8a5617fd462914557fe63c265a7f1c10e7dae32858eebb80/collation/1"; + assert_eq!( + protocol_names.try_get_protocol(&collation_main.into()), + Some((PeerSet::Collation, TestVersion(1).into())), + ); + + let collation_legacy = "/polkadot/collation/1"; + assert_eq!( + protocol_names.try_get_protocol(&collation_legacy.into()), + Some((PeerSet::Collation, TestVersion(1).into())), + ); + } + + #[test] + fn all_protocol_versions_are_registered() { + let genesis_hash = Hash::from([ + 122, 200, 116, 29, 232, 183, 20, 109, 138, 86, 23, 253, 70, 41, 20, 85, 127, 230, 60, + 38, 90, 127, 28, 16, 231, 218, 227, 40, 88, 238, 187, 128, + ]); + let protocol_names = PeerSetProtocolNames::new(genesis_hash, None); + + for protocol in PeerSet::iter() { + match protocol { + PeerSet::Validation => + for version in ValidationVersion::iter() { + assert_eq!( + protocol_names.get_name(protocol, version.into()), + PeerSetProtocolNames::generate_name( + &genesis_hash, + None, + protocol, + version.into(), + ), + ); + }, + PeerSet::Collation => + for version in CollationVersion::iter() { + assert_eq!( + protocol_names.get_name(protocol, version.into()), + PeerSetProtocolNames::generate_name( + &genesis_hash, + None, + protocol, + version.into(), + ), + ); + }, + } + } + } + + #[test] + fn all_protocol_versions_have_labels() { + for protocol in PeerSet::iter() { + match protocol { + PeerSet::Validation => + for version in ValidationVersion::iter() { + protocol + .get_protocol_label(version.into()) + .expect("All validation protocol versions must have a label."); + }, + PeerSet::Collation => + for version in CollationVersion::iter() { + protocol + .get_protocol_label(version.into()) + .expect("All collation protocol versions must have a label."); + }, + } + } + } } diff --git a/node/network/protocol/src/request_response/mod.rs b/node/network/protocol/src/request_response/mod.rs index a1d37c5fe61e..92ee5977864e 100644 --- a/node/network/protocol/src/request_response/mod.rs +++ b/node/network/protocol/src/request_response/mod.rs @@ -32,13 +32,13 @@ //! //! Versioned (v1 module): The actual requests and responses as sent over the network. -use std::{borrow::Cow, collections::HashMap, time::Duration, u64}; +use std::{collections::HashMap, time::Duration, u64}; use futures::channel::mpsc; use polkadot_primitives::v2::{MAX_CODE_SIZE, MAX_POV_SIZE}; use strum::{EnumIter, IntoEnumIterator}; -pub use sc_network::{config as network, config::RequestResponseConfig}; +pub use sc_network::{config as network, config::RequestResponseConfig, ProtocolName}; /// Everything related to handling of incoming requests. pub mod incoming; @@ -121,6 +121,10 @@ const POV_RESPONSE_SIZE: u64 = MAX_POV_SIZE as u64 + 10_000; /// This is `MAX_CODE_SIZE` plus some additional space for protocol overhead. const STATEMENT_RESPONSE_SIZE: u64 = MAX_CODE_SIZE as u64 + 10_000; +/// We can have relative large timeouts here, there is no value of hitting a +/// timeout as we want to get statements through to each node in any case. +pub const DISPUTE_REQUEST_TIMEOUT: Duration = Duration::from_secs(12); + impl Protocol { /// Get a configuration for a given Request response protocol. /// @@ -194,9 +198,7 @@ impl Protocol { /// Responses are just confirmation, in essence not even a bit. So 100 seems /// plenty. max_response_size: 100, - /// We can have relative large timeouts here, there is no value of hitting a - /// timeout as we want to get statements through to each node in any case. - request_timeout: Duration::from_secs(12), + request_timeout: DISPUTE_REQUEST_TIMEOUT, inbound_queue: Some(tx), }, }; @@ -248,7 +250,7 @@ impl Protocol { } /// Fallback protocol names of this protocol, as understood by substrate networking. - fn get_fallback_names(self) -> Vec> { + fn get_fallback_names(self) -> Vec { std::iter::once(self.get_legacy_name().into()).collect() } @@ -276,7 +278,7 @@ pub trait IsRequest { /// Type for getting on the wire [`Protocol`] names using genesis hash & fork id. pub struct ReqProtocolNames { - names: HashMap>, + names: HashMap, } impl ReqProtocolNames { @@ -290,7 +292,7 @@ impl ReqProtocolNames { } /// Get on the wire [`Protocol`] name. - pub fn get_name(&self, protocol: Protocol) -> Cow<'static, str> { + pub fn get_name(&self, protocol: Protocol) -> ProtocolName { self.names .get(&protocol) .expect("All `Protocol` enum variants are added above via `strum`; qed") @@ -302,7 +304,7 @@ impl ReqProtocolNames { protocol: Protocol, genesis_hash: &Hash, fork_id: Option<&str>, - ) -> Cow<'static, str> { + ) -> ProtocolName { let prefix = if let Some(fork_id) = fork_id { format!("/{}/{}", hex::encode(genesis_hash), fork_id) } else { diff --git a/node/network/statement-distribution/Cargo.toml b/node/network/statement-distribution/Cargo.toml index 4e7ce83bec1e..a0e06b357cbe 100644 --- a/node/network/statement-distribution/Cargo.toml +++ b/node/network/statement-distribution/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-statement-distribution" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Statement Distribution Subsystem" edition = "2021" @@ -9,14 +9,14 @@ edition = "2021" futures = "0.3.21" gum = { package = "tracing-gum", path = "../../gum" } polkadot-primitives = { path = "../../../primitives" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-node-subsystem = {path = "../../subsystem" } polkadot-node-primitives = { path = "../../primitives" } polkadot-node-subsystem-util = { path = "../../subsystem-util" } polkadot-node-network-protocol = { path = "../../network/protocol" } arrayvec = "0.5.2" -indexmap = "1.9.0" +indexmap = "1.9.1" parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } thiserror = "1.0.31" fatality = "0.0.6" @@ -24,13 +24,13 @@ fatality = "0.0.6" [dev-dependencies] polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" } assert_matches = "1.4.0" -sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures-timer = "3.0.2" polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" } diff --git a/node/network/statement-distribution/src/lib.rs b/node/network/statement-distribution/src/lib.rs index 38d4022c633b..17ca5d8ea4ac 100644 --- a/node/network/statement-distribution/src/lib.rs +++ b/node/network/statement-distribution/src/lib.rs @@ -27,7 +27,7 @@ use parity_scale_codec::Encode; use polkadot_node_network_protocol::{ self as net_protocol, - grid_topology::{RequiredRouting, SessionBoundGridTopologyStorage, SessionGridTopology}, + grid_topology::{GridNeighbors, RequiredRouting, SessionBoundGridTopologyStorage}, peer_set::{IsAuthority, PeerSet}, request_response::{v1 as request_v1, IncomingRequestReceiver}, v1::{self as protocol_v1, StatementMetadata}, @@ -910,7 +910,10 @@ async fn circulate_statement_and_dependents( .with_candidate(statement.payload().candidate_hash()) .with_stage(jaeger::Stage::StatementDistribution); - let topology = topology_store.get_topology_or_fallback(active_head.session_index); + let topology = topology_store + .get_topology_or_fallback(active_head.session_index) + .local_grid_neighbors(); + // First circulate the statement directly to all peers needing it. // The borrow of `active_head` needs to encompass only this (Rust) statement. let outputs: Option<(CandidateHash, Vec)> = { @@ -996,7 +999,7 @@ fn is_statement_large(statement: &SignedFullStatement) -> (bool, Option) // Half max size seems to be a good threshold to start not using notifications: let threshold = - PeerSet::Validation.get_info(IsAuthority::Yes).max_notification_size as usize / 2; + PeerSet::Validation.get_max_notification_size(IsAuthority::Yes) as usize / 2; (size >= threshold, Some(size)) }, @@ -1009,7 +1012,7 @@ fn is_statement_large(statement: &SignedFullStatement) -> (bool, Option) #[overseer::contextbounds(StatementDistribution, prefix=self::overseer)] async fn circulate_statement<'a, Context>( required_routing: RequiredRouting, - topology: &SessionGridTopology, + topology: &GridNeighbors, peers: &mut HashMap, ctx: &mut Context, relay_parent: Hash, @@ -1352,7 +1355,8 @@ async fn handle_incoming_message_and_circulate<'a, Context, R>( let session_index = runtime.get_session_index_for_child(ctx.sender(), relay_parent).await; let topology = match session_index { - Ok(session_index) => topology_storage.get_topology_or_fallback(session_index), + Ok(session_index) => + topology_storage.get_topology_or_fallback(session_index).local_grid_neighbors(), Err(e) => { gum::debug!( target: LOG_TARGET, @@ -1361,7 +1365,7 @@ async fn handle_incoming_message_and_circulate<'a, Context, R>( e ); - topology_storage.get_current_topology() + topology_storage.get_current_topology().local_grid_neighbors() }, }; let required_routing = @@ -1588,7 +1592,7 @@ async fn handle_incoming_message<'a, Context>( #[overseer::contextbounds(StatementDistribution, prefix=self::overseer)] async fn update_peer_view_and_maybe_send_unlocked( peer: PeerId, - topology: &SessionGridTopology, + topology: &GridNeighbors, peer_data: &mut PeerData, ctx: &mut Context, active_heads: &HashMap, @@ -1673,16 +1677,22 @@ async fn handle_network_update( let _ = metrics.time_network_bridge_update_v1("new_gossip_topology"); let new_session_index = topology.session; - let new_topology: SessionGridTopology = topology.into(); - let old_topology = topology_storage.get_current_topology(); - let newly_added = new_topology.peers_diff(old_topology); - topology_storage.update_topology(new_session_index, new_topology); + let new_topology = topology.topology; + let old_topology = + topology_storage.get_current_topology().local_grid_neighbors().clone(); + topology_storage.update_topology(new_session_index, new_topology, topology.local_index); + + let newly_added = topology_storage + .get_current_topology() + .local_grid_neighbors() + .peers_diff(&old_topology); + for peer in newly_added { if let Some(data) = peers.get_mut(&peer) { let view = std::mem::take(&mut data.view); update_peer_view_and_maybe_send_unlocked( peer, - topology_storage.get_current_topology(), + topology_storage.get_current_topology().local_grid_neighbors(), data, ctx, &*active_heads, @@ -1717,7 +1727,7 @@ async fn handle_network_update( Some(data) => update_peer_view_and_maybe_send_unlocked( peer, - topology_storage.get_current_topology(), + topology_storage.get_current_topology().local_grid_neighbors(), data, ctx, &*active_heads, diff --git a/node/network/statement-distribution/src/tests.rs b/node/network/statement-distribution/src/tests.rs index efc9ca896bb1..f3b9db00aef4 100644 --- a/node/network/statement-distribution/src/tests.rs +++ b/node/network/statement-distribution/src/tests.rs @@ -20,6 +20,8 @@ use futures::executor::{self, block_on}; use futures_timer::Delay; use parity_scale_codec::{Decode, Encode}; use polkadot_node_network_protocol::{ + grid_topology::{SessionGridTopology, TopologyPeerInfo}, + peer_set::ValidationVersion, request_response::{ v1::{StatementFetchingRequest, StatementFetchingResponse}, IncomingRequest, Recipient, ReqProtocolNames, Requests, @@ -508,7 +510,7 @@ fn peer_view_update_sends_messages() { let peer = PeerId::random(); executor::block_on(async move { - let mut topology: SessionGridTopology = Default::default(); + let mut topology = GridNeighbors::empty(); topology.peers_x = HashSet::from_iter(vec![peer.clone()].into_iter()); update_peer_view_and_maybe_send_unlocked( peer.clone(), @@ -638,7 +640,7 @@ fn circulated_statement_goes_to_all_peers_with_view() { }; let statement = StoredStatement { comparator: &comparator, statement: &statement }; - let mut topology: SessionGridTopology = Default::default(); + let mut topology = GridNeighbors::empty(); topology.peers_x = HashSet::from_iter(vec![peer_a.clone(), peer_b.clone(), peer_c.clone()].into_iter()); let needs_dependents = circulate_statement( @@ -779,7 +781,12 @@ fn receiving_from_one_sends_to_another_and_to_candidate_backing() { handle .send(FromOrchestra::Communication { msg: StatementDistributionMessage::NetworkBridgeUpdate( - NetworkBridgeEvent::PeerConnected(peer_a.clone(), ObservedRole::Full, 1, None), + NetworkBridgeEvent::PeerConnected( + peer_a.clone(), + ObservedRole::Full, + ValidationVersion::V1.into(), + None, + ), ), }) .await; @@ -787,7 +794,12 @@ fn receiving_from_one_sends_to_another_and_to_candidate_backing() { handle .send(FromOrchestra::Communication { msg: StatementDistributionMessage::NetworkBridgeUpdate( - NetworkBridgeEvent::PeerConnected(peer_b.clone(), ObservedRole::Full, 1, None), + NetworkBridgeEvent::PeerConnected( + peer_b.clone(), + ObservedRole::Full, + ValidationVersion::V1.into(), + None, + ), ), }) .await; @@ -977,7 +989,7 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing( NetworkBridgeEvent::PeerConnected( peer_a.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), Some(HashSet::from([Sr25519Keyring::Alice.public().into()])), ), ), @@ -990,7 +1002,7 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing( NetworkBridgeEvent::PeerConnected( peer_b.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), Some(HashSet::from([Sr25519Keyring::Bob.public().into()])), ), ), @@ -1002,7 +1014,7 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing( NetworkBridgeEvent::PeerConnected( peer_c.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), Some(HashSet::from([Sr25519Keyring::Charlie.public().into()])), ), ), @@ -1014,7 +1026,7 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing( NetworkBridgeEvent::PeerConnected( peer_bad.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), None, ), ), @@ -1492,7 +1504,7 @@ fn share_prioritizes_backing_group() { NetworkBridgeEvent::PeerConnected( peer, ObservedRole::Full, - 1, + ValidationVersion::V1.into(), Some(HashSet::from([pair.public().into()])), ), ), @@ -1515,7 +1527,7 @@ fn share_prioritizes_backing_group() { NetworkBridgeEvent::PeerConnected( peer_a.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), Some(HashSet::from([Sr25519Keyring::Alice.public().into()])), ), ), @@ -1527,7 +1539,7 @@ fn share_prioritizes_backing_group() { NetworkBridgeEvent::PeerConnected( peer_b.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), Some(HashSet::from([Sr25519Keyring::Bob.public().into()])), ), ), @@ -1539,7 +1551,7 @@ fn share_prioritizes_backing_group() { NetworkBridgeEvent::PeerConnected( peer_c.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), Some(HashSet::from([Sr25519Keyring::Charlie.public().into()])), ), ), @@ -1551,7 +1563,7 @@ fn share_prioritizes_backing_group() { NetworkBridgeEvent::PeerConnected( peer_bad.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), None, ), ), @@ -1563,7 +1575,7 @@ fn share_prioritizes_backing_group() { NetworkBridgeEvent::PeerConnected( peer_other_group.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), Some(HashSet::from([Sr25519Keyring::Dave.public().into()])), ), ), @@ -1786,7 +1798,7 @@ fn peer_cant_flood_with_large_statements() { NetworkBridgeEvent::PeerConnected( peer_a.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), Some(HashSet::from([Sr25519Keyring::Alice.public().into()])), ), ), @@ -1993,7 +2005,7 @@ fn handle_multiple_seconded_statements() { NetworkBridgeEvent::PeerConnected( peer.clone(), ObservedRole::Full, - 1, + ValidationVersion::V1.into(), None, ), ), @@ -2008,42 +2020,77 @@ fn handle_multiple_seconded_statements() { .await; } - // Explicitly add all `lucky` peers to the gossip peers to ensure that neither `peerA` not `peerB` - // receive statements + // Set up a topology which puts peers a & b in a column together. let gossip_topology = { - let mut t = network_bridge_event::NewGossipTopology { - session: 1, - our_neighbors_x: HashMap::new(), - our_neighbors_y: HashMap::new(), - }; - - // Create a topology to ensure that we send messages not to `peer_a`/`peer_b` - for (i, peer) in lucky_peers.iter().enumerate() { - let authority_id = AuthorityPair::generate().0.public(); - t.our_neighbors_y.insert( - authority_id, - network_bridge_event::TopologyPeerInfo { - peer_ids: vec![peer.clone()], - validator_index: (i as u32 + 2_u32).into(), - }, - ); + // create a lucky_peers+1 * lucky_peers+1 grid topology where we are at index 2, sharing + // a row with peer_a (0) and peer_b (1) and a column with all the lucky peers. + // the rest is filled with junk. + // This is an absolute garbage hack depending on quirks of the implementation + // and not on sound architecture. + + let n_lucky = lucky_peers.len(); + let dim = n_lucky + 1; + let grid_size = dim * dim; + let topology_peer_info: Vec<_> = (0..grid_size) + .map(|i| { + if i == 0 { + TopologyPeerInfo { + peer_ids: vec![peer_a.clone()], + validator_index: ValidatorIndex(0), + discovery_id: AuthorityPair::generate().0.public(), + } + } else if i == 1 { + TopologyPeerInfo { + peer_ids: vec![peer_b.clone()], + validator_index: ValidatorIndex(1), + discovery_id: AuthorityPair::generate().0.public(), + } + } else if i == 2 { + TopologyPeerInfo { + peer_ids: vec![], + validator_index: ValidatorIndex(2), + discovery_id: AuthorityPair::generate().0.public(), + } + } else if (i - 2) % dim == 0 { + let lucky_index = ((i - 2) / dim) - 1; + TopologyPeerInfo { + peer_ids: vec![lucky_peers[lucky_index].clone()], + validator_index: ValidatorIndex(i as _), + discovery_id: AuthorityPair::generate().0.public(), + } + } else { + TopologyPeerInfo { + peer_ids: vec![PeerId::random()], + validator_index: ValidatorIndex(i as _), + discovery_id: AuthorityPair::generate().0.public(), + } + } + }) + .collect(); + + // also a hack: this is only required to be accurate for + // the validator indices we compute grid neighbors for. + let mut shuffled_indices = vec![0; grid_size]; + shuffled_indices[2] = 2; + + // Some sanity checking to make sure this hack is set up correctly. + let topology = SessionGridTopology::new(shuffled_indices, topology_peer_info); + let grid_neighbors = topology.compute_grid_neighbors_for(ValidatorIndex(2)).unwrap(); + assert_eq!(grid_neighbors.peers_x.len(), 25); + assert!(grid_neighbors.peers_x.contains(&peer_a)); + assert!(grid_neighbors.peers_x.contains(&peer_b)); + assert!(!grid_neighbors.peers_y.contains(&peer_b)); + assert!(!grid_neighbors.route_to_peer(RequiredRouting::GridY, &peer_b)); + assert_eq!(grid_neighbors.peers_y.len(), lucky_peers.len()); + for lucky in &lucky_peers { + assert!(grid_neighbors.peers_y.contains(lucky)); } - t.our_neighbors_x.insert( - AuthorityPair::generate().0.public(), - network_bridge_event::TopologyPeerInfo { - peer_ids: vec![peer_a.clone()], - validator_index: 0_u32.into(), - }, - ); - t.our_neighbors_x.insert( - AuthorityPair::generate().0.public(), - network_bridge_event::TopologyPeerInfo { - peer_ids: vec![peer_b.clone()], - validator_index: 1_u32.into(), - }, - ); - t + network_bridge_event::NewGossipTopology { + session: 1, + topology, + local_index: Some(ValidatorIndex(2)), + } }; handle diff --git a/node/orchestra/Cargo.toml b/node/orchestra/Cargo.toml deleted file mode 100644 index 8686003f475b..000000000000 --- a/node/orchestra/Cargo.toml +++ /dev/null @@ -1,37 +0,0 @@ -[package] -name = "orchestra" -version = "0.0.1" -authors = ["Parity Technologies "] -edition = "2021" -description = "Generate an orchestra of subsystems from a single struct." -repository = "https://github.com/paritytech/polkadot" -license = "MIT OR Apache-2.0" -autoexamples = false - -[dependencies] -tracing = "0.1.35" -futures = "0.3" -async-trait = "0.1" -thiserror = "1" -metered = { package = "prioritized-metered-channel", version = "0.2.0", path = "../metered-channel" } -orchestra-proc-macro = { version = "0.0.1", path = "./proc-macro" } -futures-timer = "3.0.2" -pin-project = "1.0" -dyn-clonable = "0.9" - -[dev-dependencies] -trybuild = "1.0.61" -rustversion = "1.0.6" - - -[[example]] -name = "duo" -crate-type = ["bin"] - -[[example]] -name = "solo" -crate-type = ["bin"] - -[features] -default = [] -expand = ["orchestra-proc-macro/expand"] diff --git a/node/orchestra/README.md b/node/orchestra/README.md deleted file mode 100644 index 2cfe4bb0a884..000000000000 --- a/node/orchestra/README.md +++ /dev/null @@ -1,99 +0,0 @@ -# orchestra - -The orchestra pattern is a partial actor pattern, with a global orchestrator regarding -relevant work items. - -## proc-macro - -The proc macro provides a convenience generator with a builder pattern, -where at it's core it creates and spawns a set of subsystems, which are purely -declarative. - -```rust - #[orchestra(signal=SigSigSig, event=Event, gen=AllMessages, error=OrchestraError)] - pub struct Opera { - #[subsystem(MsgA, sends: [MsgB])] - sub_a: AwesomeSubSysA, - - #[subsystem(MsgB, sends: [MsgA])] - sub_b: AwesomeSubSysB, - } -``` - -* Each subsystem is annotated with `#[subsystem(_)]` where `MsgA` respectively `MsgB` are the messages -being consumed by that particular subsystem. Each of those subsystems is required to implement the subsystem -trait with the correct trait bounds. Commonly this is achieved -by using `#[subsystem]` and `#[contextbounds]` macro. - * `#[contextbounds(Foo, error=Yikes, prefix=wherethetraitsat)]` can applied to `impl`-blocks and `fn`-blocks. It will add additional trait bounds for the generic `Context` with `Context: FooContextTrait` for `::Sender: FooSenderTrait` besides a few more. Note that `Foo` here references the name of the subsystem as declared in `#[orchestra(..)]` macro. - * `#[subsystem(Foo, error=Yikes, prefix=wherethetraitsat)]` is a extension to the above, implementing `trait Subsystem`. -* `error=` tells the orchestra to use the user provided -error type, if not provided a builtin one is used. Note that this is the one error type used throughout all calls, so make sure it does impl `From` for all other error types `E` that are relevant to your application. -* `event=` declares an external event type, that injects certain events -into the orchestra, without participating in the subsystem pattern. -* `signal=` defines a signal type to be used for the orchestra. This is a shared "tick" or "clock" for all subsystems. -* `gen=` defines a wrapping `enum` type that is used to wrap all messages that can be consumed by _any_ subsystem. - -```rust - /// Execution context, always required. - pub struct DummyCtx; - - /// Task spawner, always required - /// and must implement `trait orchestra::Spawner`. - pub struct DummySpawner; - - fn main() { - let _orchestra = Opera::builder() - .sub_a(AwesomeSubSysA::default()) - .sub_b(AwesomeSubSysB::default()) - .spawner(DummySpawner) - .build(); - } -``` - -In the shown `main`, the orchestra is created by means of a generated, compile time erroring -builder pattern. - -The builder requires all subsystems, baggage fields (additional struct data) and spawner to be -set via the according setter method before `build` method could even be called. Failure to do -such an initialization will lead to a compile error. This is implemented by encoding each -builder field in a set of so called `state generics`, meaning that each field can be either -`Init` or `Missing`, so each setter translates a state from `Missing` to `Init` state -for the specific struct field. Therefore, if you see a compile time error that blames about -`Missing` where `Init` is expected it usually means that some subsystems or baggage fields were -not set prior to the `build` call. - -To exclude subsystems from such a check, one can set `wip` attribute on some subsystem that -is not ready to be included in the Orchestra: - -```rust - #[orchestra(signal=SigSigSig, event=Event, gen=AllMessages, error=OrchestraError)] - pub struct Opera { - #[subsystem(MsgA, sends: MsgB)] - sub_a: AwesomeSubSysA, - - #[subsystem(MsgB, sends: MsgA), wip] - sub_b: AwesomeSubSysB, // This subsystem will not be required nor allowed to be set - } -``` - -Baggage fields can be initialized more than one time, however, it is not true for subsystems: -subsystems must be initialized only once (another compile time check) or be _replaced_ by -a special setter like method `replace_`. - -A task spawner and subsystem context are required to be defined with `Spawner` and respectively `SubsystemContext` implemented. - -## Debugging - -As always, debugging is notoriously annoying with bugged proc-macros. - -Therefore [`expander`](https://github.com/drahnr/expander) is employed to yield better -error messages. Enable with `--feature=orchestra/expand`. - -## License - -Licensed under either of - -* Apache License, Version 2.0, (LICENSE-APACHE or ) -* MIT license (LICENSE-MIT or ) - -at your option. diff --git a/node/orchestra/adr/01-adr.md b/node/orchestra/adr/01-adr.md deleted file mode 100644 index 3b1cb57eb322..000000000000 --- a/node/orchestra/adr/01-adr.md +++ /dev/null @@ -1,21 +0,0 @@ -# Limit outgoing messages - -## Status - -Accepted + implemented. - -## Context - -Previously, there was no way to limit and hence reason about a subset of subsystems, and if they form a cycle. Limiting the outgoing message types is a first step to create respective graphs and use classic graph algorithms to detect those and leave it to the user to resolve these. - -## Decision - -Annotate the `#[orchestra]` inner `#[subsystem(..)]` annotation -with an aditional set of outgoing messages and enforce this via more fine grained trait bounds on the `Sender` and `::Sender` bounds. - -## Consequences - -* A graph will be spawn for every compilation under the `OUT_DIR` of the crate where `#[orchestra]` is specified. -* Each subsystem has a consuming message which is often referred to as generic `M` (no change on that, is as before), but now we have trait `AssociateOutgoing { type OutgoingMessages = ..; }` which defines an outgoing helper `enum` that is generated with an ident constructed as `${Subsystem}OutgoingMessages` where `${Subsystem}` is the subsystem identifier as used in the orchestra declaration. `${Subsystem}OutgoingMessages` is used throughout everywhere to constrain the outgoing messages (commonly referred to as `OutgoingMessage` generic bounded by `${Subsystem}OutgoingMessages: From` or `::OutgoingMessages: From`. It's what allows the construction of the graph and compile time verification. -* `${Subsystem}SenderTrait` and `${Subsystem}ContextTrait` are accumulation traits or wrapper traits, that combine over all annotated M or `OutgoingMessages` from the orchestra declaration or their respective outgoing types. It is usage convenience and assures consistency within a subsystem while also maintaining a single source of truth for which messages can be sent by a particular subsystem. Note that this is sidestepped for the test subsystem, which may consume `gen=AllMessages`, the global message wrapper type. -* `Job`-based subsystems, being on their way out, are patched, but they now are generic over the `Sender` type, leaking that type. diff --git a/node/orchestra/examples/duo.rs b/node/orchestra/examples/duo.rs deleted file mode 100644 index 7fd465981273..000000000000 --- a/node/orchestra/examples/duo.rs +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![allow(dead_code)] // orchestra events are not used - -//! A dummy to be used with cargo expand - -use orchestra::{self as orchestra, Spawner, *}; -use std::{collections::HashMap, sync::Arc}; -mod misc; - -pub use self::misc::*; - -/// Concrete subsystem implementation for `MsgStrukt` msg type. -#[derive(Default)] -pub struct AwesomeSubSys; - -#[orchestra::subsystem(Awesome, error=Yikes)] -impl AwesomeSubSys { - fn start(self, mut ctx: Context) -> SpawnedSubsystem { - let mut sender = ctx.sender().clone(); - ctx.spawn( - "AwesomeSubsys", - Box::pin(async move { - sender.send_message(Plinko).await; - }), - ) - .unwrap(); - unimplemented!("starting yay!") - } -} - -#[derive(Default)] -pub struct Fortified; - -#[orchestra::subsystem(GoblinTower, error=Yikes)] -impl Fortified { - fn start(self, mut ctx: Context) -> SpawnedSubsystem { - let mut sender = ctx.sender().clone(); - ctx.spawn( - "GoblinTower", - Box::pin(async move { - sender.send_message(MsgStrukt(8u8)).await; - }), - ) - .unwrap(); - unimplemented!("welcum") - } -} - -#[orchestra(signal=SigSigSig, event=EvX, error=Yikes, gen=AllMessages)] -struct Duo { - #[subsystem(consumes: MsgStrukt, sends: [Plinko])] - sub0: Awesome, - - #[subsystem(blocking, consumes: Plinko, sends: [MsgStrukt])] - plinkos: GoblinTower, - - i_like_pi: f64, - i_like_tuple: (f64, f64), - i_like_generic: Arc, - i_like_hash: HashMap<(U, V), Arc>, -} - -fn main() { - use futures::{executor, pin_mut}; - - executor::block_on(async move { - let (orchestra, _handle): (Duo<_, f64, u32, f32, f64>, _) = Duo::builder() - .sub0(AwesomeSubSys::default()) - .plinkos(Fortified::default()) - .i_like_pi(::std::f64::consts::PI) - .i_like_tuple((::std::f64::consts::PI, ::std::f64::consts::PI)) - .i_like_generic(Arc::new(42.0)) - .i_like_hash(HashMap::new()) - .spawner(DummySpawner) - .build() - .unwrap(); - - assert_eq!(orchestra.i_like_pi.floor() as i8, 3); - assert_eq!(orchestra.i_like_generic.floor() as i8, 42); - assert_eq!(orchestra.i_like_hash.len() as i8, 0); - - let orchestra_fut = orchestra - .running_subsystems - .into_future() - .timeout(std::time::Duration::from_millis(300)) - .fuse(); - - pin_mut!(orchestra_fut); - - orchestra_fut.await - }); -} diff --git a/node/orchestra/examples/misc.rs b/node/orchestra/examples/misc.rs deleted file mode 100644 index ffd5001d07bd..000000000000 --- a/node/orchestra/examples/misc.rs +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use orchestra::{Spawner, *}; - -#[derive(Debug, Clone, Copy)] -pub enum SigSigSig { - Conclude, - Foo, -} - -#[derive(Debug, Clone)] -pub struct DummySpawner; - -impl Spawner for DummySpawner { - fn spawn_blocking( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn blocking {} {}", task_name, subsystem_name.unwrap_or("default")) - } - - fn spawn( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn {} {}", task_name, subsystem_name.unwrap_or("default")) - } -} - -/// The external event. -#[derive(Debug, Clone)] -pub struct EvX; - -impl EvX { - pub fn focus<'a, T>(&'a self) -> Result { - unimplemented!("focus") - } -} - -#[derive(Debug, Clone, Copy)] -pub struct Yikes; - -impl std::fmt::Display for Yikes { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - writeln!(f, "yikes!") - } -} - -impl std::error::Error for Yikes {} - -impl From for Yikes { - fn from(_: orchestra::OrchestraError) -> Yikes { - Yikes - } -} - -impl From for Yikes { - fn from(_: orchestra::mpsc::SendError) -> Yikes { - Yikes - } -} - -#[derive(Debug, Clone)] -pub struct MsgStrukt(pub u8); - -#[derive(Debug, Clone, Copy)] -pub struct Plinko; diff --git a/node/orchestra/examples/solo.rs b/node/orchestra/examples/solo.rs deleted file mode 100644 index 67ebc292e46d..000000000000 --- a/node/orchestra/examples/solo.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![allow(dead_code)] // orchestra events are not used - -//! A minimal demo to be used with cargo expand. - -use orchestra::{self as orchestra, Spawner, *}; -mod misc; - -pub use self::misc::*; - -#[orchestra(signal=SigSigSig, event=EvX, error=Yikes, gen=AllMessages)] -struct Solo { - #[subsystem(consumes: Plinko, sends: [MsgStrukt])] - goblin_tower: GoblinTower, -} - -#[derive(Default)] -pub struct Fortified; - -#[orchestra::subsystem(GoblinTower, error=Yikes)] -impl Fortified { - fn start(self, mut ctx: Context) -> SpawnedSubsystem { - let mut sender = ctx.sender().clone(); - ctx.spawn( - "GoblinTower", - Box::pin(async move { - sender.send_message(MsgStrukt(8u8)).await; - }), - ) - .unwrap(); - unimplemented!("welcum") - } -} - -fn main() { - use futures::{executor, pin_mut}; - - executor::block_on(async move { - let (orchestra, _handle): (Solo<_>, _) = Solo::builder() - .goblin_tower(Fortified::default()) - .spawner(DummySpawner) - .build() - .unwrap(); - - let orchestra_fut = orchestra - .running_subsystems - .into_future() - .timeout(std::time::Duration::from_millis(300)) - .fuse(); - - pin_mut!(orchestra_fut); - - orchestra_fut.await - }); -} diff --git a/node/orchestra/proc-macro/Cargo.toml b/node/orchestra/proc-macro/Cargo.toml deleted file mode 100644 index e7873f4571bd..000000000000 --- a/node/orchestra/proc-macro/Cargo.toml +++ /dev/null @@ -1,38 +0,0 @@ -[package] -name = "orchestra-proc-macro" -version = "0.0.1" -authors = ["Parity Technologies "] -edition = "2021" -description = "Generate an orchestra of subsystems from a single annotated struct definition." -repository = "https://github.com/paritytech/polkadot" -license = "MIT OR Apache-2.0" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[lib] -proc-macro = true - -[dependencies] -syn = { version = "1.0.95", features = ["full", "extra-traits"] } -quote = "1.0.20" -proc-macro2 = "1.0.40" -proc-macro-crate = "1.1.3" -expander = { version = "0.0.6", default-features = false } -petgraph = "0.6.0" -itertools = { version = "0.10.3" } - -[dev-dependencies] -assert_matches = "1.5" -orchestra = { path = "../" } -thiserror = "1" -tracing = "0.1" - -[features] -default = [] # enable "graph" by default, blocked by -# write the expanded version to a `orchestra-expansion.[a-f0-9]{10}.rs` -# in the `OUT_DIR` as defined by `cargo` for the `expander` crate. -expand = [] -# Create directional message consuming / outgoing graph. -# Generates: `${OUT_DIR}/${orchestra|lowercase}-subsystem-messaging.dot` -graph = [] diff --git a/node/orchestra/proc-macro/build.rs b/node/orchestra/proc-macro/build.rs deleted file mode 100644 index 24bd09048397..000000000000 --- a/node/orchestra/proc-macro/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - // populate OUT_DIR -} diff --git a/node/orchestra/proc-macro/src/graph.rs b/node/orchestra/proc-macro/src/graph.rs deleted file mode 100644 index 2fd07e5ec711..000000000000 --- a/node/orchestra/proc-macro/src/graph.rs +++ /dev/null @@ -1,432 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use quote::ToTokens; -use syn::{Ident, Path}; - -use petgraph::{graph::NodeIndex, Graph}; -use std::collections::{hash_map::RandomState, HashMap, HashSet}; - -use super::*; - -/// Representation of all subsystem connections -pub(crate) struct ConnectionGraph<'a> { - /// Graph of connected subsystems - /// - /// The graph represents a subsystem as a node or `NodeIndex` - /// and edges are messages sent, directed from the sender to - /// the receiver of the message. - pub(crate) graph: Graph, - /// Cycles within the graph - #[cfg_attr(not(feature = "graph"), allow(dead_code))] - pub(crate) sccs: Vec>, - /// Messages that are never being sent (and by which subsystem), but are consumed - /// Maps the message `Path` to the subsystem `Ident` represented by `NodeIndex`. - #[cfg_attr(not(feature = "graph"), allow(dead_code))] - pub(crate) unsent_messages: HashMap<&'a Path, (&'a Ident, NodeIndex)>, - /// Messages being sent (and by which subsystem), but not consumed by any subsystem - /// Maps the message `Path` to the subsystem `Ident` represented by `NodeIndex`. - #[cfg_attr(not(feature = "graph"), allow(dead_code))] - pub(crate) unconsumed_messages: HashMap<&'a Path, Vec<(&'a Ident, NodeIndex)>>, -} - -impl<'a> ConnectionGraph<'a> { - /// Generates all subsystem types and related accumulation traits. - pub(crate) fn construct(ssfs: &'a [SubSysField]) -> Self { - // create a directed graph with all the subsystems as nodes and the messages as edges - // key is always the message path, values are node indices in the graph and the subsystem generic identifier - // store the message path and the source sender, both in the graph as well as identifier - let mut outgoing_lut = HashMap::<&Path, Vec<(&Ident, NodeIndex)>>::with_capacity(128); - // same for consuming the incoming messages - let mut consuming_lut = HashMap::<&Path, (&Ident, NodeIndex)>::with_capacity(128); - - let mut graph = Graph::::new(); - - // prepare the full index of outgoing and source subsystems - for ssf in ssfs { - let node_index = graph.add_node(ssf.generic.clone()); - for outgoing in ssf.messages_to_send.iter() { - outgoing_lut.entry(outgoing).or_default().push((&ssf.generic, node_index)); - } - if let Some(_first_consument) = - consuming_lut.insert(&ssf.message_to_consume, (&ssf.generic, node_index)) - { - // bail, two subsystems consuming the same message - } - } - - for (message_ty, (_consuming_subsystem_ident, consuming_node_index)) in consuming_lut.iter() - { - // match the outgoing ones that were registered above with the consumed message - if let Some(origin_subsystems) = outgoing_lut.get(message_ty) { - for (_origin_subsystem_ident, sending_node_index) in origin_subsystems.iter() { - graph.add_edge( - *sending_node_index, - *consuming_node_index, - (*message_ty).clone(), - ); - } - } - } - - // extract unsent and unreceived messages - let outgoing_set = HashSet::<_, RandomState>::from_iter(outgoing_lut.keys().cloned()); - let consuming_set = HashSet::<_, RandomState>::from_iter(consuming_lut.keys().cloned()); - - let mut unsent_messages = consuming_lut; - unsent_messages.retain(|k, _v| !outgoing_set.contains(k)); - - let mut unconsumed_messages = outgoing_lut; - unconsumed_messages.retain(|k, _v| !consuming_set.contains(k)); - - let scc = Self::extract_scc(&graph); - - Self { graph, sccs: scc, unsent_messages, unconsumed_messages } - } - - /// Extract the strongly connected components (`scc`) which each - /// includes at least one cycle each. - fn extract_scc(graph: &Graph) -> Vec> { - use petgraph::visit::EdgeRef; - - // there is no guarantee regarding the node indices in the individual sccs - let sccs = petgraph::algo::kosaraju_scc(&graph); - let sccs = Vec::from_iter(sccs.into_iter().filter(|scc| { - match scc.len() { - 1 => { - // contains sccs of length one, - // which do not exists, might be an upstream bug? - let node_idx = scc[0]; - graph - .edges_directed(node_idx, petgraph::Direction::Outgoing) - .find(|edge| edge.target() == node_idx) - .is_some() - }, - 0 => false, - _n => true, - } - })); - match sccs.len() { - 0 => println!("✅ Found no strongly connected components, hence no cycles exist"), - 1 => println!( - "⚡ Found 1 strongly connected component which includes at least one cycle" - ), - n => println!( - "⚡ Found {n} strongly connected components which includes at least one cycle each" - ), - } - - let greek_alphabet = greek_alphabet(); - - for (scc_idx, scc) in sccs.iter().enumerate() { - let scc_tag = greek_alphabet.get(scc_idx).copied().unwrap_or('_'); - let mut acc = Vec::with_capacity(scc.len()); - assert!(scc.len() > 0); - let mut node_idx = scc[0].clone(); - let print_idx = scc_idx + 1; - // track which ones were visited and which step - // the step is required to truncate the output - // which is required to greedily find a cycle in the strongly connected component - let mut visited = HashMap::new(); - for step in 0..scc.len() { - if let Some(edge) = - graph.edges_directed(node_idx, petgraph::Direction::Outgoing).find(|edge| { - scc.iter().find(|&scc_node_idx| *scc_node_idx == edge.target()).is_some() - }) { - let next = edge.target(); - visited.insert(node_idx, step); - - let subsystem_name = &graph[node_idx].to_string(); - let message_name = &graph[edge.id()].to_token_stream().to_string(); - acc.push(format!("{subsystem_name} ~~{{{message_name:?}}}~~> ")); - node_idx = next; - - if let Some(step) = visited.get(&next) { - // we've been there, so there is a cycle - // cut off the extra tail - assert!(acc.len() >= *step); - acc.drain(..step); - // there might be more cycles in this cluster, - // but for they are ignored, the graph shows - // the entire strongly connected component. - break - } - } else { - eprintln!("cycle({print_idx:03}) ∈ {scc_tag}: Missing connection in hypothesized cycle after {step} steps, this is a bug 🐛"); - break - } - } - let acc = String::from_iter(acc); - println!("cycle({print_idx:03}) ∈ {scc_tag}: {acc} *"); - } - - sccs - } - - /// Render a graphviz (aka dot graph) to a file. - /// - /// Cycles are annotated with the lower - #[cfg(feature = "graph")] - pub(crate) fn graphviz(self, dest: &mut impl std::io::Write) -> std::io::Result<()> { - use self::graph_helpers::*; - use petgraph::{ - dot::{self, Dot}, - visit::{EdgeRef, IntoEdgeReferences, IntoNodeReferences}, - }; - - // only write the grap content, we want a custom color scheme - let config = &[ - dot::Config::GraphContentOnly, - dot::Config::EdgeNoLabel, - dot::Config::NodeNoLabel, - ][..]; - - let Self { mut graph, unsent_messages, unconsumed_messages, sccs } = self; - - // the greek alphabet, lowercase - let greek_alphabet = greek_alphabet(); - - const COLOR_SCHEME_N: usize = 10; // rdylgn10 - - // Adding more than 10, is _definitely_ too much visual clutter in the graph. - const UPPER_BOUND: usize = 10; - - assert!(UPPER_BOUND <= GREEK_ALPHABET_SIZE); - assert!(UPPER_BOUND <= COLOR_SCHEME_N); - - let n = sccs.len(); - let n = if n > UPPER_BOUND { - eprintln!("Too many ({n}) strongly connected components, only annotating the first {UPPER_BOUND}"); - UPPER_BOUND - } else { - n - }; - - // restructure for lookups - let mut scc_lut = HashMap::>::with_capacity(n); - // lookup the color index (which is equiv to the index in the cycle set vector _plus one_) - // based on the cycle_tag (the greek char) - let mut color_lut = HashMap::::with_capacity(COLOR_SCHEME_N); - for (scc_idx, scc) in sccs.into_iter().take(UPPER_BOUND).enumerate() { - for node_idx in scc { - let _ = scc_lut.entry(node_idx).or_default().insert(greek_alphabet[scc_idx]); - } - color_lut.insert(greek_alphabet[scc_idx], scc_idx + 1); - } - let color_lut = &color_lut; - - // Adding nodes is ok, the `NodeIndex` is append only as long - // there are no removals. - - // Depict sink for unconsumed messages - let unconsumed_idx = graph.add_node(quote::format_ident!("SENT_TO_NONONE")); - for (message_name, subsystems) in unconsumed_messages { - // iterate over all subsystems that send such a message - for (_sub_name, sub_node_idx) in subsystems { - graph.add_edge(sub_node_idx, unconsumed_idx, message_name.clone()); - } - } - - // depict source of unsent message, this is legit when - // integrated with an external source, and sending messages based - // on that - let unsent_idx = graph.add_node(quote::format_ident!("NEVER_SENT_ANYWHERE")); - for (message_name, (_sub_name, sub_node_idx)) in unsent_messages { - graph.add_edge(unsent_idx, sub_node_idx, message_name.clone()); - } - let unsent_node_label = r#"label="✨",fillcolor=black,shape=doublecircle,style=filled,fontname="NotoColorEmoji""#; - let unconsumed_node_label = r#"label="💀",fillcolor=black,shape=doublecircle,style=filled,fontname="NotoColorEmoji""#; - let edge_attr = |_graph: &Graph, - edge: <&Graph as IntoEdgeReferences>::EdgeRef| - -> String { - let source = edge.source(); - let sink = edge.target(); - - let message_name = - edge.weight().get_ident().expect("Must have a trailing identifier. qed"); - - // use the intersection only, that's the set of cycles the edge is part of - if let Some(edge_intersecting_scc_tags) = scc_lut.get(&source).and_then(|source_set| { - scc_lut.get(&sink).and_then(move |sink_set| { - let intersection = - HashSet::<_, RandomState>::from_iter(source_set.intersection(sink_set)); - if intersection.is_empty() { - None - } else { - Some(intersection) - } - }) - }) { - if edge_intersecting_scc_tags.len() != 1 { - unreachable!("Strongly connected components are disjunct by definition. qed"); - } - let scc_tag = edge_intersecting_scc_tags.iter().next().unwrap(); - let color = get_color_by_tag(scc_tag, color_lut); - let scc_tag_str = cycle_tags_to_annotation(edge_intersecting_scc_tags, color_lut); - format!( - r#"color="{color}",fontcolor="{color}",xlabel=<{scc_tag_str}>,label="{message_name}""#, - ) - } else { - format!(r#"label="{message_name}""#,) - } - }; - let node_attr = - |_graph: &Graph, - (node_index, subsystem_name): <&Graph as IntoNodeReferences>::NodeRef| - -> String { - if node_index == unsent_idx { - unsent_node_label.to_owned().clone() - } else if node_index == unconsumed_idx { - unconsumed_node_label.to_owned().clone() - } else if let Some(edge_intersecting_scc_tags) = scc_lut.get(&node_index) { - if edge_intersecting_scc_tags.len() != 1 { - unreachable!( - "Strongly connected components are disjunct by definition. qed" - ); - }; - let scc_tag = edge_intersecting_scc_tags.iter().next().unwrap(); - let color = get_color_by_tag(scc_tag, color_lut); - - let scc_tag_str = - cycle_tags_to_annotation(edge_intersecting_scc_tags, color_lut); - format!( - r#"color="{color}",fontcolor="{color}",xlabel=<{scc_tag_str}>,label="{subsystem_name}""#, - ) - } else { - format!(r#"label="{subsystem_name}""#) - } - }; - let dot = Dot::with_attr_getters( - &graph, config, &edge_attr, // with state, the reference is a trouble maker - &node_attr, - ); - dest.write_all( - format!( - r#"digraph {{ - node [colorscheme={}] - {:?} -}}"#, - color_scheme(), - &dot - ) - .as_bytes(), - )?; - Ok(()) - } -} - -const GREEK_ALPHABET_SIZE: usize = 24; - -fn greek_alphabet() -> [char; GREEK_ALPHABET_SIZE] { - let mut alphabet = ['\u{03B1}'; 24]; - alphabet - .iter_mut() - .enumerate() - // closure should never return `None`, - // but rather safe than sorry - .for_each(|(i, c)| { - *c = char::from_u32(*c as u32 + i as u32).unwrap(); - }); - alphabet -} - -#[cfg(feature = "graph")] -mod graph_helpers { - use super::HashMap; - - pub(crate) const fn color_scheme() -> &'static str { - "rdylgn10" - } - - pub(crate) fn get_color_by_idx(color_idx: usize) -> String { - let scheme = color_scheme(); - format!("/{scheme}/{color_idx}") - } - - pub(crate) fn get_color_by_tag(scc_tag: &char, color_lut: &HashMap) -> String { - get_color_by_idx(color_lut.get(scc_tag).copied().unwrap_or_default()) - } - - /// A node can be member of multiple cycles, - /// but only of one strongly connected component. - pub(crate) fn cycle_tags_to_annotation<'a>( - cycle_tags: impl IntoIterator, - color_lut: &HashMap, - ) -> String { - // Must use fully qualified syntax: - // - let cycle_annotation = String::from_iter(itertools::Itertools::intersperse( - cycle_tags.into_iter().map(|scc_tag| { - let color = get_color_by_tag(scc_tag, color_lut); - format!(r#"{scc_tag}"#) - }), - ",".to_owned(), - )); - cycle_annotation - } -} - -#[cfg(test)] -mod tests { - // whenever this starts working, we should consider - // replacing the all caps idents with something like - // the below. - // - // - // For now the rendering is modified, the ident is a placeholder. - #[test] - #[should_panic] - fn check_ident() { - let _ident = quote::format_ident!("x💀x"); - } - - #[test] - fn kosaraju_scc_check_nodes_cannot_be_part_of_two_clusters() { - let mut graph = petgraph::graph::DiGraph::::new(); - - let a_idx = graph.add_node('A'); - let b_idx = graph.add_node('B'); - let c_idx = graph.add_node('C'); - let d_idx = graph.add_node('D'); - let e_idx = graph.add_node('E'); - let f_idx = graph.add_node('F'); - - graph.add_edge(a_idx, b_idx, "10"); - graph.add_edge(b_idx, c_idx, "11"); - graph.add_edge(c_idx, a_idx, "12"); - - graph.add_edge(a_idx, d_idx, "20"); - graph.add_edge(d_idx, c_idx, "21"); - - graph.add_edge(b_idx, e_idx, "30"); - graph.add_edge(e_idx, c_idx, "31"); - - graph.add_edge(c_idx, f_idx, "40"); - - let mut sccs = dbg!(petgraph::algo::kosaraju_scc(&graph)); - - dbg!(graph); - - sccs.sort_by(|a, b| { - if a.len() < b.len() { - std::cmp::Ordering::Greater - } else { - std::cmp::Ordering::Less - } - }); - assert_eq!(sccs.len(), 2); // `f` and everything else - assert_eq!(sccs[0].len(), 5); // every node but `f` - } -} diff --git a/node/orchestra/proc-macro/src/impl_builder.rs b/node/orchestra/proc-macro/src/impl_builder.rs deleted file mode 100644 index 1be25d45b5e4..000000000000 --- a/node/orchestra/proc-macro/src/impl_builder.rs +++ /dev/null @@ -1,759 +0,0 @@ -// Copyright (C) 2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use quote::{format_ident, quote}; -use syn::{parse_quote, Path, PathSegment, TypePath}; - -use super::*; - -fn recollect_without_idx(x: &[T], idx: usize) -> Vec { - let mut v = Vec::::with_capacity(x.len().saturating_sub(1)); - v.extend(x.iter().take(idx).cloned()); - v.extend(x.iter().skip(idx + 1).cloned()); - v -} - -/// Implement a builder pattern for the `Orchestra`-type, -/// which acts as the gateway to constructing the orchestra. -/// -/// Elements tagged with `wip` are not covered here. -pub(crate) fn impl_builder(info: &OrchestraInfo) -> proc_macro2::TokenStream { - let orchestra_name = info.orchestra_name.clone(); - let builder = format_ident!("{}Builder", orchestra_name); - let handle = format_ident!("{}Handle", orchestra_name); - let connector = format_ident!("{}Connector", orchestra_name); - let subsystem_ctx_name = format_ident!("{}SubsystemContext", orchestra_name); - - let subsystem_name = &info.subsystem_names_without_wip(); - let subsystem_generics = &info.subsystem_generic_types(); - - let consumes = &info.consumes_without_wip(); - let channel_name = &info.channel_names_without_wip(""); - let channel_name_unbounded = &info.channel_names_without_wip("_unbounded"); - - let channel_name_tx = &info.channel_names_without_wip("_tx"); - let channel_name_unbounded_tx = &info.channel_names_without_wip("_unbounded_tx"); - - let channel_name_rx = &info.channel_names_without_wip("_rx"); - let channel_name_unbounded_rx = &info.channel_names_without_wip("_unbounded_rx"); - - let baggage_name = &info.baggage_names(); - let baggage_generic_ty = &info.baggage_generic_types(); - - // State generics that are used to encode each field's status (Init/Missing) - let baggage_passthrough_state_generics = baggage_name - .iter() - .enumerate() - .map(|(idx, _)| format_ident!("InitStateBaggage{}", idx)) - .collect::>(); - let subsystem_passthrough_state_generics = subsystem_name - .iter() - .enumerate() - .map(|(idx, _)| format_ident!("InitStateSubsystem{}", idx)) - .collect::>(); - - let error_ty = &info.extern_error_ty; - - let support_crate = info.support_crate_name(); - - let blocking = &info - .subsystems() - .iter() - .map(|x| { - if x.blocking { - quote! { Blocking } - } else { - quote! { Regular } - } - }) - .collect::>(); - - // Helpers to use within quote! macros - let spawner_where_clause: syn::TypeParam = parse_quote! { - S: #support_crate ::Spawner - }; - - // Field names and real types - let field_name = subsystem_name.iter().chain(baggage_name.iter()).collect::>(); - let field_type = subsystem_generics - .iter() - .map(|ident| { - syn::Type::Path(TypePath { - qself: None, - path: Path::from(PathSegment::from(ident.clone())), - }) - }) - .chain(info.baggage().iter().map(|bag| bag.field_ty.clone())) - .collect::>(); - - // Setters logic - - // For each setter we need to leave the remaining fields untouched and - // remove the field that we are fixing in this setter - // For subsystems `*_with` and `replace_*` setters are needed. - let subsystem_specific_setters = - info.subsystems().iter().filter(|ssf| !ssf.wip).enumerate().map(|(idx, ssf)| { - let field_name = &ssf.name; - let field_type = &ssf.generic; - let subsystem_consumes = &ssf.message_to_consume; - // Remove state generic for the item to be replaced. It sufficient to know `field_type` for - // that since we always move from `Init<#field_type>` to `Init`. - let impl_subsystem_state_generics = recollect_without_idx(&subsystem_passthrough_state_generics[..], idx); - - let field_name_with = format_ident!("{}_with", field_name); - let field_name_replace = format_ident!("replace_{}", field_name); - - // In a setter we replace `Uninit` with `Init` leaving all other - // types as they are, as such they will be free generics. - let mut current_state_generics = subsystem_passthrough_state_generics - .iter() - .map(|subsystem_state_generic_ty| parse_quote!(#subsystem_state_generic_ty)) - .collect::>(); - current_state_generics[idx] = parse_quote! { Missing<#field_type> }; - - // Generics that will be present after initializing a specific `Missing<_>` field. - let mut post_setter_state_generics = current_state_generics.clone(); - post_setter_state_generics[idx] = parse_quote! { Init<#field_type> }; - - let mut post_replace_state_generics = current_state_generics.clone(); - post_replace_state_generics[idx] = parse_quote! { Init }; - - // All fields except the one we update with the new argument - // see the loop below. - let to_keep_subsystem_name = recollect_without_idx(&subsystem_name[..], idx); - - let subsystem_sender_trait = format_ident!("{}SenderTrait", field_type); - let _subsystem_ctx_trait = format_ident!("{}ContextTrait", field_type); - - let builder_where_clause = quote!{ - #field_type : #support_crate::Subsystem< #subsystem_ctx_name< #subsystem_consumes >, #error_ty>, - < #subsystem_ctx_name < #subsystem_consumes > as #support_crate :: SubsystemContext>::Sender: - #subsystem_sender_trait, - }; - - // Create the field init `fn` - quote! { - impl - #builder - where - #builder_where_clause - { - /// Specify the subsystem in the builder directly - pub fn #field_name (self, var: #field_type ) -> - #builder - { - #builder { - #field_name: Init::< #field_type >::Value(var), - #( - #to_keep_subsystem_name: self. #to_keep_subsystem_name, - )* - #( - #baggage_name: self. #baggage_name, - )* - spawner: self.spawner, - - channel_capacity: self.channel_capacity, - signal_capacity: self.signal_capacity, - } - } - /// Specify the the initialization function for a subsystem - pub fn #field_name_with<'a, F>(self, subsystem_init_fn: F ) -> - #builder - where - F: 'static + FnOnce(#handle) -> - ::std::result::Result<#field_type, #error_ty>, - { - let boxed_func = Init::<#field_type>::Fn( - Box::new(subsystem_init_fn) as SubsystemInitFn<#field_type> - ); - #builder { - #field_name: boxed_func, - #( - #to_keep_subsystem_name: self. #to_keep_subsystem_name, - )* - #( - #baggage_name: self. #baggage_name, - )* - spawner: self.spawner, - - - channel_capacity: self.channel_capacity, - signal_capacity: self.signal_capacity, - } - } - } - - impl - #builder - where - #builder_where_clause - { - /// Replace a subsystem by another implementation for the - /// consumable message type. - pub fn #field_name_replace(self, gen_replacement_fn: F) - -> #builder - where - #field_type: 'static, - F: 'static + FnOnce(#field_type) -> NEW, - NEW: #support_crate ::Subsystem<#subsystem_ctx_name< #subsystem_consumes >, #error_ty>, - { - let replacement: Init = match self.#field_name { - Init::Fn(fx) => - Init::::Fn(Box::new(move |handle: #handle| { - let orig = fx(handle)?; - Ok(gen_replacement_fn(orig)) - })), - Init::Value(val) => - Init::Value(gen_replacement_fn(val)), - }; - #builder { - #field_name: replacement, - #( - #to_keep_subsystem_name: self. #to_keep_subsystem_name, - )* - #( - #baggage_name: self. #baggage_name, - )* - spawner: self.spawner, - - channel_capacity: self.channel_capacity, - signal_capacity: self.signal_capacity, - } - } - } - } - }); - - // Produce setters for all baggage fields as well - let baggage_specific_setters = info.baggage().iter().enumerate().map(|(idx, bag_field)| { - // Baggage fields follow subsystems - let fname = &bag_field.field_name; - let field_type = &bag_field.field_ty; - let impl_baggage_state_generics = recollect_without_idx(&baggage_passthrough_state_generics[..], idx); - let to_keep_baggage_name = recollect_without_idx(&baggage_name[..], idx); - - let mut pre_setter_generics = baggage_passthrough_state_generics - .iter() - .map(|gen_ty| parse_quote!(#gen_ty)) - .collect::>(); - pre_setter_generics[idx] = parse_quote! { Missing<#field_type> }; - - let mut post_setter_generics = pre_setter_generics.clone(); - post_setter_generics[idx] = parse_quote! { Init<#field_type> }; - - // Baggage can also be generic, so we need to include that to a signature - let preserved_baggage_generics = &bag_field.generic_types; - quote! { - impl - #builder - { - /// Specify the baggage in the builder when it was not initialized before - pub fn #fname (self, var: #field_type ) -> - #builder - { - #builder { - #fname: Init::<#field_type>::Value(var), - #( - #subsystem_name: self. #subsystem_name, - )* - #( - #to_keep_baggage_name: self. #to_keep_baggage_name, - )* - spawner: self.spawner, - - channel_capacity: self.channel_capacity, - signal_capacity: self.signal_capacity, - } - } - } - impl - #builder { - /// Specify the baggage in the builder when it has been previously initialized - pub fn #fname (self, var: #field_type ) -> - #builder - { - #builder { - #fname: Init::<#field_type>::Value(var), - #( - #subsystem_name: self. #subsystem_name, - )* - #( - #to_keep_baggage_name: self. #to_keep_baggage_name, - )* - spawner: self.spawner, - - channel_capacity: self.channel_capacity, - signal_capacity: self.signal_capacity, - } - } - } - } - }); - - let event = &info.extern_event_ty; - let initialized_builder = format_ident!("Initialized{}", builder); - // The direct generics as expected by the `Orchestra<_,_,..>`, without states - let initialized_builder_generics = quote! { - S, #( #baggage_generic_ty, )* #( #subsystem_generics, )* - }; - - let builder_where_clause = info - .subsystems() - .iter() - .map(|ssf| { - let field_type = &ssf.generic; - let consumes = &ssf.message_to_consume; - let subsystem_sender_trait = format_ident!("{}SenderTrait", ssf.generic); - let subsystem_ctx_trait = format_ident!("{}ContextTrait", ssf.generic); - quote! { - #field_type: - #support_crate::Subsystem< #subsystem_ctx_name < #consumes>, #error_ty>, - <#subsystem_ctx_name< #consumes > as #subsystem_ctx_trait>::Sender: - #subsystem_sender_trait, - #subsystem_ctx_name< #consumes >: - #subsystem_ctx_trait, - } - }) - .fold(TokenStream::new(), |mut ts, addendum| { - ts.extend(addendum); - ts - }); - - let mut ts = quote! { - /// Convenience alias. - type SubsystemInitFn = Box ::std::result::Result >; - - /// Type for the initialized field of the orchestra builder - pub enum Init { - /// Defer initialization to a point where the `handle` is available. - Fn(SubsystemInitFn), - /// Directly initialize the subsystem with the given subsystem type `T`. - /// Also used for baggage fields - Value(T), - } - /// Type marker for the uninitialized field of the orchestra builder. - /// `PhantomData` is used for type hinting when creating uninitialized - /// builder, e.g. to avoid specifying the generics when instantiating - /// the `FooBuilder` when calling `Foo::builder()` - #[derive(Debug)] - pub struct Missing(::core::marker::PhantomData); - - /// Trait used to mark fields status in a builder - trait OrchestraFieldState {} - - impl OrchestraFieldState for Init {} - impl OrchestraFieldState for Missing {} - - impl ::std::default::Default for Missing { - fn default() -> Self { - Missing::(::core::marker::PhantomData::::default()) - } - } - - impl #orchestra_name - where - #spawner_where_clause, - { - /// Create a new orchestra utilizing the builder. - pub fn builder< #( #subsystem_generics),* >() -> - #builder #(, Missing< #field_type > )* > - where - #builder_where_clause - { - #builder :: new() - } - } - }; - - ts.extend(quote! { - /// Handle for an orchestra. - pub type #handle = #support_crate ::metered::MeteredSender< #event >; - - /// External connector. - pub struct #connector { - /// Publicly accessible handle, to be used for setting up - /// components that are _not_ subsystems but access is needed - /// due to other limitations. - /// - /// For subsystems, use the `_with` variants of the builder. - handle: #handle, - /// The side consumed by the `spawned` side of the orchestra pattern. - consumer: #support_crate ::metered::MeteredReceiver < #event >, - } - - impl #connector { - /// Obtain access to the orchestra handle. - pub fn as_handle_mut(&mut self) -> &mut #handle { - &mut self.handle - } - /// Obtain access to the orchestra handle. - pub fn as_handle(&self) -> &#handle { - &self.handle - } - /// Obtain a clone of the handle. - pub fn handle(&self) -> #handle { - self.handle.clone() - } - - /// Create a new connector with non-default event channel capacity. - pub fn with_event_capacity(event_channel_capacity: usize) -> Self { - let (events_tx, events_rx) = #support_crate ::metered::channel::< - #event - >(event_channel_capacity); - - Self { - handle: events_tx, - consumer: events_rx, - } - } - } - - impl ::std::default::Default for #connector { - fn default() -> Self { - Self::with_event_capacity(SIGNAL_CHANNEL_CAPACITY) - } - } - }); - - ts.extend(quote!{ - /// Builder pattern to create compile time safe construction path. - pub struct #builder - { - #( - #subsystem_name: #subsystem_passthrough_state_generics, - )* - #( - #baggage_name: #baggage_passthrough_state_generics, - )* - spawner: InitStateSpawner, - // user provided runtime overrides, - // if `None`, the `orchestra(message_capacity=123,..)` is used - // or the default value. - channel_capacity: Option, - signal_capacity: Option, - } - }); - - ts.extend(quote! { - impl<#initialized_builder_generics> #builder, #( Missing<#field_type>, )*> - { - /// Create a new builder pattern, with all fields being uninitialized. - fn new() -> Self { - // explicitly assure the required traits are implemented - fn trait_from_must_be_implemented() - where - E: ::std::error::Error + Send + Sync + 'static + From<#support_crate ::OrchestraError> - {} - - trait_from_must_be_implemented::< #error_ty >(); - - Self { - #( - #field_name: Missing::<#field_type>::default(), - )* - spawner: Missing::::default(), - - channel_capacity: None, - signal_capacity: None, - } - } - } - }); - - // Spawner setter - ts.extend(quote!{ - impl - #builder, #( #subsystem_passthrough_state_generics, )* #( #baggage_passthrough_state_generics, )*> - where - #spawner_where_clause, - { - /// The `spawner` to use for spawning tasks. - pub fn spawner(self, spawner: S) -> #builder< - Init, - #( #subsystem_passthrough_state_generics, )* - #( #baggage_passthrough_state_generics, )* - > - { - #builder { - #( - #field_name: self. #field_name, - )* - spawner: Init::::Value(spawner), - - channel_capacity: self.channel_capacity, - signal_capacity: self.signal_capacity, - } - } - } - }); - - // message and signal channel capacity - ts.extend(quote! { - impl - #builder, #( #subsystem_passthrough_state_generics, )* #( #baggage_passthrough_state_generics, )*> - where - #spawner_where_clause, - { - /// Set the interconnecting signal channel capacity. - pub fn signal_channel_capacity(mut self, capacity: usize) -> Self - { - self.signal_capacity = Some(capacity); - self - } - - /// Set the interconnecting message channel capacities. - pub fn message_channel_capacity(mut self, capacity: usize) -> Self - { - self.channel_capacity = Some(capacity); - self - } - } - }); - - // Create the string literals for spawn. - let subsystem_name_str_literal = subsystem_name - .iter() - .map(|ident| proc_macro2::Literal::string(ident.to_string().replace("_", "-").as_str())) - .collect::>(); - - ts.extend(quote! { - /// Type used to represent a builder where all fields are initialized and the orchestra could be constructed. - pub type #initialized_builder<#initialized_builder_generics> = #builder, #( Init<#field_type>, )*>; - - // A builder specialization where all fields are set - impl<#initialized_builder_generics> #initialized_builder<#initialized_builder_generics> - where - #spawner_where_clause, - #builder_where_clause - { - /// Complete the construction and create the orchestra type. - pub fn build(self) - -> ::std::result::Result<(#orchestra_name, #handle), #error_ty> { - let connector = #connector ::with_event_capacity( - self.signal_capacity.unwrap_or(SIGNAL_CHANNEL_CAPACITY) - ); - self.build_with_connector(connector) - } - - /// Complete the construction and create the orchestra type based on an existing `connector`. - pub fn build_with_connector(self, connector: #connector) - -> ::std::result::Result<(#orchestra_name, #handle), #error_ty> - { - let #connector { - handle: events_tx, - consumer: events_rx, - } = connector; - - let handle = events_tx.clone(); - - let (to_orchestra_tx, to_orchestra_rx) = #support_crate ::metered::unbounded::< - ToOrchestra - >(); - - #( - let (#channel_name_tx, #channel_name_rx) - = - #support_crate ::metered::channel::< - MessagePacket< #consumes > - >( - self.channel_capacity.unwrap_or(CHANNEL_CAPACITY) - ); - )* - - #( - let (#channel_name_unbounded_tx, #channel_name_unbounded_rx) = - #support_crate ::metered::unbounded::< - MessagePacket< #consumes > - >(); - )* - - let channels_out = - ChannelsOut { - #( - #channel_name: #channel_name_tx .clone(), - )* - #( - #channel_name_unbounded: #channel_name_unbounded_tx, - )* - }; - - let mut spawner = match self.spawner { - Init::Value(value) => value, - _ => unreachable!("Only ever init spawner as value. qed"), - }; - - let mut running_subsystems = #support_crate ::FuturesUnordered::< - BoxFuture<'static, ::std::result::Result<(), #error_ty > > - >::new(); - - #( - let #subsystem_name = match self. #subsystem_name { - Init::Fn(func) => func(handle.clone())?, - Init::Value(val) => val, - }; - - let unbounded_meter = #channel_name_unbounded_rx.meter().clone(); - // Prefer unbounded channel when selecting - let message_rx: SubsystemIncomingMessages< #consumes > = #support_crate ::select_with_strategy( - #channel_name_rx, #channel_name_unbounded_rx, - #support_crate ::select_message_channel_strategy - ); - let (signal_tx, signal_rx) = #support_crate ::metered::channel( - self.signal_capacity.unwrap_or(SIGNAL_CHANNEL_CAPACITY) - ); - - let ctx = #subsystem_ctx_name::< #consumes >::new( - signal_rx, - message_rx, - channels_out.clone(), - to_orchestra_tx.clone(), - #subsystem_name_str_literal - ); - - let #subsystem_name: OrchestratedSubsystem< #consumes > = - spawn::<_,_, #blocking, _, _, _>( - &mut spawner, - #channel_name_tx, - signal_tx, - unbounded_meter, - ctx, - #subsystem_name, - #subsystem_name_str_literal, - &mut running_subsystems, - )?; - )* - - use #support_crate ::StreamExt; - - let to_orchestra_rx = to_orchestra_rx.fuse(); - let orchestra = #orchestra_name { - #( - #subsystem_name, - )* - - #( - #baggage_name: match self. #baggage_name { - Init::Value(val) => val, - _ => panic!("unexpected baggage initialization, must be value"), - }, - )* - - spawner, - running_subsystems, - events_rx, - to_orchestra_rx, - }; - - Ok((orchestra, handle)) - } - } - }); - - ts.extend(baggage_specific_setters); - ts.extend(subsystem_specific_setters); - ts.extend(impl_task_kind(info)); - ts -} - -pub(crate) fn impl_task_kind(info: &OrchestraInfo) -> proc_macro2::TokenStream { - let signal = &info.extern_signal_ty; - let error_ty = &info.extern_error_ty; - let support_crate = info.support_crate_name(); - - let ts = quote! { - /// Task kind to launch. - pub trait TaskKind { - /// Spawn a task, it depends on the implementer if this is blocking or not. - fn launch_task(spawner: &mut S, task_name: &'static str, subsystem_name: &'static str, future: BoxFuture<'static, ()>); - } - - #[allow(missing_docs)] - struct Regular; - impl TaskKind for Regular { - fn launch_task(spawner: &mut S, task_name: &'static str, subsystem_name: &'static str, future: BoxFuture<'static, ()>) { - spawner.spawn(task_name, Some(subsystem_name), future) - } - } - - #[allow(missing_docs)] - struct Blocking; - impl TaskKind for Blocking { - fn launch_task(spawner: &mut S, task_name: &'static str, subsystem_name: &'static str, future: BoxFuture<'static, ()>) { - spawner.spawn_blocking(task_name, Some(subsystem_name), future) - } - } - - /// Spawn task of kind `self` using spawner `S`. - pub fn spawn( - spawner: &mut S, - message_tx: #support_crate ::metered::MeteredSender>, - signal_tx: #support_crate ::metered::MeteredSender< #signal >, - // meter for the unbounded channel - unbounded_meter: #support_crate ::metered::Meter, - ctx: Ctx, - s: SubSys, - subsystem_name: &'static str, - futures: &mut #support_crate ::FuturesUnordered >>, - ) -> ::std::result::Result, #error_ty > - where - S: #support_crate ::Spawner, - M: std::fmt::Debug + Send + 'static, - TK: TaskKind, - Ctx: #support_crate ::SubsystemContext, - E: ::std::error::Error + Send + Sync + 'static + ::std::convert::From<#support_crate ::OrchestraError>, - SubSys: #support_crate ::Subsystem, - { - let #support_crate ::SpawnedSubsystem:: { future, name } = s.start(ctx); - - let (tx, rx) = #support_crate ::oneshot::channel(); - - let fut = Box::pin(async move { - if let Err(e) = future.await { - #support_crate ::tracing::error!(subsystem=name, err = ?e, "subsystem exited with error"); - } else { - #support_crate ::tracing::debug!(subsystem=name, "subsystem exited without an error"); - } - let _ = tx.send(()); - }); - - ::launch_task(spawner, name, subsystem_name, fut); - - futures.push(Box::pin( - rx.map(|e| { - #support_crate ::tracing::warn!(err = ?e, "dropping error"); - Ok(()) - }) - )); - - let instance = Some(SubsystemInstance { - meters: #support_crate ::SubsystemMeters { - unbounded: unbounded_meter, - bounded: message_tx.meter().clone(), - signals: signal_tx.meter().clone(), - }, - tx_signal: signal_tx, - tx_bounded: message_tx, - signals_received: 0, - name, - }); - - Ok(OrchestratedSubsystem { - instance, - }) - } - }; - - ts -} diff --git a/node/orchestra/proc-macro/src/impl_channels_out.rs b/node/orchestra/proc-macro/src/impl_channels_out.rs deleted file mode 100644 index 5b694d15229d..000000000000 --- a/node/orchestra/proc-macro/src/impl_channels_out.rs +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (C) 2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use quote::quote; -use syn::Result; - -use super::*; - -/// Implement the helper type `ChannelsOut` and `MessagePacket`. -pub(crate) fn impl_channels_out_struct(info: &OrchestraInfo) -> Result { - let message_wrapper = info.message_wrapper.clone(); - - let channel_name = &info.channel_names_without_wip(""); - let channel_name_unbounded = &info.channel_names_without_wip("_unbounded"); - - let consumes = &info.consumes_without_wip(); - - let consumes_variant = &info.variant_names_without_wip(); - let unconsumes_variant = &info.variant_names_only_wip(); - - let support_crate = info.support_crate_name(); - - let ts = quote! { - /// Collection of channels to the individual subsystems. - /// - /// Naming is from the point of view of the orchestra. - #[derive(Debug, Clone)] - pub struct ChannelsOut { - #( - /// Bounded channel sender, connected to a subsystem. - pub #channel_name: - #support_crate ::metered::MeteredSender< - MessagePacket< #consumes > - >, - )* - - #( - /// Unbounded channel sender, connected to a subsystem. - pub #channel_name_unbounded: - #support_crate ::metered::UnboundedMeteredSender< - MessagePacket< #consumes > - >, - )* - } - - #[allow(unreachable_code)] - // when no defined messages in enum - impl ChannelsOut { - /// Send a message via a bounded channel. - pub async fn send_and_log_error( - &mut self, - signals_received: usize, - message: #message_wrapper, - ) { - - let res: ::std::result::Result<_, _> = match message { - #( - #message_wrapper :: #consumes_variant ( inner ) => { - self. #channel_name .send( - #support_crate ::make_packet(signals_received, inner) - ).await.map_err(|_| stringify!( #channel_name )) - } - )* - // subsystems that are wip - #( - #message_wrapper :: #unconsumes_variant ( _ ) => Ok(()), - )* - // dummy message type - #message_wrapper :: Empty => Ok(()), - - #[allow(unreachable_patterns)] - // And everything that's not WIP but no subsystem consumes it - unused_msg => { - #support_crate :: tracing :: warn!("Nothing consumes {:?}", unused_msg); - Ok(()) - } - }; - - if let Err(subsystem_name) = res { - #support_crate ::tracing::debug!( - target: LOG_TARGET, - "Failed to send (bounded) a message to {} subsystem", - subsystem_name - ); - } - } - - /// Send a message to another subsystem via an unbounded channel. - pub fn send_unbounded_and_log_error( - &self, - signals_received: usize, - message: #message_wrapper, - ) { - let res: ::std::result::Result<_, _> = match message { - #( - #message_wrapper :: #consumes_variant (inner) => { - self. #channel_name_unbounded .unbounded_send( - #support_crate ::make_packet(signals_received, inner) - ) - .map_err(|_| stringify!( #channel_name )) - }, - )* - // subsystems that are wip - #( - #message_wrapper :: #unconsumes_variant ( _ ) => Ok(()), - )* - // dummy message type - #message_wrapper :: Empty => Ok(()), - - // And everything that's not WIP but no subsystem consumes it - #[allow(unreachable_patterns)] - unused_msg => { - #support_crate :: tracing :: warn!("Nothing consumes {:?}", unused_msg); - Ok(()) - } - }; - - if let Err(subsystem_name) = res { - #support_crate ::tracing::debug!( - target: LOG_TARGET, - "Failed to send_unbounded a message to {} subsystem", - subsystem_name - ); - } - } - } - - }; - Ok(ts) -} diff --git a/node/orchestra/proc-macro/src/impl_message_wrapper.rs b/node/orchestra/proc-macro/src/impl_message_wrapper.rs deleted file mode 100644 index 3c2f99999208..000000000000 --- a/node/orchestra/proc-macro/src/impl_message_wrapper.rs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (C) 2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use quote::quote; -use syn::{spanned::Spanned, Result}; - -use super::*; - -/// Generates the wrapper type enum. -pub(crate) fn impl_message_wrapper_enum(info: &OrchestraInfo) -> Result { - let consumes = info.any_message(); - let consumes_variant = info.variant_names(); - - let outgoing = &info.outgoing_ty; - - let message_wrapper = &info.message_wrapper; - - let (outgoing_from_impl, outgoing_decl) = if let Some(outgoing) = outgoing { - let outgoing_variant = outgoing.get_ident().ok_or_else(|| { - syn::Error::new( - outgoing.span(), - "Missing identifier to use as enum variant for outgoing.", - ) - })?; - ( - quote! { - impl ::std::convert::From< #outgoing > for #message_wrapper { - fn from(message: #outgoing) -> Self { - #message_wrapper :: #outgoing_variant ( message ) - } - } - }, - quote! { - #outgoing_variant ( #outgoing ) , - }, - ) - } else { - (TokenStream::new(), TokenStream::new()) - }; - - let ts = quote! { - /// Generated message type wrapper over all possible messages - /// used by any subsystem. - #[allow(missing_docs)] - #[derive(Debug)] - pub enum #message_wrapper { - #( - #consumes_variant ( #consumes ), - )* - #outgoing_decl - // dummy message type - Empty, - } - - impl ::std::convert::From< () > for #message_wrapper { - fn from(_: ()) -> Self { - #message_wrapper :: Empty - } - } - - #( - impl ::std::convert::From< #consumes > for #message_wrapper { - fn from(message: #consumes) -> Self { - #message_wrapper :: #consumes_variant ( message ) - } - } - )* - - #outgoing_from_impl - }; - - Ok(ts) -} diff --git a/node/orchestra/proc-macro/src/impl_orchestra.rs b/node/orchestra/proc-macro/src/impl_orchestra.rs deleted file mode 100644 index 66ff6c60939b..000000000000 --- a/node/orchestra/proc-macro/src/impl_orchestra.rs +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright (C) 2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use quote::quote; - -use super::*; - -pub(crate) fn impl_orchestra_struct(info: &OrchestraInfo) -> proc_macro2::TokenStream { - let message_wrapper = &info.message_wrapper.clone(); - let orchestra_name = info.orchestra_name.clone(); - let subsystem_name = &info.subsystem_names_without_wip(); - let support_crate = info.support_crate_name(); - - let baggage_decl = &info.baggage_decl(); - - let baggage_generic_ty = &info.baggage_generic_types(); - - let generics = quote! { - < S, #( #baggage_generic_ty, )* > - }; - - let where_clause = quote! { - where - S: #support_crate ::Spawner, - }; - // TODO add `where ..` clauses for baggage types - // TODO - - let consumes = &info.consumes_without_wip(); - let consumes_variant = &info.variant_names_without_wip(); - let unconsumes_variant = &info.variant_names_only_wip(); - - let signal_ty = &info.extern_signal_ty; - - let error_ty = &info.extern_error_ty; - - let event_ty = &info.extern_event_ty; - - let message_channel_capacity = info.message_channel_capacity; - let signal_channel_capacity = info.signal_channel_capacity; - - let log_target = - syn::LitStr::new(orchestra_name.to_string().to_lowercase().as_str(), orchestra_name.span()); - - let ts = quote! { - /// Capacity of a bounded message channel between orchestra and subsystem - /// but also for bounded channels between two subsystems. - const CHANNEL_CAPACITY: usize = #message_channel_capacity; - - /// Capacity of a signal channel between a subsystem and the orchestra. - const SIGNAL_CHANNEL_CAPACITY: usize = #signal_channel_capacity; - - /// The log target tag. - const LOG_TARGET: &'static str = #log_target; - - /// The orchestra. - pub struct #orchestra_name #generics { - - #( - /// A subsystem instance. - #subsystem_name: OrchestratedSubsystem< #consumes >, - )* - - #( - /// A user specified addendum field. - #baggage_decl , - )* - - /// Responsible for driving the subsystem futures. - spawner: S, - - /// The set of running subsystems. - running_subsystems: #support_crate ::FuturesUnordered< - BoxFuture<'static, ::std::result::Result<(), #error_ty>> - >, - - /// Gather running subsystems' outbound streams into one. - to_orchestra_rx: #support_crate ::stream::Fuse< - #support_crate ::metered::UnboundedMeteredReceiver< #support_crate ::ToOrchestra > - >, - - /// Events that are sent to the orchestra from the outside world. - events_rx: #support_crate ::metered::MeteredReceiver< #event_ty >, - } - - impl #generics #orchestra_name #generics #where_clause { - /// Send the given signal, a termination signal, to all subsystems - /// and wait for all subsystems to go down. - /// - /// The definition of a termination signal is up to the user and - /// implementation specific. - pub async fn wait_terminate(&mut self, signal: #signal_ty, timeout: ::std::time::Duration) -> ::std::result::Result<(), #error_ty > { - #( - ::std::mem::drop(self. #subsystem_name .send_signal(signal.clone()).await); - )* - let _ = signal; - - let mut timeout_fut = #support_crate ::Delay::new( - timeout - ).fuse(); - - loop { - #support_crate ::futures::select! { - _ = self.running_subsystems.next() => - if self.running_subsystems.is_empty() { - break; - }, - _ = timeout_fut => break, - complete => break, - } - } - - Ok(()) - } - - /// Broadcast a signal to all subsystems. - pub async fn broadcast_signal(&mut self, signal: #signal_ty) -> ::std::result::Result<(), #error_ty > { - #( - let _ = self. #subsystem_name .send_signal(signal.clone()).await; - )* - let _ = signal; - - Ok(()) - } - - /// Route a particular message to a subsystem that consumes the message. - pub async fn route_message(&mut self, message: #message_wrapper, origin: &'static str) -> ::std::result::Result<(), #error_ty > { - match message { - #( - #message_wrapper :: #consumes_variant ( inner ) => - OrchestratedSubsystem::< #consumes >::send_message2(&mut self. #subsystem_name, inner, origin ).await?, - )* - // subsystems that are still work in progress - #( - #message_wrapper :: #unconsumes_variant ( _ ) => {} - )* - #message_wrapper :: Empty => {} - - // And everything that's not WIP but no subsystem consumes it - #[allow(unreachable_patterns)] - unused_msg => { - #support_crate :: tracing :: warn!("Nothing consumes {:?}", unused_msg); - } - } - Ok(()) - } - - /// Extract information from each subsystem. - pub fn map_subsystems<'a, Mapper, Output>(&'a self, mapper: Mapper) - -> Vec - where - #( - Mapper: MapSubsystem<&'a OrchestratedSubsystem< #consumes >, Output=Output>, - )* - { - vec![ - #( - mapper.map_subsystem( & self. #subsystem_name ), - )* - ] - } - - /// Get access to internal task spawner. - pub fn spawner<'a> (&'a mut self) -> &'a mut S { - &mut self.spawner - } - } - - }; - - ts -} - -pub(crate) fn impl_orchestrated_subsystem(info: &OrchestraInfo) -> proc_macro2::TokenStream { - let signal = &info.extern_signal_ty; - let error_ty = &info.extern_error_ty; - let support_crate = info.support_crate_name(); - - let ts = quote::quote! { - /// A subsystem that the orchestrator orchestrates. - /// - /// Ties together the [`Subsystem`] itself and it's running instance - /// (which may be missing if the [`Subsystem`] is not running at the moment - /// for whatever reason). - /// - /// [`Subsystem`]: trait.Subsystem.html - pub struct OrchestratedSubsystem { - /// The instance. - pub instance: std::option::Option< - #support_crate ::SubsystemInstance - >, - } - - impl OrchestratedSubsystem { - /// Send a message to the wrapped subsystem. - /// - /// If the inner `instance` is `None`, nothing is happening. - pub async fn send_message2(&mut self, message: M, origin: &'static str) -> ::std::result::Result<(), #error_ty > { - const MESSAGE_TIMEOUT: Duration = Duration::from_secs(10); - - if let Some(ref mut instance) = self.instance { - match instance.tx_bounded.send(MessagePacket { - signals_received: instance.signals_received, - message: message.into(), - }).timeout(MESSAGE_TIMEOUT).await - { - None => { - #support_crate ::tracing::error!( - target: LOG_TARGET, - %origin, - "Subsystem {} appears unresponsive.", - instance.name, - ); - Err(#error_ty :: from( - #support_crate ::OrchestraError::SubsystemStalled(instance.name) - )) - } - Some(res) => res.map_err(Into::into), - } - } else { - Ok(()) - } - } - - /// Send a signal to the wrapped subsystem. - /// - /// If the inner `instance` is `None`, nothing is happening. - pub async fn send_signal(&mut self, signal: #signal) -> ::std::result::Result<(), #error_ty > { - const SIGNAL_TIMEOUT: ::std::time::Duration = ::std::time::Duration::from_secs(10); - - if let Some(ref mut instance) = self.instance { - match instance.tx_signal.send(signal).timeout(SIGNAL_TIMEOUT).await { - None => { - Err(#error_ty :: from( - #support_crate ::OrchestraError::SubsystemStalled(instance.name) - )) - } - Some(res) => { - let res = res.map_err(Into::into); - if res.is_ok() { - instance.signals_received += 1; - } - res - } - } - } else { - Ok(()) - } - } - } - }; - ts -} diff --git a/node/orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs b/node/orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs deleted file mode 100644 index 58e95ca72890..000000000000 --- a/node/orchestra/proc-macro/src/impl_subsystem_ctx_sender.rs +++ /dev/null @@ -1,654 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use proc_macro2::TokenStream; -use quote::quote; -use syn::{Ident, Path, Result, Type}; - -use petgraph::{visit::EdgeRef, Direction}; - -use super::*; - -/// Generates all subsystem types and related accumulation traits. -pub(crate) fn impl_subsystem_types_all(info: &OrchestraInfo) -> Result { - let mut ts = TokenStream::new(); - - let orchestra_name = &info.orchestra_name; - let span = orchestra_name.span(); - let all_messages_wrapper = &info.message_wrapper; - let support_crate = info.support_crate_name(); - let signal_ty = &info.extern_signal_ty; - let error_ty = &info.extern_error_ty; - - let cg = graph::ConnectionGraph::construct(info.subsystems()); - let graph = &cg.graph; - - // All outgoing edges are now usable to derive everything we need - for node_index in graph.node_indices() { - let subsystem_name = graph[node_index].to_string(); - let outgoing_wrapper = Ident::new(&(subsystem_name + "OutgoingMessages"), span); - - // cannot be a hashmap, duplicate keys and sorting required - // maps outgoing messages to the subsystem that consumes it - let outgoing_to_consumer = graph - .edges_directed(node_index, Direction::Outgoing) - .map(|edge| { - let message_ty = edge.weight(); - let subsystem_generic_consumer = graph[edge.target()].clone(); - Ok((to_variant(message_ty, span.clone())?, subsystem_generic_consumer)) - }) - .collect::>>()?; - - // Split it for usage with quote - let outgoing_variant = outgoing_to_consumer.iter().map(|x| x.0.clone()).collect::>(); - let subsystem_generic = outgoing_to_consumer.into_iter().map(|x| x.1).collect::>(); - - ts.extend(quote! { - impl ::std::convert::From< #outgoing_wrapper > for #all_messages_wrapper { - fn from(message: #outgoing_wrapper) -> Self { - match message { - #( - #outgoing_wrapper :: #outgoing_variant ( msg ) => #all_messages_wrapper :: #subsystem_generic ( msg ), - )* - #outgoing_wrapper :: Empty => #all_messages_wrapper :: Empty, - // And everything that's not WIP but no subsystem consumes it - #[allow(unreachable_patterns)] - unused_msg => { - #support_crate :: tracing :: warn!("Nothing consumes {:?}", unused_msg); - #all_messages_wrapper :: Empty - } - } - } - } - }) - } - - // Dump the graph to file. - #[cfg(feature = "graph")] - { - let path = std::path::PathBuf::from(env!("OUT_DIR")) - .join(orchestra_name.to_string().to_lowercase() + "-subsystem-messaging.dot"); - if let Err(e) = std::fs::OpenOptions::new() - .truncate(true) - .create(true) - .write(true) - .open(&path) - .and_then(|mut f| cg.graphviz(&mut f)) - { - eprintln!("Failed to write dot graph to {}: {:?}", path.display(), e); - } else { - println!("Wrote dot graph to {}", path.display()); - } - } - - let subsystem_sender_name = &Ident::new(&(orchestra_name.to_string() + "Sender"), span); - let subsystem_ctx_name = &Ident::new(&(orchestra_name.to_string() + "SubsystemContext"), span); - ts.extend(impl_subsystem_context(info, &subsystem_sender_name, &subsystem_ctx_name)); - - ts.extend(impl_associate_outgoing_messages_trait(&all_messages_wrapper)); - - ts.extend(impl_subsystem_sender( - support_crate, - info.subsystems().iter().map(|ssf| { - let outgoing_wrapper = - Ident::new(&(ssf.generic.to_string() + "OutgoingMessages"), span); - outgoing_wrapper - }), - &all_messages_wrapper, - &subsystem_sender_name, - )); - - // Create all subsystem specific types, one by one - for ssf in info.subsystems() { - let subsystem_name = ssf.generic.to_string(); - let outgoing_wrapper = &Ident::new(&(subsystem_name.clone() + "OutgoingMessages"), span); - - let subsystem_ctx_trait = &Ident::new(&(subsystem_name.clone() + "ContextTrait"), span); - let subsystem_sender_trait = &Ident::new(&(subsystem_name.clone() + "SenderTrait"), span); - - ts.extend(impl_per_subsystem_helper_traits( - info, - subsystem_ctx_name, - subsystem_ctx_trait, - subsystem_sender_name, - subsystem_sender_trait, - &ssf.message_to_consume, - &ssf.messages_to_send, - outgoing_wrapper, - )); - - ts.extend(impl_associate_outgoing_messages(&ssf.message_to_consume, &outgoing_wrapper)); - - ts.extend(impl_wrapper_enum(&outgoing_wrapper, ssf.messages_to_send.as_slice())?); - } - - // impl the emtpy tuple handling for tests - let empty_tuple: Type = parse_quote! { () }; - ts.extend(impl_subsystem_context_trait_for( - empty_tuple.clone(), - &[], - empty_tuple, - all_messages_wrapper, - subsystem_ctx_name, - subsystem_sender_name, - support_crate, - signal_ty, - error_ty, - )); - - Ok(ts) -} - -/// Extract the final component of the message type path as used in the `#[subsystem(consumes: path::to::Foo)]` annotation. -fn to_variant(path: &Path, span: Span) -> Result { - let ident = path - .segments - .last() - .ok_or_else(|| syn::Error::new(span, "Path is empty, but it must end with an identifier")) - .map(|segment| segment.ident.clone())?; - Ok(ident) -} - -/// Converts the outgoing message types to variants. -/// -/// Note: Commonly this is `${X}Message` becomes `${X}OutgoingMessages::${X}Message` -/// where for `AllMessages` it would be `AllMessages::${X}`. -fn to_variants(message_types: &[Path], span: Span) -> Result> { - let variants: Vec<_> = - Result::from_iter(message_types.into_iter().map(|path| to_variant(path, span.clone())))?; - Ok(variants) -} - -/// Generates the wrapper type enum, no bells or whistles. -pub(crate) fn impl_wrapper_enum(wrapper: &Ident, message_types: &[Path]) -> Result { - // The message types are path based, each of them must finish with a type - // and as such we do this upfront. - let variants = to_variants(message_types, wrapper.span())?; - - let ts = quote! { - #[allow(missing_docs)] - #[derive(Debug)] - pub enum #wrapper { - #( - #variants ( #message_types ), - )* - Empty, - } - - #( - impl ::std::convert::From< #message_types > for #wrapper { - fn from(message: #message_types) -> Self { - #wrapper :: #variants ( message ) - } - } - )* - - // Useful for unit and integration tests: - impl ::std::convert::From< () > for #wrapper { - fn from(_message: ()) -> Self { - #wrapper :: Empty - } - } - }; - Ok(ts) -} - -/// Create the subsystem sender type and implements `trait SubsystemSender` -/// for the `#outgoing_wrappers: From` with the proper associated types. -pub(crate) fn impl_subsystem_sender( - support_crate: &Path, - outgoing_wrappers: impl IntoIterator, - all_messages_wrapper: &Ident, - subsystem_sender_name: &Ident, -) -> TokenStream { - let mut ts = quote! { - /// Connector to send messages towards all subsystems, - /// while tracking the which signals where already received. - #[derive(Debug)] - pub struct #subsystem_sender_name < OutgoingWrapper > { - /// Collection of channels to all subsystems. - channels: ChannelsOut, - /// Systemwide tick for which signals were received by all subsystems. - signals_received: SignalsReceived, - /// Keep that marker around. - _phantom: ::core::marker::PhantomData< OutgoingWrapper >, - } - - // can't derive due to `PhantomData` and `OutgoingWrapper` not being - // bounded by `Clone`. - impl std::clone::Clone for #subsystem_sender_name < OutgoingWrapper > { - fn clone(&self) -> Self { - Self { - channels: self.channels.clone(), - signals_received: self.signals_received.clone(), - _phantom: ::core::marker::PhantomData::default(), - } - } - } - }; - - // Create the same for a wrapping enum: - // - // 1. subsystem specific `*OutgoingMessages`-type - // 2. orchestra-global-`AllMessages`-type - let wrapped = |outgoing_wrapper: &TokenStream| { - quote! { - #[#support_crate ::async_trait] - impl SubsystemSender< OutgoingMessage > for #subsystem_sender_name < #outgoing_wrapper > - where - OutgoingMessage: Send + 'static, - #outgoing_wrapper: ::std::convert::From + Send, - #all_messages_wrapper: ::std::convert::From< #outgoing_wrapper > + Send, - { - async fn send_message(&mut self, msg: OutgoingMessage) - { - self.channels.send_and_log_error( - self.signals_received.load(), - <#all_messages_wrapper as ::std::convert::From<_>> ::from ( - <#outgoing_wrapper as ::std::convert::From<_>> :: from ( msg ) - ) - ).await; - } - - async fn send_messages(&mut self, msgs: I) - where - I: IntoIterator + Send, - I::IntoIter: Iterator + Send, - { - for msg in msgs { - self.send_message( msg ).await; - } - } - - fn send_unbounded_message(&mut self, msg: OutgoingMessage) - { - self.channels.send_unbounded_and_log_error( - self.signals_received.load(), - <#all_messages_wrapper as ::std::convert::From<_>> ::from ( - <#outgoing_wrapper as ::std::convert::From<_>> :: from ( msg ) - ) - ); - } - } - } - }; - - for outgoing_wrapper in outgoing_wrappers { - ts.extend(wrapped("e! { - #outgoing_wrapper - })); - } - - ts.extend(wrapped("e! { - () - })); - - ts -} - -/// Define the `trait AssociateOutgoing` and implement it for `#all_messages_wrapper` and `()`. -pub(crate) fn impl_associate_outgoing_messages_trait(all_messages_wrapper: &Ident) -> TokenStream { - quote! { - /// Binds a generated type covering all declared outgoing messages, - /// which implements `#generated_outgoing: From` for all annotated types - /// of a particular subsystem. - /// - /// Note: This works because there is a 1?:1 relation between consumed messages and subsystems. - pub trait AssociateOutgoing: ::std::fmt::Debug + Send { - /// The associated _outgoing_ messages for a subsystem that _consumes_ the message `Self`. - type OutgoingMessages: Into< #all_messages_wrapper > + ::std::fmt::Debug + Send; - } - - // Helper for tests, where nothing is ever sent. - impl AssociateOutgoing for () { - type OutgoingMessages = (); - } - - // Helper for tests, allows sending of arbitrary messages give - // an test context. - impl AssociateOutgoing for #all_messages_wrapper { - type OutgoingMessages = #all_messages_wrapper ; - } - } -} - -/// Implement `AssociateOutgoing` for `#consumes` being handled by a particular subsystem. -/// -/// Binds the outgoing messages to the inbound message. -/// -/// Note: Works, since there is a 1:1 relation between inbound message type and subsystem declarations. -/// Note: A workaround until default associated types work in `rustc`. -pub(crate) fn impl_associate_outgoing_messages( - consumes: &Path, - outgoing_wrapper: &Ident, -) -> TokenStream { - quote! { - impl AssociateOutgoing for #outgoing_wrapper { - type OutgoingMessages = #outgoing_wrapper; - } - - impl AssociateOutgoing for #consumes { - type OutgoingMessages = #outgoing_wrapper; - } - } -} - -/// Implement `trait SubsystemContext` for a particular subsystem context, -/// that is generated by the proc-macro too. -pub(crate) fn impl_subsystem_context_trait_for( - consumes: Type, - outgoing: &[Type], - outgoing_wrapper: Type, - all_messages_wrapper: &Ident, - subsystem_ctx_name: &Ident, - subsystem_sender_name: &Ident, - support_crate: &Path, - signal: &Path, - error_ty: &Path, -) -> TokenStream { - // impl the subsystem context trait - let where_clause = quote! { - #consumes: AssociateOutgoing + ::std::fmt::Debug + Send + 'static, - #all_messages_wrapper: From< #outgoing_wrapper >, - #all_messages_wrapper: From< #consumes >, - #outgoing_wrapper: #( From< #outgoing > )+*, - }; - - quote! { - #[#support_crate ::async_trait] - impl #support_crate ::SubsystemContext for #subsystem_ctx_name < #consumes > - where - #where_clause - { - type Message = #consumes; - type Signal = #signal; - type OutgoingMessages = #outgoing_wrapper; - type Sender = #subsystem_sender_name < #outgoing_wrapper >; - type Error = #error_ty; - - async fn try_recv(&mut self) -> ::std::result::Result>, ()> { - match #support_crate ::poll!(self.recv()) { - #support_crate ::Poll::Ready(msg) => Ok(Some(msg.map_err(|_| ())?)), - #support_crate ::Poll::Pending => Ok(None), - } - } - - async fn recv(&mut self) -> ::std::result::Result, #error_ty> { - loop { - // If we have a message pending an orchestra signal, we only poll for signals - // in the meantime. - if let Some((needs_signals_received, msg)) = self.pending_incoming.take() { - if needs_signals_received <= self.signals_received.load() { - return Ok( #support_crate ::FromOrchestra::Communication { msg }); - } else { - self.pending_incoming = Some((needs_signals_received, msg)); - - // wait for next signal. - let signal = self.signals.next().await - .ok_or(#support_crate ::OrchestraError::Context( - "Signal channel is terminated and empty." - .to_owned() - ))?; - - self.signals_received.inc(); - return Ok( #support_crate ::FromOrchestra::Signal(signal)) - } - } - - let mut await_message = self.messages.next().fuse(); - let mut await_signal = self.signals.next().fuse(); - let signals_received = self.signals_received.load(); - let pending_incoming = &mut self.pending_incoming; - - // Otherwise, wait for the next signal or incoming message. - let from_orchestra = #support_crate ::futures::select_biased! { - signal = await_signal => { - let signal = signal - .ok_or( #support_crate ::OrchestraError::Context( - "Signal channel is terminated and empty." - .to_owned() - ))?; - - #support_crate ::FromOrchestra::Signal(signal) - } - msg = await_message => { - let packet = msg - .ok_or( #support_crate ::OrchestraError::Context( - "Message channel is terminated and empty." - .to_owned() - ))?; - - if packet.signals_received > signals_received { - // wait until we've received enough signals to return this message. - *pending_incoming = Some((packet.signals_received, packet.message)); - continue; - } else { - // we know enough to return this message. - #support_crate ::FromOrchestra::Communication { msg: packet.message} - } - } - }; - - if let #support_crate ::FromOrchestra::Signal(_) = from_orchestra { - self.signals_received.inc(); - } - - return Ok(from_orchestra); - } - } - - fn sender(&mut self) -> &mut Self::Sender { - &mut self.to_subsystems - } - - fn spawn(&mut self, name: &'static str, s: Pin + Send>>) - -> ::std::result::Result<(), #error_ty> - { - self.to_orchestra.unbounded_send(#support_crate ::ToOrchestra::SpawnJob { - name, - subsystem: Some(self.name()), - s, - }).map_err(|_| #support_crate ::OrchestraError::TaskSpawn(name))?; - Ok(()) - } - - fn spawn_blocking(&mut self, name: &'static str, s: Pin + Send>>) - -> ::std::result::Result<(), #error_ty> - { - self.to_orchestra.unbounded_send(#support_crate ::ToOrchestra::SpawnBlockingJob { - name, - subsystem: Some(self.name()), - s, - }).map_err(|_| #support_crate ::OrchestraError::TaskSpawn(name))?; - Ok(()) - } - } - } -} - -/// Implement the additional subsystem accumulation traits, for simplified usage, -/// i.e. `${Subsystem}SenderTrait` and `${Subsystem}ContextTrait`. -pub(crate) fn impl_per_subsystem_helper_traits( - info: &OrchestraInfo, - subsystem_ctx_name: &Ident, - subsystem_ctx_trait: &Ident, - subsystem_sender_name: &Ident, - subsystem_sender_trait: &Ident, - consumes: &Path, - outgoing: &[Path], - outgoing_wrapper: &Ident, -) -> TokenStream { - let all_messages_wrapper = &info.message_wrapper; - let signal_ty = &info.extern_signal_ty; - let error_ty = &info.extern_error_ty; - let support_crate = info.support_crate_name(); - - let mut ts = TokenStream::new(); - - // Create a helper trait bound of all outgoing messages, and the generated wrapper type - // for ease of use within subsystems: - let acc_sender_trait_bounds = quote! { - #support_crate ::SubsystemSender< #outgoing_wrapper > - #( - + #support_crate ::SubsystemSender< #outgoing > - )* - + #support_crate ::SubsystemSender< () > - + Send - + 'static - }; - - ts.extend(quote! { - /// A abstracting trait for usage with subsystems. - pub trait #subsystem_sender_trait : #acc_sender_trait_bounds - {} - - impl #subsystem_sender_trait for T - where - T: #acc_sender_trait_bounds - {} - }); - - // Create a helper accumulated per subsystem trait bound: - let where_clause = quote! { - #consumes: AssociateOutgoing + ::std::fmt::Debug + Send + 'static, - #all_messages_wrapper: From< #outgoing_wrapper >, - #all_messages_wrapper: From< #consumes >, - #all_messages_wrapper: From< () >, - #outgoing_wrapper: #( From< #outgoing > )+*, - #outgoing_wrapper: From< () >, - }; - - ts.extend(quote! { - /// Accumulative trait for a particular subsystem wrapper. - pub trait #subsystem_ctx_trait : SubsystemContext < - Message = #consumes, - Signal = #signal_ty, - OutgoingMessages = #outgoing_wrapper, - // Sender, - Error = #error_ty, - > - where - #where_clause - ::Sender: - #subsystem_sender_trait - + #acc_sender_trait_bounds, - { - /// Sender. - type Sender: #subsystem_sender_trait; - } - - impl #subsystem_ctx_trait for T - where - T: SubsystemContext < - Message = #consumes, - Signal = #signal_ty, - OutgoingMessages = #outgoing_wrapper, - // Sender - Error = #error_ty, - >, - #where_clause - ::Sender: - #subsystem_sender_trait - + #acc_sender_trait_bounds, - { - type Sender = ::Sender; - } - }); - - ts.extend(impl_subsystem_context_trait_for( - parse_quote! { #consumes }, - &Vec::from_iter(outgoing.iter().map(|path| { - parse_quote! { #path } - })), - parse_quote! { #outgoing_wrapper }, - all_messages_wrapper, - subsystem_ctx_name, - subsystem_sender_name, - support_crate, - signal_ty, - error_ty, - )); - ts -} - -/// Generate the subsystem context type and provide `fn new` on it. -/// -/// Note: The generated `fn new` is used by the [builder pattern](../impl_builder.rs). -pub(crate) fn impl_subsystem_context( - info: &OrchestraInfo, - subsystem_sender_name: &Ident, - subsystem_ctx_name: &Ident, -) -> TokenStream { - let signal_ty = &info.extern_signal_ty; - let support_crate = info.support_crate_name(); - - let ts = quote! { - /// A context type that is given to the [`Subsystem`] upon spawning. - /// It can be used by [`Subsystem`] to communicate with other [`Subsystem`]s - /// or to spawn it's [`SubsystemJob`]s. - /// - /// [`Orchestra`]: struct.Orchestra.html - /// [`Subsystem`]: trait.Subsystem.html - /// [`SubsystemJob`]: trait.SubsystemJob.html - #[derive(Debug)] - #[allow(missing_docs)] - pub struct #subsystem_ctx_name { - signals: #support_crate ::metered::MeteredReceiver< #signal_ty >, - messages: SubsystemIncomingMessages< M >, - to_subsystems: #subsystem_sender_name < ::OutgoingMessages >, - to_orchestra: #support_crate ::metered::UnboundedMeteredSender< - #support_crate ::ToOrchestra - >, - signals_received: SignalsReceived, - pending_incoming: Option<(usize, M)>, - name: &'static str - } - - impl #subsystem_ctx_name - where - M: AssociateOutgoing + Send + 'static, - { - /// Create a new context. - fn new( - signals: #support_crate ::metered::MeteredReceiver< #signal_ty >, - messages: SubsystemIncomingMessages< M >, - to_subsystems: ChannelsOut, - to_orchestra: #support_crate ::metered::UnboundedMeteredSender<#support_crate:: ToOrchestra>, - name: &'static str - ) -> Self { - let signals_received = SignalsReceived::default(); - #subsystem_ctx_name :: { - signals, - messages, - to_subsystems: #subsystem_sender_name :: < ::OutgoingMessages > { - channels: to_subsystems, - signals_received: signals_received.clone(), - _phantom: ::core::marker::PhantomData::default(), - }, - to_orchestra, - signals_received, - pending_incoming: None, - name - } - } - - fn name(&self) -> &'static str { - self.name - } - } - }; - - ts -} diff --git a/node/orchestra/proc-macro/src/lib.rs b/node/orchestra/proc-macro/src/lib.rs deleted file mode 100644 index df3f216afdf6..000000000000 --- a/node/orchestra/proc-macro/src/lib.rs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use proc_macro2::{Ident, Span, TokenStream}; -use syn::{parse_quote, spanned::Spanned, Path}; - -mod graph; -mod impl_builder; -mod impl_channels_out; -mod impl_message_wrapper; -mod impl_orchestra; -mod impl_subsystem_ctx_sender; -mod orchestra; -mod parse; -mod subsystem; - -#[cfg(test)] -mod tests; - -use impl_builder::*; -use impl_channels_out::*; -use impl_message_wrapper::*; -use impl_orchestra::*; -use impl_subsystem_ctx_sender::*; -use parse::*; - -use self::{orchestra::*, subsystem::*}; - -/// Obtain the support crate `Path` as `TokenStream`. -pub(crate) fn support_crate() -> Result { - Ok(if cfg!(test) { - parse_quote! {crate} - } else { - use proc_macro_crate::{crate_name, FoundCrate}; - let crate_name = crate_name("orchestra")?; - match crate_name { - FoundCrate::Itself => parse_quote! {crate}, - FoundCrate::Name(name) => Ident::new(&name, Span::call_site()).into(), - } - }) -} - -#[proc_macro_attribute] -pub fn orchestra( - attr: proc_macro::TokenStream, - item: proc_macro::TokenStream, -) -> proc_macro::TokenStream { - let attr: TokenStream = attr.into(); - let item: TokenStream = item.into(); - impl_orchestra_gen(attr, item) - .unwrap_or_else(|err| err.to_compile_error()) - .into() -} - -#[proc_macro_attribute] -pub fn subsystem( - attr: proc_macro::TokenStream, - item: proc_macro::TokenStream, -) -> proc_macro::TokenStream { - let attr: TokenStream = attr.into(); - let item: TokenStream = item.into(); - impl_subsystem_context_trait_bounds(attr, item, MakeSubsystem::ImplSubsystemTrait) - .unwrap_or_else(|err| err.to_compile_error()) - .into() -} - -#[proc_macro_attribute] -pub fn contextbounds( - attr: proc_macro::TokenStream, - item: proc_macro::TokenStream, -) -> proc_macro::TokenStream { - let attr: TokenStream = attr.into(); - let item: TokenStream = item.into(); - impl_subsystem_context_trait_bounds(attr, item, MakeSubsystem::AddContextTraitBounds) - .unwrap_or_else(|err| err.to_compile_error()) - .into() -} diff --git a/node/orchestra/proc-macro/src/orchestra.rs b/node/orchestra/proc-macro/src/orchestra.rs deleted file mode 100644 index ab1f9af3082f..000000000000 --- a/node/orchestra/proc-macro/src/orchestra.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use proc_macro2::TokenStream; -use syn::{parse2, Result}; - -use super::{parse::*, *}; - -pub(crate) fn impl_orchestra_gen( - attr: TokenStream, - orig: TokenStream, -) -> Result { - let args: OrchestraAttrArgs = parse2(attr)?; - let message_wrapper = args.message_wrapper; - - let of: OrchestraGuts = parse2(orig)?; - - let support_crate = support_crate().expect("The crate this macro is run for, includes the proc-macro support as dependency, otherwise it could not be run in the first place. qed"); - let info = OrchestraInfo { - support_crate, - subsystems: of.subsystems, - baggage: of.baggage, - orchestra_name: of.name, - message_wrapper, - message_channel_capacity: args.message_channel_capacity, - signal_channel_capacity: args.signal_channel_capacity, - extern_event_ty: args.extern_event_ty, - extern_signal_ty: args.extern_signal_ty, - extern_error_ty: args.extern_error_ty, - outgoing_ty: args.outgoing_ty, - }; - - let mut additive = impl_orchestra_struct(&info); - additive.extend(impl_builder(&info)); - - additive.extend(impl_orchestrated_subsystem(&info)); - additive.extend(impl_channels_out_struct(&info)); - additive.extend(impl_subsystem_types_all(&info)?); - - additive.extend(impl_message_wrapper_enum(&info)?); - - let ts = expander::Expander::new("orchestra-expansion") - .add_comment("Generated orchestra code by `#[orchestra(..)]`".to_owned()) - .dry(!cfg!(feature = "expand")) - .verbose(true) - // once all our needed format options are available on stable - // we should enabled this again, until then too many warnings - // are generated - // .fmt(expander::Edition::_2021) - .write_to_out_dir(additive) - .expect("Expander does not fail due to IO in OUT_DIR. qed"); - - Ok(ts) -} diff --git a/node/orchestra/proc-macro/src/parse/mod.rs b/node/orchestra/proc-macro/src/parse/mod.rs deleted file mode 100644 index 05d6cc2efcd7..000000000000 --- a/node/orchestra/proc-macro/src/parse/mod.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -mod kw { - syn::custom_keyword!(event); - syn::custom_keyword!(signal); - syn::custom_keyword!(error); - syn::custom_keyword!(outgoing); - syn::custom_keyword!(gen); - syn::custom_keyword!(signal_capacity); - syn::custom_keyword!(message_capacity); - syn::custom_keyword!(subsystem); - syn::custom_keyword!(prefix); -} - -mod parse_orchestra_attr; -mod parse_orchestra_struct; - -mod parse_subsystem_attr; - -#[cfg(test)] -mod tests; - -pub(crate) use self::{parse_orchestra_attr::*, parse_orchestra_struct::*}; - -pub(crate) use self::parse_subsystem_attr::*; diff --git a/node/orchestra/proc-macro/src/parse/parse_orchestra_attr.rs b/node/orchestra/proc-macro/src/parse/parse_orchestra_attr.rs deleted file mode 100644 index 27486b5697a2..000000000000 --- a/node/orchestra/proc-macro/src/parse/parse_orchestra_attr.rs +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use super::kw; -use proc_macro2::Span; -use quote::{quote, ToTokens}; -use std::collections::{hash_map::RandomState, HashMap}; -use syn::{ - parse::{Parse, ParseBuffer}, - punctuated::Punctuated, - spanned::Spanned, - Error, Ident, LitInt, Path, Result, Token, -}; - -#[derive(Clone, Debug)] -enum OrchestraAttrItem { - ExternEventType { tag: kw::event, eq_token: Token![=], value: Path }, - ExternOrchestraSignalType { tag: kw::signal, eq_token: Token![=], value: Path }, - ExternErrorType { tag: kw::error, eq_token: Token![=], value: Path }, - OutgoingType { tag: kw::outgoing, eq_token: Token![=], value: Path }, - MessageWrapperName { tag: kw::gen, eq_token: Token![=], value: Ident }, - SignalChannelCapacity { tag: kw::signal_capacity, eq_token: Token![=], value: usize }, - MessageChannelCapacity { tag: kw::message_capacity, eq_token: Token![=], value: usize }, -} - -impl ToTokens for OrchestraAttrItem { - fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { - let ts = match self { - Self::ExternEventType { tag, eq_token, value } => { - quote! { #tag #eq_token, #value } - }, - Self::ExternOrchestraSignalType { tag, eq_token, value } => { - quote! { #tag #eq_token, #value } - }, - Self::ExternErrorType { tag, eq_token, value } => { - quote! { #tag #eq_token, #value } - }, - Self::OutgoingType { tag, eq_token, value } => { - quote! { #tag #eq_token, #value } - }, - Self::MessageWrapperName { tag, eq_token, value } => { - quote! { #tag #eq_token, #value } - }, - Self::SignalChannelCapacity { tag, eq_token, value } => { - quote! { #tag #eq_token, #value } - }, - Self::MessageChannelCapacity { tag, eq_token, value } => { - quote! { #tag #eq_token, #value } - }, - }; - tokens.extend(ts.into_iter()); - } -} - -impl Parse for OrchestraAttrItem { - fn parse(input: &ParseBuffer) -> Result { - let lookahead = input.lookahead1(); - if lookahead.peek(kw::event) { - Ok(OrchestraAttrItem::ExternEventType { - tag: input.parse::()?, - eq_token: input.parse()?, - value: input.parse()?, - }) - } else if lookahead.peek(kw::signal) { - Ok(OrchestraAttrItem::ExternOrchestraSignalType { - tag: input.parse::()?, - eq_token: input.parse()?, - value: input.parse()?, - }) - } else if lookahead.peek(kw::error) { - Ok(OrchestraAttrItem::ExternErrorType { - tag: input.parse::()?, - eq_token: input.parse()?, - value: input.parse()?, - }) - } else if lookahead.peek(kw::outgoing) { - Ok(OrchestraAttrItem::OutgoingType { - tag: input.parse::()?, - eq_token: input.parse()?, - value: input.parse()?, - }) - } else if lookahead.peek(kw::gen) { - Ok(OrchestraAttrItem::MessageWrapperName { - tag: input.parse::()?, - eq_token: input.parse()?, - value: input.parse()?, - }) - } else if lookahead.peek(kw::signal_capacity) { - Ok(OrchestraAttrItem::SignalChannelCapacity { - tag: input.parse::()?, - eq_token: input.parse()?, - value: input.parse::()?.base10_parse::()?, - }) - } else if lookahead.peek(kw::message_capacity) { - Ok(OrchestraAttrItem::MessageChannelCapacity { - tag: input.parse::()?, - eq_token: input.parse()?, - value: input.parse::()?.base10_parse::()?, - }) - } else { - Err(lookahead.error()) - } - } -} - -/// Attribute arguments -#[derive(Clone, Debug)] -pub(crate) struct OrchestraAttrArgs { - pub(crate) message_wrapper: Ident, - pub(crate) extern_event_ty: Path, - pub(crate) extern_signal_ty: Path, - pub(crate) extern_error_ty: Path, - pub(crate) outgoing_ty: Option, - pub(crate) signal_channel_capacity: usize, - pub(crate) message_channel_capacity: usize, -} - -macro_rules! extract_variant { - ($unique:expr, $variant:ident ; default = $fallback:expr) => { - extract_variant!($unique, $variant).unwrap_or_else(|| $fallback) - }; - ($unique:expr, $variant:ident ; err = $err:expr) => { - extract_variant!($unique, $variant).ok_or_else(|| Error::new(Span::call_site(), $err)) - }; - ($unique:expr, $variant:ident) => { - $unique.values().find_map(|item| { - if let OrchestraAttrItem::$variant { value, .. } = item { - Some(value.clone()) - } else { - None - } - }) - }; -} - -impl Parse for OrchestraAttrArgs { - fn parse(input: &ParseBuffer) -> Result { - let items: Punctuated = - input.parse_terminated(OrchestraAttrItem::parse)?; - - let mut unique = HashMap::< - std::mem::Discriminant, - OrchestraAttrItem, - RandomState, - >::default(); - for item in items { - if let Some(first) = unique.insert(std::mem::discriminant(&item), item.clone()) { - let mut e = Error::new( - item.span(), - format!("Duplicate definition of orchestra generation type found"), - ); - e.combine(Error::new(first.span(), "previously defined here.")); - return Err(e) - } - } - - let signal_channel_capacity = - extract_variant!(unique, SignalChannelCapacity; default = 64_usize); - let message_channel_capacity = - extract_variant!(unique, MessageChannelCapacity; default = 1024_usize); - - let error = extract_variant!(unique, ExternErrorType; err = "Must declare the orchestra error type via `error=..`.")?; - let event = extract_variant!(unique, ExternEventType; err = "Must declare the orchestra event type via `event=..`.")?; - let signal = extract_variant!(unique, ExternOrchestraSignalType; err = "Must declare the orchestra signal type via `signal=..`.")?; - let message_wrapper = extract_variant!(unique, MessageWrapperName; err = "Must declare the orchestra generated wrapping message type via `gen=..`.")?; - let outgoing = extract_variant!(unique, OutgoingType); - - Ok(OrchestraAttrArgs { - signal_channel_capacity, - message_channel_capacity, - extern_event_ty: event, - extern_signal_ty: signal, - extern_error_ty: error, - outgoing_ty: outgoing, - message_wrapper, - }) - } -} diff --git a/node/orchestra/proc-macro/src/parse/parse_orchestra_struct.rs b/node/orchestra/proc-macro/src/parse/parse_orchestra_struct.rs deleted file mode 100644 index e8ab449af632..000000000000 --- a/node/orchestra/proc-macro/src/parse/parse_orchestra_struct.rs +++ /dev/null @@ -1,601 +0,0 @@ -// Copyright (C) 2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use itertools::Itertools; -use proc_macro2::{Span, TokenStream}; -use std::collections::{hash_map::RandomState, HashMap, HashSet}; -use syn::{ - parenthesized, - parse::{Parse, ParseStream}, - punctuated::Punctuated, - spanned::Spanned, - token::Bracket, - AttrStyle, Error, Field, FieldsNamed, GenericParam, Ident, ItemStruct, Path, PathSegment, - Result, Token, Type, Visibility, -}; - -use quote::{quote, ToTokens}; - -mod kw { - syn::custom_keyword!(wip); - syn::custom_keyword!(blocking); - syn::custom_keyword!(consumes); - syn::custom_keyword!(sends); -} - -#[derive(Clone, Debug)] -pub(crate) enum SubSysAttrItem { - /// The subsystem is still a work in progress - /// and should not be communicated with. - Wip(kw::wip), - /// The subsystem is blocking and requires to be - /// spawned on an exclusive thread. - Blocking(kw::blocking), - /// Message to be sent by this subsystem. - Sends(Sends), - /// Message to be consumed by this subsystem. - Consumes(Consumes), -} - -impl Parse for SubSysAttrItem { - fn parse(input: ParseStream) -> Result { - let lookahead = input.lookahead1(); - Ok(if lookahead.peek(kw::wip) { - Self::Wip(input.parse::()?) - } else if lookahead.peek(kw::blocking) { - Self::Blocking(input.parse::()?) - } else if lookahead.peek(kw::sends) { - Self::Sends(input.parse::()?) - } else { - Self::Consumes(input.parse::()?) - }) - } -} - -impl ToTokens for SubSysAttrItem { - fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { - let ts = match self { - Self::Wip(wip) => { - quote! { #wip } - }, - Self::Blocking(blocking) => { - quote! { #blocking } - }, - Self::Sends(_) => { - quote! {} - }, - Self::Consumes(_) => { - quote! {} - }, - }; - tokens.extend(ts.into_iter()); - } -} - -/// A field of the struct annotated with -/// `#[subsystem(A, B, C)]` -#[derive(Clone, Debug)] -pub(crate) struct SubSysField { - /// Name of the field. - pub(crate) name: Ident, - /// Generate generic type name for the `AllSubsystems` type - /// which is also used `#wrapper_message :: #variant` variant - /// part. - pub(crate) generic: Ident, - /// Type of message to be consumed by the subsystem. - pub(crate) message_to_consume: Path, - /// Types of messages to be sent by the subsystem. - pub(crate) messages_to_send: Vec, - /// If the subsystem implementation is blocking execution and hence - /// has to be spawned on a separate thread or thread pool. - pub(crate) blocking: bool, - /// The subsystem is a work in progress. - /// Avoids dispatching `Wrapper` type messages, but generates the variants. - /// Does not require the subsystem to be instantiated with the builder pattern. - pub(crate) wip: bool, -} - -// Converts a type enum to a path if this type is a TypePath -fn try_type_to_path(ty: &Type, span: Span) -> Result { - match ty { - Type::Path(path) => Ok(path.path.clone()), - _ => Err(Error::new(span, "Type must be a path expression.")), - } -} - -// Converts a Rust type to a list of idents recursively checking the possible values -fn flatten_type(ty: &Type, span: Span) -> Result> { - match ty { - syn::Type::Array(ar) => flatten_type(&ar.elem, span), - syn::Type::Paren(par) => flatten_type(&par.elem, span), - syn::Type::Path(type_path) => type_path - .path - .segments - .iter() - .map(|seg| flatten_path_segments(seg, span.clone())) - .flatten_ok() - .collect::>>(), - syn::Type::Tuple(tup) => tup - .elems - .iter() - .map(|element| flatten_type(element, span.clone())) - .flatten_ok() - .collect::>>(), - _ => Err(Error::new(span, format!("Unsupported type: {:?}", ty))), - } -} - -// Flatten segments of some path to a list of idents used in these segments -fn flatten_path_segments(path_segment: &PathSegment, span: Span) -> Result> { - let mut result = vec![path_segment.ident.clone()]; - - match &path_segment.arguments { - syn::PathArguments::AngleBracketed(args) => { - let mut recursive_idents = args - .args - .iter() - .map(|generic_argument| match generic_argument { - syn::GenericArgument::Type(ty) => flatten_type(ty, span.clone()), - _ => Err(Error::new( - span, - format!( - "Field has a generic with an unsupported parameter {:?}", - generic_argument - ), - )), - }) - .flatten_ok() - .collect::>>()?; - result.append(&mut recursive_idents); - }, - syn::PathArguments::None => {}, - _ => - return Err(Error::new( - span, - format!( - "Field has a generic with an unsupported path {:?}", - path_segment.arguments - ), - )), - } - - Ok(result) -} - -macro_rules! extract_variant { - ($unique:expr, $variant:ident ; default = $fallback:expr) => { - extract_variant!($unique, $variant).unwrap_or_else(|| $fallback) - }; - ($unique:expr, $variant:ident ; err = $err:expr) => { - extract_variant!($unique, $variant).ok_or_else(|| Error::new(Span::call_site(), $err)) - }; - ($unique:expr, $variant:ident take) => { - $unique.values().find_map(|item| { - if let SubSysAttrItem::$variant(value) = item { - Some(value.clone()) - } else { - None - } - }) - }; - ($unique:expr, $variant:ident) => { - $unique.values().find_map(|item| { - if let SubSysAttrItem::$variant(_) = item { - Some(true) - } else { - None - } - }) - }; -} - -#[derive(Debug, Clone)] -pub(crate) struct Sends { - #[allow(dead_code)] - pub(crate) keyword_sends: kw::sends, - #[allow(dead_code)] - pub(crate) colon: Token![:], - #[allow(dead_code)] - pub(crate) bracket: Option, - pub(crate) sends: Punctuated, -} - -impl Parse for Sends { - fn parse(input: syn::parse::ParseStream) -> Result { - let content; - let keyword_sends = input.parse()?; - let colon = input.parse()?; - let (bracket, sends) = if !input.peek(syn::token::Bracket) { - let mut sends = Punctuated::new(); - sends.push_value(input.parse::()?); - (None, sends) - } else { - let bracket = Some(syn::bracketed!(content in input)); - let sends = Punctuated::parse_terminated(&content)?; - (bracket, sends) - }; - Ok(Self { keyword_sends, colon, bracket, sends }) - } -} - -#[derive(Debug, Clone)] -pub(crate) struct Consumes { - #[allow(dead_code)] - pub(crate) keyword_consumes: Option, - #[allow(dead_code)] - pub(crate) colon: Option, - pub(crate) consumes: Path, -} - -impl Parse for Consumes { - fn parse(input: syn::parse::ParseStream) -> Result { - let lookahead = input.lookahead1(); - Ok(if lookahead.peek(kw::consumes) { - Self { - keyword_consumes: Some(input.parse()?), - colon: input.parse()?, - consumes: input.parse()?, - } - } else { - Self { keyword_consumes: None, colon: None, consumes: input.parse()? } - }) - } -} - -/// Parses `(Foo, sends = [Bar, Baz])` -/// including the `(` and `)`. -#[derive(Debug, Clone)] -pub(crate) struct SubSystemAttrItems { - /// The subsystem is in progress, only generate the `Wrapper` variant, but do not forward messages - /// and also not include the subsystem in the list of subsystems. - pub(crate) wip: bool, - /// If there are blocking components in the subsystem and hence it should be - /// spawned on a dedicated thread pool for such subssytems. - pub(crate) blocking: bool, - /// The message type being consumed by the subsystem. - pub(crate) consumes: Option, - pub(crate) sends: Option, -} - -impl Parse for SubSystemAttrItems { - fn parse(input: syn::parse::ParseStream) -> Result { - let span = input.span(); - - let content; - let _paren_token = parenthesized!(content in input); - - let items = content.call(Punctuated::::parse_terminated)?; - - let mut unique = HashMap::< - std::mem::Discriminant, - SubSysAttrItem, - RandomState, - >::default(); - - for item in items { - if let Some(first) = unique.insert(std::mem::discriminant(&item), item.clone()) { - let mut e = - Error::new(item.span(), "Duplicate definition of subsystem attribute found"); - e.combine(Error::new(first.span(), "previously defined here.")); - return Err(e) - } - } - - // A subsystem makes no sense if not one of them is provided - let sends = extract_variant!(unique, Sends take); - let consumes = extract_variant!(unique, Consumes take); - if sends.as_ref().map(|sends| sends.sends.is_empty()).unwrap_or(true) && consumes.is_none() - { - return Err(Error::new( - span, - "Must have at least one of `consumes: [..]` and `sends: [..]`.", - )) - } - - let blocking = extract_variant!(unique, Blocking; default = false); - let wip = extract_variant!(unique, Wip; default = false); - - Ok(Self { blocking, wip, sends, consumes }) - } -} - -/// Fields that are _not_ subsystems. -#[derive(Debug, Clone)] -pub(crate) struct BaggageField { - pub(crate) field_name: Ident, - pub(crate) field_ty: Type, - pub(crate) generic_types: Vec, - pub(crate) vis: Visibility, -} - -#[derive(Clone, Debug)] -pub(crate) struct OrchestraInfo { - /// Where the support crate `::orchestra` lives. - pub(crate) support_crate: Path, - - /// Fields annotated with `#[subsystem(..)]`. - pub(crate) subsystems: Vec, - /// Fields that do not define a subsystem, - /// but are mere baggage. - pub(crate) baggage: Vec, - /// Name of the wrapping enum for all messages, defaults to `AllMessages`. - pub(crate) message_wrapper: Ident, - /// Name of the orchestra struct, used as a prefix for - /// almost all generated types. - pub(crate) orchestra_name: Ident, - - /// Size of the bounded channel. - pub(crate) message_channel_capacity: usize, - /// Size of the bounded signal channel. - pub(crate) signal_channel_capacity: usize, - - /// Signals to be sent, sparse information that is used intermittently. - pub(crate) extern_signal_ty: Path, - - /// Incoming event type from the outer world, usually an external framework of some sort. - pub(crate) extern_event_ty: Path, - - /// Type of messages that are sent to an external subsystem. - /// Merely here to be included during generation of `#message_wrapper` type. - pub(crate) outgoing_ty: Option, - - /// Incoming event type from the outer world, commonly from the network. - pub(crate) extern_error_ty: Path, -} - -impl OrchestraInfo { - pub(crate) fn support_crate_name(&self) -> &Path { - &self.support_crate - } - - pub(crate) fn variant_names(&self) -> Vec { - self.subsystems.iter().map(|ssf| ssf.generic.clone()).collect::>() - } - - pub(crate) fn variant_names_without_wip(&self) -> Vec { - self.subsystems - .iter() - .filter(|ssf| !ssf.wip) - .map(|ssf| ssf.generic.clone()) - .collect::>() - } - - pub(crate) fn variant_names_only_wip(&self) -> Vec { - self.subsystems - .iter() - .filter(|ssf| ssf.wip) - .map(|ssf| ssf.generic.clone()) - .collect::>() - } - - pub(crate) fn subsystems(&self) -> &[SubSysField] { - self.subsystems.as_slice() - } - - pub(crate) fn subsystem_names_without_wip(&self) -> Vec { - self.subsystems - .iter() - .filter(|ssf| !ssf.wip) - .map(|ssf| ssf.name.clone()) - .collect::>() - } - - pub(crate) fn subsystem_generic_types(&self) -> Vec { - self.subsystems - .iter() - .filter(|ssf| !ssf.wip) - .map(|sff| sff.generic.clone()) - .collect::>() - } - - pub(crate) fn baggage(&self) -> &[BaggageField] { - self.baggage.as_slice() - } - - pub(crate) fn baggage_names(&self) -> Vec { - self.baggage.iter().map(|bag| bag.field_name.clone()).collect::>() - } - pub(crate) fn baggage_decl(&self) -> Vec { - self.baggage - .iter() - .map(|bag| { - let BaggageField { vis, field_ty, field_name, .. } = bag; - quote! { #vis #field_name: #field_ty } - }) - .collect::>() - } - - pub(crate) fn baggage_generic_types(&self) -> Vec { - self.baggage - .iter() - .flat_map(|bag| bag.generic_types.clone()) - .collect::>() - } - - pub(crate) fn any_message(&self) -> Vec { - self.subsystems - .iter() - .map(|ssf| ssf.message_to_consume.clone()) - .collect::>() - } - - pub(crate) fn channel_names_without_wip(&self, suffix: &'static str) -> Vec { - self.subsystems - .iter() - .filter(|ssf| !ssf.wip) - .map(|ssf| Ident::new(&(ssf.name.to_string() + suffix), ssf.name.span())) - .collect::>() - } - - pub(crate) fn consumes_without_wip(&self) -> Vec { - self.subsystems - .iter() - .filter(|ssf| !ssf.wip) - .map(|ssf| ssf.message_to_consume.clone()) - .collect::>() - } -} - -/// Internals of the orchestra. -#[derive(Debug, Clone)] -pub(crate) struct OrchestraGuts { - pub(crate) name: Ident, - pub(crate) subsystems: Vec, - pub(crate) baggage: Vec, -} - -impl OrchestraGuts { - pub(crate) fn parse_fields( - name: Ident, - baggage_generics: HashSet, - fields: FieldsNamed, - ) -> Result { - let n = fields.named.len(); - let mut subsystems = Vec::with_capacity(n); - let mut baggage = Vec::with_capacity(n); - - // The types of `#[subsystem(..)]` annotated fields - // have to be unique, since they are used as generics - // for the builder pattern besides other places. - let mut unique_subsystem_idents = HashSet::::new(); - for Field { attrs, vis, ident, ty, .. } in fields.named.into_iter() { - // collect all subsystem annotations per field - let mut subsystem_attr = - attrs.iter().filter(|attr| attr.style == AttrStyle::Outer).filter_map(|attr| { - let span = attr.path.span(); - attr.path.get_ident().filter(|ident| *ident == "subsystem").map(move |_ident| { - let attr_tokens = attr.tokens.clone(); - (attr_tokens, span) - }) - }); - let ident = ident.ok_or_else(|| { - Error::new( - ty.span(), - "Missing identifier for field, only named fields are expected.", - ) - })?; - - // a `#[subsystem(..)]` annotation exists - if let Some((attr_tokens, span)) = subsystem_attr.next() { - if let Some((_attr_tokens2, span2)) = subsystem_attr.next() { - return Err({ - let mut err = Error::new(span, "The first subsystem annotation is at"); - err.combine(Error::new(span2, "but another here for the same field.")); - err - }) - } - - let span = attr_tokens.span(); - - let attr_tokens = attr_tokens.clone(); - let subsystem_attrs: SubSystemAttrItems = syn::parse2(attr_tokens.clone())?; - - let field_ty = try_type_to_path(&ty, span)?; - let generic = field_ty - .get_ident() - .ok_or_else(|| { - Error::new( - field_ty.span(), - "Must be an identifier, not a path. It will be used as a generic.", - ) - })? - .clone(); - // check for unique subsystem name, otherwise we'd create invalid code: - if let Some(previous) = unique_subsystem_idents.get(&generic) { - let mut e = Error::new(generic.span(), "Duplicate subsystem names"); - e.combine(Error::new(previous.span(), "previously defined here.")); - return Err(e) - } - unique_subsystem_idents.insert(generic.clone()); - - let SubSystemAttrItems { wip, blocking, consumes, sends, .. } = subsystem_attrs; - - // messages to be sent - let sends = if let Some(sends) = sends { - Vec::from_iter(sends.sends.iter().cloned()) - } else { - vec![] - }; - // messages deemed for consumption - let consumes = if let Some(consumes) = consumes { - consumes.consumes - } else { - return Err(Error::new(span, "Must provide exactly one consuming message type")) - }; - - subsystems.push(SubSysField { - name: ident, - generic, - message_to_consume: consumes, - messages_to_send: sends, - wip, - blocking, - }); - } else { - let flattened = flatten_type(&ty, ident.span())?; - let generic_types = flattened - .iter() - .filter(|flat_ident| baggage_generics.contains(flat_ident)) - .cloned() - .collect::>(); - baggage.push(BaggageField { field_name: ident, generic_types, field_ty: ty, vis }); - } - } - Ok(Self { name, subsystems, baggage }) - } -} - -impl Parse for OrchestraGuts { - fn parse(input: ParseStream) -> Result { - let ds: ItemStruct = input.parse()?; - match ds.fields { - syn::Fields::Named(named) => { - let name = ds.ident.clone(); - - // collect the independent subsystem generics - // which need to be carried along, there are the non-generated ones - let mut orig_generics = ds.generics; - - // remove defaults from types - let mut baggage_generic_idents = HashSet::with_capacity(orig_generics.params.len()); - orig_generics.params = orig_generics - .params - .into_iter() - .map(|mut generic| { - match generic { - GenericParam::Type(ref mut param) => { - baggage_generic_idents.insert(param.ident.clone()); - param.eq_token = None; - param.default = None; - }, - _ => {}, - } - generic - }) - .collect(); - - Self::parse_fields(name, baggage_generic_idents, named) - }, - syn::Fields::Unit => Err(Error::new( - ds.fields.span(), - "Must be a struct with named fields. Not an unit struct.", - )), - syn::Fields::Unnamed(unnamed) => Err(Error::new( - unnamed.span(), - "Must be a struct with named fields. Not an unnamed fields struct.", - )), - } - } -} diff --git a/node/orchestra/proc-macro/src/parse/parse_subsystem_attr.rs b/node/orchestra/proc-macro/src/parse/parse_subsystem_attr.rs deleted file mode 100644 index 6df4a4c8e292..000000000000 --- a/node/orchestra/proc-macro/src/parse/parse_subsystem_attr.rs +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use super::kw; -use proc_macro2::Span; -use quote::{quote, ToTokens}; -use std::collections::{hash_map::RandomState, HashMap}; -use syn::{ - parse::{Parse, ParseBuffer}, - punctuated::Punctuated, - spanned::Spanned, - Error, Ident, Path, Result, Token, -}; - -#[derive(Clone, Debug)] -enum SubsystemAttrItem { - /// Error type provided by the user. - Error { tag: kw::error, eq_token: Token![=], value: Path }, - /// For which slot in the orchestra this should be plugged. - /// - /// The subsystem implementation can and should have a different name - /// from the declared parameter type in the orchestra. - Subsystem { tag: Option, eq_token: Option, value: Ident }, - /// The prefix to apply when a subsystem is implemented in a different file/crate - /// than the orchestra itself. - /// - /// Important for `#[subsystem(..)]` to reference the traits correctly. - TraitPrefix { tag: kw::prefix, eq_token: Token![=], value: Path }, -} - -impl ToTokens for SubsystemAttrItem { - fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { - let ts = match self { - Self::TraitPrefix { tag, eq_token, value } => { - quote! { #tag #eq_token, #value } - }, - Self::Error { tag, eq_token, value } => { - quote! { #tag #eq_token, #value } - }, - Self::Subsystem { tag, eq_token, value } => { - quote! { #tag #eq_token, #value } - }, - }; - tokens.extend(ts.into_iter()); - } -} - -impl Parse for SubsystemAttrItem { - fn parse(input: &ParseBuffer) -> Result { - let lookahead = input.lookahead1(); - if lookahead.peek(kw::error) { - Ok(SubsystemAttrItem::Error { - tag: input.parse::()?, - eq_token: input.parse()?, - value: input.parse()?, - }) - } else if lookahead.peek(kw::prefix) { - Ok(SubsystemAttrItem::TraitPrefix { - tag: input.parse::()?, - eq_token: input.parse()?, - value: input.parse()?, - }) - } else if lookahead.peek(kw::subsystem) { - Ok(SubsystemAttrItem::Subsystem { - tag: Some(input.parse::()?), - eq_token: Some(input.parse()?), - value: input.parse()?, - }) - } else { - Ok(SubsystemAttrItem::Subsystem { tag: None, eq_token: None, value: input.parse()? }) - } - } -} - -/// Attribute arguments `$args` in `#[subsystem( $args )]`. -#[derive(Clone, Debug)] -pub(crate) struct SubsystemAttrArgs { - span: Span, - pub(crate) error_path: Option, - pub(crate) subsystem_ident: Ident, - pub(crate) trait_prefix_path: Option, -} - -impl Spanned for SubsystemAttrArgs { - fn span(&self) -> Span { - self.span.clone() - } -} - -macro_rules! extract_variant { - ($unique:expr, $variant:ident ; default = $fallback:expr) => { - extract_variant!($unique, $variant).unwrap_or_else(|| $fallback) - }; - ($unique:expr, $variant:ident ; err = $err:expr) => { - extract_variant!($unique, $variant).ok_or_else(|| Error::new(Span::call_site(), $err)) - }; - ($unique:expr, $variant:ident) => { - $unique.values().find_map(|item| match item { - SubsystemAttrItem::$variant { value, .. } => Some(value.clone()), - _ => None, - }) - }; -} - -impl Parse for SubsystemAttrArgs { - fn parse(input: &ParseBuffer) -> Result { - let span = input.span(); - let items: Punctuated = - input.parse_terminated(SubsystemAttrItem::parse)?; - - let mut unique = HashMap::< - std::mem::Discriminant, - SubsystemAttrItem, - RandomState, - >::default(); - for item in items { - if let Some(first) = unique.insert(std::mem::discriminant(&item), item.clone()) { - let mut e = Error::new( - item.span(), - format!("Duplicate definition of subsystem generation type found"), - ); - e.combine(Error::new(first.span(), "previously defined here.")); - return Err(e) - } - } - let error_path = extract_variant!(unique, Error); - let subsystem_ident = extract_variant!(unique, Subsystem; err = "Must annotate the identical orchestra error type via `subsystem=..` or plainly as `Subsystem` as specified in the orchestra declaration.")?; - let trait_prefix_path = extract_variant!(unique, TraitPrefix); - Ok(SubsystemAttrArgs { span, error_path, subsystem_ident, trait_prefix_path }) - } -} diff --git a/node/orchestra/proc-macro/src/parse/tests.rs b/node/orchestra/proc-macro/src/parse/tests.rs deleted file mode 100644 index 3bcfda45db80..000000000000 --- a/node/orchestra/proc-macro/src/parse/tests.rs +++ /dev/null @@ -1,294 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use super::*; -use crate::{SubSysAttrItem, SubSystemAttrItems}; -use assert_matches::assert_matches; -use quote::quote; -use syn::parse_quote; - -mod attr { - use super::*; - - #[test] - fn attr_full_works() { - let attr: OrchestraAttrArgs = parse_quote! { - gen=AllMessage, event=::some::why::ExternEvent, signal=SigSigSig, signal_capacity=111, message_capacity=222, - error=OrchestraError, - }; - assert_matches!(attr, OrchestraAttrArgs { - message_channel_capacity, - signal_channel_capacity, - .. - } => { - assert_eq!(message_channel_capacity, 222); - assert_eq!(signal_channel_capacity, 111); - }); - } - - #[test] - fn attr_partial_works() { - let attr: OrchestraAttrArgs = parse_quote! { - gen=AllMessage, event=::some::why::ExternEvent, signal=::foo::SigSigSig, - error=OrchestraError, - }; - assert_matches!(attr, OrchestraAttrArgs { - message_channel_capacity: _, - signal_channel_capacity: _, - .. - } => { - }); - } -} - -mod strukt { - - use super::*; - - #[test] - fn parse_subsystem_attr_item_works_00_wip() { - assert_matches!( - syn::parse2::(quote! { - wip - }), Ok(SubSysAttrItem::Wip(_)) => { - }); - } - - #[test] - fn parse_subsystem_attr_item_works_02_sends() { - assert_matches!( - syn::parse2::(quote! { - sends: [A, B, C] - }), Ok(SubSysAttrItem::Sends(sends)) => { - assert_eq!(sends.sends.len(), 3); - }); - } - - #[test] - fn parse_subsystem_attr_item_works_03_sends() { - assert_matches!( - syn::parse2::(quote! { - sends: [A] - }), Ok(SubSysAttrItem::Sends(sends)) => { - assert_eq!(sends.sends.len(), 1); - }); - } - - #[test] - fn parse_subsystem_attr_item_works_04_sends() { - assert_matches!( - syn::parse2::(quote! { - sends: [A,] - }), Ok(SubSysAttrItem::Sends(sends)) => { - assert_eq!(sends.sends.len(), 1); - }); - } - - #[test] - fn parse_subsystem_attr_item_works_05_sends() { - assert_matches!( - syn::parse2::(quote! { - sends: [] - }), Ok(SubSysAttrItem::Sends(sends)) => { - assert_eq!(sends.sends.len(), 0); - }); - } - - #[test] - fn parse_subsystem_attr_item_works_06_consumes() { - assert_matches!( - syn::parse2::(quote! { - consumes: Foo - }), Ok(SubSysAttrItem::Consumes(_consumes)) => { - }); - } - - #[test] - fn parse_subsystem_attr_item_works_07_consumes() { - assert_matches!( - syn::parse2::(quote! { - Foo - }), Ok(SubSysAttrItem::Consumes(_consumes)) => { - }); - } - - #[test] - fn parse_subsystem_attributes_works_00() { - syn::parse2::(quote! { - (wip, blocking, consumes: Foo, sends: []) - }) - .unwrap(); - } - - #[test] - fn parse_subsystem_attributes_works_01() { - assert_matches!( - syn::parse2::(quote! { - (blocking, Foo, sends: []) - }), Ok(_) => { - }); - } - - #[test] - fn parse_subsystem_attributes_works_02() { - assert_matches!( - syn::parse2::(quote! { - (consumes: Foo, sends: [Bar]) - }), Ok(_) => { - }); - } - - #[test] - fn parse_subsystem_attributes_works_03() { - assert_matches!( - syn::parse2::(quote! { - (blocking, consumes: Foo, sends: [Bar]) - }), Ok(_) => { - }); - } - - #[test] - fn parse_subsystem_attributes_works_04() { - assert_matches!( - syn::parse2::(quote! { - (wip, consumes: Foo, sends: [Bar]) - }), Ok(_) => { - }); - } - - #[test] - fn parse_subsystem_attributes_works_05() { - assert_matches!( - syn::parse2::(quote! { - (consumes: Foo) - }), Ok(_) => { - }); - } - - #[test] - fn parse_subsystem_attributes_works_06() { - assert_matches!( - syn::parse2::(quote! { - (sends: [Foo], consumes: Bar) - }), Ok(_) => { - }); - } - - #[test] - fn parse_subsystem_attributes_works_07_duplicate_send() { - assert_matches!( - syn::parse2::(quote! { - (sends: [Foo], Bar, Y) - }), Err(e) => { - dbg!(e) - }); - } - - #[test] - fn parse_subsystem_attributes_works_08() { - assert_matches!( - syn::parse2::(quote! { - (sends: [Foo], consumes: Bar) - }), Ok(_) => { - }); - } - - #[test] - fn parse_subsystem_attributes_works_09_neither_consumes_nor_sends() { - assert_matches!( - syn::parse2::(quote! { - (sends: []) - }), Err(e) => { - // must either consume smth or sends smth, neither is NOK - dbg!(e) - }); - } - - #[test] - fn parse_subsystem_attributes_works_10_empty_with_braces() { - assert_matches!( - syn::parse2::(quote! { - () - }), Err(e) => { - dbg!(e) - }); - } - - #[test] - fn parse_subsystem_attributes_works_11_empty() { - assert_matches!( - syn::parse2::(quote! { - - }), Err(e) => { - dbg!(e) - }); - } - - #[test] - fn parse_subsystem_attributes_works_12_duplicate_consumes_different_fmt() { - assert_matches!( - syn::parse2::(quote! { - (Foo, consumes = Foo) - }), Err(e) => { - dbg!(e) - }); - } - - #[test] - fn struct_parse_baggage() { - let item: OrchestraGuts = parse_quote! { - pub struct Ooooh where X: Secrit { - #[subsystem(consumes: Foo, sends: [])] - sub0: FooSubsystem, - - metrics: Metrics, - } - }; - let _ = dbg!(item); - } - - #[test] - fn struct_parse_full() { - let item: OrchestraGuts = parse_quote! { - pub struct Ooooh where X: Secrit { - #[subsystem(consumes: Foo, sends: [])] - sub0: FooSubsystem, - - #[subsystem(blocking, consumes: Bar, sends: [])] - yyy: BaersBuyBilliardBalls, - - #[subsystem(blocking, consumes: Twain, sends: [])] - fff: Beeeeep, - - #[subsystem(consumes: Rope)] - mc: MountainCave, - - metrics: Metrics, - } - }; - let _ = dbg!(item); - } - - #[test] - fn struct_parse_basic() { - let item: OrchestraGuts = parse_quote! { - pub struct Ooooh { - #[subsystem(consumes: Foo, sends: [])] - sub0: FooSubsystem, - } - }; - let _ = dbg!(item); - } -} diff --git a/node/orchestra/proc-macro/src/subsystem.rs b/node/orchestra/proc-macro/src/subsystem.rs deleted file mode 100644 index 27f50704bb94..000000000000 --- a/node/orchestra/proc-macro/src/subsystem.rs +++ /dev/null @@ -1,309 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Generates the bounds for a particular subsystem `Context` and associate `type Sender`. -//! -//! -//! ## Implement `trait Subsystem` via `subsystem` -//! -//! ```ignore -//! # use orchestra_proc_macro::subsystem; -//! # mod somewhere { -//! # use orchestra_proc_macro::orchestra; -//! # pub use orchestra::*; -//! # -//! # #[derive(Debug, thiserror::Error)] -//! # #[error("Yikes!")] -//! # pub struct Yikes; -//! # impl From for Yikes { -//! # fn from(_: OrchestraError) -> Yikes { Yikes } -//! # } -//! # impl From for Yikes { -//! # fn from(_: mpsc::SendError) -> Yikes { Yikes } -//! # } -//! # -//! # #[derive(Debug)] -//! # pub struct Eve; -//! # -//! # #[derive(Debug, Clone)] -//! # pub struct Sig; -//! # -//! # #[derive(Debug, Clone, Copy)] -//! # pub struct A; -//! # #[derive(Debug, Clone, Copy)] -//! # pub struct B; -//! # -//! # #[orchestra(signal=Sig, gen=AllOfThem, event=Eve, error=Yikes)] -//! # pub struct Wonderland { -//! # #[subsystem(A, sends: [B])] -//! # foo: Foo, -//! # #[subsystem(B, sends: [A])] -//! # bar: Bar, -//! # } -//! # } -//! # use somewhere::{Yikes, SpawnedSubsystem}; -//! # -//! # struct FooSubsystem; -//! # -//! #[subsystem(Foo, error = Yikes, prefix = somewhere)] -//! impl FooSubsystem { -//! fn start(self, context: Context) -> SpawnedSubsystem { -//! // .. -//! # let _ = context; -//! # unimplemented!() -//! } -//! } -//! ``` -//! -//! expands to -//! -//! ```ignore -//! # use orchestra_proc_macro::subsystem; -//! # mod somewhere { -//! # use orchestra_proc_macro::orchestra; -//! # pub use orchestra::*; -//! # -//! # #[derive(Debug, thiserror::Error)] -//! # #[error("Yikes!")] -//! # pub struct Yikes; -//! # impl From for Yikes { -//! # fn from(_: OrchestraError) -> Yikes { Yikes } -//! # } -//! # impl From for Yikes { -//! # fn from(_: mpsc::SendError) -> Yikes { Yikes } -//! # } -//! # -//! # #[derive(Debug)] -//! # pub struct Eve; -//! # -//! # #[derive(Debug, Clone)] -//! # pub struct Sig; -//! # -//! # #[derive(Debug, Clone, Copy)] -//! # pub struct A; -//! # #[derive(Debug, Clone, Copy)] -//! # pub struct B; -//! # -//! # #[orchestra(signal=Sig, gen=AllOfThem, event=Eve, error=Yikes)] -//! # pub struct Wonderland { -//! # #[subsystem(A, sends: [B])] -//! # foo: Foo, -//! # #[subsystem(B, sends: [A])] -//! # bar: Bar, -//! # } -//! # } -//! # use somewhere::{Yikes, SpawnedSubsystem}; -//! # use orchestra as support_crate; -//! # -//! # struct FooSubsystem; -//! # -//! impl support_crate::Subsystem for FooSubsystem -//! where -//! Context: somewhere::FooContextTrait, -//! Context: support_crate::SubsystemContext, -//! ::Sender: somewhere::FooSenderTrait, -//! ::Sender: somewhere::FooSenderTrait, -//! { -//! fn start(self, context: Context) -> SpawnedSubsystem { -//! // .. -//! # let _ = context; -//! # unimplemented!() -//! } -//! } -//! ``` -//! -//! where `support_crate` is either equivalent to `somewhere` or derived from the cargo manifest. -//! -//! -//! ## Add additional trait bounds for a generic `Context` via `contextbounds` -//! -//! ### To an `ImplItem` -//! -//! ```ignore -//! #[contextbounds(Foo, prefix = somewhere)] -//! impl X { -//! .. -//! } -//! ``` -//! -//! expands to -//! -//! ```ignore -//! impl X -//! where -//! Context: somewhere::FooSubsystemTrait, -//! Context: support_crate::SubsystemContext, -//! ::Sender: somewhere::FooSenderTrait, -//! ::Sender: somewhere::FooSenderTrait, -//! { -//! } -//! ``` -//! -//! ### To a free standing `Fn` (not a method, that's covered by the above) -//! -//! ```ignore -//! #[contextbounds(Foo, prefix = somewhere)] -//! fn do_smth(context: &mut Context) { -//! .. -//! } -//! ``` -//! -//! expands to -//! -//! ```ignore -//! fn do_smth(context: &mut Context) -//! where -//! Context: somewhere::FooSubsystemTrait, -//! Context: support_crate::SubsystemContext, -//! ::Sender: somewhere::FooSenderTrait, -//! ::Sender: somewhere::FooSenderTrait, -//! { -//! } -//! ``` -use proc_macro2::TokenStream; -use quote::{format_ident, ToTokens}; -use syn::{parse2, parse_quote, punctuated::Punctuated, Result}; - -use super::{parse::*, *}; - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub(crate) enum MakeSubsystem { - /// Implements `trait Subsystem` and apply the trait bounds to the `Context` generic. - /// - /// Relevant to `impl Item` only. - ImplSubsystemTrait, - /// Only apply the trait bounds to the context. - AddContextTraitBounds, -} - -pub(crate) fn impl_subsystem_context_trait_bounds( - attr: TokenStream, - orig: TokenStream, - make_subsystem: MakeSubsystem, -) -> Result { - let args = parse2::(attr.clone())?; - let span = args.span(); - let SubsystemAttrArgs { error_path, subsystem_ident, trait_prefix_path, .. } = args; - - let mut item = parse2::(orig)?; - - // always prefer the direct usage, if it's not there, let's see if there is - // a `prefix=*` provided. Either is ok. - - // Technically this is two different things: - // The place where the `#[orchestra]` is annotated is where all `trait *SenderTrait` and - // `trait *ContextTrait` types exist. - // The other usage is the true support crate `orchestra`, where the static ones - // are declared. - // Right now, if the `support_crate` is not included, it falls back silently to the `trait_prefix_path`. - let support_crate = support_crate() - .or_else(|_e| { - trait_prefix_path.clone().ok_or_else(|| { - syn::Error::new(attr.span(), "Couldn't find `orchestra` in manifest, but also missing a `prefix=` to help trait bound resolution") - }) - })?; - - let trait_prefix_path = trait_prefix_path.unwrap_or_else(|| parse_quote! { self }); - if trait_prefix_path.segments.trailing_punct() { - return Err(syn::Error::new(trait_prefix_path.span(), "Must not end with `::`")) - } - - let subsystem_ctx_trait = format_ident!("{}ContextTrait", subsystem_ident); - let subsystem_sender_trait = format_ident!("{}SenderTrait", subsystem_ident); - - let extra_where_predicates: Punctuated = parse_quote! { - Context: #trait_prefix_path::#subsystem_ctx_trait, - Context: #support_crate::SubsystemContext, - ::Sender: #trait_prefix_path::#subsystem_sender_trait, - ::Sender: #trait_prefix_path::#subsystem_sender_trait, - }; - - let apply_ctx_bound_if_present = move |generics: &mut syn::Generics| -> bool { - if generics - .params - .iter() - .find(|generic| match generic { - syn::GenericParam::Type(ty) if ty.ident == "Context" => true, - _ => false, - }) - .is_some() - { - let where_clause = generics.make_where_clause(); - where_clause.predicates.extend(extra_where_predicates.clone()); - true - } else { - false - } - }; - - match item { - syn::Item::Impl(ref mut struktured_impl) => { - if make_subsystem == MakeSubsystem::ImplSubsystemTrait { - let error_path = error_path.ok_or_else(|| { - syn::Error::new( - span, - "Must annotate the identical orchestra error type via `error=..`.", - ) - })?; - // Only replace the subsystem trait if it's desired. - struktured_impl.trait_.replace(( - None, - parse_quote! { - #support_crate::Subsystem - }, - syn::token::For::default(), - )); - } - - apply_ctx_bound_if_present(&mut struktured_impl.generics); - for item in struktured_impl.items.iter_mut() { - match item { - syn::ImplItem::Method(method) => { - apply_ctx_bound_if_present(&mut method.sig.generics); - }, - _others => { - // don't error, just nop - }, - } - } - }, - syn::Item::Fn(ref mut struktured_fn) => { - if make_subsystem == MakeSubsystem::ImplSubsystemTrait { - return Err(syn::Error::new(struktured_fn.span(), "Cannot make a free function a subsystem, did you mean to apply `contextbound` instead?")) - } - apply_ctx_bound_if_present(&mut struktured_fn.sig.generics); - }, - other => - return Err(syn::Error::new( - other.span(), - "Macro can only be annotated on functions or struct implementations", - )), - }; - - Ok(item.to_token_stream()) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn is_path() { - let _p: Path = parse_quote! { self }; - let _p: Path = parse_quote! { crate }; - let _p: Path = parse_quote! { ::foo }; - let _p: Path = parse_quote! { bar }; - } -} diff --git a/node/orchestra/proc-macro/src/tests.rs b/node/orchestra/proc-macro/src/tests.rs deleted file mode 100644 index 2b19b5f29a56..000000000000 --- a/node/orchestra/proc-macro/src/tests.rs +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use super::*; -use assert_matches::assert_matches; -use quote::quote; -use syn::parse_quote; - -#[test] -fn print() { - let attr = quote! { - gen=AllMessage, - event=::some::why::ExternEvent, - signal=SigSigSig, - signal_capacity=111, - message_capacity=222, - error=OrchestraError, - }; - - let item = quote! { - pub struct Ooooh where X: Secrit { - #[subsystem(Foo)] - sub0: FooSubsystem, - - #[subsystem(blocking, Bar)] - yyy: BaersBuyBilliardBalls, - - #[subsystem(blocking, Twain)] - fff: Beeeeep, - - #[subsystem(Rope)] - mc: MountainCave, - - metrics: Metrics, - } - }; - - let output = impl_orchestra_gen(attr, item).expect("Simple example always works. qed"); - println!("//generated:"); - println!("{}", output); -} - -#[test] -fn struct_parse_full() { - let item: OrchestraGuts = parse_quote! { - pub struct Ooooh where X: Secrit { - #[subsystem(Foo)] - sub0: FooSubsystem, - - #[subsystem(blocking, Bar)] - yyy: BaersBuyBilliardBalls, - - #[subsystem(blocking, Twain)] - fff: Beeeeep, - - #[subsystem(Rope)] - mc: MountainCave, - - metrics: Metrics, - } - }; - let _ = dbg!(item); -} - -#[test] -fn struct_parse_basic() { - let item: OrchestraGuts = parse_quote! { - pub struct Ooooh { - #[subsystem(Foo)] - sub0: FooSubsystem, - } - }; - let _ = dbg!(item); -} - -#[test] -fn attr_full() { - let attr: OrchestraAttrArgs = parse_quote! { - gen=AllMessage, event=::some::why::ExternEvent, signal=SigSigSig, signal_capacity=111, message_capacity=222, - error=OrchestraError, - }; - assert_matches!(attr, OrchestraAttrArgs { - message_channel_capacity, - signal_channel_capacity, - .. - } => { - assert_eq!(message_channel_capacity, 222); - assert_eq!(signal_channel_capacity, 111); - }); -} - -#[test] -fn attr_partial() { - let attr: OrchestraAttrArgs = parse_quote! { - gen=AllMessage, event=::some::why::ExternEvent, signal=::foo::SigSigSig, - error=OrchestraError, - }; - assert_matches!(attr, OrchestraAttrArgs { - message_channel_capacity: _, - signal_channel_capacity: _, - .. - } => { - }); -} diff --git a/node/orchestra/src/lib.rs b/node/orchestra/src/lib.rs deleted file mode 100644 index 15bd661e7200..000000000000 --- a/node/orchestra/src/lib.rs +++ /dev/null @@ -1,549 +0,0 @@ -// Copyright (C) 2021 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! # Orchestra -//! -//! `orchestra` provides a global information flow of what a token of information. -//! The token is arbitrary, but is used to notify all `Subsystem`s of what is relevant -//! and what is not. -//! -//! For the motivations behind implementing the orchestra itself you should -//! check out that guide, documentation in this crate will focus and be of -//! technical nature. -//! -//! An `Orchestra` is something that allows spawning/stopping and orchestrating -//! asynchronous tasks as well as establishing a well-defined and easy to use -//! protocol that the tasks can use to communicate with each other. It is desired -//! that this protocol is the only way tasks communicate with each other, however -//! at this moment there are no foolproof guards against other ways of communication. -//! -//! The `Orchestra` is instantiated with a pre-defined set of `Subsystems` that -//! share the same behavior from `Orchestra`'s point of view. -//! -//! ```text -//! +-----------------------------+ -//! | Orchesta | -//! +-----------------------------+ -//! -//! ................| Orchestra "holds" these and uses |............. -//! . them to (re)start things . -//! . . -//! . +-------------------+ +---------------------+ . -//! . | Subsystem1 | | Subsystem2 | . -//! . +-------------------+ +---------------------+ . -//! . | | . -//! .................................................................. -//! | | -//! start() start() -//! V V -//! ..................| Orchestra "runs" these |....................... -//! . +--------------------+ +---------------------+ . -//! . | SubsystemInstance1 | <-- bidir --> | SubsystemInstance2 | . -//! . +--------------------+ +---------------------+ . -//! .................................................................. -//! ``` - -// #![deny(unused_results)] -// unused dependencies can not work for test and examples at the same time -// yielding false positives -#![deny(missing_docs)] -#![deny(unused_crate_dependencies)] - -pub use orchestra_proc_macro::{contextbounds, orchestra, subsystem}; - -#[doc(hidden)] -pub use metered; -#[doc(hidden)] -pub use tracing; - -#[doc(hidden)] -pub use async_trait::async_trait; -#[doc(hidden)] -pub use futures::{ - self, - channel::{mpsc, oneshot}, - future::{BoxFuture, Fuse, Future}, - poll, select, - stream::{self, select, select_with_strategy, FuturesUnordered, PollNext}, - task::{Context, Poll}, - FutureExt, StreamExt, -}; -#[doc(hidden)] -pub use std::pin::Pin; - -use std::sync::{ - atomic::{self, AtomicUsize}, - Arc, -}; -#[doc(hidden)] -pub use std::time::Duration; - -#[doc(hidden)] -pub use futures_timer::Delay; - -use std::fmt; - -#[cfg(test)] -mod tests; - -/// A spawner -#[dyn_clonable::clonable] -pub trait Spawner: Clone + Send + Sync { - /// Spawn the given blocking future. - /// - /// The given `group` and `name` is used to identify the future in tracing. - fn spawn_blocking( - &self, - name: &'static str, - group: Option<&'static str>, - future: futures::future::BoxFuture<'static, ()>, - ); - /// Spawn the given non-blocking future. - /// - /// The given `group` and `name` is used to identify the future in tracing. - fn spawn( - &self, - name: &'static str, - group: Option<&'static str>, - future: futures::future::BoxFuture<'static, ()>, - ); -} - -/// A type of messages that are sent from a [`Subsystem`] to the declared orchestra. -/// -/// Used to launch jobs. -pub enum ToOrchestra { - /// A message that wraps something the `Subsystem` is desiring to - /// spawn on the orchestra and a `oneshot::Sender` to signal the result - /// of the spawn. - SpawnJob { - /// Name of the task to spawn which be shown in jaeger and tracing logs. - name: &'static str, - /// Subsystem of the task to spawn which be shown in jaeger and tracing logs. - subsystem: Option<&'static str>, - /// The future to execute. - s: BoxFuture<'static, ()>, - }, - - /// Same as `SpawnJob` but for blocking tasks to be executed on a - /// dedicated thread pool. - SpawnBlockingJob { - /// Name of the task to spawn which be shown in jaeger and tracing logs. - name: &'static str, - /// Subsystem of the task to spawn which be shown in jaeger and tracing logs. - subsystem: Option<&'static str>, - /// The future to execute. - s: BoxFuture<'static, ()>, - }, -} - -impl fmt::Debug for ToOrchestra { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::SpawnJob { name, subsystem, .. } => { - writeln!(f, "SpawnJob{{ {}, {} ..}}", name, subsystem.unwrap_or("default")) - }, - Self::SpawnBlockingJob { name, subsystem, .. } => { - writeln!(f, "SpawnBlockingJob{{ {}, {} ..}}", name, subsystem.unwrap_or("default")) - }, - } - } -} - -/// A helper trait to map a subsystem to smth. else. -pub trait MapSubsystem { - /// The output type of the mapping. - type Output; - - /// Consumes a `T` per subsystem, and maps it to `Self::Output`. - fn map_subsystem(&self, sub: T) -> Self::Output; -} - -impl MapSubsystem for F -where - F: Fn(T) -> U, -{ - type Output = U; - - fn map_subsystem(&self, sub: T) -> U { - (self)(sub) - } -} - -/// A wrapping type for messages. -/// -/// Includes a counter to synchronize signals with messages, -/// such that no inconsistent message sequences are prevented. -#[derive(Debug)] -pub struct MessagePacket { - /// Signal level at the point of reception. - /// - /// Required to assure signals were consumed _before_ - /// consuming messages that are based on the assumption - /// that a certain signal was assumed. - pub signals_received: usize, - /// The message to be sent/consumed. - pub message: T, -} - -/// Create a packet from its parts. -pub fn make_packet(signals_received: usize, message: T) -> MessagePacket { - MessagePacket { signals_received, message } -} - -/// A functor to specify strategy of the channels selection in the `SubsystemIncomingMessages` -pub fn select_message_channel_strategy(_: &mut ()) -> PollNext { - PollNext::Right -} - -/// Incoming messages from both the bounded and unbounded channel. -pub type SubsystemIncomingMessages = self::stream::SelectWithStrategy< - self::metered::MeteredReceiver>, - self::metered::UnboundedMeteredReceiver>, - fn(&mut ()) -> self::stream::PollNext, - (), ->; - -/// Watermark to track the received signals. -#[derive(Debug, Default, Clone)] -pub struct SignalsReceived(Arc); - -impl SignalsReceived { - /// Load the current value of received signals. - pub fn load(&self) -> usize { - // It's imperative that we prevent reading a stale value from memory because of reordering. - // Memory barrier to ensure that no reads or writes in the current thread before this load are reordered. - // All writes in other threads using release semantics become visible to the current thread. - self.0.load(atomic::Ordering::Acquire) - } - - /// Increase the number of signals by one. - pub fn inc(&self) { - self.0.fetch_add(1, atomic::Ordering::AcqRel); - } -} - -/// A trait to support the origin annotation -/// such that errors across subsystems can be easier tracked. -pub trait AnnotateErrorOrigin: 'static + Send + Sync + std::error::Error { - /// Annotate the error with a origin `str`. - /// - /// Commonly this is used to create nested enum variants. - /// - /// ```rust,ignore - /// E::WithOrigin("I am originally from Cowtown.", E::Variant) - /// ``` - fn with_origin(self, origin: &'static str) -> Self; -} - -/// An asynchronous subsystem task.. -/// -/// In essence it's just a new type wrapping a `BoxFuture`. -pub struct SpawnedSubsystem -where - E: std::error::Error + Send + Sync + 'static + From, -{ - /// Name of the subsystem being spawned. - pub name: &'static str, - /// The task of the subsystem being spawned. - pub future: BoxFuture<'static, Result<(), E>>, -} - -/// An error type that describes faults that may happen -/// -/// These are: -/// * Channels being closed -/// * Subsystems dying when they are not expected to -/// * Subsystems not dying when they are told to die -/// * etc. -#[derive(thiserror::Error, Debug)] -#[allow(missing_docs)] -pub enum OrchestraError { - #[error(transparent)] - NotifyCancellation(#[from] oneshot::Canceled), - - #[error(transparent)] - QueueError(#[from] mpsc::SendError), - - #[error("Failed to spawn task {0}")] - TaskSpawn(&'static str), - - #[error(transparent)] - Infallible(#[from] std::convert::Infallible), - - #[error("Failed to {0}")] - Context(String), - - #[error("Subsystem stalled: {0}")] - SubsystemStalled(&'static str), - - /// Per origin (or subsystem) annotations to wrap an error. - #[error("Error originated in {origin}")] - FromOrigin { - /// An additional annotation tag for the origin of `source`. - origin: &'static str, - /// The wrapped error. Marked as source for tracking the error chain. - #[source] - source: Box, - }, -} - -/// Alias for a result with error type `OrchestraError`. -pub type OrchestraResult = std::result::Result; - -/// Collection of meters related to a subsystem. -#[derive(Clone)] -pub struct SubsystemMeters { - #[allow(missing_docs)] - pub bounded: metered::Meter, - #[allow(missing_docs)] - pub unbounded: metered::Meter, - #[allow(missing_docs)] - pub signals: metered::Meter, -} - -impl SubsystemMeters { - /// Read the values of all subsystem `Meter`s. - pub fn read(&self) -> SubsystemMeterReadouts { - SubsystemMeterReadouts { - bounded: self.bounded.read(), - unbounded: self.unbounded.read(), - signals: self.signals.read(), - } - } -} - -/// Set of readouts of the `Meter`s of a subsystem. -pub struct SubsystemMeterReadouts { - #[allow(missing_docs)] - pub bounded: metered::Readout, - #[allow(missing_docs)] - pub unbounded: metered::Readout, - #[allow(missing_docs)] - pub signals: metered::Readout, -} - -/// A running instance of some [`Subsystem`]. -/// -/// [`Subsystem`]: trait.Subsystem.html -/// -/// `M` here is the inner message type, and _not_ the generated `enum AllMessages` or `#message_wrapper` type. -pub struct SubsystemInstance { - /// Send sink for `Signal`s to be sent to a subsystem. - pub tx_signal: crate::metered::MeteredSender, - /// Send sink for `Message`s to be sent to a subsystem. - pub tx_bounded: crate::metered::MeteredSender>, - /// All meters of the particular subsystem instance. - pub meters: SubsystemMeters, - /// The number of signals already received. - /// Required to assure messages and signals - /// are processed correctly. - pub signals_received: usize, - /// Name of the subsystem instance. - pub name: &'static str, -} - -/// A message type that a subsystem receives from an orchestra. -/// It wraps signals from an orchestra and messages that are circulating -/// between subsystems. -/// -/// It is generic over over the message type `M` that a particular `Subsystem` may use. -#[derive(Debug)] -pub enum FromOrchestra { - /// Signal from the `Orchestra`. - Signal(Signal), - - /// Some other `Subsystem`'s message. - Communication { - /// Contained message - msg: Message, - }, -} - -impl From for FromOrchestra { - fn from(signal: Signal) -> Self { - Self::Signal(signal) - } -} - -/// A context type that is given to the [`Subsystem`] upon spawning. -/// It can be used by [`Subsystem`] to communicate with other [`Subsystem`]s -/// or spawn jobs. -/// -/// [`Orchestra`]: struct.Orchestra.html -/// [`SubsystemJob`]: trait.SubsystemJob.html -#[async_trait::async_trait] -pub trait SubsystemContext: Send + 'static { - /// The message type of this context. Subsystems launched with this context will expect - /// to receive messages of this type. Commonly uses the wrapping `enum` commonly called - /// `AllMessages`. - type Message: ::std::fmt::Debug + Send + 'static; - /// And the same for signals. - type Signal: ::std::fmt::Debug + Send + 'static; - /// The overarching messages `enum` for this particular subsystem. - type OutgoingMessages: ::std::fmt::Debug + Send + 'static; - - // The overarching messages `enum` for this particular subsystem. - // type AllMessages: From + From + std::fmt::Debug + Send + 'static; - - /// The sender type as provided by `sender()` and underlying. - type Sender: Clone + Send + 'static + SubsystemSender; - /// The error type. - type Error: ::std::error::Error + ::std::convert::From + Sync + Send + 'static; - - /// Try to asynchronously receive a message. - /// - /// Has to be used with caution, if you loop over this without - /// using `pending!()` macro you will end up with a busy loop! - async fn try_recv(&mut self) -> Result>, ()>; - - /// Receive a message. - async fn recv(&mut self) -> Result, Self::Error>; - - /// Spawn a child task on the executor. - fn spawn( - &mut self, - name: &'static str, - s: ::std::pin::Pin + Send>>, - ) -> Result<(), Self::Error>; - - /// Spawn a blocking child task on the executor's dedicated thread pool. - fn spawn_blocking( - &mut self, - name: &'static str, - s: ::std::pin::Pin + Send>>, - ) -> Result<(), Self::Error>; - - /// Send a direct message to some other `Subsystem`, routed based on message type. - // #[deprecated(note = "Use `self.sender().send_message(msg) instead, avoid passing around the full context.")] - async fn send_message(&mut self, msg: T) - where - Self::OutgoingMessages: From + Send, - T: Send, - { - self.sender().send_message(::from(msg)).await - } - - /// Send multiple direct messages to other `Subsystem`s, routed based on message type. - // #[deprecated(note = "Use `self.sender().send_message(msg) instead, avoid passing around the full context.")] - async fn send_messages(&mut self, msgs: I) - where - Self::OutgoingMessages: From + Send, - I: IntoIterator + Send, - I::IntoIter: Send, - T: Send, - { - self.sender() - .send_messages(msgs.into_iter().map(::from)) - .await - } - - /// Send a message using the unbounded connection. - // #[deprecated(note = "Use `self.sender().send_unbounded_message(msg) instead, avoid passing around the full context.")] - fn send_unbounded_message(&mut self, msg: X) - where - Self::OutgoingMessages: From + Send, - X: Send, - { - self.sender().send_unbounded_message(::from(msg)) - } - - /// Obtain the sender. - fn sender(&mut self) -> &mut Self::Sender; -} - -/// A trait that describes the [`Subsystem`]s that can run on the [`Orchestra`]. -/// -/// It is generic over the message type circulating in the system. -/// The idea that we want some type containing persistent state that -/// can spawn actually running subsystems when asked. -/// -/// [`Orchestra`]: struct.Orchestra.html -/// [`Subsystem`]: trait.Subsystem.html -pub trait Subsystem -where - Ctx: SubsystemContext, - E: std::error::Error + Send + Sync + 'static + From, -{ - /// Start this `Subsystem` and return `SpawnedSubsystem`. - fn start(self, ctx: Ctx) -> SpawnedSubsystem; -} - -/// Sender end of a channel to interface with a subsystem. -#[async_trait::async_trait] -pub trait SubsystemSender: Clone + Send + 'static -where - OutgoingMessage: Send, -{ - /// Send a direct message to some other `Subsystem`, routed based on message type. - async fn send_message(&mut self, msg: OutgoingMessage); - - /// Send multiple direct messages to other `Subsystem`s, routed based on message type. - async fn send_messages(&mut self, msgs: I) - where - I: IntoIterator + Send, - I::IntoIter: Send; - - /// Send a message onto the unbounded queue of some other `Subsystem`, routed based on message - /// type. - /// - /// This function should be used only when there is some other bounding factor on the messages - /// sent with it. Otherwise, it risks a memory leak. - fn send_unbounded_message(&mut self, msg: OutgoingMessage); -} - -/// A future that wraps another future with a `Delay` allowing for time-limited futures. -#[pin_project::pin_project] -pub struct Timeout { - #[pin] - future: F, - #[pin] - delay: Delay, -} - -/// Extends `Future` to allow time-limited futures. -pub trait TimeoutExt: Future { - /// Adds a timeout of `duration` to the given `Future`. - /// Returns a new `Future`. - fn timeout(self, duration: Duration) -> Timeout - where - Self: Sized, - { - Timeout { future: self, delay: Delay::new(duration) } - } -} - -impl TimeoutExt for F where F: Future {} - -impl Future for Timeout -where - F: Future, -{ - type Output = Option; - - fn poll(self: Pin<&mut Self>, ctx: &mut Context) -> Poll { - let this = self.project(); - - if this.delay.poll(ctx).is_ready() { - return Poll::Ready(None) - } - - if let Poll::Ready(output) = this.future.poll(ctx) { - return Poll::Ready(Some(output)) - } - - Poll::Pending - } -} diff --git a/node/orchestra/src/tests.rs b/node/orchestra/src/tests.rs deleted file mode 100644 index 4b622faf889f..000000000000 --- a/node/orchestra/src/tests.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[test] -#[rustversion::attr(not(stable), ignore)] -fn ui_compile_fail() { - // Only run the ui tests when `RUN_UI_TESTS` is set. - if std::env::var("RUN_UI_TESTS").is_err() { - return - } - - let t = trybuild::TestCases::new(); - t.compile_fail("tests/ui/err-*.rs"); -} - -#[test] -#[rustversion::attr(not(stable), ignore)] -fn ui_pass() { - // Only run the ui tests when `RUN_UI_TESTS` is set. - if std::env::var("RUN_UI_TESTS").is_err() { - return - } - - let t = trybuild::TestCases::new(); - t.pass("tests/ui/ok-*.rs"); -} diff --git a/node/orchestra/tests/ui/err-01-duplicate-consumer.rs b/node/orchestra/tests/ui/err-01-duplicate-consumer.rs deleted file mode 100644 index 589bcede9963..000000000000 --- a/node/orchestra/tests/ui/err-01-duplicate-consumer.rs +++ /dev/null @@ -1,38 +0,0 @@ -#![allow(dead_code)] - -use orchestra::*; - -#[derive(Default)] -struct AwesomeSubSys; - -#[derive(Default)] -struct AwesomeSubSys2; - -#[derive(Clone, Debug)] -struct SigSigSig; - -struct Event; - -#[derive(Clone)] -struct MsgStrukt(u8); - -#[orchestra(signal=SigSigSig, event=Event, gen=AllMessages, error=OrchestraError)] -struct Orchestra { - #[subsystem(MsgStrukt)] - sub0: AwesomeSubSys, - - #[subsystem(MsgStrukt)] - sub1: AwesomeSubSys2, -} - -#[derive(Debug, Clone)] -struct DummySpawner; - -struct DummyCtx; - -fn main() { - let orchestra = Orchestra::<_,_>::builder() - .sub0(AwesomeSubSys::default()) - .spawner(DummySpawner) - .build(|| -> DummyCtx { DummyCtx } ); -} diff --git a/node/orchestra/tests/ui/err-01-duplicate-consumer.stderr b/node/orchestra/tests/ui/err-01-duplicate-consumer.stderr deleted file mode 100644 index af27b95a2ea0..000000000000 --- a/node/orchestra/tests/ui/err-01-duplicate-consumer.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0119]: conflicting implementations of trait `std::convert::From` for type `AllMessages` - --> tests/ui/err-01-duplicate-consumer.rs:19:1 - | -19 | #[orchestra(signal=SigSigSig, event=Event, gen=AllMessages, error=OrchestraError)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | first implementation here - | conflicting implementation for `AllMessages` - | - = note: this error originates in the attribute macro `orchestra` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0119]: conflicting implementations of trait `AssociateOutgoing` for type `MsgStrukt` - --> tests/ui/err-01-duplicate-consumer.rs:19:1 - | -19 | #[orchestra(signal=SigSigSig, event=Event, gen=AllMessages, error=OrchestraError)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | first implementation here - | conflicting implementation for `MsgStrukt` - | - = note: this error originates in the attribute macro `orchestra` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/node/orchestra/tests/ui/err-02-enum.rs b/node/orchestra/tests/ui/err-02-enum.rs deleted file mode 100644 index 8d1ddeac6dda..000000000000 --- a/node/orchestra/tests/ui/err-02-enum.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![allow(dead_code)] - -use orchestra::*; - -#[derive(Default)] -struct AwesomeSubSys; - -struct SigSigSig; - -struct Event; - -#[derive(Clone, Debug)] -struct MsgStrukt(u8); - -#[orchestra(signal=SigSigSig, event=Event, gen=AllMessages, error=OrchestraError)] -enum Orchestra { - #[subsystem(MsgStrukt)] - Sub0(AwesomeSubSys), -} - -#[derive(Debug, Clone)] -struct DummySpawner; - -struct DummyCtx; - -fn main() { - let orchestra = Orchestra::<_,_>::builder() - .sub0(AwesomeSubSys::default()) - .i_like_pie(std::f64::consts::PI) - .spawner(DummySpawner) - .build(|| -> DummyCtx { DummyCtx } ); -} diff --git a/node/orchestra/tests/ui/err-02-enum.stderr b/node/orchestra/tests/ui/err-02-enum.stderr deleted file mode 100644 index 4694f5db9730..000000000000 --- a/node/orchestra/tests/ui/err-02-enum.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: expected `struct` - --> tests/ui/err-02-enum.rs:16:1 - | -16 | enum Orchestra { - | ^^^^ - -error[E0433]: failed to resolve: use of undeclared type `Orchestra` - --> tests/ui/err-02-enum.rs:27:18 - | -27 | let orchestra = Orchestra::<_,_>::builder() - | ^^^^^^^^^ use of undeclared type `Orchestra` diff --git a/node/orchestra/tests/ui/err-03-subsys-twice.rs b/node/orchestra/tests/ui/err-03-subsys-twice.rs deleted file mode 100644 index 187d9e1e7a5b..000000000000 --- a/node/orchestra/tests/ui/err-03-subsys-twice.rs +++ /dev/null @@ -1,39 +0,0 @@ -#![allow(dead_code)] - -use orchestra::*; - -#[derive(Default)] -struct AwesomeSubSys; - -#[derive(Clone, Debug)] -struct SigSigSig; - -struct Event; - -#[derive(Clone, Debug)] -struct MsgStrukt(u8); - -#[derive(Clone, Debug)] -struct MsgStrukt2(f64); - -#[orchestra(signal=SigSigSig, event=Event, gen=AllMessages, error=OrchestraError)] -struct Orchestra { - #[subsystem(MsgStrukt)] - sub0: AwesomeSubSys, - - #[subsystem(MsgStrukt2)] - sub1: AwesomeSubSys, -} - -#[derive(Debug, Clone)] -struct DummySpawner; - -struct DummyCtx; - -fn main() { - let orchestra = Orchestra::<_,_>::builder() - .sub0(AwesomeSubSys::default()) - .i_like_pie(std::f64::consts::PI) - .spawner(DummySpawner) - .build(|| -> DummyCtx { DummyCtx } ); -} diff --git a/node/orchestra/tests/ui/err-03-subsys-twice.stderr b/node/orchestra/tests/ui/err-03-subsys-twice.stderr deleted file mode 100644 index de69031b248b..000000000000 --- a/node/orchestra/tests/ui/err-03-subsys-twice.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: Duplicate subsystem names - --> tests/ui/err-03-subsys-twice.rs:25:8 - | -25 | sub1: AwesomeSubSys, - | ^^^^^^^^^^^^^ - -error: previously defined here. - --> tests/ui/err-03-subsys-twice.rs:22:8 - | -22 | sub0: AwesomeSubSys, - | ^^^^^^^^^^^^^ - -error[E0433]: failed to resolve: use of undeclared type `Orchestra` - --> tests/ui/err-03-subsys-twice.rs:34:18 - | -34 | let orchestra = Orchestra::<_,_>::builder() - | ^^^^^^^^^ use of undeclared type `Orchestra` diff --git a/node/orchestra/tests/ui/err-04-missing-error.rs b/node/orchestra/tests/ui/err-04-missing-error.rs deleted file mode 100644 index 74672a4549a4..000000000000 --- a/node/orchestra/tests/ui/err-04-missing-error.rs +++ /dev/null @@ -1,36 +0,0 @@ -#![allow(dead_code)] - -use orchestra::*; - -#[derive(Default)] -struct AwesomeSubSys; - -#[derive(Clone, Debug)] -struct SigSigSig; - -struct Event; - -#[derive(Clone)] -struct MsgStrukt(u8); - -#[orchestra(signal=SigSigSig, event=Event, gen=AllMessages)] -struct Orchestra { - #[subsystem(MsgStrukt)] - sub0: AwesomeSubSys, - - i_like_pie: f64, -} - -#[derive(Debug, Clone)] -struct DummySpawner; - -struct DummyCtx; - -fn main() { - let _ = Orchestra::builder() - .sub0(AwesomeSubSys::default()) - .i_like_pie(std::f64::consts::PI) - .spawner(DummySpawner) - .build() - .unwrap(); -} diff --git a/node/orchestra/tests/ui/err-04-missing-error.stderr b/node/orchestra/tests/ui/err-04-missing-error.stderr deleted file mode 100644 index 70c3e790eafc..000000000000 --- a/node/orchestra/tests/ui/err-04-missing-error.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: Must declare the orchestra error type via `error=..`. - --> tests/ui/err-04-missing-error.rs:16:1 - | -16 | #[orchestra(signal=SigSigSig, event=Event, gen=AllMessages)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this error originates in the attribute macro `orchestra` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0433]: failed to resolve: use of undeclared type `Orchestra` - --> tests/ui/err-04-missing-error.rs:30:10 - | -30 | let _ = Orchestra::builder() - | ^^^^^^^^^ use of undeclared type `Orchestra` diff --git a/node/orchestra/tests/ui/err-05-missing-field.rs b/node/orchestra/tests/ui/err-05-missing-field.rs deleted file mode 100644 index f351724072b6..000000000000 --- a/node/orchestra/tests/ui/err-05-missing-field.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![allow(dead_code)] - -use orchestra::*; - -#[derive(Default)] -struct AwesomeSubSys; - -impl ::orchestra::Subsystem, OrchestraError> for AwesomeSubSys { - fn start(self, _ctx: OrchestraSubsystemContext) -> SpawnedSubsystem { - unimplemented!("starting yay!") - } -} - -#[derive(Clone, Debug)] -pub struct SigSigSig; - -pub struct Event; - -#[derive(Clone, Debug)] -pub struct MsgStrukt(u8); - -#[orchestra(signal=SigSigSig, error=OrchestraError, event=Event, gen=AllMessages)] -struct Orchestra { - #[subsystem(MsgStrukt)] - sub0: AwesomeSubSys, - i_like_pie: f64, -} - -#[derive(Debug, Clone)] -pub struct DummySpawner; - -impl Spawner for DummySpawner { - fn spawn_blocking( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn blocking {} {}", task_name, subsystem_name.unwrap_or("default")) - } - - fn spawn( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn {} {}", task_name, subsystem_name.unwrap_or("default")) - } -} - -struct DummyCtx; - -fn main() { - let _ = Orchestra::builder() - .sub0(AwesomeSubSys::default()) - //.i_like_pie(std::f64::consts::PI) // The filed is not initialised - .spawner(DummySpawner) - .build() - .unwrap(); -} diff --git a/node/orchestra/tests/ui/err-05-missing-field.stderr b/node/orchestra/tests/ui/err-05-missing-field.stderr deleted file mode 100644 index 84778a427552..000000000000 --- a/node/orchestra/tests/ui/err-05-missing-field.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0599]: no method named `build` found for struct `OrchestraBuilder, Init, Missing>` in the current scope - --> tests/ui/err-05-missing-field.rs:59:4 - | -22 | #[orchestra(signal=SigSigSig, error=OrchestraError, event=Event, gen=AllMessages)] - | ---------------------------------------------------------------------------------- method `build` not found for this struct -... -59 | .build() - | ^^^^^ method not found in `OrchestraBuilder, Init, Missing>` - | - = note: the method was found for - - `OrchestraBuilder, Init, Init>` diff --git a/node/orchestra/tests/ui/err-06-missing-subsystem.rs b/node/orchestra/tests/ui/err-06-missing-subsystem.rs deleted file mode 100644 index 85b1b2f618fe..000000000000 --- a/node/orchestra/tests/ui/err-06-missing-subsystem.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![allow(dead_code)] - -use orchestra::*; - -#[derive(Default)] -struct AwesomeSubSys; - -impl ::orchestra::Subsystem, OrchestraError> for AwesomeSubSys { - fn start(self, _ctx: OrchestraSubsystemContext) -> SpawnedSubsystem { - unimplemented!("starting yay!") - } -} - -#[derive(Clone, Debug)] -pub struct SigSigSig; - -pub struct Event; - -#[derive(Clone, Debug)] -pub struct MsgStrukt(u8); - -#[orchestra(signal=SigSigSig, error=OrchestraError, event=Event, gen=AllMessages)] -struct Orchestra { - #[subsystem(MsgStrukt)] - sub0: AwesomeSubSys, - i_like_pie: f64, -} - -#[derive(Debug, Clone)] -pub struct DummySpawner; - -impl Spawner for DummySpawner { - fn spawn_blocking( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn blocking {} {}", task_name, subsystem_name.unwrap_or("default")) - } - - fn spawn( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn {} {}", task_name, subsystem_name.unwrap_or("default")) - } -} - -struct DummyCtx; - -fn main() { - let _ = Orchestra::builder() - //.sub0(AwesomeSubSys::default()) // Subsystem is uninitialized - .i_like_pie(std::f64::consts::PI) - .spawner(DummySpawner) - .build() - .unwrap(); -} diff --git a/node/orchestra/tests/ui/err-06-missing-subsystem.stderr b/node/orchestra/tests/ui/err-06-missing-subsystem.stderr deleted file mode 100644 index 767d7feae398..000000000000 --- a/node/orchestra/tests/ui/err-06-missing-subsystem.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0599]: no method named `build` found for struct `OrchestraBuilder, Missing<_>, Init>` in the current scope - --> tests/ui/err-06-missing-subsystem.rs:59:4 - | -22 | #[orchestra(signal=SigSigSig, error=OrchestraError, event=Event, gen=AllMessages)] - | ---------------------------------------------------------------------------------- method `build` not found for this struct -... -59 | .build() - | ^^^^^ method not found in `OrchestraBuilder, Missing<_>, Init>` - | - = note: the method was found for - - `OrchestraBuilder, Init, Init>` diff --git a/node/orchestra/tests/ui/err-07-missing-spawner.rs b/node/orchestra/tests/ui/err-07-missing-spawner.rs deleted file mode 100644 index 45f0af1c6e50..000000000000 --- a/node/orchestra/tests/ui/err-07-missing-spawner.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![allow(dead_code)] - -use orchestra::*; - -#[derive(Default)] -struct AwesomeSubSys; - -impl ::orchestra::Subsystem, OrchestraError> for AwesomeSubSys { - fn start(self, _ctx: OrchestraSubsystemContext) -> SpawnedSubsystem { - unimplemented!("starting yay!") - } -} - -#[derive(Clone, Debug)] -pub struct SigSigSig; - -pub struct Event; - -#[derive(Clone, Debug)] -pub struct MsgStrukt(u8); - -#[orchestra(signal=SigSigSig, error=OrchestraError, event=Event, gen=AllMessages)] -struct Orchestra { - #[subsystem(MsgStrukt)] - sub0: AwesomeSubSys, - i_like_pie: f64, -} - -#[derive(Debug, Clone)] -pub struct DummySpawner; - -impl Spawner for DummySpawner { - fn spawn_blocking( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn blocking {} {}", task_name, subsystem_name.unwrap_or("default")) - } - - fn spawn( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn {} {}", task_name, subsystem_name.unwrap_or("default")) - } -} - -struct DummyCtx; - -fn main() { - let _ = Orchestra::builder() - .sub0(AwesomeSubSys::default()) - .i_like_pie(std::f64::consts::PI) - //.spawner(DummySpawner) // Spawner is missing - .build() - .unwrap(); -} diff --git a/node/orchestra/tests/ui/err-07-missing-spawner.stderr b/node/orchestra/tests/ui/err-07-missing-spawner.stderr deleted file mode 100644 index 1b5fb5413ced..000000000000 --- a/node/orchestra/tests/ui/err-07-missing-spawner.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0599]: no method named `build` found for struct `OrchestraBuilder, Init, Init>` in the current scope - --> tests/ui/err-07-missing-spawner.rs:59:4 - | -22 | #[orchestra(signal=SigSigSig, error=OrchestraError, event=Event, gen=AllMessages)] - | ---------------------------------------------------------------------------------- method `build` not found for this struct -... -59 | .build() - | ^^^^^ method not found in `OrchestraBuilder, Init, Init>` - | - = note: the method was found for - - `OrchestraBuilder, Init, Init>` diff --git a/node/orchestra/tests/ui/err-08-duplicate-subsystem.rs b/node/orchestra/tests/ui/err-08-duplicate-subsystem.rs deleted file mode 100644 index 8a3eab1ee726..000000000000 --- a/node/orchestra/tests/ui/err-08-duplicate-subsystem.rs +++ /dev/null @@ -1,62 +0,0 @@ -#![allow(dead_code)] - -use orchestra::*; - -#[derive(Default)] -struct AwesomeSubSys; - -impl ::orchestra::Subsystem, OrchestraError> for AwesomeSubSys { - fn start(self, _ctx: OrchestraSubsystemContext) -> SpawnedSubsystem { - unimplemented!("starting yay!") - } -} - -#[derive(Clone, Debug)] -pub struct SigSigSig; - -pub struct Event; - -#[derive(Clone, Debug)] -pub struct MsgStrukt(u8); - -#[orchestra(signal=SigSigSig, error=OrchestraError, event=Event, gen=AllMessages)] -struct Orchestra { - #[subsystem(MsgStrukt)] - sub0: AwesomeSubSys, - i_like_pie: f64, -} - -#[derive(Debug, Clone)] -pub struct DummySpawner; - -impl Spawner for DummySpawner { - fn spawn_blocking( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn blocking {} {}", task_name, subsystem_name.unwrap_or("default")) - } - - fn spawn( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn {} {}", task_name, subsystem_name.unwrap_or("default")) - } -} - -struct DummyCtx; - -fn main() { - let _ = Orchestra::builder() - .sub0(AwesomeSubSys::default()) - .sub0(AwesomeSubSys::default()) // Duplicate subsystem - .i_like_pie(std::f64::consts::PI) - .spawner(DummySpawner) - .build() - .unwrap(); -} diff --git a/node/orchestra/tests/ui/err-08-duplicate-subsystem.stderr b/node/orchestra/tests/ui/err-08-duplicate-subsystem.stderr deleted file mode 100644 index b95c0d0a7daf..000000000000 --- a/node/orchestra/tests/ui/err-08-duplicate-subsystem.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0599]: no method named `sub0` found for struct `OrchestraBuilder, Init, Missing>` in the current scope - --> tests/ui/err-08-duplicate-subsystem.rs:57:4 - | -22 | #[orchestra(signal=SigSigSig, error=OrchestraError, event=Event, gen=AllMessages)] - | ---------------------------------------------------------------------------------- method `sub0` not found for this struct -... -57 | .sub0(AwesomeSubSys::default()) // Duplicate subsystem - | ^^^^-------------------------- help: remove the arguments - | | - | field, not a method diff --git a/node/orchestra/tests/ui/err-09-uninit_generic_baggage.rs b/node/orchestra/tests/ui/err-09-uninit_generic_baggage.rs deleted file mode 100644 index c90979c4e4e8..000000000000 --- a/node/orchestra/tests/ui/err-09-uninit_generic_baggage.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![allow(dead_code)] - -use orchestra::*; - -#[derive(Default)] -struct AwesomeSubSys; - -impl ::orchestra::Subsystem, OrchestraError> for AwesomeSubSys { - fn start(self, _ctx: OrchestraSubsystemContext) -> SpawnedSubsystem { - unimplemented!("starting yay!") - } -} - -#[derive(Clone, Debug)] -pub struct SigSigSig; - -pub struct Event; - -#[derive(Clone, Debug)] -pub struct MsgStrukt(u8); - -#[orchestra(signal=SigSigSig, error=OrchestraError, event=Event, gen=AllMessages)] -struct Orchestra { - #[subsystem(MsgStrukt)] - sub0: AwesomeSubSys, - i_like_pie: T, -} - -#[derive(Debug, Clone)] -pub struct DummySpawner; - -impl Spawner for DummySpawner { - fn spawn_blocking( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn blocking {} {}", task_name, subsystem_name.unwrap_or("default")) - } - - fn spawn( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - unimplemented!("spawn {} {}", task_name, subsystem_name.unwrap_or("default")) - } -} - -struct DummyCtx; - -fn main() { - let (_, _): (Orchestra<_, f64>, _) = Orchestra::builder() - .sub0(AwesomeSubSys::default()) - //.i_like_pie(std::f64::consts::PI) // The filed is not initialised - .spawner(DummySpawner) - .build() - .unwrap(); -} diff --git a/node/orchestra/tests/ui/err-09-uninit_generic_baggage.stderr b/node/orchestra/tests/ui/err-09-uninit_generic_baggage.stderr deleted file mode 100644 index ef9743fcdf22..000000000000 --- a/node/orchestra/tests/ui/err-09-uninit_generic_baggage.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0599]: no method named `build` found for struct `OrchestraBuilder, Init, Missing<_>>` in the current scope - --> tests/ui/err-09-uninit_generic_baggage.rs:59:4 - | -22 | #[orchestra(signal=SigSigSig, error=OrchestraError, event=Event, gen=AllMessages)] - | ---------------------------------------------------------------------------------- method `build` not found for this struct -... -59 | .build() - | ^^^^^ method not found in `OrchestraBuilder, Init, Missing<_>>` - | - = note: the method was found for - - `OrchestraBuilder, Init, Init>` diff --git a/node/orchestra/tests/ui/ok-01-wip.rs b/node/orchestra/tests/ui/ok-01-wip.rs deleted file mode 100644 index 5a2fad40540e..000000000000 --- a/node/orchestra/tests/ui/ok-01-wip.rs +++ /dev/null @@ -1,74 +0,0 @@ -#![allow(dead_code)] - -use orchestra::*; - -#[derive(Default)] -struct AwesomeSubSysA; - -impl ::orchestra::Subsystem, OrchestraError> for AwesomeSubSysA { - fn start(self, _ctx: OrchestraSubsystemContext) -> SpawnedSubsystem { - SpawnedSubsystem { name: "sub A", future: Box::pin(async move { Ok(()) }) } - } -} -impl ::orchestra::Subsystem, OrchestraError> for AwesomeSubSysB { - fn start(self, _ctx: OrchestraSubsystemContext) -> SpawnedSubsystem { - SpawnedSubsystem { name: "sub B", future: Box::pin(async move { Ok(()) }) } - } -} - -#[derive(Debug, Clone)] -pub struct DummySpawner; - -impl Spawner for DummySpawner { - fn spawn_blocking( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - println!("spawn blocking {} {}", task_name, subsystem_name.unwrap_or("default")) - } - - fn spawn( - &self, - task_name: &'static str, - subsystem_name: Option<&'static str>, - _future: futures::future::BoxFuture<'static, ()>, - ) { - println!("spawn {} {}", task_name, subsystem_name.unwrap_or("default")) - } -} - -#[derive(Default)] -pub struct AwesomeSubSysB; - -#[derive(Clone, Debug)] -pub struct SigSigSig; - -pub struct Event; - -#[derive(Clone, Debug)] -pub struct MsgA(u8); - -#[derive(Clone, Debug)] -pub struct MsgB(u8); - -#[orchestra(signal=SigSigSig, event=Event, gen=AllMessages, error=OrchestraError)] -pub struct Orchestra { - #[subsystem(MsgA)] - sub_a: AwesomeSubSysA, - - #[subsystem(wip, MsgB)] - sub_b: AwesomeSubSysB, -} - -pub struct DummyCtx; - -fn main() { - let _orchestra_builder = Orchestra::builder() - .sub_a(AwesomeSubSysA::default()) - // b is tagged as `wip` - // .sub_b(AwesomeSubSysB::default()) - .spawner(DummySpawner) - .build(); -} diff --git a/node/overseer/Cargo.toml b/node/overseer/Cargo.toml index 4c00ab49f87c..eb02b2cc1c6d 100644 --- a/node/overseer/Cargo.toml +++ b/node/overseer/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "polkadot-overseer" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] -client = { package = "sc-client-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +client = { package = "sc-client-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures = "0.3.21" futures-timer = "3.0.2" parking_lot = "0.12.0" @@ -15,16 +15,17 @@ polkadot-node-primitives = { path = "../primitives" } polkadot-node-subsystem-types = { path = "../subsystem-types" } polkadot-node-metrics = { path = "../metrics" } polkadot-primitives = { path = "../../primitives" } -orchestra = { path = "../orchestra" } +orchestra = "0.0.2" gum = { package = "tracing-gum", path = "../gum" } -lru = "0.7" -parity-util-mem = { version = "0.11.0", default-features = false } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -async-trait = "0.1.56" +lru = "0.8" +parity-util-mem = { version = "0.12.0", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +async-trait = "0.1.57" [dev-dependencies] -metered = { package = "prioritized-metered-channel", path = "../metered-channel" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +metered = { package = "prioritized-metered-channel", version = "0.2.0" } + +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures = { version = "0.3.21", features = ["thread-pool"] } femme = "2.2.1" assert_matches = "1.4.0" diff --git a/node/overseer/src/lib.rs b/node/overseer/src/lib.rs index 21160bddaecb..70dbe92b2432 100644 --- a/node/overseer/src/lib.rs +++ b/node/overseer/src/lib.rs @@ -62,6 +62,7 @@ use std::{ collections::{hash_map, HashMap}, fmt::{self, Debug}, + num::NonZeroUsize, pin::Pin, sync::Arc, time::Duration, @@ -112,7 +113,10 @@ pub use orchestra::{ /// Store 2 days worth of blocks, not accounting for forks, /// in the LRU cache. Assumes a 6-second block time. -pub const KNOWN_LEAVES_CACHE_SIZE: usize = 2 * 24 * 3600 / 6; +pub const KNOWN_LEAVES_CACHE_SIZE: NonZeroUsize = match NonZeroUsize::new(2 * 24 * 3600 / 6) { + Some(cap) => cap, + None => panic!("Known leaves cache size must be non-zero"), +}; #[cfg(test)] mod tests; @@ -843,6 +847,11 @@ where self.metrics.on_head_activated(); if let Some(listeners) = self.activation_external_listeners.remove(hash) { + gum::trace!( + target: LOG_TARGET, + relay_parent = ?hash, + "Leaf got activated, notifying exterinal listeners" + ); for listener in listeners { // it's fine if the listener is no longer interested let _ = listener.send(Ok(())); @@ -884,14 +893,20 @@ where fn handle_external_request(&mut self, request: ExternalRequest) { match request { ExternalRequest::WaitForActivation { hash, response_channel } => { - // We use known leaves here because the `WaitForActivation` message - // is primarily concerned about leaves which subsystems have simply - // not been made aware of yet. Anything in the known leaves set, - // even if stale, has been activated in the past. - if self.known_leaves.peek(&hash).is_some() { + if self.active_leaves.get(&hash).is_some() { + gum::trace!( + target: LOG_TARGET, + relay_parent = ?hash, + "Leaf was already ready - answering `WaitForActivation`" + ); // it's fine if the listener is no longer interested let _ = response_channel.send(Ok(())); } else { + gum::trace!( + target: LOG_TARGET, + relay_parent = ?hash, + "Leaf not yet ready - queuing `WaitForActivation` sender" + ); self.activation_external_listeners .entry(hash) .or_default() diff --git a/node/overseer/src/tests.rs b/node/overseer/src/tests.rs index 121c707c2541..dee4c7cbbba9 100644 --- a/node/overseer/src/tests.rs +++ b/node/overseer/src/tests.rs @@ -873,8 +873,9 @@ fn test_network_bridge_tx_msg() -> NetworkBridgeTxMessage { fn test_network_bridge_rx_msg() -> NetworkBridgeRxMessage { NetworkBridgeRxMessage::NewGossipTopology { session: SessionIndex::from(0_u32), - our_neighbors_x: HashMap::new(), - our_neighbors_y: HashMap::new(), + local_index: None, + canonical_shuffling: Vec::new(), + shuffled_indices: Vec::new(), } } diff --git a/node/primitives/Cargo.toml b/node/primitives/Cargo.toml index e946a6b0457e..137231f4272b 100644 --- a/node/primitives/Cargo.toml +++ b/node/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-primitives" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" description = "Primitives types for the Node-side" @@ -10,12 +10,12 @@ bounded-vec = "0.6" futures = "0.3.21" polkadot-primitives = { path = "../../primitives" } parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus-vrf = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus-vrf = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-parachain = { path = "../../parachain", default-features = false } schnorrkel = "0.9.1" thiserror = "1.0.31" diff --git a/node/primitives/src/disputes/mod.rs b/node/primitives/src/disputes/mod.rs index ec7bb6abc3b7..ee047c7bcc22 100644 --- a/node/primitives/src/disputes/mod.rs +++ b/node/primitives/src/disputes/mod.rs @@ -30,6 +30,8 @@ use polkadot_primitives::v2::{ /// `DisputeMessage` and related types. mod message; pub use message::{DisputeMessage, Error as DisputeMessageCheckError, UncheckedDisputeMessage}; +mod status; +pub use status::{dispute_is_inactive, DisputeStatus, Timestamp, ACTIVE_DURATION_SECS}; /// A checked dispute statement from an associated validator. #[derive(Debug, Clone)] diff --git a/node/primitives/src/disputes/status.rs b/node/primitives/src/disputes/status.rs new file mode 100644 index 000000000000..c0ffb907423b --- /dev/null +++ b/node/primitives/src/disputes/status.rs @@ -0,0 +1,125 @@ +// Copyright 2017-2022 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 . + +use parity_scale_codec::{Decode, Encode}; + +/// Timestamp based on the 1 Jan 1970 UNIX base, which is persistent across node restarts and OS reboots. +pub type Timestamp = u64; + +/// The status of dispute. This is a state machine which can be altered by the +/// helper methods. +#[derive(Debug, Clone, Copy, Encode, Decode, PartialEq)] +pub enum DisputeStatus { + /// The dispute is active and unconcluded. + #[codec(index = 0)] + Active, + /// The dispute has been concluded in favor of the candidate + /// since the given timestamp. + #[codec(index = 1)] + ConcludedFor(Timestamp), + /// The dispute has been concluded against the candidate + /// since the given timestamp. + /// + /// This takes precedence over `ConcludedFor` in the case that + /// both are true, which is impossible unless a large amount of + /// validators are participating on both sides. + #[codec(index = 2)] + ConcludedAgainst(Timestamp), + /// Dispute has been confirmed (more than `byzantine_threshold` have already participated/ or + /// we have seen the candidate included already/participated successfully ourselves). + #[codec(index = 3)] + Confirmed, +} + +impl DisputeStatus { + /// Initialize the status to the active state. + pub fn active() -> DisputeStatus { + DisputeStatus::Active + } + + /// Move status to confirmed status, if not yet concluded/confirmed already. + pub fn confirm(self) -> DisputeStatus { + match self { + DisputeStatus::Active => DisputeStatus::Confirmed, + DisputeStatus::Confirmed => DisputeStatus::Confirmed, + DisputeStatus::ConcludedFor(_) | DisputeStatus::ConcludedAgainst(_) => self, + } + } + + /// Check whether the dispute is not a spam dispute. + pub fn is_confirmed_concluded(&self) -> bool { + match self { + &DisputeStatus::Confirmed | + &DisputeStatus::ConcludedFor(_) | + DisputeStatus::ConcludedAgainst(_) => true, + &DisputeStatus::Active => false, + } + } + + /// Transition the status to a new status after observing the dispute has concluded for the candidate. + /// This may be a no-op if the status was already concluded. + pub fn concluded_for(self, now: Timestamp) -> DisputeStatus { + match self { + DisputeStatus::Active | DisputeStatus::Confirmed => DisputeStatus::ConcludedFor(now), + DisputeStatus::ConcludedFor(at) => DisputeStatus::ConcludedFor(std::cmp::min(at, now)), + against => against, + } + } + + /// Transition the status to a new status after observing the dispute has concluded against the candidate. + /// This may be a no-op if the status was already concluded. + pub fn concluded_against(self, now: Timestamp) -> DisputeStatus { + match self { + DisputeStatus::Active | DisputeStatus::Confirmed => + DisputeStatus::ConcludedAgainst(now), + DisputeStatus::ConcludedFor(at) => + DisputeStatus::ConcludedAgainst(std::cmp::min(at, now)), + DisputeStatus::ConcludedAgainst(at) => + DisputeStatus::ConcludedAgainst(std::cmp::min(at, now)), + } + } + + /// Whether the disputed candidate is possibly invalid. + pub fn is_possibly_invalid(&self) -> bool { + match self { + DisputeStatus::Active | + DisputeStatus::Confirmed | + DisputeStatus::ConcludedAgainst(_) => true, + DisputeStatus::ConcludedFor(_) => false, + } + } + + /// Yields the timestamp this dispute concluded at, if any. + pub fn concluded_at(&self) -> Option { + match self { + DisputeStatus::Active | DisputeStatus::Confirmed => None, + DisputeStatus::ConcludedFor(at) | DisputeStatus::ConcludedAgainst(at) => Some(*at), + } + } +} + +/// The choice here is fairly arbitrary. But any dispute that concluded more than a few minutes ago +/// is not worth considering anymore. Changing this value has little to no bearing on consensus, +/// and really only affects the work that the node might do on startup during periods of many +/// disputes. +pub const ACTIVE_DURATION_SECS: Timestamp = 180; + +/// Returns true if the dispute has concluded for longer than [`ACTIVE_DURATION_SECS`]. +pub fn dispute_is_inactive(status: &DisputeStatus, now: &Timestamp) -> bool { + let at = status.concluded_at(); + + at.is_some() && at.unwrap() + ACTIVE_DURATION_SECS < *now +} diff --git a/node/primitives/src/lib.rs b/node/primitives/src/lib.rs index 882b75a0e81f..4551ce9855e3 100644 --- a/node/primitives/src/lib.rs +++ b/node/primitives/src/lib.rs @@ -46,8 +46,9 @@ pub mod approval; /// Disputes related types. pub mod disputes; pub use disputes::{ - CandidateVotes, DisputeMessage, DisputeMessageCheckError, InvalidDisputeVote, - SignedDisputeStatement, UncheckedDisputeMessage, ValidDisputeVote, + dispute_is_inactive, CandidateVotes, DisputeMessage, DisputeMessageCheckError, DisputeStatus, + InvalidDisputeVote, SignedDisputeStatement, Timestamp, UncheckedDisputeMessage, + ValidDisputeVote, ACTIVE_DURATION_SECS, }; // For a 16-ary Merkle Prefix Trie, we can expect at most 16 32-byte hashes per node @@ -72,7 +73,7 @@ pub const BACKING_EXECUTION_TIMEOUT: Duration = Duration::from_secs(2); /// ensure that in the absence of extremely large disparities between hardware, /// blocks that pass backing are considerd executable by approval checkers or /// dispute participants. -pub const APPROVAL_EXECUTION_TIMEOUT: Duration = Duration::from_secs(6); +pub const APPROVAL_EXECUTION_TIMEOUT: Duration = Duration::from_secs(12); /// Linked to `MAX_FINALITY_LAG` in relay chain selection, /// `MAX_HEADS_LOOK_BACK` in `approval-voting` and diff --git a/node/service/Cargo.toml b/node/service/Cargo.toml index 4816754f1a11..90036b57484e 100644 --- a/node/service/Cargo.toml +++ b/node/service/Cargo.toml @@ -1,64 +1,66 @@ [package] name = "polkadot-service" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" +rust-version = "1.60" [dependencies] # Substrate Client -sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -babe = { package = "sc-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -beefy-gadget = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-sync-state-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -service = { package = "sc-service", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -telemetry = { package = "sc-telemetry", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +babe = { package = "sc-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +beefy-gadget = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-sync-state-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +service = { package = "sc-service", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +telemetry = { package = "sc-telemetry", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } # Substrate Primitives -sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -consensus_common = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -grandpa_primitives = { package = "sp-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-offchain = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-storage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +consensus_common = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +grandpa_primitives = { package = "sp-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-offchain = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-storage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } # Substrate Pallets -pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } # Substrate Other -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } # External Crates futures = "0.3.21" @@ -67,11 +69,11 @@ gum = { package = "tracing-gum", path = "../gum/" } serde = { version = "1.0.137", features = ["derive"] } serde_json = "1.0.81" thiserror = "1.0.31" -kvdb = "0.11.0" -kvdb-rocksdb = { version = "0.15.2", optional = true } +kvdb = "0.12.0" +kvdb-rocksdb = { version = "0.16.0", optional = true } parity-db = { version = "0.3.16", optional = true } -async-trait = "0.1.53" -lru = "0.7" +async-trait = "0.1.57" +lru = "0.8" # Polkadot polkadot-node-core-parachains-inherent = { path = "../core/parachains-inherent" } @@ -173,32 +175,32 @@ westend-native = [ "westend-runtime", "westend-runtime-constants", "polkadot-cli rococo-native = [ "rococo-runtime", "rococo-runtime-constants", "polkadot-client/rococo" ] runtime-benchmarks = [ - "polkadot-runtime/runtime-benchmarks", - "kusama-runtime/runtime-benchmarks", - "westend-runtime/runtime-benchmarks", - "rococo-runtime/runtime-benchmarks" + "polkadot-runtime?/runtime-benchmarks", + "kusama-runtime?/runtime-benchmarks", + "westend-runtime?/runtime-benchmarks", + "rococo-runtime?/runtime-benchmarks", + + "service/runtime-benchmarks", ] try-runtime = [ - "polkadot-runtime/try-runtime", - "kusama-runtime/try-runtime", - "westend-runtime/try-runtime", - "rococo-runtime/try-runtime", + "polkadot-runtime?/try-runtime", + "kusama-runtime?/try-runtime", + "westend-runtime?/try-runtime", + "rococo-runtime?/try-runtime", ] fast-runtime = [ - "polkadot-runtime/fast-runtime", - "kusama-runtime/fast-runtime", - "westend-runtime/fast-runtime", - "rococo-runtime/fast-runtime", + "polkadot-runtime?/fast-runtime", + "kusama-runtime?/fast-runtime", + "westend-runtime?/fast-runtime", + "rococo-runtime?/fast-runtime", ] malus = ["full-node"] runtime-metrics = [ "polkadot-client/runtime-metrics", - "rococo-runtime/runtime-metrics", - "westend-runtime/runtime-metrics", - "kusama-runtime/runtime-metrics", - "polkadot-runtime/runtime-metrics", + "rococo-runtime?/runtime-metrics", + "westend-runtime?/runtime-metrics", + "kusama-runtime?/runtime-metrics", + "polkadot-runtime?/runtime-metrics", "polkadot-runtime-parachains/runtime-metrics" ] - -staging-client = ["polkadot-node-core-provisioner/staging-client"] diff --git a/node/service/src/chain_spec.rs b/node/service/src/chain_spec.rs index c4fe17640d18..e2c0a7bfdf94 100644 --- a/node/service/src/chain_spec.rs +++ b/node/service/src/chain_spec.rs @@ -17,6 +17,7 @@ //! Polkadot chain configurations. use beefy_primitives::crypto::AuthorityId as BeefyId; +use frame_support::weights::Weight; use grandpa::AuthorityId as GrandpaId; #[cfg(feature = "kusama-native")] use kusama_runtime as kusama; @@ -189,7 +190,8 @@ fn default_parachains_host_configuration( max_upward_queue_count: 8, max_upward_queue_size: 1024 * 1024, max_downward_message_size: 1024 * 1024, - ump_service_total_weight: 100_000_000_000, + ump_service_total_weight: Weight::from_ref_time(100_000_000_000) + .set_proof_size(MAX_POV_SIZE as u64), max_upward_message_size: 50 * 1024, max_upward_message_num_per_candidate: 5, hrmp_sender_deposit: 0, @@ -1047,26 +1049,35 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime:: }) .collect::>(), }, + phragmen_election: Default::default(), babe: rococo_runtime::BabeConfig { authorities: Default::default(), epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG), }, grandpa: Default::default(), im_online: Default::default(), - collective: Default::default(), - membership: Default::default(), + democracy: rococo_runtime::DemocracyConfig::default(), + council: rococo::CouncilConfig { members: vec![], phantom: Default::default() }, + technical_committee: rococo::TechnicalCommitteeConfig { + members: vec![], + phantom: Default::default(), + }, + technical_membership: Default::default(), + treasury: Default::default(), authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] }, + claims: rococo::ClaimsConfig { claims: vec![], vesting: vec![] }, + vesting: rococo::VestingConfig { vesting: vec![] }, sudo: rococo_runtime::SudoConfig { key: Some(endowed_accounts[0].clone()) }, paras: rococo_runtime::ParasConfig { paras: vec![] }, hrmp: Default::default(), configuration: rococo_runtime::ConfigurationConfig { config: default_parachains_host_configuration(), }, + gilt: Default::default(), registrar: rococo_runtime::RegistrarConfig { next_free_para_id: polkadot_primitives::v2::LOWEST_PUBLIC_ID, }, xcm_pallet: Default::default(), - transaction_payment: Default::default(), } } @@ -1598,8 +1609,17 @@ pub fn rococo_testnet_genesis( }, grandpa: Default::default(), im_online: Default::default(), - collective: Default::default(), - membership: Default::default(), + phragmen_election: Default::default(), + democracy: rococo::DemocracyConfig::default(), + council: rococo::CouncilConfig { members: vec![], phantom: Default::default() }, + technical_committee: rococo::TechnicalCommitteeConfig { + members: vec![], + phantom: Default::default(), + }, + technical_membership: Default::default(), + treasury: Default::default(), + claims: rococo::ClaimsConfig { claims: vec![], vesting: vec![] }, + vesting: rococo::VestingConfig { vesting: vec![] }, authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] }, sudo: rococo_runtime::SudoConfig { key: Some(root_key.clone()) }, hrmp: Default::default(), @@ -1609,12 +1629,12 @@ pub fn rococo_testnet_genesis( ..default_parachains_host_configuration() }, }, + gilt: Default::default(), paras: rococo_runtime::ParasConfig { paras: vec![] }, registrar: rococo_runtime::RegistrarConfig { next_free_para_id: polkadot_primitives::v2::LOWEST_PUBLIC_ID, }, xcm_pallet: Default::default(), - transaction_payment: Default::default(), } } diff --git a/node/service/src/lib.rs b/node/service/src/lib.rs index 206809aeefe8..3619d05c7592 100644 --- a/node/service/src/lib.rs +++ b/node/service/src/lib.rs @@ -46,9 +46,11 @@ use { self as chain_selection_subsystem, Config as ChainSelectionConfig, }, polkadot_node_core_dispute_coordinator::Config as DisputeCoordinatorConfig, - polkadot_node_network_protocol::request_response::ReqProtocolNames, + polkadot_node_network_protocol::{ + peer_set::PeerSetProtocolNames, request_response::ReqProtocolNames, + }, polkadot_overseer::BlockInfo, - sc_client_api::{BlockBackend, ExecutorProvider}, + sc_client_api::BlockBackend, sp_core::traits::SpawnNamed, sp_trie::PrefixedMemoryDB, }; @@ -290,7 +292,7 @@ impl IdentifyVariant for Box { } #[cfg(feature = "full-node")] -fn open_database(db_source: &DatabaseSource) -> Result, Error> { +pub fn open_database(db_source: &DatabaseSource) -> Result, Error> { let parachains_db = match db_source { DatabaseSource::RocksDb { path, .. } => parachains_db::open_creating_rocksdb( path.clone(), @@ -519,7 +521,7 @@ where client.clone(), ); - let babe_config = babe::Config::get(&*client)?; + let babe_config = babe::configuration(&*client)?; let (block_import, babe_link) = babe::block_import(babe_config.clone(), beefy_block_import, client.clone())?; @@ -539,11 +541,10 @@ where slot_duration, ); - Ok((timestamp, slot)) + Ok((slot, timestamp)) }, &task_manager.spawn_essential_handle(), config.prometheus_registry(), - consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone()), telemetry.as_ref().map(|x| x.handle()), )?; @@ -717,6 +718,11 @@ where Ok(leaves.into_iter().rev().take(MAX_ACTIVE_LEAVES).collect()) } +pub const AVAILABILITY_CONFIG: AvailabilityConfig = AvailabilityConfig { + col_data: parachains_db::REAL_COLUMNS.col_availability_data, + col_meta: parachains_db::REAL_COLUMNS.col_availability_meta, +}; + /// Create a new full node of arbitrary runtime and executor. /// /// This is an advanced feature and not recommended for general use. Generally, `build_full` is @@ -799,7 +805,7 @@ where let auth_or_collator = role.is_authority() || is_collator.is_collator(); let requires_overseer_for_chain_sel = local_keystore.is_some() && auth_or_collator; - let pvf_checker_enabled = !is_collator.is_collator() && chain_spec.is_versi(); + let pvf_checker_enabled = role.is_authority() && !is_collator.is_collator(); let select_chain = if requires_overseer_for_chain_sel { let metrics = @@ -843,19 +849,36 @@ where .extra_sets .push(grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone())); - let beefy_protocol_name = - beefy_gadget::protocol_standard_name(&genesis_hash, &config.chain_spec); + let beefy_gossip_proto_name = + beefy_gadget::gossip_protocol_name(&genesis_hash, config.chain_spec.fork_id()); + // `beefy_on_demand_justifications_handler` is given to `beefy-gadget` task to be run, + // while `beefy_req_resp_cfg` is added to `config.network.request_response_protocols`. + let (beefy_on_demand_justifications_handler, beefy_req_resp_cfg) = + beefy_gadget::communication::request_response::BeefyJustifsRequestHandler::new( + &genesis_hash, + config.chain_spec.fork_id(), + client.clone(), + ); if enable_beefy { config .network .extra_sets - .push(beefy_gadget::beefy_peers_set_config(beefy_protocol_name.clone())); + .push(beefy_gadget::communication::beefy_peers_set_config( + beefy_gossip_proto_name.clone(), + )); + config.network.request_response_protocols.push(beefy_req_resp_cfg); } + let peerset_protocol_names = + PeerSetProtocolNames::new(genesis_hash, config.chain_spec.fork_id()); + { use polkadot_network_bridge::{peer_sets_info, IsAuthority}; let is_authority = if role.is_authority() { IsAuthority::Yes } else { IsAuthority::No }; - config.network.extra_sets.extend(peer_sets_info(is_authority)); + config + .network + .extra_sets + .extend(peer_sets_info(is_authority, &peerset_protocol_names)); } let req_protocol_names = ReqProtocolNames::new(&genesis_hash, config.chain_spec.fork_id()); @@ -886,7 +909,7 @@ where grandpa_hard_forks, )); - let (network, system_rpc_tx, network_starter) = + let (network, system_rpc_tx, tx_handler_controller, network_starter) = service::build_network(service::BuildNetworkParams { config: &config, client: client.clone(), @@ -919,11 +942,6 @@ where let parachains_db = open_database(&config.database)?; - let availability_config = AvailabilityConfig { - col_data: parachains_db::REAL_COLUMNS.col_availability_data, - col_meta: parachains_db::REAL_COLUMNS.col_availability_meta, - }; - let approval_voting_config = ApprovalVotingConfig { col_data: parachains_db::REAL_COLUMNS.col_approval_data, slot_duration_millis: slot_duration.as_millis() as u64, @@ -961,6 +979,7 @@ where transaction_pool: transaction_pool.clone(), task_manager: &mut task_manager, system_rpc_tx, + tx_handler_controller, telemetry: telemetry.as_mut(), })?; @@ -1056,13 +1075,14 @@ where spawner, is_collator, approval_voting_config, - availability_config, + availability_config: AVAILABILITY_CONFIG, candidate_validation_config, chain_selection_config, dispute_coordinator_config, pvf_checker_enabled, overseer_message_channel_capacity_override, req_protocol_names, + peerset_protocol_names, }, ) .map_err(|e| { @@ -1105,9 +1125,6 @@ where }; if role.is_authority() { - let can_author_with = - consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone()); - let proposer = sc_basic_authorship::ProposerFactory::new( task_manager.spawn_handle(), client.clone(), @@ -1147,13 +1164,12 @@ where slot_duration, ); - Ok((timestamp, slot, parachain)) + Ok((slot, timestamp, parachain)) } }, force_authoring, backoff_authoring_blocks, babe_link, - can_author_with, block_proposal_slot_portion: babe::SlotProportion::new(2f32 / 3f32), max_block_proposal_slot_portion: None, telemetry: telemetry.as_ref().map(|x| x.handle()), @@ -1169,19 +1185,28 @@ where if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None }; if enable_beefy { + let justifications_protocol_name = beefy_on_demand_justifications_handler.protocol_name(); + let network_params = beefy_gadget::BeefyNetworkParams { + network: network.clone(), + gossip_protocol_name: beefy_gossip_proto_name, + justifications_protocol_name, + _phantom: core::marker::PhantomData::, + }; + let payload_provider = beefy_primitives::mmr::MmrRootProvider::new(client.clone()); let beefy_params = beefy_gadget::BeefyParams { client: client.clone(), backend: backend.clone(), + payload_provider, runtime: client.clone(), key_store: keystore_opt.clone(), - network: network.clone(), + network_params, min_block_delta: if chain_spec.is_wococo() { 4 } else { 8 }, prometheus_registry: prometheus_registry.clone(), - protocol_name: beefy_protocol_name, links: beefy_links, + on_demand_justifications_handler: beefy_on_demand_justifications_handler, }; - let gadget = beefy_gadget::start_beefy_gadget::<_, _, _, _, _>(beefy_params); + let gadget = beefy_gadget::start_beefy_gadget::<_, _, _, _, _, _>(beefy_params); // Wococo's purpose is to be a testbed for BEEFY, so if it fails we'll // bring the node down with it to make sure it is noticed. diff --git a/node/service/src/overseer.rs b/node/service/src/overseer.rs index 622b815944ae..a8ce3e5eaaf0 100644 --- a/node/service/src/overseer.rs +++ b/node/service/src/overseer.rs @@ -24,8 +24,9 @@ use polkadot_node_core_av_store::Config as AvailabilityConfig; use polkadot_node_core_candidate_validation::Config as CandidateValidationConfig; use polkadot_node_core_chain_selection::Config as ChainSelectionConfig; use polkadot_node_core_dispute_coordinator::Config as DisputeCoordinatorConfig; -use polkadot_node_network_protocol::request_response::{ - v1 as request_v1, IncomingRequestReceiver, ReqProtocolNames, +use polkadot_node_network_protocol::{ + peer_set::PeerSetProtocolNames, + request_response::{v1 as request_v1, IncomingRequestReceiver, ReqProtocolNames}, }; #[cfg(any(feature = "malus", test))] pub use polkadot_overseer::{ @@ -122,6 +123,8 @@ where pub overseer_message_channel_capacity_override: Option, /// Request-response protocol names source. pub req_protocol_names: ReqProtocolNames, + /// [`PeerSet`] protocol names to protocols mapping. + pub peerset_protocol_names: PeerSetProtocolNames, } /// Obtain a prepared `OverseerBuilder`, that is initialized @@ -151,6 +154,7 @@ pub fn prepared_overseer_builder<'a, Spawner, RuntimeClient>( pvf_checker_enabled, overseer_message_channel_capacity_override, req_protocol_names, + peerset_protocol_names, }: OverseerGenArgs<'a, Spawner, RuntimeClient>, ) -> Result< InitializedOverseerBuilder< @@ -206,12 +210,14 @@ where authority_discovery_service.clone(), network_bridge_metrics.clone(), req_protocol_names, + peerset_protocol_names.clone(), )) .network_bridge_rx(NetworkBridgeRxSubsystem::new( network_service.clone(), authority_discovery_service.clone(), Box::new(network_service.clone()), network_bridge_metrics, + peerset_protocol_names, )) .availability_distribution(AvailabilityDistributionSubsystem::new( keystore.clone(), diff --git a/node/service/src/parachains_db/upgrade.rs b/node/service/src/parachains_db/upgrade.rs index ad995f41ed82..73321ae04c09 100644 --- a/node/service/src/parachains_db/upgrade.rs +++ b/node/service/src/parachains_db/upgrade.rs @@ -121,7 +121,7 @@ fn rocksdb_migrate_from_version_0_to_1(path: &Path) -> Result<(), Error> { .to_str() .ok_or_else(|| super::other_io_error("Invalid database path".into()))?; let db_cfg = DatabaseConfig::with_columns(super::columns::v0::NUM_COLUMNS); - let db = Database::open(&db_cfg, db_path)?; + let mut db = Database::open(&db_cfg, db_path)?; db.add_column()?; db.add_column()?; diff --git a/node/subsystem-test-helpers/Cargo.toml b/node/subsystem-test-helpers/Cargo.toml index 17ae055168ee..2a3e5e8123d1 100644 --- a/node/subsystem-test-helpers/Cargo.toml +++ b/node/subsystem-test-helpers/Cargo.toml @@ -1,22 +1,22 @@ [package] name = "polkadot-node-subsystem-test-helpers" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" description = "Subsystem traits and message definitions" [dependencies] -async-trait = "0.1.53" +async-trait = "0.1.57" futures = "0.3.21" parking_lot = "0.12.0" polkadot-node-subsystem = { path = "../subsystem" } polkadot-node-subsystem-util = { path = "../subsystem-util" } polkadot-primitives = { path = "../../primitives" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [dev-dependencies] polkadot-overseer = { path = "../overseer" } diff --git a/node/subsystem-test-helpers/src/lib.rs b/node/subsystem-test-helpers/src/lib.rs index e2e61c2006d8..79f833b7558c 100644 --- a/node/subsystem-test-helpers/src/lib.rs +++ b/node/subsystem-test-helpers/src/lib.rs @@ -30,6 +30,7 @@ use sp_core::testing::TaskExecutor; use std::{ convert::Infallible, + future::Future, pin::Pin, sync::Arc, task::{Context, Poll, Waker}, @@ -391,6 +392,34 @@ macro_rules! arbitrary_order { }; } +/// Future that yields the execution once and resolves +/// immediately after. +/// +/// Useful when one wants to poll the background task to completion +/// before sending messages to it in order to avoid races. +pub struct Yield(bool); + +impl Yield { + /// Returns new `Yield` future. + pub fn new() -> Self { + Self(false) + } +} + +impl Future for Yield { + type Output = (); + + fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { + if !self.0 { + self.0 = true; + cx.waker().wake_by_ref(); + Poll::Pending + } else { + Poll::Ready(()) + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/node/subsystem-types/Cargo.toml b/node/subsystem-types/Cargo.toml index 413085095955..3dfc5041702a 100644 --- a/node/subsystem-types/Cargo.toml +++ b/node/subsystem-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-subsystem-types" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" description = "Subsystem traits and message definitions" @@ -13,12 +13,12 @@ polkadot-node-primitives = { path = "../primitives" } polkadot-node-network-protocol = { path = "../network/protocol" } polkadot-statement-table = { path = "../../statement-table" } polkadot-node-jaeger = { path = "../jaeger" } -orchestra = { path = "../orchestra" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +orchestra = "0.0.2" +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } smallvec = "1.8.0" -substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } thiserror = "1.0.31" -async-trait = "0.1.56" +async-trait = "0.1.57" diff --git a/node/subsystem-types/src/messages.rs b/node/subsystem-types/src/messages.rs index 10a5201cc524..6e4983813984 100644 --- a/node/subsystem-types/src/messages.rs +++ b/node/subsystem-types/src/messages.rs @@ -35,8 +35,8 @@ use polkadot_node_network_protocol::{ use polkadot_node_primitives::{ approval::{BlockApprovalMeta, IndirectAssignmentCert, IndirectSignedApprovalVote}, AvailableData, BabeEpoch, BlockWeight, CandidateVotes, CollationGenerationConfig, - CollationSecondedSignal, DisputeMessage, ErasureChunk, PoV, SignedDisputeStatement, - SignedFullStatement, ValidationResult, + CollationSecondedSignal, DisputeMessage, DisputeStatus, ErasureChunk, PoV, + SignedDisputeStatement, SignedFullStatement, ValidationResult, }; use polkadot_primitives::v2::{ AuthorityDiscoveryId, BackedCandidate, BlockNumber, CandidateEvent, CandidateHash, @@ -271,7 +271,7 @@ pub enum DisputeCoordinatorMessage { /// Fetch a list of all recent disputes the co-ordinator is aware of. /// These are disputes which have occurred any time in recent sessions, /// and which may have already concluded. - RecentDisputes(oneshot::Sender>), + RecentDisputes(oneshot::Sender>), /// Fetch a list of all active disputes that the coordinator is aware of. /// These disputes are either not yet concluded or recently concluded. ActiveDisputes(oneshot::Sender>), @@ -328,18 +328,13 @@ pub enum NetworkBridgeRxMessage { NewGossipTopology { /// The session info this gossip topology is concerned with. session: SessionIndex, - /// Ids of our neighbors in the X dimensions of the new gossip topology, - /// along with their validator indices within the session. - /// - /// We're not necessarily connected to all of them, but we should - /// try to be. - our_neighbors_x: HashMap, - /// Ids of our neighbors in the X dimensions of the new gossip topology, - /// along with their validator indices within the session. - /// - /// We're not necessarily connected to all of them, but we should - /// try to be. - our_neighbors_y: HashMap, + /// Our validator index in the session, if any. + local_index: Option, + /// The canonical shuffling of validators for the session. + canonical_shuffling: Vec<(AuthorityDiscoveryId, ValidatorIndex)>, + /// The reverse mapping of `canonical_shuffling`: from validator index + /// to the index in `canonical_shuffling` + shuffled_indices: Vec, }, } @@ -430,6 +425,10 @@ pub enum AvailabilityDistributionMessage { relay_parent: Hash, /// Validator to fetch the PoV from. from_validator: ValidatorIndex, + /// The id of the parachain that produced this PoV. + /// This field is only used to provide more context when logging errors + /// from the `AvailabilityDistribution` subsystem. + para_id: ParaId, /// Candidate hash to fetch the PoV for. candidate_hash: CandidateHash, /// Expected hash of the PoV, a PoV not matching this hash will be rejected. @@ -699,10 +698,15 @@ pub enum RuntimeApiRequest { OccupiedCoreAssumption, RuntimeApiSender>, ), - /// Returns all on-chain disputes at given block number. - StagingDisputes( - RuntimeApiSender)>>, - ), + /// Returns all on-chain disputes at given block number. Available in `v3`. + Disputes(RuntimeApiSender)>>), +} + +impl RuntimeApiRequest { + /// Runtime version requirements for each message + + /// `Disputes` + pub const DISPUTES_RUNTIME_REQUIREMENT: u32 = 3; } /// A message to the Runtime API subsystem. diff --git a/node/subsystem-types/src/messages/network_bridge_event.rs b/node/subsystem-types/src/messages/network_bridge_event.rs index 4cf2bed6ef8a..5abad8a3c22c 100644 --- a/node/subsystem-types/src/messages/network_bridge_event.rs +++ b/node/subsystem-types/src/messages/network_bridge_event.rs @@ -14,37 +14,25 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use std::{ - collections::{HashMap, HashSet}, - convert::TryFrom, -}; +use std::{collections::HashSet, convert::TryFrom}; pub use sc_network::{PeerId, ReputationChange}; use polkadot_node_network_protocol::{ - grid_topology::SessionGridTopology, ObservedRole, OurView, ProtocolVersion, View, WrongVariant, + grid_topology::SessionGridTopology, peer_set::ProtocolVersion, ObservedRole, OurView, View, + WrongVariant, }; use polkadot_primitives::v2::{AuthorityDiscoveryId, SessionIndex, ValidatorIndex}; -/// Information about a peer in the gossip topology for a session. -#[derive(Debug, Clone, PartialEq)] -pub struct TopologyPeerInfo { - /// The validator's known peer IDs. - pub peer_ids: Vec, - /// The index of the validator in the discovery keys of the corresponding - /// `SessionInfo`. This can extend _beyond_ the set of active parachain validators. - pub validator_index: ValidatorIndex, -} - /// A struct indicating new gossip topology. #[derive(Debug, Clone, PartialEq)] pub struct NewGossipTopology { /// The session index this topology corresponds to. pub session: SessionIndex, - /// Neighbors in the 'X' dimension of the grid. - pub our_neighbors_x: HashMap, - /// Neighbors in the 'Y' dimension of the grid. - pub our_neighbors_y: HashMap, + /// The topology itself. + pub topology: SessionGridTopology, + /// The local validator index, if any. + pub local_index: Option, } /// Events from network. @@ -121,19 +109,3 @@ impl NetworkBridgeEvent { }) } } - -impl From for SessionGridTopology { - fn from(topology: NewGossipTopology) -> Self { - let peers_x = - topology.our_neighbors_x.values().flat_map(|p| &p.peer_ids).cloned().collect(); - let peers_y = - topology.our_neighbors_y.values().flat_map(|p| &p.peer_ids).cloned().collect(); - - let validator_indices_x = - topology.our_neighbors_x.values().map(|p| p.validator_index.clone()).collect(); - let validator_indices_y = - topology.our_neighbors_y.values().map(|p| p.validator_index.clone()).collect(); - - SessionGridTopology { peers_x, peers_y, validator_indices_x, validator_indices_y } - } -} diff --git a/node/subsystem-types/src/runtime_client.rs b/node/subsystem-types/src/runtime_client.rs index 2aa9e2bffb82..259c94fd4e51 100644 --- a/node/subsystem-types/src/runtime_client.rs +++ b/node/subsystem-types/src/runtime_client.rs @@ -186,7 +186,7 @@ pub trait RuntimeApiSubsystemClient { /// Returns all onchain disputes. /// This is a staging method! Do not use on production runtimes! - async fn staging_get_disputes( + async fn disputes( &self, at: Hash, ) -> Result)>, ApiError>; @@ -375,10 +375,10 @@ where self.runtime_api().session_info_before_version_2(&BlockId::Hash(at), index) } - async fn staging_get_disputes( + async fn disputes( &self, at: Hash, ) -> Result)>, ApiError> { - self.runtime_api().staging_get_disputes(&BlockId::Hash(at)) + self.runtime_api().disputes(&BlockId::Hash(at)) } } diff --git a/node/subsystem-util/Cargo.toml b/node/subsystem-util/Cargo.toml index 51cf3a28ad12..ec866746663f 100644 --- a/node/subsystem-util/Cargo.toml +++ b/node/subsystem-util/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "polkadot-node-subsystem-util" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" description = "Subsystem traits and message definitions" [dependencies] -async-trait = "0.1.53" +async-trait = "0.1.57" futures = "0.3.21" itertools = "0.10" parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } @@ -17,7 +17,7 @@ thiserror = "1.0.31" fatality = "0.0.6" gum = { package = "tracing-gum", path = "../gum" } derive_more = "0.99.17" -lru = "0.7.7" +lru = "0.8.0" polkadot-node-subsystem = {path = "../subsystem" } polkadot-node-jaeger = { path = "../jaeger" } @@ -26,14 +26,14 @@ polkadot-node-network-protocol = { path = "../network/protocol" } polkadot-primitives = { path = "../../primitives" } polkadot-node-primitives = { path = "../primitives" } polkadot-overseer = { path = "../overseer" } -metered = { package = "prioritized-metered-channel", path = "../metered-channel" , "version" = "0.2.0" } +metered = { package = "prioritized-metered-channel", version = "0.2.0" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } -kvdb = "0.11.0" -parity-util-mem = { version = "0.11", default-features = false } +kvdb = "0.12.0" +parity-util-mem = { version = "0.12.0", default-features = false } parity-db = { version = "0.3.13" } [dev-dependencies] @@ -44,5 +44,5 @@ log = "0.4.17" polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" } lazy_static = "1.4.0" polkadot-primitives-test-helpers = { path = "../../primitives/test-helpers" } -kvdb-shared-tests = "0.9.0" +kvdb-shared-tests = "0.10.0" tempfile = "3.1.0" diff --git a/node/subsystem-util/src/database.rs b/node/subsystem-util/src/database.rs index a6b31043302f..6f338b5d6440 100644 --- a/node/subsystem-util/src/database.rs +++ b/node/subsystem-util/src/database.rs @@ -16,7 +16,7 @@ //! Database trait for polkadot db. -pub use kvdb::{DBTransaction, DBValue, KeyValueDB}; +pub use kvdb::{DBKeyValue, DBTransaction, DBValue, KeyValueDB}; /// Database trait with ordered key capacity. pub trait Database: KeyValueDB { @@ -27,7 +27,7 @@ pub trait Database: KeyValueDB { /// Implementation for database supporting `KeyValueDB` already. pub mod kvdb_impl { - use super::{DBTransaction, DBValue, Database, KeyValueDB}; + use super::{DBKeyValue, DBTransaction, DBValue, Database, KeyValueDB}; use kvdb::{DBOp, IoStats, IoStatsKind}; use parity_util_mem::{MallocSizeOf, MallocSizeOfOps}; use std::{collections::BTreeSet, io::Result}; @@ -86,7 +86,7 @@ pub mod kvdb_impl { self.db.get(col, key) } - fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option> { + fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Result> { self.ensure_is_indexed(col); self.db.get_by_prefix(col, prefix) } @@ -96,7 +96,7 @@ pub mod kvdb_impl { self.db.write(transaction) } - fn iter<'a>(&'a self, col: u32) -> Box, Box<[u8]>)> + 'a> { + fn iter<'a>(&'a self, col: u32) -> Box> + 'a> { self.ensure_is_indexed(col); self.db.iter(col) } @@ -105,15 +105,11 @@ pub mod kvdb_impl { &'a self, col: u32, prefix: &'a [u8], - ) -> Box, Box<[u8]>)> + 'a> { + ) -> Box> + 'a> { self.ensure_is_indexed(col); self.db.iter_with_prefix(col, prefix) } - fn restore(&self, _new_db: &str) -> Result<()> { - unimplemented!("restore is unsupported") - } - fn io_stats(&self, kind: IoStatsKind) -> IoStats { self.db.io_stats(kind) } @@ -122,7 +118,7 @@ pub mod kvdb_impl { self.db.has_key(col, key) } - fn has_prefix(&self, col: u32, prefix: &[u8]) -> bool { + fn has_prefix(&self, col: u32, prefix: &[u8]) -> Result { self.ensure_is_indexed(col); self.db.has_prefix(col, prefix) } @@ -138,8 +134,8 @@ pub mod kvdb_impl { /// Utilities for using parity-db database. pub mod paritydb_impl { - use super::{DBTransaction, DBValue, Database, KeyValueDB}; - use kvdb::{DBOp, IoStats, IoStatsKind}; + use super::{DBKeyValue, DBTransaction, DBValue, Database, KeyValueDB}; + use kvdb::DBOp; use parity_db::Db; use parking_lot::Mutex; use std::{collections::BTreeSet, io::Result, sync::Arc}; @@ -179,18 +175,20 @@ pub mod paritydb_impl { map_err(self.db.get(col as u8, key)) } - fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option> { - self.iter_with_prefix(col, prefix).next().map(|(_, v)| v) + fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Result> { + self.iter_with_prefix(col, prefix) + .next() + .transpose() + .map(|mb| mb.map(|(_, v)| v)) } - fn iter<'a>(&'a self, col: u32) -> Box, Box<[u8]>)> + 'a> { - let mut iter = handle_err(self.db.iter(col as u8)); + fn iter<'a>(&'a self, col: u32) -> Box> + 'a> { + let mut iter = match self.db.iter(col as u8) { + Ok(iter) => iter, + Err(e) => return Box::new(std::iter::once(map_err(Err(e)))), + }; Box::new(std::iter::from_fn(move || { - if let Some((key, value)) = handle_err(iter.next()) { - Some((key.into_boxed_slice(), value.into_boxed_slice())) - } else { - None - } + iter.next().transpose().map(|r| map_err(r.map(|(k, v)| (k.into(), v)))) })) } @@ -198,39 +196,26 @@ pub mod paritydb_impl { &'a self, col: u32, prefix: &'a [u8], - ) -> Box, Box<[u8]>)> + 'a> { + ) -> Box> + 'a> { if prefix.len() == 0 { return self.iter(col) } - let mut iter = handle_err(self.db.iter(col as u8)); - handle_err(iter.seek(prefix)); + let mut iter = match self.db.iter(col as u8) { + Ok(iter) => iter, + Err(e) => return Box::new(std::iter::once(map_err(Err(e)))), + }; + if let Err(e) = iter.seek(prefix) { + return Box::new(std::iter::once(map_err(Err(e)))) + } Box::new(std::iter::from_fn(move || { - if let Some((key, value)) = handle_err(iter.next()) { - key.starts_with(prefix) - .then(|| (key.into_boxed_slice(), value.into_boxed_slice())) - } else { - None - } + iter.next().transpose().and_then(|r| { + map_err(r.map(|(k, v)| k.starts_with(prefix).then(|| (k.into(), v)))) + .transpose() + }) })) } - fn restore(&self, _new_db: &str) -> Result<()> { - unimplemented!("restore is unsupported") - } - - fn io_stats(&self, _kind: IoStatsKind) -> IoStats { - unimplemented!("io_stats not supported by parity_db"); - } - - fn has_key(&self, col: u32, key: &[u8]) -> Result { - map_err(self.db.get_size(col as u8, key).map(|r| r.is_some())) - } - - fn has_prefix(&self, col: u32, prefix: &[u8]) -> bool { - self.get_by_prefix(col, prefix).is_some() - } - - fn write(&self, transaction: DBTransaction) -> std::io::Result<()> { + fn write(&self, transaction: DBTransaction) -> Result<()> { let mut ops = transaction.ops.into_iter(); // TODO using a key iterator or native delete here would be faster. let mut current_prefix_iter: Option<(parity_db::BTreeIterator, u8, Vec)> = None; diff --git a/node/subsystem-util/src/determine_new_blocks.rs b/node/subsystem-util/src/determine_new_blocks.rs index c2b54160cc86..aad1625798c2 100644 --- a/node/subsystem-util/src/determine_new_blocks.rs +++ b/node/subsystem-util/src/determine_new_blocks.rs @@ -124,7 +124,7 @@ where Ok(Ok(h)) => h, } }) - .for_each(|x| requests.push(x)); + .for_each(|x| requests.push_back(x)); let batch_headers: Vec<_> = requests.flat_map(|x: Option
| stream::iter(x)).collect().await; diff --git a/node/subsystem-util/src/rolling_session_window.rs b/node/subsystem-util/src/rolling_session_window.rs index dd9282b50fe5..0ff2dc6deb13 100644 --- a/node/subsystem-util/src/rolling_session_window.rs +++ b/node/subsystem-util/src/rolling_session_window.rs @@ -20,15 +20,17 @@ //! care about the state of particular blocks. pub use polkadot_node_primitives::{new_session_window_size, SessionWindowSize}; -use polkadot_primitives::v2::{Hash, SessionIndex, SessionInfo}; +use polkadot_primitives::v2::{BlockNumber, Hash, SessionIndex, SessionInfo}; use futures::channel::oneshot; use polkadot_node_subsystem::{ - errors::RuntimeApiError, - messages::{RuntimeApiMessage, RuntimeApiRequest}, + errors::{ChainApiError, RuntimeApiError}, + messages::{ChainApiMessage, RuntimeApiMessage, RuntimeApiRequest}, overseer, }; +const LOG_TARGET: &str = "parachain::rolling-session-window"; + /// Sessions unavailable in state to cache. #[derive(Debug, Clone, thiserror::Error)] pub enum SessionsUnavailableReason { @@ -38,9 +40,18 @@ pub enum SessionsUnavailableReason { /// The runtime API itself returned an error. #[error(transparent)] RuntimeApi(#[from] RuntimeApiError), + /// The chain API itself returned an error. + #[error(transparent)] + ChainApi(#[from] ChainApiError), /// Missing session info from runtime API for given `SessionIndex`. #[error("Missing session index {0:?}")] Missing(SessionIndex), + /// Missing last finalized block number. + #[error("Missing last finalized block number")] + MissingLastFinalizedBlock, + /// Missing last finalized block hash. + #[error("Missing last finalized block hash")] + MissingLastFinalizedBlockHash(BlockNumber), } /// Information about the sessions being fetched. @@ -98,11 +109,18 @@ impl RollingSessionWindow { block_hash: Hash, ) -> Result where - Sender: overseer::SubsystemSender, + Sender: overseer::SubsystemSender + + overseer::SubsystemSender, { let session_index = get_session_index_for_child(&mut sender, block_hash).await?; + let earliest_non_finalized_block_session = + Self::earliest_non_finalized_block_session(&mut sender).await?; - let window_start = session_index.saturating_sub(window_size.get() - 1); + // This will increase the session window to cover the full unfinalized chain. + let window_start = std::cmp::min( + session_index.saturating_sub(window_size.get() - 1), + earliest_non_finalized_block_session, + ); match load_all_sessions(&mut sender, block_hash, window_start, session_index).await { Err(kind) => Err(SessionsUnavailable { @@ -146,6 +164,87 @@ impl RollingSessionWindow { self.earliest_session + (self.session_info.len() as SessionIndex).saturating_sub(1) } + async fn earliest_non_finalized_block_session( + sender: &mut Sender, + ) -> Result + where + Sender: overseer::SubsystemSender + + overseer::SubsystemSender, + { + let last_finalized_height = { + let (tx, rx) = oneshot::channel(); + sender.send_message(ChainApiMessage::FinalizedBlockNumber(tx)).await; + match rx.await { + Ok(Ok(number)) => number, + Ok(Err(e)) => + return Err(SessionsUnavailable { + kind: SessionsUnavailableReason::ChainApi(e), + info: None, + }), + Err(err) => { + gum::warn!( + target: LOG_TARGET, + ?err, + "Failed fetching last finalized block number" + ); + return Err(SessionsUnavailable { + kind: SessionsUnavailableReason::MissingLastFinalizedBlock, + info: None, + }) + }, + } + }; + + let (tx, rx) = oneshot::channel(); + // We want to get the session index for the child of the last finalized block. + sender + .send_message(ChainApiMessage::FinalizedBlockHash(last_finalized_height, tx)) + .await; + let last_finalized_hash_parent = match rx.await { + Ok(Ok(maybe_hash)) => maybe_hash, + Ok(Err(e)) => + return Err(SessionsUnavailable { + kind: SessionsUnavailableReason::ChainApi(e), + info: None, + }), + Err(err) => { + gum::warn!(target: LOG_TARGET, ?err, "Failed fetching last finalized block hash"); + return Err(SessionsUnavailable { + kind: SessionsUnavailableReason::MissingLastFinalizedBlockHash( + last_finalized_height, + ), + info: None, + }) + }, + }; + + // Get the session in which the last finalized block was authored. + if let Some(last_finalized_hash_parent) = last_finalized_hash_parent { + let session = + match get_session_index_for_child(sender, last_finalized_hash_parent).await { + Ok(session_index) => session_index, + Err(err) => { + gum::warn!( + target: LOG_TARGET, + ?err, + ?last_finalized_hash_parent, + "Failed fetching session index" + ); + return Err(err) + }, + }; + + Ok(session) + } else { + return Err(SessionsUnavailable { + kind: SessionsUnavailableReason::MissingLastFinalizedBlockHash( + last_finalized_height, + ), + info: None, + }) + } + } + /// When inspecting a new import notification, updates the session info cache to match /// the session of the imported block's child. /// @@ -153,12 +252,18 @@ impl RollingSessionWindow { /// not change often and import notifications are expected to be typically increasing in session number. /// /// some backwards drift in session index is acceptable. - pub async fn cache_session_info_for_head( + pub async fn cache_session_info_for_head( &mut self, - sender: &mut impl overseer::SubsystemSender, + sender: &mut Sender, block_hash: Hash, - ) -> Result { + ) -> Result + where + Sender: overseer::SubsystemSender + + overseer::SubsystemSender, + { let session_index = get_session_index_for_child(sender, block_hash).await?; + let earliest_non_finalized_block_session = + Self::earliest_non_finalized_block_session(sender).await?; let old_window_start = self.earliest_session; @@ -171,7 +276,12 @@ impl RollingSessionWindow { let old_window_end = latest; - let window_start = session_index.saturating_sub(self.window_size.get() - 1); + // Ensure we keep sessions up to last finalized block by adjusting the window start. + // This will increase the session window to cover the full unfinalized chain. + let window_start = std::cmp::min( + session_index.saturating_sub(self.window_size.get() - 1), + earliest_non_finalized_block_session, + ); // keep some of the old window, if applicable. let overlap_start = window_start.saturating_sub(old_window_start); @@ -319,6 +429,14 @@ mod tests { parent_hash: Default::default(), }; + let finalized_header = Header { + digest: Default::default(), + extrinsics_root: Default::default(), + number: 0, + state_root: Default::default(), + parent_hash: Default::default(), + }; + let pool = TaskExecutor::new(); let (mut ctx, mut handle) = make_subsystem_context::(pool.clone()); @@ -358,6 +476,37 @@ mod tests { } ); + assert_matches!( + handle.recv().await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber( + s_tx, + )) => { + let _ = s_tx.send(Ok(finalized_header.number)); + } + ); + + assert_matches!( + handle.recv().await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash( + block_number, + s_tx, + )) => { + assert_eq!(block_number, finalized_header.number); + let _ = s_tx.send(Ok(Some(finalized_header.hash()))); + } + ); + + assert_matches!( + handle.recv().await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + h, + RuntimeApiRequest::SessionIndexForChild(s_tx), + )) => { + assert_eq!(h, finalized_header.hash()); + let _ = s_tx.send(Ok(session)); + } + ); + for i in expect_requests_from..=session { assert_matches!( handle.recv().await, @@ -485,6 +634,108 @@ mod tests { cache_session_info_test(0, 3, Some(window), 2); } + #[test] + fn any_session_stretch_for_unfinalized_chain() { + // Session index of the tip of our fake test chain. + let session: SessionIndex = 100; + let genesis_session: SessionIndex = 0; + + let header = Header { + digest: Default::default(), + extrinsics_root: Default::default(), + number: 5, + state_root: Default::default(), + parent_hash: Default::default(), + }; + + let finalized_header = Header { + digest: Default::default(), + extrinsics_root: Default::default(), + number: 0, + state_root: Default::default(), + parent_hash: Default::default(), + }; + + let pool = TaskExecutor::new(); + let (mut ctx, mut handle) = make_subsystem_context::<(), _>(pool.clone()); + + let hash = header.hash(); + + let test_fut = { + let sender = ctx.sender().clone(); + Box::pin(async move { + let res = RollingSessionWindow::new(sender, TEST_WINDOW_SIZE, hash).await; + assert!(res.is_err()); + }) + }; + + let aux_fut = Box::pin(async move { + assert_matches!( + handle.recv().await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + h, + RuntimeApiRequest::SessionIndexForChild(s_tx), + )) => { + assert_eq!(h, hash); + let _ = s_tx.send(Ok(session)); + } + ); + + assert_matches!( + handle.recv().await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber( + s_tx, + )) => { + let _ = s_tx.send(Ok(finalized_header.number)); + } + ); + + assert_matches!( + handle.recv().await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash( + block_number, + s_tx, + )) => { + assert_eq!(block_number, finalized_header.number); + let _ = s_tx.send(Ok(Some(finalized_header.hash()))); + } + ); + + assert_matches!( + handle.recv().await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + h, + RuntimeApiRequest::SessionIndexForChild(s_tx), + )) => { + assert_eq!(h, finalized_header.hash()); + let _ = s_tx.send(Ok(0)); + } + ); + + // Unfinalized chain starts at geneisis block, so session 0 is how far we stretch. + for i in genesis_session..=session { + assert_matches!( + handle.recv().await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + h, + RuntimeApiRequest::SessionInfo(j, s_tx), + )) => { + assert_eq!(h, hash); + assert_eq!(i, j); + + let _ = s_tx.send(Ok(if i == session { + None + } else { + Some(dummy_session_info(i)) + })); + } + ); + } + }); + + futures::executor::block_on(futures::future::join(test_fut, aux_fut)); + } + #[test] fn any_session_unavailable_for_caching_means_no_change() { let session: SessionIndex = 6; @@ -498,6 +749,14 @@ mod tests { parent_hash: Default::default(), }; + let finalized_header = Header { + digest: Default::default(), + extrinsics_root: Default::default(), + number: 0, + state_root: Default::default(), + parent_hash: Default::default(), + }; + let pool = TaskExecutor::new(); let (mut ctx, mut handle) = make_subsystem_context::<(), _>(pool.clone()); @@ -523,6 +782,37 @@ mod tests { } ); + assert_matches!( + handle.recv().await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber( + s_tx, + )) => { + let _ = s_tx.send(Ok(finalized_header.number)); + } + ); + + assert_matches!( + handle.recv().await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash( + block_number, + s_tx, + )) => { + assert_eq!(block_number, finalized_header.number); + let _ = s_tx.send(Ok(Some(finalized_header.hash()))); + } + ); + + assert_matches!( + handle.recv().await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + h, + RuntimeApiRequest::SessionIndexForChild(s_tx), + )) => { + assert_eq!(h, finalized_header.hash()); + let _ = s_tx.send(Ok(session)); + } + ); + for i in start_session..=session { assert_matches!( handle.recv().await, @@ -586,6 +876,37 @@ mod tests { } ); + assert_matches!( + handle.recv().await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockNumber( + s_tx, + )) => { + let _ = s_tx.send(Ok(header.number)); + } + ); + + assert_matches!( + handle.recv().await, + AllMessages::ChainApi(ChainApiMessage::FinalizedBlockHash( + block_number, + s_tx, + )) => { + assert_eq!(block_number, header.number); + let _ = s_tx.send(Ok(Some(header.hash()))); + } + ); + + assert_matches!( + handle.recv().await, + AllMessages::RuntimeApi(RuntimeApiMessage::Request( + h, + RuntimeApiRequest::SessionIndexForChild(s_tx), + )) => { + assert_eq!(h, header.hash()); + let _ = s_tx.send(Ok(session)); + } + ); + assert_matches!( handle.recv().await, AllMessages::RuntimeApi(RuntimeApiMessage::Request( diff --git a/node/subsystem-util/src/runtime/mod.rs b/node/subsystem-util/src/runtime/mod.rs index fc660a9dc6df..7fcae2c57b09 100644 --- a/node/subsystem-util/src/runtime/mod.rs +++ b/node/subsystem-util/src/runtime/mod.rs @@ -16,7 +16,7 @@ //! Convenient interface to runtime information. -use std::cmp::max; +use std::num::NonZeroUsize; use lru::LruCache; @@ -52,7 +52,7 @@ pub struct Config { pub keystore: Option, /// How many sessions should we keep in the cache? - pub session_cache_lru_size: usize, + pub session_cache_lru_size: NonZeroUsize, } /// Caching of session info. @@ -95,7 +95,7 @@ impl Default for Config { Self { keystore: None, // Usually we need to cache the current and the last session. - session_cache_lru_size: 2, + session_cache_lru_size: NonZeroUsize::new(2).expect("2 is larger than 0; qed"), } } } @@ -109,7 +109,10 @@ impl RuntimeInfo { /// Create with more elaborate configuration options. pub fn new_with_config(cfg: Config) -> Self { Self { - session_index_cache: LruCache::new(max(10, cfg.session_cache_lru_size)), + session_index_cache: LruCache::new( + cfg.session_cache_lru_size + .max(NonZeroUsize::new(10).expect("10 is larger than 0; qed")), + ), session_info_cache: LruCache::new(cfg.session_cache_lru_size), keystore: cfg.keystore, } diff --git a/node/subsystem/Cargo.toml b/node/subsystem/Cargo.toml index 84a99bbda21b..1d783f748b45 100644 --- a/node/subsystem/Cargo.toml +++ b/node/subsystem/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-node-subsystem" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" description = "Subsystem traits and message definitions and the generated overseer" diff --git a/node/test/client/Cargo.toml b/node/test/client/Cargo.toml index 746b39d97b7c..91ba27476c04 100644 --- a/node/test/client/Cargo.toml +++ b/node/test/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-test-client" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -14,20 +14,20 @@ polkadot-primitives = { path = "../../../primitives" } polkadot-node-subsystem = { path = "../../subsystem" } # Substrate dependencies -substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [dev-dependencies] -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures = "0.3.21" diff --git a/node/test/performance-test/Cargo.toml b/node/test/performance-test/Cargo.toml index e42fe946caf5..55d74ad62f1d 100644 --- a/node/test/performance-test/Cargo.toml +++ b/node/test/performance-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-performance-test" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -19,3 +19,6 @@ kusama-runtime = { path = "../../../runtime/kusama" } [[bin]] name = "gen-ref-constants" path = "src/gen_ref_constants.rs" + +[features] +runtime-benchmarks = ["kusama-runtime/runtime-benchmarks"] diff --git a/node/test/service/Cargo.toml b/node/test/service/Cargo.toml index f4196da2aad3..a85a7db081ab 100644 --- a/node/test/service/Cargo.toml +++ b/node/test/service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-test-service" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -26,41 +26,41 @@ test-runtime-constants = { path = "../../../runtime/test-runtime/constants" } polkadot-runtime-parachains = { path = "../../../runtime/parachains" } # Substrate dependencies -sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -babe = { package = "sc-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -consensus_common = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -grandpa_primitives = { package = "sp-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-service = { git = "https://github.com/paritytech/substrate", default-features = false, features = [ "wasmtime" ] , branch = "polkadot-v0.9.28" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +babe = { package = "sc-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +consensus_common = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +grandpa_primitives = { package = "sp-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-service = { git = "https://github.com/paritytech/substrate", default-features = false, features = [ "wasmtime" ] , branch = "polkadot-v0.9.31" } +sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +substrate-test-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [dev-dependencies] -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } serde_json = "1.0.81" -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } tokio = { version = "1.19.2", features = ["macros"] } [features] diff --git a/node/test/service/src/lib.rs b/node/test/service/src/lib.rs index 6e7e4d0e0b87..8fe31ce2b5b4 100644 --- a/node/test/service/src/lib.rs +++ b/node/test/service/src/lib.rs @@ -37,11 +37,8 @@ use polkadot_test_runtime::{ }; use sc_chain_spec::ChainSpec; use sc_client_api::execution_extensions::ExecutionStrategies; -use sc_network::{ - config::{NetworkConfiguration, TransportConfig}, - multiaddr, -}; -use sc_network_common::service::NetworkStateInfo; +use sc_network::{config::NetworkConfiguration, multiaddr}; +use sc_network_common::{config::TransportConfig, service::NetworkStateInfo}; use sc_service::{ config::{ DatabaseSource, KeystoreConfig, MultiaddrWithPeerId, WasmExecutionMethod, @@ -139,7 +136,7 @@ pub fn node_config( is_validator: bool, ) -> Configuration { let base_path = BasePath::new_temp_dir().expect("could not create temporary directory"); - let root = base_path.path(); + let root = base_path.path().join(key.to_string()); let role = if is_validator { Role::Authority } else { Role::Full }; let key_seed = key.to_seed(); let mut spec = polkadot_local_testnet_config(); @@ -176,10 +173,9 @@ pub fn node_config( keystore: KeystoreConfig::InMemory, keystore_remote: Default::default(), database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 }, - state_cache_size: 16777216, - state_cache_child_ratio: None, + trie_cache_maximum_size: Some(64 * 1024 * 1024), state_pruning: Default::default(), - blocks_pruning: BlocksPruning::All, + blocks_pruning: BlocksPruning::KeepFinalized, chain_spec: Box::new(spec), wasm_method: WasmExecutionMethod::Compiled { instantiation_strategy: WasmtimeInstantiationStrategy::PoolingCopyOnWrite, @@ -289,7 +285,7 @@ impl PolkadotTestNode { /// Send an extrinsic to this node. pub async fn send_extrinsic( &self, - function: impl Into, + function: impl Into, caller: Sr25519Keyring, ) -> Result { let extrinsic = construct_extrinsic(&*self.client, function, caller, 0); @@ -346,7 +342,7 @@ impl PolkadotTestNode { /// Construct an extrinsic that can be applied to the test runtime. pub fn construct_extrinsic( client: &Client, - function: impl Into, + function: impl Into, caller: Sr25519Keyring, nonce: u32, ) -> UncheckedExtrinsic { @@ -397,7 +393,7 @@ pub fn construct_transfer_extrinsic( dest: sp_keyring::AccountKeyring, value: Balance, ) -> UncheckedExtrinsic { - let function = polkadot_test_runtime::Call::Balances(pallet_balances::Call::transfer { + let function = polkadot_test_runtime::RuntimeCall::Balances(pallet_balances::Call::transfer { dest: MultiSigner::from(dest.public()).into_account().into(), value, }); diff --git a/node/test/service/tests/call-function.rs b/node/test/service/tests/call-function.rs index 5c149766c6fb..8678a0a08a2b 100644 --- a/node/test/service/tests/call-function.rs +++ b/node/test/service/tests/call-function.rs @@ -24,7 +24,7 @@ async fn call_function_actually_work() { let alice = run_validator_node(alice_config, None); - let function = polkadot_test_runtime::Call::Balances(pallet_balances::Call::transfer { + let function = polkadot_test_runtime::RuntimeCall::Balances(pallet_balances::Call::transfer { dest: Charlie.to_account_id().into(), value: 1, }); diff --git a/node/zombienet-backchannel/Cargo.toml b/node/zombienet-backchannel/Cargo.toml index 1b6d177a59ed..74cd56ec521a 100644 --- a/node/zombienet-backchannel/Cargo.toml +++ b/node/zombienet-backchannel/Cargo.toml @@ -2,7 +2,7 @@ name = "zombienet-backchannel" description = "Zombienet backchannel to notify test runner and coordinate with malus actors." license = "GPL-3.0-only" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" readme = "README.md" @@ -12,7 +12,7 @@ publish = false tokio = { version = "1.19.2", default-features = false, features = ["macros", "net", "rt-multi-thread", "sync"] } url = "2.0.0" tokio-tungstenite = "0.17" -futures-util = "0.3.21" +futures-util = "0.3.23" lazy_static = "1.4.0" parity-scale-codec = { version = "3.1.5", features = ["derive"] } reqwest = "0.11" diff --git a/parachain/Cargo.toml b/parachain/Cargo.toml index 3c20156f1003..f146ee8a778d 100644 --- a/parachain/Cargo.toml +++ b/parachain/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-parachain" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Types and utilities for creating and working with parachains" edition = "2021" @@ -10,12 +10,12 @@ edition = "2021" # this crate for WASM. This is critical to avoid forcing all parachain WASM into implementing # various unnecessary Substrate-specific endpoints. parity-scale-codec = { version = "3.1.5", default-features = false, features = [ "derive" ] } -parity-util-mem = { version = "0.11.0", default-features = false, optional = true } +parity-util-mem = { version = "0.12.0", default-features = false, optional = true } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } polkadot-core-primitives = { path = "../core-primitives", default-features = false } derive_more = "0.99.11" diff --git a/parachain/src/primitives.rs b/parachain/src/primitives.rs index e5baaba2430e..2c18b178271f 100644 --- a/parachain/src/primitives.rs +++ b/parachain/src/primitives.rs @@ -316,7 +316,7 @@ impl DmpMessageHandler for () { _max_weight: Weight, ) -> Weight { iter.for_each(drop); - 0 + Weight::zero() } } @@ -349,7 +349,7 @@ impl XcmpMessageHandler for () { _max_weight: Weight, ) -> Weight { for _ in iter {} - 0 + Weight::zero() } } diff --git a/parachain/test-parachains/Cargo.toml b/parachain/test-parachains/Cargo.toml index acc10d93551d..ae418661e313 100644 --- a/parachain/test-parachains/Cargo.toml +++ b/parachain/test-parachains/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-parachains" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Integration tests using the test-parachains" edition = "2021" @@ -13,7 +13,7 @@ adder = { package = "test-parachain-adder", path = "adder" } halt = { package = "test-parachain-halt", path = "halt" } [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] default = ["std"] diff --git a/parachain/test-parachains/adder/Cargo.toml b/parachain/test-parachains/adder/Cargo.toml index 07519aefd84b..b376fc021c8a 100644 --- a/parachain/test-parachains/adder/Cargo.toml +++ b/parachain/test-parachains/adder/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-parachain-adder" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Test parachain which adds to a number as its state transition" edition = "2021" @@ -9,15 +9,15 @@ build = "build.rs" [dependencies] parachain = { package = "polkadot-parachain", path = "../../", default-features = false, features = [ "wasm-api" ] } parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } tiny-keccak = { version = "2.0.2", features = ["keccak"] } -dlmalloc = { version = "0.2.3", features = [ "global" ] } +dlmalloc = { version = "0.2.4", features = [ "global" ] } # We need to make sure the global allocator is disabled until we have support of full substrate externalities -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, features = [ "disable_allocator" ] , branch = "polkadot-v0.9.28" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, features = [ "disable_allocator" ] , branch = "polkadot-v0.9.31" } [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] default = [ "std" ] diff --git a/parachain/test-parachains/adder/collator/Cargo.toml b/parachain/test-parachains/adder/collator/Cargo.toml index 94a295bcc35e..c1b2335374bf 100644 --- a/parachain/test-parachains/adder/collator/Cargo.toml +++ b/parachain/test-parachains/adder/collator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-parachain-adder-collator" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Collator for the adder test parachain" edition = "2021" @@ -15,7 +15,7 @@ path = "bin/puppet_worker.rs" [dependencies] parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } -clap = { version = "3.1", features = ["derive"] } +clap = { version = "4.0.9", features = ["derive"] } futures = "0.3.21" futures-timer = "3.0.2" log = "0.4.17" @@ -27,9 +27,9 @@ polkadot-service = { path = "../../../../node/service", features = ["rococo-nati polkadot-node-primitives = { path = "../../../../node/primitives" } polkadot-node-subsystem = { path = "../../../../node/subsystem" } -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } # This one is tricky. Even though it is not used directly by the collator, we still need it for the # `puppet_worker` binary, which is required for the integration test. However, this shouldn't be @@ -40,8 +40,8 @@ polkadot-node-core-pvf = { path = "../../../../node/core/pvf" } polkadot-parachain = { path = "../../.." } polkadot-test-service = { path = "../../../../node/test/service" } -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } tokio = { version = "1.19.2", features = ["macros"] } diff --git a/parachain/test-parachains/adder/collator/src/cli.rs b/parachain/test-parachains/adder/collator/src/cli.rs index 8e55a7821f3d..a71837c4663a 100644 --- a/parachain/test-parachains/adder/collator/src/cli.rs +++ b/parachain/test-parachains/adder/collator/src/cli.rs @@ -23,11 +23,11 @@ use sc_cli::{RuntimeVersion, SubstrateCli}; #[derive(Debug, Parser)] pub enum Subcommand { /// Export the genesis state of the parachain. - #[clap(name = "export-genesis-state")] + #[command(name = "export-genesis-state")] ExportGenesisState(ExportGenesisStateCommand), /// Export the genesis wasm of the parachain. - #[clap(name = "export-genesis-wasm")] + #[command(name = "export-genesis-wasm")] ExportGenesisWasm(ExportGenesisWasmCommand), } @@ -41,20 +41,21 @@ pub struct ExportGenesisWasmCommand {} #[allow(missing_docs)] #[derive(Debug, Parser)] +#[group(skip)] pub struct RunCmd { #[allow(missing_docs)] #[clap(flatten)] pub base: sc_cli::RunCmd, /// Id of the parachain this collator collates for. - #[clap(long)] + #[arg(long)] pub parachain_id: Option, } #[allow(missing_docs)] #[derive(Debug, Parser)] pub struct Cli { - #[clap(subcommand)] + #[command(subcommand)] pub subcommand: Option, #[clap(flatten)] diff --git a/parachain/test-parachains/halt/Cargo.toml b/parachain/test-parachains/halt/Cargo.toml index bb1f3d61be67..262c6436f1b5 100644 --- a/parachain/test-parachains/halt/Cargo.toml +++ b/parachain/test-parachains/halt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-parachain-halt" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Test parachain which executes forever" edition = "2021" @@ -9,7 +9,7 @@ build = "build.rs" [dependencies] [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] default = [ "std" ] diff --git a/parachain/test-parachains/undying/Cargo.toml b/parachain/test-parachains/undying/Cargo.toml index 2add33c559b0..6eb7d19aae11 100644 --- a/parachain/test-parachains/undying/Cargo.toml +++ b/parachain/test-parachains/undying/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-parachain-undying" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Test parachain for zombienet integration tests" edition = "2021" @@ -9,16 +9,16 @@ build = "build.rs" [dependencies] parachain = { package = "polkadot-parachain", path = "../../", default-features = false, features = [ "wasm-api" ] } parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } tiny-keccak = { version = "2.0.2", features = ["keccak"] } -dlmalloc = { version = "0.2.3", features = [ "global" ] } +dlmalloc = { version = "0.2.4", features = [ "global" ] } log = { version = "0.4.17", default-features = false } # We need to make sure the global allocator is disabled until we have support of full substrate externalities -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, features = [ "disable_allocator" ] , branch = "polkadot-v0.9.28" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, features = [ "disable_allocator" ] , branch = "polkadot-v0.9.31" } [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] default = [ "std" ] diff --git a/parachain/test-parachains/undying/collator/Cargo.toml b/parachain/test-parachains/undying/collator/Cargo.toml index 9e677a2e3e1a..638548050768 100644 --- a/parachain/test-parachains/undying/collator/Cargo.toml +++ b/parachain/test-parachains/undying/collator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-parachain-undying-collator" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Collator for the undying test parachain" edition = "2021" @@ -15,7 +15,7 @@ path = "bin/puppet_worker.rs" [dependencies] parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } -clap = { version = "3.1", features = ["derive"] } +clap = { version = "4.0.9", features = ["derive"] } futures = "0.3.19" futures-timer = "3.0.2" log = "0.4.17" @@ -27,9 +27,9 @@ polkadot-service = { path = "../../../../node/service", features = ["rococo-nati polkadot-node-primitives = { path = "../../../../node/primitives" } polkadot-node-subsystem = { path = "../../../../node/subsystem" } -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } # This one is tricky. Even though it is not used directly by the collator, we still need it for the # `puppet_worker` binary, which is required for the integration test. However, this shouldn't be @@ -40,8 +40,8 @@ polkadot-node-core-pvf = { path = "../../../../node/core/pvf" } polkadot-parachain = { path = "../../.." } polkadot-test-service = { path = "../../../../node/test/service" } -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } tokio = { version = "1.19", features = ["macros"] } diff --git a/parachain/test-parachains/undying/collator/src/cli.rs b/parachain/test-parachains/undying/collator/src/cli.rs index 4f1ff06e7472..703a0bfd46f6 100644 --- a/parachain/test-parachains/undying/collator/src/cli.rs +++ b/parachain/test-parachains/undying/collator/src/cli.rs @@ -23,11 +23,11 @@ use sc_cli::{RuntimeVersion, SubstrateCli}; #[derive(Debug, Parser)] pub enum Subcommand { /// Export the genesis state of the parachain. - #[clap(name = "export-genesis-state")] + #[command(name = "export-genesis-state")] ExportGenesisState(ExportGenesisStateCommand), /// Export the genesis wasm of the parachain. - #[clap(name = "export-genesis-wasm")] + #[command(name = "export-genesis-wasm")] ExportGenesisWasm(ExportGenesisWasmCommand), } @@ -35,16 +35,16 @@ pub enum Subcommand { #[derive(Debug, Parser)] pub struct ExportGenesisStateCommand { /// Id of the parachain this collator collates for. - #[clap(long, default_value = "100")] + #[arg(long, default_value_t = 100)] pub parachain_id: u32, /// The target raw PoV size in bytes. Minimum value is 64. - #[clap(long, default_value = "1024")] + #[arg(long, default_value_t = 1024)] pub pov_size: usize, /// The PVF execution complexity. Actually specifies how many iterations/signatures /// we compute per block. - #[clap(long, default_value = "1")] + #[arg(long, default_value_t = 1)] pub pvf_complexity: u32, } @@ -54,29 +54,30 @@ pub struct ExportGenesisWasmCommand {} #[allow(missing_docs)] #[derive(Debug, Parser)] +#[group(skip)] pub struct RunCmd { #[allow(missing_docs)] #[clap(flatten)] pub base: sc_cli::RunCmd, /// Id of the parachain this collator collates for. - #[clap(long, default_value = "2000")] + #[arg(long, default_value_t = 2000)] pub parachain_id: u32, /// The target raw PoV size in bytes. Minimum value is 64. - #[clap(long, default_value = "1024")] + #[arg(long, default_value_t = 1024)] pub pov_size: usize, /// The PVF execution complexity. Actually specifies how many iterations/signatures /// we compute per block. - #[clap(long, default_value = "1")] + #[arg(long, default_value_t = 1)] pub pvf_complexity: u32, } #[allow(missing_docs)] #[derive(Debug, Parser)] pub struct Cli { - #[clap(subcommand)] + #[command(subcommand)] pub subcommand: Option, #[clap(flatten)] diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index 97b684b1e8d4..6458e18cea2b 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-primitives" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -8,26 +8,26 @@ edition = "2021" serde = { version = "1.0.137", optional = true, features = ["derive"] } scale-info = { version = "2.1.2", default-features = false, features = ["bit-vec", "derive"] } parity-scale-codec = { version = "3.1.5", default-features = false, features = ["bit-vec", "derive"] } -primitives = { package = "sp-core", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -application-crypto = { package = "sp-application-crypto", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-consensus-slots = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -runtime_primitives = { package = "sp-runtime", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +primitives = { package = "sp-core", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +application-crypto = { package = "sp-application-crypto", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-consensus-slots = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.31" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +runtime_primitives = { package = "sp-runtime", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } polkadot-parachain = { path = "../parachain", default-features = false } polkadot-core-primitives = { path = "../core-primitives", default-features = false } -trie = { package = "sp-trie", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +trie = { package = "sp-trie", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } hex-literal = "0.3.4" -parity-util-mem = { version = "0.11.0", default-features = false, optional = true } +parity-util-mem = { version = "0.12.0", default-features = false, optional = true } [features] default = ["std"] diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 121f7cb40d23..168b5795b040 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -22,9 +22,9 @@ // `v2` is currently the latest stable version of the runtime API. pub mod v2; -// The 'staging' version is special - while other versions are set in stone, -// the staging version is malleable. Once it's released, it gets the next -// version number. +// The 'staging' version is special - it contains primitives which are +// still in development. Once they are considered stable, they will be +// moved to a new versioned module. pub mod vstaging; // `runtime_api` contains the actual API implementation. It contains stable and diff --git a/primitives/src/runtime_api.rs b/primitives/src/runtime_api.rs index 84d2cf0ec4ca..2f6793d22032 100644 --- a/primitives/src/runtime_api.rs +++ b/primitives/src/runtime_api.rs @@ -18,31 +18,97 @@ //! of the Runtime API exposed from the Runtime to the Host. //! //! The functions in trait ParachainHost` can be part of the stable API -//! (which is versioned) or they can be staging (aka unstable functions). +//! (which is versioned) or they can be staging (aka unstable/testing +//! functions). //! -//! All stable API functions should use primitives from the latest version. -//! In the time of writing of this document - this is v2. So for example: -//! ```ignore -//! fn validators() -> Vec; -//! ``` -//! indicates a function from the stable v2 API. +//! The separation outlined above is achieved with the versioned API feature +//! of `decl_runtime_apis!` and `impl_runtime_apis!`. Before moving on let's +//! see a quick example about how API versioning works. //! -//! On the other hand a staging function's name should be prefixed with -//! `staging_` like this: -//! ```ignore -//! fn staging_get_disputes() -> Vec<(vstaging::SessionIndex, vstaging::CandidateHash, vstaging::DisputeState)>; -//! ``` +//! # Runtime API versioning crash course //! -//! How a staging function becomes stable? +//! The versioning is achieved with the `api_version` attribute. It can be +//! placed on: +//! * trait declaration - represents the base version of the API. +//! * method declaration (inside a trait declaration) - represents a versioned +//! method, which is not available in the base version. +//! * trait implementation - represents which version of the API is being +//! implemented. //! -//! Once a staging function is ready to be versioned the `renamed` macro -//! should be used to rename it and version it. For the example above: -//! ```ignore -//! #[renamed("staging_get_session_disputes", 3)] -//! fn get_session_disputes() -> Vec<(v3::SessionIndex, v3::CandidateHash, v3::DisputeState)>; +//! Let's see a quick example: +//! +//! ```rust(ignore) +//! sp_api::decl_runtime_apis! { +//! #[api_version(2)] +//! pub trait MyApi { +//! fn fn1(); +//! fn fn2(); +//! #[api_version(3)] +//! fn fn3(); +//! #[api_version(4)] +//! fn fn4(); +//! } +//! } +//! +//! struct Runtime {} +//! +//! sp_api::impl_runtime_apis! { +//! #[api_version(3)] +//! impl self::MyApi for Runtime { +//! fn fn1() {} +//! fn fn2() {} +//! fn fn3() {} +//! } +//! } //! ``` +//! A new API named `MyApi` is declared with `decl_runtime_apis!`. The trait declaration +//! has got an `api_version` attribute which represents its base version - 2 in this case. +//! +//! The API has got three methods - `fn1`, `fn2`, `fn3` and `fn4`. `fn3` and `fn4` has got +//! an `api_version` attribute which makes them versioned methods. These methods do not exist +//! in the base version of the API. Behind the scenes the declaration above creates three +//! runtime APIs: +//! * `MyApiV2` with `fn1` and `fn2` +//! * `MyApiV3` with `fn1`, `fn2` and `fn3`. +//! * `MyApiV4` with `fn1`, `fn2`, `fn3` and `fn4`. +//! +//! Please note that `v4` contains all methods from `v3`, `v3` all methods from `v2` and so on. +//! +//! Back to our example. At the end runtime API is implemented for `struct Runtime` with +//! `impl_runtime_apis` macro. `api_version` attribute is attached to the `impl` block which +//! means that a version different from the base one is being implemented - in our case this +//! is `v3`. +//! +//! This version of the API contains three methods so the `impl` block has got definitions +//! for them. Note that `fn4` is not implemented as it is not part of this version of the API. +//! `impl_runtime_apis` generates a default implementation for it calling `unimplemented!()`. +//! +//! Hopefully this should be all you need to know in order to use versioned methods in the node. //! For more details about how the API versioning works refer to `spi_api` //! documentation [here](https://docs.substrate.io/rustdocs/latest/sp_api/macro.decl_runtime_apis.html). +//! +//! # How versioned methods are used for `ParachainHost` +//! +//! Let's introduce two types of `ParachainHost` API implementation: +//! * stable - used on stable production networks like Polkadot and Kusama. There is only one +//! stable API at a single point in time. +//! * staging - used on test networks like Westend or Rococo. Depending on the development needs +//! there can be zero, one or multiple staging APIs. +//! +//! The stable version of `ParachainHost` is indicated by the base version of the API. Any staging +//! method must use `api_version` attribute so that it is assigned to a specific version of a +//! staging API. This way in a single declaration one can see what's the stable version of +//! `ParachainHost` and what staging versions/functions are available. +//! +//! All stable API functions should use primitives from the latest version. +//! In the time of writing of this document - this is `v2`. So for example: +//! ```ignore +//! fn validators() -> Vec; +//! ``` +//! indicates a function from the stable `v2` API. +//! +//! All staging API functions should use primitives from `vstaging`. They should be clearly separated +//! from the stable primitives. use crate::v2; use parity_scale_codec::{Decode, Encode}; @@ -153,7 +219,7 @@ sp_api::decl_runtime_apis! { /***** STAGING *****/ /// Returns all onchain disputes. - /// This is a staging method! Do not use on production runtimes! - fn staging_get_disputes() -> Vec<(v2::SessionIndex, v2::CandidateHash, v2::DisputeState)>; + #[api_version(3)] + fn disputes() -> Vec<(v2::SessionIndex, v2::CandidateHash, v2::DisputeState)>; } } diff --git a/primitives/src/vstaging/mod.rs b/primitives/src/vstaging/mod.rs index 2f29ffbe60b7..64671bd48a60 100644 --- a/primitives/src/vstaging/mod.rs +++ b/primitives/src/vstaging/mod.rs @@ -16,4 +16,4 @@ //! Staging Primitives. -// Put any primitives used by staging API functions here +// Put any primitives used by staging APIs functions here diff --git a/primitives/test-helpers/Cargo.toml b/primitives/test-helpers/Cargo.toml index 18c7c8ebcd60..a07b66f41ab6 100644 --- a/primitives/test-helpers/Cargo.toml +++ b/primitives/test-helpers/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "polkadot-primitives-test-helpers" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-application-crypto = { package = "sp-application-crypto", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-application-crypto = { package = "sp-application-crypto", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", features = ["std"] , branch = "polkadot-v0.9.31" } polkadot-primitives = { path = "../" } rand = "0.8.5" diff --git a/primitives/test-helpers/src/lib.rs b/primitives/test-helpers/src/lib.rs index 02ba009b13cc..8873d69cdb2f 100644 --- a/primitives/test-helpers/src/lib.rs +++ b/primitives/test-helpers/src/lib.rs @@ -255,3 +255,7 @@ impl rand::RngCore for AlwaysZeroRng { Ok(()) } } + +pub fn dummy_signature() -> polkadot_primitives::v2::ValidatorSignature { + sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]) +} diff --git a/roadmap/implementers-guide/src/disputes-flow.md b/roadmap/implementers-guide/src/disputes-flow.md index 322af8e9256e..053bcfd3f2a4 100644 --- a/roadmap/implementers-guide/src/disputes-flow.md +++ b/roadmap/implementers-guide/src/disputes-flow.md @@ -96,7 +96,7 @@ Votes must be queryable by a particular validator, identified by its signing key Votes must be queryable by a particular validator, identified by a session index and the validator index valid in that session. -If there exists a negative and a positive fork for a particular block, a dispute is detected. +If there exists a negative and a positive vote for a particular block, a dispute is detected. If a dispute is detected, all currently available votes for that block must be gossiped. diff --git a/roadmap/implementers-guide/src/node/disputes/dispute-coordinator.md b/roadmap/implementers-guide/src/node/disputes/dispute-coordinator.md index b35fc0df2ca1..29a3c5ffa082 100644 --- a/roadmap/implementers-guide/src/node/disputes/dispute-coordinator.md +++ b/roadmap/implementers-guide/src/node/disputes/dispute-coordinator.md @@ -1,7 +1,7 @@ # Dispute Coordinator The coordinator is the central subsystem of the node-side components which -participate in disputes. It wraps a database, which used to track statements +participate in disputes. It wraps a database, which is used to track statements observed by _all_ validators over some window of sessions. Votes older than this session window are pruned. @@ -318,12 +318,12 @@ at some stage in the pipeline). To ensure to only spend significant work on genuine disputes, we only trigger participation at all on any _vote import_ if any of the following holds true: -- We saw the disputed candidate included on at least one fork of the chain -- We have "our" availability chunk available for that candidate as this suggests - that either availability was at least run, although it might not have - succeeded or we have been a backing node of the candidate. In both cases the - candidate is at least not completely made up and there has been some effort - already flown into that candidate. +- We saw the disputed candidate included in some not yet finalized block on at + least one fork of the chain. +- We have seen the disputed candidate backed in some not yet finalized block on + at least one fork of the chain. This ensures the candidate is at least not + completely made up and there has been some effort already flown into that + candidate. - The dispute is already confirmed: Meaning that 1/3+1 nodes already participated, as this suggests in our threat model that there was at least one honest node that already voted, so the dispute must be genuine. @@ -332,7 +332,7 @@ Note: A node might be out of sync with the chain and we might only learn about a block including a candidate, after we learned about the dispute. This means, we have to re-evaluate participation decisions on block import! -With this nodes won't waste significant resources on completely made up +With this, nodes won't waste significant resources on completely made up candidates. The next step is to process dispute participation in a (globally) ordered fashion. Meaning a majority of validators should arrive at at least roughly at the same ordering of participation, for disputes to get resolved one @@ -380,13 +380,102 @@ candidates for approval votes a similar argument holds (if they come from approval-voting), but we also don't import them until a dispute already concluded. For actual dispute votes, we need two opposing votes, so there must be an explicit `invalid` vote in the import. Only a third of the validators can be -malicious, so spam disk usage is limited to ```2*vote_size*n/3*NUM_SPAM_SLOTS```, with -n being the number of validators. -- -More reasoning behind spam considerations can be found on -this sr-lab ticket: https://github.com/paritytech/srlabs_findings/issues/179 - -## Disputes for Non Included Candidates +malicious, so spam disk usage is limited to `2*vote_size*n/3*NUM_SPAM_SLOTS`, with +`n` being the number of validators. + +## Attacks & Considerations + +The following attacks on the priority queue and best-effort queues are +considered in above design. + +### Priority Queue + +On the priority queue, we will only queue participations for candidates we have +seen included on any chain. Any attack attempt would start with a candidate +included on some chain, but an attacker could try to only reveal the including +relay chain blocks to just some honest validators and stop as soon as it learns +that some honest validator would have a relevant approval assignment. + +Without revealing the including block to any honest validator, we don't really +have an attack yet. Once the block is revealed though, the above is actually +very hard. Each honest validator will re-distribute the block it just learned +about. This means an attacker would need to pull of a targeted DoS attack, which +allows the validator to send its assignment, but prevents it from forwarding and +sharing the relay chain block. + +This sounds already hard enough, provided that we also start participation if +we learned about an including block after the dispute has been raised already +(we need to update participation queues on new leaves), but to be even safer +we choose to have an additional best-effort queue. + +### Best-Effort Queue + +While attacking the priority queue is already pretty hard, attacking the +best-effort queue is even harder. For a candidate to be a threat, it has to be +included on some chain. For it to be included, it has to have been backed before +and at least n/3 honest nodes must have seen that block, so availability +(inclusion) can be reached. Making a full third of the nodes not further +propagate a block, while at the same time allowing them to fetch chunks, sign +and distribute bitfields seems almost infeasible and even if accomplished, those +nodes would be enough to confirm a dispute and we have not even touched the +above fact that in addition, for an attack, the following including block must +be shared with honest validators as well. + +It is worth mentioning that a successful attack on the priority queue as +outlined above is already outside of our threat model, as it assumes n/3 +malicious nodes + additionally malfunctioning/DoSed nodes. Even more so for +attacks on the best-effort queue, as our threat model only allows for n/3 +malicious _or_ malfunctioning nodes in total. It would therefore be a valid +decision to ditch the best-effort queue, if it proves to become a burden or +creates other issues. + +One issue we should not be worried about though is spam. For abusing best-effort +for spam, the following scenario would be necessary: + +An attacker controls a backing group: The attacker can then have candidates +backed and choose to not provide chunks. This should come at a cost to miss out +on rewards for backing, so is not free. At the same time it is rate limited, as +a backing group can only back so many candidates legitimately. (~ 1 per slot): + +1. They have to wait until a malicious actor becomes block producer (for causing + additional forks via equivocation for example). +2. Forks are possible, but if caused by equivocation also not free. +3. For each fork the attacker has to wait until the candidate times out, for + backing another one. + +Assuming there can only be a handful of forks, 2) together with 3) the candidate +timeout restriction, frequency should indeed be in the ballpark of once per +slot. Scaling linearly in the number of controlled backing groups, so two groups +would mean 2 backings per slot, ... + +So by this reasoning an attacker could only do very limited harm and at the same +time will have to pay some price for it (it will miss out on rewards). Overall +the work done by the network might even be in the same ballpark as if actors +just behaved honestly: + +1. Validators would have fetched chunks +2. Approval checkers would have done approval checks + +While because of the attack (backing, not providing chunks and afterwards +disputing the candidate), the work for 1000 validators would be: + +All validators sending out ~ 1000 tiny requests over already established +connections, with also tiny (byte) responses. + +This means around a million requests, while in the honest case it would be ~ +10000 (30 approval checkers x330) - where each request triggers a response in +the range of kilobytes. Hence network load alone will likely be higher in the +honest case than in the DoS attempt case, which would mean the DoS attempt +actually reduces load, while also costing rewards. + +In the worst case this can happen multiple times, as we would retry that on +every vote import. The effect would still be in the same ballpark as honest +behavior though and can also be mitigated by chilling repeated availability +recovery requests for example. + +## Out of Scope + +### No Disputes for Non Included Candidates We only ever care about disputes for candidates that have been included on at least some chain (became available). This is because the availability system was @@ -421,6 +510,46 @@ even weaken it as attackers are warned before availability is reached, while at the same time adding signficant amount of complexity. We therefore punt on such disputes and concentrate on disputes the system was designed to handle. +### No Disputes for Already Finalized Blocks + +Note that by above rules in the `Participation` section, we will not participate +in disputes concerning a candidate in an already finalized block. This is +because, disputing an already finalized block is simply too late and therefore +of little value. Once finalized, bridges have already processed the block for +example, so we have to assume the damage is already done. Governance has to step +in and fix what can be fixed. + +Making disputes for already finalized blocks possible would only provide two +features: + +1. We can at least still slash attackers. +2. We can freeze the chain to some governance only mode, in an attempt to + minimize potential harm done. + +Both seem kind of worthwhile, although as argued above, it is likely that there +is not too much that can be done in 2 and we would likely only ending up DoSing +the whole system without much we can do. 1 can also be achieved via governance +mechanisms. + +In any case, our focus should be making as sure as reasonably possible that any +potentially invalid block does not get finalized in the first place. Not +allowing disputing already finalized blocks actually helps a great deal with +this goal as it massively reduces the amount of candidates that can be disputed. + +This makes attempts to overwhelm the system with disputes significantly harder +and counter measures way easier. We can limit inclusion for example (as +suggested [here](https://github.com/paritytech/polkadot/issues/5898) in case of +high dispute load. Another measure we have at our disposal is that on finality +lag block production will slow down, implicitly reducing the rate of new +candidates that can be disputed. Hence, the cutting-off of the unlimited +candidate supply of already finalized blocks, guarantees the necessary DoS +protection and ensures we can have measures in place to keep up with processing +of disputes. + +If we allowed participation for disputes for already finalized candidates, the +above spam protection mechanisms would be insufficient/relying 100% on full and +quick disabling of spamming validators. + ## Database Schema We use an underlying Key-Value database where we assume we have the following operations available: diff --git a/roadmap/implementers-guide/src/node/disputes/dispute-distribution.md b/roadmap/implementers-guide/src/node/disputes/dispute-distribution.md index b63ea2bdcbf0..6b8e5ec03cf4 100644 --- a/roadmap/implementers-guide/src/node/disputes/dispute-distribution.md +++ b/roadmap/implementers-guide/src/node/disputes/dispute-distribution.md @@ -15,6 +15,13 @@ This design should result in a protocol that is: ## Protocol +Distributing disputes needs to be a reliable protocol. We would like to make as +sure as possible that our vote got properly delivered to all concerned +validators. For this to work, this subsystem won't be gossip based, but instead +will use a request/response protocol for application level confirmations. The +request will be the payload (the actual votes/statements), the response will +be the confirmation. See [below][#wire-format]. + ### Input [`DisputeDistributionMessage`][DisputeDistributionMessage] @@ -107,16 +114,7 @@ struct VotesResponse { } ``` -## Functionality - -Distributing disputes needs to be a reliable protocol. We would like to make as -sure as possible that our vote got properly delivered to all concerned -validators. For this to work, this subsystem won't be gossip based, but instead -will use a request/response protocol for application level confirmations. The -request will be the payload (the actual votes/statements), the response will -be the confirmation. See [above][#wire-format]. - -### Starting a Dispute +## Starting a Dispute A dispute is initiated once a node sends the first `DisputeRequest` wire message, which must contain an "invalid" vote and a "valid" vote. @@ -132,7 +130,7 @@ conflicting votes available, hence we have a valid dispute. Nodes will still need to check whether the disputing votes are somewhat current and not some stale ones. -### Participating in a Dispute +## Participating in a Dispute Upon receiving a `DisputeRequest` message, a dispute distribution will trigger the import of the received votes via the dispute coordinator @@ -144,13 +142,13 @@ except that if the local node deemed the candidate valid, the `SendDispute` message will contain a valid vote signed by our node and will contain the initially received `Invalid` vote. -Note, that we rely on the coordinator to check availability for spam protection -(see below). +Note, that we rely on `dispute-coordinator` to check validity of a dispute for spam +protection (see below). -### Sending of messages +## Sending of messages Starting and participating in a dispute are pretty similar from the perspective -of dispute distribution. Once we receive a `SendDispute` message we try to make +of dispute distribution. Once we receive a `SendDispute` message, we try to make sure to get the data out. We keep track of all the parachain validators that should see the message, which are all the parachain validators of the session where the dispute happened as they will want to participate in the dispute. In @@ -159,114 +157,185 @@ session (which might be the same or not and may change during the dispute). Those authorities will not participate in the dispute, but need to see the statements so they can include them in blocks. -We keep track of connected parachain validators and authorities and will issue -warnings in the logs if connected nodes are less than two thirds of the -corresponding sets. We also only consider a message transmitted, once we -received a confirmation message. If not, we will keep retrying getting that -message out as long as the dispute is deemed alive. To determine whether a -dispute is still alive we will issue a +### Reliability + +We only consider a message transmitted, once we received a confirmation message. +If not, we will keep retrying getting that message out as long as the dispute is +deemed alive. To determine whether a dispute is still alive we will ask the +`dispute-coordinator` for a list of all still active disputes via a `DisputeCoordinatorMessage::ActiveDisputes` message before each retry run. Once a dispute is no longer live, we will clean up the state accordingly. -### Reception & Spam Considerations - -Because we are not forwarding foreign statements, spam is less of an issue in -comparison to gossip based systems. Rate limiting should be implemented at the -substrate level, see -[#7750](https://github.com/paritytech/substrate/issues/7750). Still we should -make sure that it is not possible via spamming to prevent a dispute concluding -or worse from getting noticed. - -Considered attack vectors: - -1. Invalid disputes (candidate does not exist) could make us - run out of resources. E.g. if we recorded every statement, we could run out - of disk space eventually. -2. An attacker can just flood us with notifications on any notification - protocol, assuming flood protection is not effective enough, our unbounded - buffers can fill up and we will run out of memory eventually. -3. An attacker could participate in a valid dispute, but send its votes multiple - times. -4. Attackers could spam us at a high rate with invalid disputes. Our incoming - queue of requests could get monopolized by those malicious requests and we - won't be able to import any valid disputes and we could run out of resources, - if we tried to process them all in parallel. - -For tackling 1, we make sure to not occupy resources before we don't know a -candidate is available. So we will not record statements to disk until we -recovered availability for the candidate or know by some other means that the -dispute is legit. - -For 2, we will pick up on any dispute on restart, so assuming that any realistic -memory filling attack will take some time, we should be able to participate in a -dispute under such attacks. - -Importing/discarding redundant votes should be pretty quick, so measures with -regards to 4 should suffice to prevent 3, from doing any real harm. - -For 4, full monopolization of the incoming queue should not be possible assuming -substrate handles incoming requests in a somewhat fair way. Still we want some -defense mechanisms, at the very least we need to make sure to not exhaust -resources. - -The dispute coordinator will notify us on import about unavailable candidates or -otherwise invalid imports and we can disconnect from such peers/decrease their -reputation drastically. This alone should get us quite far with regards to queue -monopolization, as availability recovery is expected to fail relatively quickly -for unavailable data. - -Still if those spam messages come at a very high rate, we might still run out of -resources if we immediately call `DisputeCoordinatorMessage::ImportStatements` -on each one of them. Secondly with our assumption of 1/3 dishonest validators, -getting rid of all of them will take some time, depending on reputation timeouts -some of them might even be able to reconnect eventually. - -To mitigate those issues we will process dispute messages with a maximum -parallelism `N`. We initiate import processes for up to `N` candidates in -parallel. Once we reached `N` parallel requests we will start back pressuring on -the incoming requests. This saves us from resource exhaustion. - -To reduce impact of malicious nodes further, we can keep track from which nodes the -currently importing statements came from and will drop requests from nodes that -already have imports in flight. - -Honest nodes are not expected to send dispute statements at a high rate, but -even if they did: - -- we will import at least the first one and if it is valid it will trigger a - dispute, preventing finality. -- Chances are good that the first sent candidate from a peer is indeed the - oldest one (if they differ in age at all). -- for the dropped request any honest node will retry sending. -- there will be other nodes notifying us about that dispute as well. -- honest votes have a speed advantage on average. Apart from the very first - dispute statement for a candidate, which might cause the availability recovery - process, imports of honest votes will be super fast, while for spam imports - they will always take some time as we have to wait for availability to fail. - -So this general rate limit, that we drop requests from same peers if they come -faster than we can import the statements should not cause any problems for -honest nodes and is in their favor. - -Size of `N`: The larger `N` the better we can handle distributed flood attacks -(see previous paragraph), but we also get potentially more availability recovery -processes happening at the same time, which slows down the individual processes. -And we rather want to have one finish quickly than lots slowly at the same time. -On the other hand, valid disputes are expected to be rare, so if we ever exhaust -`N` it is very likely that this is caused by spam and spam recoveries don't cost -too much bandwidth due to empty responses. - -Considering that an attacker would need to attack many nodes in parallel to have -any effect, an `N` of 10 seems to be a good compromise. For honest requests, most -of those imports will likely concern the same candidate, and for dishonest ones -we get to disconnect from up to ten colluding adversaries at a time. - -For the size of the channel for incoming requests: Due to dropping of repeated -requests from same nodes we can make the channel relatively large without fear -of lots of spam requests sitting there wasting our time, even after we already -blocked a peer. For valid disputes, incoming requests can become bursty. On the -other hand we will also be very quick in processing them. A channel size of 100 -requests seems plenty and should be able to handle bursts adequately. +### Order + +We assume `SendDispute` messages are coming in an order of importance, hence +`dispute-distribution` will make sure to send out network messages in the same +order, even on retry. + +### Rate Limit + +For spam protection (see below), we employ an artificial rate limiting on sending +out messages in order to not hit the rate limit at the receiving side, which +would result in our messages getting dropped and our reputation getting reduced. + +## Reception + +As we shall see the receiving side is mostly about handling spam and ensuring +the dispute-coordinator learns about disputes as fast as possible. + +Goals for the receiving side: + +1. Get new disputes to the dispute-coordinator as fast as possible, so + prioritization can happen properly. +2. Batch votes per disputes as much as possible for good import performance. +3. Prevent malicious nodes exhausting node resources by sending lots of messages. +4. Prevent malicious nodes from sending so many messages/(fake) disputes, + preventing us from concluding good ones. +5. Limit ability of malicious nodes of delaying the vote import due to batching + logic. + +Goal 1 and 2 seem to be conflicting, but an easy compromise is possible: When +learning about a new dispute, we will import the vote immediately, making the +dispute coordinator aware and also getting immediate feedback on the validity. +Then if valid we can batch further incoming votes, with less time constraints as +the dispute-coordinator already knows about the dispute. + +Goal 3 and 4 are obviously very related and both can easily be solved via rate +limiting as we shall see below. Rate limits should already be implemented at the +substrate level, but [are not](https://github.com/paritytech/substrate/issues/7750) +at the time of writing. But even if they were, the enforced substrate limits would +likely not be configurable and thus would still be to high for our needs as we can +rely on the following observations: + +1. Each honest validator will only send one message (apart from duplicates on + timeout) per candidate/dispute. +2. An honest validator needs to fully recover availability and validate the + candidate for casting a vote. + +With these two observations, we can conclude that honest validators will usually +not send messages at a high rate. We can therefore enforce conservative rate +limits and thus minimize harm spamming malicious nodes can have. + +Before we dive into how rate limiting solves all spam issues elegantly, let's +discuss that honest behaviour further: + +What about session changes? Here we might have to inform a new validator set of +lots of already existing disputes at once. + +With observation 1) and a rate limit that is per peer, we are still good: + +Let's assume a rate limit of one message per 200ms per sender. This means 5 +messages from each validator per second. 5 messages means 5 disputes! +Conclusively, we will be able to conclude 5 disputes per second - no matter what +malicious actors are doing. This is assuming dispute messages are sent ordered, +but even if not perfectly ordered: On average it will be 5 disputes per second. + +This is good enough! All those disputes are valid ones and will result in +slashing and disabling of validators. Let's assume all of them conclude `valid`, +and we disable validators only after 100 raised concluding valid disputes, we +would still start disabling misbehaving validators in only 20 seconds. + +One could also think that in addition participation is expected to take longer, +which means on average we can import/conclude disputes faster than they are +generated - regardless of dispute spam. Unfortunately this is not necessarily +true: There might be parachains with very light load where recovery and +validation can be accomplished very quickly - maybe faster than we can import +those disputes. + +This is probably an argument for not imposing a too low rate limit, although the +issue is more general: Even without any rate limit, if an attacker generates +disputes at a very high rate, nodes will be having trouble keeping participation +up, hence the problem should be mitigated at a [more fundamental +layer](https://github.com/paritytech/polkadot/issues/5898). + +For nodes that have been offline for a while, the same argument as for session +changes holds, but matters even less: We assume 2/3 of nodes to be online, so +even if the worst case 1/3 offline happens and they could not import votes fast +enough (as argued above, they in fact can) it would not matter for consensus. + +### Rate Limiting + +As suggested previously, rate limiting allows to mitigate all threats that come +from malicious actors trying to overwhelm the system in order to get away without +a slash, when it comes to dispute-distribution. In this section we will explain +how in greater detail. + +The idea is to open a queue with limited size for each peer. We will process +incoming messages as fast as we can by doing the following: + +1. Check that the sending peer is actually a valid authority - otherwise drop + message and decrease reputation/disconnect. +2. Put message on the peer's queue, if queue is full - drop it. + +Every `RATE_LIMIT` seconds (or rather milliseconds), we pause processing +incoming requests to go a full circle and process one message from each queue. +Processing means `Batching` as explained in the next section. + +### Batching + +To achieve goal 2 we will batch incoming votes/messages together before passing +them on as a single batch to the `dispute-coordinator`. To adhere to goal 1 as +well, we will do the following: + +1. For an incoming message, we check whether we have an existing batch for that + candidate, if not we import directly to the dispute-coordinator, as we have + to assume this is concerning a new dispute. +2. We open a batch and start collecting incoming messages for that candidate, + instead of immediately forwarding. +4. We keep collecting votes in the batch until we receive less than + `MIN_KEEP_BATCH_ALIVE_VOTES` unique votes in the last `BATCH_COLLECTING_INTERVAL`. This is + important to accommodate for goal 5 and also 3. +5. We send the whole batch to the dispute-coordinator. + +This together with rate limiting explained above ensures we will be able to +process valid disputes: We can limit the number of simultaneous existing batches +to some high value, but can be rather certain that this limit will never be +reached - hence we won't drop valid disputes: + +Let's assume `MIN_KEEP_BATCH_ALIVE_VOTES` is 10, `BATCH_COLLECTING_INTERVAL` +is `500ms` and above `RATE_LIMIT` is `100ms`. 1/3 of validators are malicious, +so for 1000 this means around 330 malicious actors worst case. + +All those actors can send a message every `100ms`, that is 10 per second. This +means at the begining of an attack they can open up around 3300 batches. Each +containing two votes. So memory usage is still negligible. In reality it is even +less, as we also demand 10 new votes to trickle in per batch in order to keep it +alive, every `500ms`. Hence for the first second, each batch requires 20 votes +each. Each message is 2 votes, so this means 10 messages per batch. Hence to +keep those batches alive 10 attackers are needed for each batch. This reduces +the number of opened batches by a factor of 10: So we only have 330 batches in 1 +second - each containing 20 votes. + +The next second: In order to further grow memory usage, attackers have to +maintain 10 messages per batch and second. Number of batches equals the number +of attackers, each has 10 messages per second, all are needed to maintain the +batches in memory. Therefore we have a hard cap of around 330 (number of +malicious nodes) open batches. Each can be filled with number of malicious +actor's votes. So 330 batches with each 330 votes: Let's assume approximately 100 +bytes per signature/vote. This results in a worst case memory usage of 330 * 330 +* 100 ~= 10 MiB. + +For 10_000 validators, we are already in the Gigabyte range, which means that +with a validator set that large we might want to be more strict with the rate limit or +require a larger rate of incoming votes per batch to keep them alive. + +For a thousand validators a limit on batches of around 1000 should never be +reached in practice. Hence due to rate limiting we have a very good chance to +not ever having to drop a potential valid dispute due to some resource limit. + +Further safe guards are possible: The dispute-coordinator actually +confirms/denies imports. So once we receive a denial by the dispute-coordinator +for the initial imported votes, we can opt into flushing the batch immediately +and importing the votes. This swaps memory usage for more CPU usage, but if that +import is deemed invalid again we can immediately decrease the reputation of the +sending peers, so this should be a net win. For the time being we punt on this +for simplicity. + +Instead of filling batches to maximize memory usage, attackers could also try to +overwhelm the dispute coordinator by only sending votes for new candidates all +the time. This attack vector is mitigated also by above rate limit and +decreasing the peer's reputation on denial of the invalid imports by the +coordinator. ### Node Startup diff --git a/roadmap/implementers-guide/src/protocol-chain-selection.md b/roadmap/implementers-guide/src/protocol-chain-selection.md index 4f90a26949d8..dd066df43cdd 100644 --- a/roadmap/implementers-guide/src/protocol-chain-selection.md +++ b/roadmap/implementers-guide/src/protocol-chain-selection.md @@ -43,6 +43,6 @@ The leaf-selection rule based on our definitions above is simple: we take the ma Finality gadgets, as mentioned above, will often impose an additional requirement to vote on a chain containing a specific block, known as the **required** block. Although this is typically the most recently finalized block, it is possible that it may be a block that is unfinalized. When receiving such a request: 1. If the required block is the best finalized block, then select the best viable leaf. 2. If the required block is unfinalized and non-viable, then select the required block and go no further. This is likely an indication that something bad will be finalized in the network, which will never happen when approvals & disputes are functioning correctly. Nevertheless we account for the case here. -3. If the required block is unfinalized and non-viable, then iterate over the viable leaves in descending order by score and select the first one which contains the required block in its chain. Backwards iteration is a simple way to check this, but if unfinalized chains grow long then Merkle Mountain-Ranges will most likely be more efficient. +3. If the required block is unfinalized and viable, then iterate over the viable leaves in descending order by score and select the first one which contains the required block in its chain. Backwards iteration is a simple way to check this, but if unfinalized chains grow long then Merkle Mountain-Ranges will most likely be more efficient. Once selecting a leaf, the chain should be constrained to the maximum of the required block or the highest **finalizable** ancestor. diff --git a/roadmap/implementers-guide/src/pvf-prechecking.md b/roadmap/implementers-guide/src/pvf-prechecking.md index 0daeaf0593c7..1dc7611c0cef 100644 --- a/roadmap/implementers-guide/src/pvf-prechecking.md +++ b/roadmap/implementers-guide/src/pvf-prechecking.md @@ -1,12 +1,34 @@ # PVF Pre-checking Overview -> ⚠️ This discusses a mechanism that is currently not under-development. Follow the progress under [#3211]. +> ⚠️ This discusses a mechanism that is currently under-development. Follow the progress under [#3211]. + +## Terms + +This functionality involves several processes which may be potentially +confusing: + +- **Prechecking:** This is the process of initially checking the PVF when it is + first added. We attempt *preparation* of the PVF and make sure it succeeds + within a given timeout. +- **Execution:** This actually executes the PVF. The node may not have the + artifact from prechecking, in which case this process also includes a + *preparation* job. The timeout for preparation here is more lenient than when + prechecking. +- **Preparation:** This is the process of preparing the WASM blob and includes + both *prevalidation* and *compilation*. As prevalidation is pretty minimal + right now, preparation mostly consists of compilation. Note that *prechecking* + just consists of preparation, whereas *execution* will also prepare the PVF if + the artifact is not already found. +- **Prevalidation:** Right now this just tries to deserialize the binary with + parity-wasm. It is a part of *preparation*. +- **Compilation:** This is the process of compiling a PVF from wasm code to + machine code. It is a part of *preparation*. ## Motivation Parachains' and parathreads' validation function is described by a wasm module that we refer to as a PVF. Since it's a wasm module the typical way of executing it is to compile it to machine code. Typically an optimizing compiler consists of algorithms that are able to optimize the resulting machine code heavily. However, while those algorithms perform quite well for a typical wasm code produced by standard toolchains (e.g. rustc/LLVM), those algorithms can be abused to consume a lot of resources. Moreover, since those algorithms are rather complex there is a lot of room for a bug that can crash the compiler. -If compilation of a Parachain Validation Function (PVF) takes too long or uses too much memory, this can leave a node in limbo as to whether a candidate of that parachain is valid or not. +If compilation of a Parachain Validation Function (PVF) takes too long or uses too much memory, this can leave a node in limbo as to whether a candidate of that parachain is valid or not. The amount of time that a PVF takes to compile is a subjective resource limit and as such PVFs may be maliciously crafted so that there is e.g. a 50/50 split of validators which can and cannot compile and execute the PVF. diff --git a/roadmap/implementers-guide/src/runtime/configuration.md b/roadmap/implementers-guide/src/runtime/configuration.md index 739352b202b3..96d63faccedd 100644 --- a/roadmap/implementers-guide/src/runtime/configuration.md +++ b/roadmap/implementers-guide/src/runtime/configuration.md @@ -28,7 +28,7 @@ The session change routine works as follows: ## Routines ```rust -enum InconsistentErrror { +enum InconsistentError { // ... } diff --git a/roadmap/implementers-guide/src/runtime/paras.md b/roadmap/implementers-guide/src/runtime/paras.md index af2e7add54e5..a9e99c8993bf 100644 --- a/roadmap/implementers-guide/src/runtime/paras.md +++ b/roadmap/implementers-guide/src/runtime/paras.md @@ -172,7 +172,7 @@ PastCodePruning: Vec<(ParaId, BlockNumber)>; /// The change will be applied after the first parablock for this ID included which executes /// in the context of a relay chain block with a number >= `expected_at`. FutureCodeUpgrades: map ParaId => Option; -/// The actual future code of a para. +/// Hash of the actual future code of a para. FutureCodeHash: map ParaId => Option; /// This is used by the relay-chain to communicate to a parachain a go-ahead with in the upgrade procedure. /// @@ -246,8 +246,8 @@ CodeByHash: map ValidationCodeHash => Option 1. Do pruning based on all entries in `PastCodePruning` with `BlockNumber <= now`. Update the corresponding `PastCodeMeta` and `PastCode` accordingly. 1. Toggle the upgrade related signals - 1. Collect all `(para_id, expected_at)` from `UpcomingUpgrades` where `expected_at <= now` and prune them. For each para pruned set `UpgradeGoAheadSignal` to `GoAhead`. - 1. Collect all `(para_id, next_possible_upgrade_at)` from `UpgradeCooldowns` where `next_possible_upgrade_at <= now` and prune them. For each para pruned set `UpgradeRestrictionSignal` to `Present`. + 1. Collect all `(para_id, expected_at)` from `UpcomingUpgrades` where `expected_at <= now` and prune them. For each para pruned set `UpgradeGoAheadSignal` to `GoAhead`. Reserve weight for the state modification to upgrade each para pruned. + 1. Collect all `(para_id, next_possible_upgrade_at)` from `UpgradeCooldowns` where `next_possible_upgrade_at <= now`. For each para obtained this way reserve weight to remove its `UpgradeRestrictionSignal` on finalization. ## Routines @@ -275,4 +275,4 @@ In case the PVF pre-checking is enabled, or the new code is not already present ## Finalization -No finalization routine runs for this module. +Collect all `(para_id, next_possible_upgrade_at)` from `UpgradeCooldowns` where `next_possible_upgrade_at <= now` and prune them. For each para pruned remove its `UpgradeRestrictionSignal`. diff --git a/roadmap/implementers-guide/src/types/network.md b/roadmap/implementers-guide/src/types/network.md index 0d09a682cff2..b698ca2075bf 100644 --- a/roadmap/implementers-guide/src/types/network.md +++ b/roadmap/implementers-guide/src/types/network.md @@ -145,10 +145,19 @@ These updates are posted from the [Network Bridge Subsystem](../node/utility/net struct NewGossipTopology { /// The session index this topology corresponds to. session: SessionIndex, - /// Neighbors in the 'X' dimension of the grid. - our_neighbors_x: HashMap, - /// Neighbors in the 'Y' dimension of the grid. - our_neighbors_y: HashMap, + /// The topology itself. + topology: SessionGridTopology, + /// The local validator index, if any. + local_index: Option, +} + +struct SessionGridTopology { + /// An array mapping validator indices to their indices in the + /// shuffling itself. This has the same size as the number of validators + /// in the session. + shuffled_indices: Vec, + /// The canonical shuffling of validators for the session. + canonical_shuffling: Vec, } struct TopologyPeerInfo { @@ -157,6 +166,9 @@ struct TopologyPeerInfo { /// The index of the validator in the discovery keys of the corresponding /// `SessionInfo`. This can extend _beyond_ the set of active parachain validators. validator_index: ValidatorIndex, + /// The authority discovery public key of the validator in the corresponding + /// `SessionInfo`. + discovery_id: AuthorityDiscoveryId, } enum NetworkBridgeEvent { diff --git a/roadmap/implementers-guide/src/types/overseer-protocol.md b/roadmap/implementers-guide/src/types/overseer-protocol.md index b2559c4cfda7..4b9dc97c27e2 100644 --- a/roadmap/implementers-guide/src/types/overseer-protocol.md +++ b/roadmap/implementers-guide/src/types/overseer-protocol.md @@ -555,14 +555,15 @@ enum NetworkBridgeMessage { /// Inform the distribution subsystems about the new /// gossip network topology formed. NewGossipTopology { - /// The session this topology corresponds to. - session: SessionIndex, - /// Ids of our neighbors in the X dimension of the new gossip topology. - /// We're not necessarily connected to all of them, but we should try to be. - our_neighbors_x: HashSet, - /// Ids of our neighbors in the Y dimension of the new gossip topology. - /// We're not necessarily connected to all of them, but we should try to be. - our_neighbors_y: HashSet, + /// The session info this gossip topology is concerned with. + session: SessionIndex, + /// Our validator index in the session, if any. + local_index: Option, + /// The canonical shuffling of validators for the session. + canonical_shuffling: Vec<(AuthorityDiscoveryId, ValidatorIndex)>, + /// The reverse mapping of `canonical_shuffling`: from validator index + /// to the index in `canonical_shuffling` + shuffled_indices: Vec, } } ``` diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index bd76c7009c2d..a1201553db24 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -1,32 +1,32 @@ [package] name = "polkadot-rpc" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] jsonrpsee = { version = "0.15.1", features = ["server"] } polkadot-primitives = { path = "../primitives" } -sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-consensus-babe-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-consensus-epochs = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-finality-grandpa-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-sync-state-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -txpool-api = { package = "sc-transaction-pool-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-mmr-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -beefy-gadget = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -beefy-gadget-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-consensus-babe-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-consensus-epochs = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-finality-grandpa-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-sync-state-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +txpool-api = { package = "sc-transaction-pool-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-mmr-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +beefy-gadget = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +beefy-gadget-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +substrate-state-trie-migration-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 0d6c46cc1ef5..2b3497832caa 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use jsonrpsee::RpcModule; use polkadot_primitives::v2::{AccountId, Balance, Block, BlockNumber, Hash, Nonce}; use sc_client_api::AuxStore; -use sc_consensus_babe::Epoch; +use sc_consensus_babe::{BabeConfiguration, Epoch}; use sc_finality_grandpa::FinalityProofProvider; pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; use sp_api::ProvideRuntimeApi; @@ -40,7 +40,7 @@ pub type RpcExtension = RpcModule<()>; /// Extra dependencies for BABE. pub struct BabeDeps { /// BABE protocol config. - pub babe_config: sc_consensus_babe::Config, + pub babe_config: BabeConfiguration, /// BABE pending epoch changes. pub shared_epoch_changes: sc_consensus_epochs::SharedEpochChanges, /// The keystore that manages the keys of the node. @@ -61,7 +61,9 @@ pub struct GrandpaDeps { pub finality_provider: Arc>, } -use beefy_gadget::notification::{BeefyBestBlockStream, BeefyVersionedFinalityProofStream}; +use beefy_gadget::communication::notification::{ + BeefyBestBlockStream, BeefyVersionedFinalityProofStream, +}; /// Dependencies for BEEFY pub struct BeefyDeps { /// Receives notifications about finality proof events from BEEFY. @@ -106,7 +108,11 @@ where + Sync + 'static, C::Api: frame_rpc_system::AccountNonceApi, - C::Api: pallet_mmr_rpc::MmrRuntimeApi::Hash>, + C::Api: pallet_mmr_rpc::MmrRuntimeApi< + Block, + ::Hash, + BlockNumber, + >, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: BabeApi, C::Api: BlockBuilder, diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 35cbf0cfa1a9..4284317aa5d9 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-runtime-common" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -15,34 +15,34 @@ serde = { version = "1.0.137", default-features = false } serde_derive = { version = "1.0.117", optional = true } static_assertions = "1.1.0" -beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-npos-elections = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-npos-elections = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } -pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-election-provider-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-bags-list = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-election-provider-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-bags-list = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } libsecp256k1 = { version = "0.7.0", default-features = false } @@ -53,11 +53,10 @@ xcm = { path = "../../xcm", default-features = false } [dev-dependencies] hex-literal = "0.3.4" -frame-support-test = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -trie-db = "0.23.1" +frame-support-test = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } serde_json = "1.0.81" libsecp256k1 = "0.7.0" test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../primitives/test-helpers" } @@ -109,6 +108,7 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "runtime-parachains/runtime-benchmarks", "pallet-babe/runtime-benchmarks", + "pallet-bags-list/runtime-benchmarks", ] try-runtime = [ "runtime-parachains/try-runtime", diff --git a/runtime/common/slot_range_helper/Cargo.toml b/runtime/common/slot_range_helper/Cargo.toml index 4a76616c63f6..25baa5a0e65a 100644 --- a/runtime/common/slot_range_helper/Cargo.toml +++ b/runtime/common/slot_range_helper/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "slot-range-helper" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] paste = "1.0" -enumn = "0.1.4" +enumn = "0.1.5" parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } -sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } [features] default = ["std"] diff --git a/runtime/common/src/assigned_slots.rs b/runtime/common/src/assigned_slots.rs index bac642cde589..9be227a37352 100644 --- a/runtime/common/src/assigned_slots.rs +++ b/runtime/common/src/assigned_slots.rs @@ -85,10 +85,10 @@ pub mod pallet { #[pallet::disable_frame_system_supertrait_check] pub trait Config: configuration::Config + paras::Config + slots::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Origin for assigning slots. - type AssignSlotOrigin: EnsureOrigin<::Origin>; + type AssignSlotOrigin: EnsureOrigin<::RuntimeOrigin>; /// The type representing the leasing system. type Leaser: Leaser< @@ -192,7 +192,7 @@ pub mod pallet { } // We didn't return early above, so we didn't do anything. - 0 + Weight::zero() } } @@ -579,10 +579,10 @@ mod tests { impl frame_system::offchain::SendTransactionTypes for Test where - Call: From, + RuntimeCall: From, { type Extrinsic = UncheckedExtrinsic; - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; } parameter_types! { @@ -592,8 +592,8 @@ mod tests { type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); type BlockLength = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = BlockNumber; type Hash = H256; @@ -601,7 +601,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); @@ -621,7 +621,7 @@ mod tests { impl pallet_balances::Config for Test { type Balance = u64; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -640,7 +640,7 @@ mod tests { } impl parachains_paras::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = parachains_paras::TestWeightInfo; type UnsignedPriority = ParasUnsignedPriority; type NextSessionRotation = crate::mock::TestNextSessionRotation; @@ -655,7 +655,7 @@ mod tests { } impl slots::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type Registrar = TestRegistrar; type LeasePeriod = LeasePeriod; @@ -673,7 +673,7 @@ mod tests { } impl assigned_slots::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type AssignSlotOrigin = EnsureRoot; type Leaser = Slots; type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength; @@ -738,7 +738,10 @@ mod tests { run_to_block(1); assert_noop!( - AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),), + AssignedSlots::assign_perm_parachain_slot( + RuntimeOrigin::root(), + ParaId::from(1_u32), + ), Error::::ParaDoesntExist ); }); @@ -750,7 +753,10 @@ mod tests { run_to_block(1); assert_noop!( - AssignedSlots::assign_perm_parachain_slot(Origin::signed(1), ParaId::from(1_u32),), + AssignedSlots::assign_perm_parachain_slot( + RuntimeOrigin::signed(1), + ParaId::from(1_u32), + ), BadOrigin ); }); @@ -770,7 +776,10 @@ mod tests { assert_ok!(TestRegistrar::::make_parachain(ParaId::from(1_u32))); assert_noop!( - AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),), + AssignedSlots::assign_perm_parachain_slot( + RuntimeOrigin::root(), + ParaId::from(1_u32), + ), Error::::NotParathread ); }); @@ -792,18 +801,24 @@ mod tests { assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 1, 1)); // Try to assign a perm slot in current period fails assert_noop!( - AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),), + AssignedSlots::assign_perm_parachain_slot( + RuntimeOrigin::root(), + ParaId::from(1_u32), + ), Error::::OngoingLeaseExists ); // Cleanup - assert_ok!(Slots::clear_all_leases(Origin::root(), 1.into())); + assert_ok!(Slots::clear_all_leases(RuntimeOrigin::root(), 1.into())); // Register lease for next lease period assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 2, 1)); // Should be detected and also fail assert_noop!( - AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(1_u32),), + AssignedSlots::assign_perm_parachain_slot( + RuntimeOrigin::root(), + ParaId::from(1_u32), + ), Error::::OngoingLeaseExists ); }); @@ -836,17 +851,20 @@ mod tests { )); assert_ok!(AssignedSlots::assign_perm_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(1_u32), )); assert_ok!(AssignedSlots::assign_perm_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(2_u32), )); assert_eq!(AssignedSlots::permanent_slot_count(), 2); assert_noop!( - AssignedSlots::assign_perm_parachain_slot(Origin::root(), ParaId::from(3_u32),), + AssignedSlots::assign_perm_parachain_slot( + RuntimeOrigin::root(), + ParaId::from(3_u32), + ), Error::::MaxPermanentSlotsExceeded ); }); @@ -868,7 +886,7 @@ mod tests { assert_eq!(AssignedSlots::permanent_slots(ParaId::from(1_u32)), None); assert_ok!(AssignedSlots::assign_perm_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(1_u32), )); @@ -901,7 +919,7 @@ mod tests { assert_noop!( AssignedSlots::assign_temp_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(1_u32), SlotLeasePeriodStart::Current ), @@ -917,7 +935,7 @@ mod tests { assert_noop!( AssignedSlots::assign_temp_parachain_slot( - Origin::signed(1), + RuntimeOrigin::signed(1), ParaId::from(1_u32), SlotLeasePeriodStart::Current ), @@ -941,7 +959,7 @@ mod tests { assert_noop!( AssignedSlots::assign_temp_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(1_u32), SlotLeasePeriodStart::Current ), @@ -967,7 +985,7 @@ mod tests { // Try to assign a perm slot in current period fails assert_noop!( AssignedSlots::assign_temp_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(1_u32), SlotLeasePeriodStart::Current ), @@ -975,14 +993,14 @@ mod tests { ); // Cleanup - assert_ok!(Slots::clear_all_leases(Origin::root(), 1.into())); + assert_ok!(Slots::clear_all_leases(RuntimeOrigin::root(), 1.into())); // Register lease for next lease period assert_ok!(Slots::lease_out(ParaId::from(1_u32), &1, 1, 2, 1)); // Should be detected and also fail assert_noop!( AssignedSlots::assign_temp_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(1_u32), SlotLeasePeriodStart::Current ), @@ -1006,7 +1024,7 @@ mod tests { )); assert_ok!(AssignedSlots::assign_temp_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(n as u32), SlotLeasePeriodStart::Current )); @@ -1023,7 +1041,7 @@ mod tests { )); assert_noop!( AssignedSlots::assign_temp_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(7_u32), SlotLeasePeriodStart::Current ), @@ -1047,7 +1065,7 @@ mod tests { assert_eq!(AssignedSlots::temporary_slots(ParaId::from(1_u32)), None); assert_ok!(AssignedSlots::assign_temp_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(1_u32), SlotLeasePeriodStart::Current )); @@ -1122,7 +1140,7 @@ mod tests { )); assert_ok!(AssignedSlots::assign_temp_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(n as u32), if (n % 2).is_zero() { SlotLeasePeriodStart::Current @@ -1214,7 +1232,7 @@ mod tests { run_to_block(1); assert_noop!( - AssignedSlots::unassign_parachain_slot(Origin::root(), ParaId::from(1_u32),), + AssignedSlots::unassign_parachain_slot(RuntimeOrigin::root(), ParaId::from(1_u32),), Error::::SlotNotAssigned ); }); @@ -1226,7 +1244,10 @@ mod tests { run_to_block(1); assert_noop!( - AssignedSlots::assign_perm_parachain_slot(Origin::signed(1), ParaId::from(1_u32),), + AssignedSlots::assign_perm_parachain_slot( + RuntimeOrigin::signed(1), + ParaId::from(1_u32), + ), BadOrigin ); }); @@ -1245,15 +1266,16 @@ mod tests { )); assert_ok!(AssignedSlots::assign_perm_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(1_u32), )); assert_eq!(TestRegistrar::::is_parachain(ParaId::from(1_u32)), true); - assert_ok!( - AssignedSlots::unassign_parachain_slot(Origin::root(), ParaId::from(1_u32),) - ); + assert_ok!(AssignedSlots::unassign_parachain_slot( + RuntimeOrigin::root(), + ParaId::from(1_u32), + )); assert_eq!(AssignedSlots::permanent_slot_count(), 0); assert_eq!(AssignedSlots::has_permanent_slot(ParaId::from(1_u32)), false); @@ -1276,16 +1298,17 @@ mod tests { )); assert_ok!(AssignedSlots::assign_temp_parachain_slot( - Origin::root(), + RuntimeOrigin::root(), ParaId::from(1_u32), SlotLeasePeriodStart::Current )); assert_eq!(TestRegistrar::::is_parachain(ParaId::from(1_u32)), true); - assert_ok!( - AssignedSlots::unassign_parachain_slot(Origin::root(), ParaId::from(1_u32),) - ); + assert_ok!(AssignedSlots::unassign_parachain_slot( + RuntimeOrigin::root(), + ParaId::from(1_u32), + )); assert_eq!(AssignedSlots::temporary_slot_count(), 0); assert_eq!(AssignedSlots::active_temporary_slot_count(), 0); diff --git a/runtime/common/src/auctions.rs b/runtime/common/src/auctions.rs index b937a26d5671..f9181a7eac7b 100644 --- a/runtime/common/src/auctions.rs +++ b/runtime/common/src/auctions.rs @@ -50,16 +50,16 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn new_auction() -> Weight { - 0 + Weight::zero() } fn bid() -> Weight { - 0 + Weight::zero() } fn cancel_auction() -> Weight { - 0 + Weight::zero() } fn on_initialize() -> Weight { - 0 + Weight::zero() } } @@ -80,7 +80,7 @@ type WinnersData = #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::{pallet_prelude::*, traits::EnsureOrigin, weights::DispatchClass}; + use frame_support::{dispatch::DispatchClass, pallet_prelude::*, traits::EnsureOrigin}; use frame_system::{ensure_root, ensure_signed, pallet_prelude::*}; #[pallet::pallet] @@ -91,7 +91,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The type representing the leasing system. type Leaser: Leaser< @@ -117,7 +117,7 @@ pub mod pallet { type Randomness: Randomness; /// The origin which may initiate auctions. - type InitiateOrigin: EnsureOrigin; + type InitiateOrigin: EnsureOrigin; /// Weight Information for the Extrinsics in the Pallet type WeightInfo: WeightInfo; @@ -709,8 +709,8 @@ mod tests { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = BlockNumber; type Hash = H256; @@ -718,7 +718,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -739,7 +739,7 @@ mod tests { impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); @@ -867,7 +867,7 @@ mod tests { } impl Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Leaser = TestLeaser; type Registrar = TestRegistrar; type EndingPeriod = EndingPeriod; @@ -955,8 +955,8 @@ mod tests { new_test_ext().execute_with(|| { run_to_block(1); - assert_noop!(Auctions::new_auction(Origin::signed(1), 5, 1), BadOrigin); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); + assert_noop!(Auctions::new_auction(RuntimeOrigin::signed(1), 5, 1), BadOrigin); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); assert_eq!(AuctionCounter::::get(), 1); assert_eq!( @@ -970,8 +970,8 @@ mod tests { fn bidding_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 5)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5)); assert_eq!(Balances::reserved_balance(1), 5); assert_eq!(Balances::free_balance(1), 5); @@ -986,12 +986,12 @@ mod tests { fn under_bidding_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 5)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5)); assert_storage_noop!({ - assert_ok!(Auctions::bid(Origin::signed(2), 0.into(), 1, 1, 4, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 1, 4, 1)); }); }); } @@ -1000,9 +1000,9 @@ mod tests { fn over_bidding_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 5)); - assert_ok!(Auctions::bid(Origin::signed(2), 0.into(), 1, 1, 4, 6)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 1, 4, 6)); assert_eq!(Balances::reserved_balance(1), 0); assert_eq!(Balances::free_balance(1), 10); @@ -1020,7 +1020,7 @@ mod tests { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); assert_eq!(AuctionCounter::::get(), 1); assert_eq!( @@ -1082,8 +1082,8 @@ mod tests { fn can_win_auction() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1)); assert_eq!(Balances::reserved_balance(1), 1); assert_eq!(Balances::free_balance(1), 9); run_to_block(9); @@ -1105,8 +1105,8 @@ mod tests { fn can_win_auction_with_late_randomness() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1)); assert_eq!(Balances::reserved_balance(1), 1); assert_eq!(Balances::free_balance(1), 9); assert_eq!( @@ -1159,8 +1159,8 @@ mod tests { fn can_win_incomplete_auction() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 4, 4, 5)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 4, 4, 5)); run_to_block(9); assert_eq!(leases(), vec![((0.into(), 4), LeaseData { leaser: 1, amount: 5 }),]); @@ -1172,11 +1172,11 @@ mod tests { fn should_choose_best_combination() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 1)); - assert_ok!(Auctions::bid(Origin::signed(2), 0.into(), 1, 2, 3, 4)); - assert_ok!(Auctions::bid(Origin::signed(3), 0.into(), 1, 4, 4, 2)); - assert_ok!(Auctions::bid(Origin::signed(1), 1.into(), 1, 1, 4, 2)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 2, 3, 4)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), 0.into(), 1, 4, 4, 2)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1.into(), 1, 1, 4, 2)); run_to_block(9); assert_eq!( @@ -1199,15 +1199,15 @@ mod tests { fn gap_bid_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); // User 1 will make a bid for period 1 and 4 for the same Para 0 - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 4, 4, 4)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 4, 4, 4)); // User 2 and 3 will make a bid for para 1 on period 2 and 3 respectively - assert_ok!(Auctions::bid(Origin::signed(2), 1.into(), 1, 2, 2, 2)); - assert_ok!(Auctions::bid(Origin::signed(3), 1.into(), 1, 3, 3, 3)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 1.into(), 1, 2, 2, 2)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), 1.into(), 1, 3, 3, 3)); // Total reserved should be the max of the two assert_eq!(Balances::reserved_balance(1), 4); @@ -1238,16 +1238,16 @@ mod tests { fn deposit_credit_should_work() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 5)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 5)); assert_eq!(Balances::reserved_balance(1), 5); run_to_block(10); assert_eq!(leases(), vec![((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),]); assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 2)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 2, 2, 2, 6)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 2)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 2, 2, 6)); // Only 1 reserved since we have a deposit credit of 5. assert_eq!(Balances::reserved_balance(1), 1); run_to_block(20); @@ -1267,16 +1267,16 @@ mod tests { fn deposit_credit_on_alt_para_should_not_count() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 1, 5)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 5)); assert_eq!(Balances::reserved_balance(1), 5); run_to_block(10); assert_eq!(leases(), vec![((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),]); assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 2)); - assert_ok!(Auctions::bid(Origin::signed(1), 1.into(), 2, 2, 2, 6)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 2)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1.into(), 2, 2, 2, 6)); // 6 reserved since we are bidding on a new para; only works because we don't assert_eq!(Balances::reserved_balance(1), 6); run_to_block(20); @@ -1298,11 +1298,11 @@ mod tests { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); for i in 1..6u64 { run_to_block(i as _); - assert_ok!(Auctions::bid(Origin::signed(i), 0.into(), 1, 1, 4, i)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(i), 0.into(), 1, 1, 4, i)); for j in 1..6 { assert_eq!(Balances::reserved_balance(j), if j == i { j } else { 0 }); assert_eq!(Balances::free_balance(j), if j == i { j * 9 } else { j * 10 }); @@ -1327,11 +1327,11 @@ mod tests { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 0, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 0, 1)); for i in 1..6u64 { run_to_block(((i - 1) / 2 + 1) as _); - assert_ok!(Auctions::bid(Origin::signed(i), 0.into(), 1, 1, 4, i)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(i), 0.into(), 1, 1, 4, i)); for j in 1..6 { assert_eq!(Balances::reserved_balance(j), if j <= i { j } else { 0 }); assert_eq!(Balances::free_balance(j), if j <= i { j * 9 } else { j * 10 }); @@ -1405,19 +1405,19 @@ mod tests { fn lower_bids_are_correctly_refunded() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 1, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 1, 1)); let para_1 = ParaId::from(1_u32); let para_2 = ParaId::from(2_u32); // Make a bid and reserve a balance - assert_ok!(Auctions::bid(Origin::signed(1), para_1, 1, 1, 4, 10)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 10)); assert_eq!(Balances::reserved_balance(1), 10); assert_eq!(ReservedAmounts::::get((1, para_1)), Some(10)); assert_eq!(Balances::reserved_balance(2), 0); assert_eq!(ReservedAmounts::::get((2, para_2)), None); // Bigger bid, reserves new balance and returns funds - assert_ok!(Auctions::bid(Origin::signed(2), para_2, 1, 1, 4, 20)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 1, 4, 20)); assert_eq!(Balances::reserved_balance(1), 0); assert_eq!(ReservedAmounts::::get((1, para_1)), None); assert_eq!(Balances::reserved_balance(2), 20); @@ -1429,14 +1429,14 @@ mod tests { fn initialize_winners_in_ending_period_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 9, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 1)); let para_1 = ParaId::from(1_u32); let para_2 = ParaId::from(2_u32); let para_3 = ParaId::from(3_u32); // Make bids - assert_ok!(Auctions::bid(Origin::signed(1), para_1, 1, 1, 4, 10)); - assert_ok!(Auctions::bid(Origin::signed(2), para_2, 1, 3, 4, 20)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 10)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 3, 4, 20)); assert_eq!( Auctions::auction_status(System::block_number()), @@ -1466,7 +1466,7 @@ mod tests { AuctionStatus::::EndingPeriod(1, 0) ); assert_eq!(Auctions::winning(1), Some(winning)); - assert_ok!(Auctions::bid(Origin::signed(3), para_3, 1, 3, 4, 30)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 3, 4, 30)); run_to_block(12); assert_eq!( @@ -1482,9 +1482,9 @@ mod tests { fn handle_bid_requires_registered_para() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); assert_noop!( - Auctions::bid(Origin::signed(1), 1337.into(), 1, 1, 4, 1), + Auctions::bid(RuntimeOrigin::signed(1), 1337.into(), 1, 1, 4, 1), Error::::ParaNotRegistered ); assert_ok!(TestRegistrar::::register( @@ -1493,7 +1493,7 @@ mod tests { dummy_head_data(), dummy_validation_code() )); - assert_ok!(Auctions::bid(Origin::signed(1), 1337.into(), 1, 1, 4, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1337.into(), 1, 1, 4, 1)); }); } @@ -1501,8 +1501,8 @@ mod tests { fn handle_bid_checks_existing_lease_periods() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 2, 3, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 2, 3, 1)); assert_eq!(Balances::reserved_balance(1), 1); assert_eq!(Balances::free_balance(1), 9); run_to_block(9); @@ -1518,21 +1518,21 @@ mod tests { // Para 1 just won an auction above and won some lease periods. // No bids can work which overlap these periods. - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); assert_noop!( - Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 4, 1), + Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 4, 1), Error::::AlreadyLeasedOut, ); assert_noop!( - Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 2, 1), + Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 2, 1), Error::::AlreadyLeasedOut, ); assert_noop!( - Auctions::bid(Origin::signed(1), 0.into(), 2, 3, 4, 1), + Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 3, 4, 1), Error::::AlreadyLeasedOut, ); // This is okay, not an overlapping bid. - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 1, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 1, 1)); }); } @@ -1544,14 +1544,14 @@ mod tests { SampleLength::set(10); run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 9, 11)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 11)); let para_1 = ParaId::from(1_u32); let para_2 = ParaId::from(2_u32); let para_3 = ParaId::from(3_u32); // Make bids - assert_ok!(Auctions::bid(Origin::signed(1), para_1, 1, 11, 14, 10)); - assert_ok!(Auctions::bid(Origin::signed(2), para_2, 1, 13, 14, 20)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 11, 14, 10)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 13, 14, 20)); assert_eq!( Auctions::auction_status(System::block_number()), @@ -1576,7 +1576,7 @@ mod tests { assert_eq!(Auctions::winning(0), Some(winning)); // New bids update the current winning - assert_ok!(Auctions::bid(Origin::signed(3), para_3, 1, 14, 14, 30)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 14, 14, 30)); winning[SlotRange::ThreeThree as u8 as usize] = Some((3, para_3, 30)); assert_eq!(Auctions::winning(0), Some(winning)); @@ -1588,7 +1588,7 @@ mod tests { assert_eq!(Auctions::winning(1), Some(winning)); run_to_block(25); // Overbid mid sample - assert_ok!(Auctions::bid(Origin::signed(3), para_3, 1, 13, 14, 30)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 13, 14, 30)); winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 30)); assert_eq!(Auctions::winning(1), Some(winning)); @@ -1629,7 +1629,7 @@ mod tests { ); run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 9, 11)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 11)); run_to_block(9); assert_eq!( @@ -1704,13 +1704,13 @@ mod tests { fn can_cancel_auction() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); - assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 1, 4, 1)); + assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1)); + assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1)); assert_eq!(Balances::reserved_balance(1), 1); assert_eq!(Balances::free_balance(1), 9); - assert_noop!(Auctions::cancel_auction(Origin::signed(6)), BadOrigin); - assert_ok!(Auctions::cancel_auction(Origin::root())); + assert_noop!(Auctions::cancel_auction(RuntimeOrigin::signed(6)), BadOrigin); + assert_ok!(Auctions::cancel_auction(RuntimeOrigin::root())); assert!(AuctionInfo::::get().is_none()); assert_eq!(Balances::reserved_balance(1), 0); @@ -1729,9 +1729,9 @@ mod benchmarking { use frame_benchmarking::{account, benchmarks, whitelisted_caller}; - fn assert_last_event(generic_event: ::Event) { + fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(event, &system_event); @@ -1784,7 +1784,7 @@ mod benchmarking { let duration = T::BlockNumber::max_value(); let lease_period_index = LeasePeriodOf::::max_value(); let origin = T::InitiateOrigin::successful_origin(); - }: _(origin, duration, lease_period_index) + }: _(origin, duration, lease_period_index) verify { assert_last_event::(Event::::AuctionStarted { auction_index: AuctionCounter::::get(), diff --git a/runtime/common/src/claims.rs b/runtime/common/src/claims.rs index e2731f9336cc..bb0663ec34f7 100644 --- a/runtime/common/src/claims.rs +++ b/runtime/common/src/claims.rs @@ -55,19 +55,19 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn claim() -> Weight { - 0 + Weight::zero() } fn mint_claim() -> Weight { - 0 + Weight::zero() } fn claim_attest() -> Weight { - 0 + Weight::zero() } fn attest() -> Weight { - 0 + Weight::zero() } fn move_claim() -> Weight { - 0 + Weight::zero() } } @@ -172,11 +172,11 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; type VestingSchedule: VestingSchedule; #[pallet::constant] type Prefix: Get<&'static [u8]>; - type MoveClaimOrigin: EnsureOrigin; + type MoveClaimOrigin: EnsureOrigin; type WeightInfo: WeightInfo; } @@ -597,11 +597,11 @@ impl Pallet { #[scale_info(skip_type_params(T))] pub struct PrevalidateAttests(sp_std::marker::PhantomData) where - ::Call: IsSubType>; + ::RuntimeCall: IsSubType>; impl Debug for PrevalidateAttests where - ::Call: IsSubType>, + ::RuntimeCall: IsSubType>, { #[cfg(feature = "std")] fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { @@ -616,7 +616,7 @@ where impl PrevalidateAttests where - ::Call: IsSubType>, + ::RuntimeCall: IsSubType>, { /// Create new `SignedExtension` to check runtime version. pub fn new() -> Self { @@ -626,10 +626,10 @@ where impl SignedExtension for PrevalidateAttests where - ::Call: IsSubType>, + ::RuntimeCall: IsSubType>, { type AccountId = T::AccountId; - type Call = ::Call; + type Call = ::RuntimeCall; type AdditionalSigned = (); type Pre = (); const IDENTIFIER: &'static str = "PrevalidateAttests"; @@ -715,10 +715,9 @@ mod tests { use claims::Call as ClaimsCall; use frame_support::{ assert_err, assert_noop, assert_ok, - dispatch::DispatchError::BadOrigin, + dispatch::{DispatchError::BadOrigin, GetDispatchInfo, Pays}, ord_parameter_types, parameter_types, - traits::{ExistenceRequirement, GenesisBuild}, - weights::{GetDispatchInfo, Pays}, + traits::{ExistenceRequirement, GenesisBuild, WithdrawReasons}, }; use pallet_balances; use sp_runtime::{ @@ -751,8 +750,8 @@ mod tests { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -760,7 +759,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -779,7 +778,7 @@ mod tests { impl pallet_balances::Config for Test { type Balance = u64; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -791,14 +790,17 @@ mod tests { parameter_types! { pub const MinVestedTransfer: u64 = 1; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } impl pallet_vesting::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BlockNumberToBalance = Identity; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = (); + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; const MAX_VESTING_SCHEDULES: u32 = 28; } @@ -810,7 +812,7 @@ mod tests { } impl Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type VestingSchedule = Vesting; type Prefix = Prefix; type MoveClaimOrigin = frame_system::EnsureSignedBy; @@ -886,7 +888,7 @@ mod tests { new_test_ext().execute_with(|| { assert_eq!(Balances::free_balance(42), 0); assert_ok!(Claims::claim( - Origin::none(), + RuntimeOrigin::none(), 42, sig::(&alice(), &42u64.encode(), &[][..]) )); @@ -901,16 +903,25 @@ mod tests { new_test_ext().execute_with(|| { assert_eq!(Balances::free_balance(42), 0); assert_noop!( - Claims::move_claim(Origin::signed(1), eth(&alice()), eth(&bob()), None), + Claims::move_claim(RuntimeOrigin::signed(1), eth(&alice()), eth(&bob()), None), BadOrigin ); - assert_ok!(Claims::move_claim(Origin::signed(6), eth(&alice()), eth(&bob()), None)); + assert_ok!(Claims::move_claim( + RuntimeOrigin::signed(6), + eth(&alice()), + eth(&bob()), + None + )); assert_noop!( - Claims::claim(Origin::none(), 42, sig::(&alice(), &42u64.encode(), &[][..])), + Claims::claim( + RuntimeOrigin::none(), + 42, + sig::(&alice(), &42u64.encode(), &[][..]) + ), Error::::SignerHasNoClaim ); assert_ok!(Claims::claim( - Origin::none(), + RuntimeOrigin::none(), 42, sig::(&bob(), &42u64.encode(), &[][..]) )); @@ -923,10 +934,15 @@ mod tests { #[test] fn claim_attest_moving_works() { new_test_ext().execute_with(|| { - assert_ok!(Claims::move_claim(Origin::signed(6), eth(&dave()), eth(&bob()), None)); + assert_ok!(Claims::move_claim( + RuntimeOrigin::signed(6), + eth(&dave()), + eth(&bob()), + None + )); let s = sig::(&bob(), &42u64.encode(), StatementKind::Regular.to_text()); assert_ok!(Claims::claim_attest( - Origin::none(), + RuntimeOrigin::none(), 42, s, StatementKind::Regular.to_text().to_vec() @@ -938,8 +954,16 @@ mod tests { #[test] fn attest_moving_works() { new_test_ext().execute_with(|| { - assert_ok!(Claims::move_claim(Origin::signed(6), eth(&eve()), eth(&bob()), Some(42))); - assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec())); + assert_ok!(Claims::move_claim( + RuntimeOrigin::signed(6), + eth(&eve()), + eth(&bob()), + Some(42) + )); + assert_ok!(Claims::attest( + RuntimeOrigin::signed(42), + StatementKind::Saft.to_text().to_vec() + )); assert_eq!(Balances::free_balance(&42), 300); }); } @@ -948,20 +972,28 @@ mod tests { fn claiming_does_not_bypass_signing() { new_test_ext().execute_with(|| { assert_ok!(Claims::claim( - Origin::none(), + RuntimeOrigin::none(), 42, sig::(&alice(), &42u64.encode(), &[][..]) )); assert_noop!( - Claims::claim(Origin::none(), 42, sig::(&dave(), &42u64.encode(), &[][..])), + Claims::claim( + RuntimeOrigin::none(), + 42, + sig::(&dave(), &42u64.encode(), &[][..]) + ), Error::::InvalidStatement, ); assert_noop!( - Claims::claim(Origin::none(), 42, sig::(&eve(), &42u64.encode(), &[][..])), + Claims::claim( + RuntimeOrigin::none(), + 42, + sig::(&eve(), &42u64.encode(), &[][..]) + ), Error::::InvalidStatement, ); assert_ok!(Claims::claim( - Origin::none(), + RuntimeOrigin::none(), 42, sig::(&frank(), &42u64.encode(), &[][..]) )); @@ -974,7 +1006,7 @@ mod tests { assert_eq!(Balances::free_balance(42), 0); let s = sig::(&dave(), &42u64.encode(), StatementKind::Saft.to_text()); let r = Claims::claim_attest( - Origin::none(), + RuntimeOrigin::none(), 42, s.clone(), StatementKind::Saft.to_text().to_vec(), @@ -982,7 +1014,7 @@ mod tests { assert_noop!(r, Error::::InvalidStatement); let r = Claims::claim_attest( - Origin::none(), + RuntimeOrigin::none(), 42, s, StatementKind::Regular.to_text().to_vec(), @@ -993,7 +1025,7 @@ mod tests { let s = sig::(&dave(), &42u64.encode(), StatementKind::Regular.to_text()); assert_ok!(Claims::claim_attest( - Origin::none(), + RuntimeOrigin::none(), 42, s, StatementKind::Regular.to_text().to_vec() @@ -1003,7 +1035,7 @@ mod tests { let s = sig::(&dave(), &42u64.encode(), StatementKind::Regular.to_text()); let r = Claims::claim_attest( - Origin::none(), + RuntimeOrigin::none(), 42, s, StatementKind::Regular.to_text().to_vec(), @@ -1017,14 +1049,20 @@ mod tests { new_test_ext().execute_with(|| { assert_eq!(Balances::free_balance(42), 0); assert_noop!( - Claims::attest(Origin::signed(69), StatementKind::Saft.to_text().to_vec()), + Claims::attest(RuntimeOrigin::signed(69), StatementKind::Saft.to_text().to_vec()), Error::::SenderHasNoClaim ); assert_noop!( - Claims::attest(Origin::signed(42), StatementKind::Regular.to_text().to_vec()), + Claims::attest( + RuntimeOrigin::signed(42), + StatementKind::Regular.to_text().to_vec() + ), Error::::InvalidStatement ); - assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec())); + assert_ok!(Claims::attest( + RuntimeOrigin::signed(42), + StatementKind::Saft.to_text().to_vec() + )); assert_eq!(Balances::free_balance(&42), 300); assert_eq!(Claims::total(), total_claims() - 300); }); @@ -1036,13 +1074,16 @@ mod tests { assert_eq!(Balances::free_balance(42), 0); // Alice's claim is 100 assert_ok!(Claims::claim( - Origin::none(), + RuntimeOrigin::none(), 42, sig::(&alice(), &42u64.encode(), &[][..]) )); assert_eq!(Balances::free_balance(&42), 100); // Eve's claim is 300 through Account 42 - assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec())); + assert_ok!(Claims::attest( + RuntimeOrigin::signed(42), + StatementKind::Saft.to_text().to_vec() + )); assert_eq!(Balances::free_balance(&42), 100 + 300); assert_eq!(Claims::total(), total_claims() - 400); }); @@ -1052,7 +1093,7 @@ mod tests { fn valid_attest_transactions_are_free() { new_test_ext().execute_with(|| { let p = PrevalidateAttests::::new(); - let c = Call::Claims(ClaimsCall::attest { + let c = RuntimeCall::Claims(ClaimsCall::attest { statement: StatementKind::Saft.to_text().to_vec(), }); let di = c.get_dispatch_info(); @@ -1066,13 +1107,13 @@ mod tests { fn invalid_attest_transactions_are_recognized() { new_test_ext().execute_with(|| { let p = PrevalidateAttests::::new(); - let c = Call::Claims(ClaimsCall::attest { + let c = RuntimeCall::Claims(ClaimsCall::attest { statement: StatementKind::Regular.to_text().to_vec(), }); let di = c.get_dispatch_info(); let r = p.validate(&42, &c, &di, 20); assert!(r.is_err()); - let c = Call::Claims(ClaimsCall::attest { + let c = RuntimeCall::Claims(ClaimsCall::attest { statement: StatementKind::Saft.to_text().to_vec(), }); let di = c.get_dispatch_info(); @@ -1086,7 +1127,7 @@ mod tests { new_test_ext().execute_with(|| { assert_eq!(Balances::free_balance(42), 0); let s = sig::(&dave(), &42u64.encode(), &[]); - let r = Claims::claim(Origin::none(), 42, s.clone()); + let r = Claims::claim(RuntimeOrigin::none(), 42, s.clone()); assert_noop!(r, Error::::InvalidStatement); }); } @@ -1095,18 +1136,22 @@ mod tests { fn add_claim_works() { new_test_ext().execute_with(|| { assert_noop!( - Claims::mint_claim(Origin::signed(42), eth(&bob()), 200, None, None), + Claims::mint_claim(RuntimeOrigin::signed(42), eth(&bob()), 200, None, None), sp_runtime::traits::BadOrigin, ); assert_eq!(Balances::free_balance(42), 0); assert_noop!( - Claims::claim(Origin::none(), 69, sig::(&bob(), &69u64.encode(), &[][..])), + Claims::claim( + RuntimeOrigin::none(), + 69, + sig::(&bob(), &69u64.encode(), &[][..]) + ), Error::::SignerHasNoClaim, ); - assert_ok!(Claims::mint_claim(Origin::root(), eth(&bob()), 200, None, None)); + assert_ok!(Claims::mint_claim(RuntimeOrigin::root(), eth(&bob()), 200, None, None)); assert_eq!(Claims::total(), total_claims() + 200); assert_ok!(Claims::claim( - Origin::none(), + RuntimeOrigin::none(), 69, sig::(&bob(), &69u64.encode(), &[][..]) )); @@ -1120,23 +1165,33 @@ mod tests { fn add_claim_with_vesting_works() { new_test_ext().execute_with(|| { assert_noop!( - Claims::mint_claim(Origin::signed(42), eth(&bob()), 200, Some((50, 10, 1)), None), + Claims::mint_claim( + RuntimeOrigin::signed(42), + eth(&bob()), + 200, + Some((50, 10, 1)), + None + ), sp_runtime::traits::BadOrigin, ); assert_eq!(Balances::free_balance(42), 0); assert_noop!( - Claims::claim(Origin::none(), 69, sig::(&bob(), &69u64.encode(), &[][..])), + Claims::claim( + RuntimeOrigin::none(), + 69, + sig::(&bob(), &69u64.encode(), &[][..]) + ), Error::::SignerHasNoClaim, ); assert_ok!(Claims::mint_claim( - Origin::root(), + RuntimeOrigin::root(), eth(&bob()), 200, Some((50, 10, 1)), None )); assert_ok!(Claims::claim( - Origin::none(), + RuntimeOrigin::none(), 69, sig::(&bob(), &69u64.encode(), &[][..]) )); @@ -1161,7 +1216,7 @@ mod tests { new_test_ext().execute_with(|| { assert_noop!( Claims::mint_claim( - Origin::signed(42), + RuntimeOrigin::signed(42), eth(&bob()), 200, None, @@ -1173,7 +1228,7 @@ mod tests { let signature = sig::(&bob(), &69u64.encode(), StatementKind::Regular.to_text()); assert_noop!( Claims::claim_attest( - Origin::none(), + RuntimeOrigin::none(), 69, signature.clone(), StatementKind::Regular.to_text().to_vec() @@ -1181,18 +1236,18 @@ mod tests { Error::::SignerHasNoClaim ); assert_ok!(Claims::mint_claim( - Origin::root(), + RuntimeOrigin::root(), eth(&bob()), 200, None, Some(StatementKind::Regular) )); assert_noop!( - Claims::claim_attest(Origin::none(), 69, signature.clone(), vec![],), + Claims::claim_attest(RuntimeOrigin::none(), 69, signature.clone(), vec![],), Error::::SignerHasNoClaim ); assert_ok!(Claims::claim_attest( - Origin::none(), + RuntimeOrigin::none(), 69, signature.clone(), StatementKind::Regular.to_text().to_vec() @@ -1207,7 +1262,7 @@ mod tests { assert_eq!(Balances::free_balance(42), 0); assert_err!( Claims::claim( - Origin::signed(42), + RuntimeOrigin::signed(42), 42, sig::(&alice(), &42u64.encode(), &[][..]) ), @@ -1221,12 +1276,16 @@ mod tests { new_test_ext().execute_with(|| { assert_eq!(Balances::free_balance(42), 0); assert_ok!(Claims::claim( - Origin::none(), + RuntimeOrigin::none(), 42, sig::(&alice(), &42u64.encode(), &[][..]) )); assert_noop!( - Claims::claim(Origin::none(), 42, sig::(&alice(), &42u64.encode(), &[][..])), + Claims::claim( + RuntimeOrigin::none(), + 42, + sig::(&alice(), &42u64.encode(), &[][..]) + ), Error::::SignerHasNoClaim ); }); @@ -1245,7 +1304,7 @@ mod tests { CurrencyOf::::make_free_balance_be(&69, total_claims()); assert_eq!(Balances::free_balance(69), total_claims()); assert_ok!(Claims::mint_claim( - Origin::root(), + RuntimeOrigin::root(), eth(&bob()), 200, Some((50, 10, 1)), @@ -1256,7 +1315,11 @@ mod tests { // They should not be able to claim assert_noop!( - Claims::claim(Origin::none(), 69, sig::(&bob(), &69u64.encode(), &[][..])), + Claims::claim( + RuntimeOrigin::none(), + 69, + sig::(&bob(), &69u64.encode(), &[][..]) + ), Error::::VestedBalanceExists, ); }); @@ -1267,7 +1330,11 @@ mod tests { new_test_ext().execute_with(|| { assert_eq!(Balances::free_balance(42), 0); assert_noop!( - Claims::claim(Origin::none(), 42, sig::(&alice(), &69u64.encode(), &[][..])), + Claims::claim( + RuntimeOrigin::none(), + 42, + sig::(&alice(), &69u64.encode(), &[][..]) + ), Error::::SignerHasNoClaim ); }); @@ -1278,7 +1345,11 @@ mod tests { new_test_ext().execute_with(|| { assert_eq!(Balances::free_balance(42), 0); assert_noop!( - Claims::claim(Origin::none(), 42, sig::(&bob(), &69u64.encode(), &[][..])), + Claims::claim( + RuntimeOrigin::none(), + 42, + sig::(&bob(), &69u64.encode(), &[][..]) + ), Error::::SignerHasNoClaim ); }); diff --git a/runtime/common/src/crowdloan/migration.rs b/runtime/common/src/crowdloan/migration.rs index 1d29b4a68200..775d70f92458 100644 --- a/runtime/common/src/crowdloan/migration.rs +++ b/runtime/common/src/crowdloan/migration.rs @@ -90,7 +90,7 @@ pub mod crowdloan_index_migration { /// This migration converts crowdloans to use a crowdloan index rather than the parachain id as a /// unique identifier. This makes it easier to swap two crowdloans between parachains. pub fn migrate() -> frame_support::weights::Weight { - let mut weight = 0; + let mut weight = Weight::zero(); // First migrate `NextTrieIndex` counter to `NextFundIndex`. diff --git a/runtime/common/src/crowdloan/mod.rs b/runtime/common/src/crowdloan/mod.rs index 4b2c29f5398d..1f84af3f2ee9 100644 --- a/runtime/common/src/crowdloan/mod.rs +++ b/runtime/common/src/crowdloan/mod.rs @@ -106,31 +106,31 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn create() -> Weight { - 0 + Weight::zero() } fn contribute() -> Weight { - 0 + Weight::zero() } fn withdraw() -> Weight { - 0 + Weight::zero() } fn refund(_k: u32) -> Weight { - 0 + Weight::zero() } fn dissolve() -> Weight { - 0 + Weight::zero() } fn edit() -> Weight { - 0 + Weight::zero() } fn add_memo() -> Weight { - 0 + Weight::zero() } fn on_initialize(_n: u32) -> Weight { - 0 + Weight::zero() } fn poke() -> Weight { - 0 + Weight::zero() } } @@ -189,7 +189,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// `PalletId` for the crowdloan pallet. An appropriate value could be `PalletId(*b"py/cfund")` #[pallet::constant] @@ -892,8 +892,8 @@ mod tests { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = BlockNumber; type Hash = H256; @@ -901,7 +901,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -920,7 +920,7 @@ mod tests { impl pallet_balances::Config for Test { type Balance = u64; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -1072,7 +1072,7 @@ mod tests { } impl Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type SubmissionDeposit = SubmissionDeposit; type MinContribution = MinContribution; type PalletId = CrowdloanPalletId; @@ -1129,8 +1129,8 @@ mod tests { } } - fn last_event() -> Event { - System::events().pop().expect("Event expected").event + fn last_event() -> RuntimeEvent { + System::events().pop().expect("RuntimeEvent expected").event } #[test] @@ -1168,7 +1168,7 @@ mod tests { new_test_ext().execute_with(|| { let para = new_para(); // Now try to create a crowdloan campaign - assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 9, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 9, None)); // This is what the initial `fund_info` should look like let fund_info = FundInfo { depositor: 1, @@ -1201,7 +1201,7 @@ mod tests { let para = new_para(); // Now try to create a crowdloan campaign assert_ok!(Crowdloan::create( - Origin::signed(1), + RuntimeOrigin::signed(1), para, 1000, 1, @@ -1241,12 +1241,15 @@ mod tests { let para = new_para(); let e = Error::::InvalidParaId; - assert_noop!(Crowdloan::create(Origin::signed(1), 1.into(), 1000, 1, 4, 9, None), e); + assert_noop!( + Crowdloan::create(RuntimeOrigin::signed(1), 1.into(), 1000, 1, 4, 9, None), + e + ); // Cannot create a crowdloan with bad lease periods let e = Error::::LastPeriodBeforeFirstPeriod; - assert_noop!(Crowdloan::create(Origin::signed(1), para, 1000, 4, 1, 9, None), e); + assert_noop!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 4, 1, 9, None), e); let e = Error::::LastPeriodTooFarInFuture; - assert_noop!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 9, 9, None), e); + assert_noop!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 9, 9, None), e); // Cannot create a crowdloan without some deposit funds assert_ok!(TestRegistrar::::register( @@ -1257,14 +1260,22 @@ mod tests { )); let e = BalancesError::::InsufficientBalance; assert_noop!( - Crowdloan::create(Origin::signed(1337), ParaId::from(1234), 1000, 1, 3, 9, None), + Crowdloan::create( + RuntimeOrigin::signed(1337), + ParaId::from(1234), + 1000, + 1, + 3, + 9, + None + ), e ); // Cannot create a crowdloan with nonsense end date // This crowdloan would end in lease period 2, but is bidding for some slot that starts in lease period 1. assert_noop!( - Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 41, None), + Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 41, None), Error::::EndTooFarInFuture ); }); @@ -1277,13 +1288,13 @@ mod tests { let index = NextFundIndex::::get(); // Set up a crowdloan - assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 9, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 9, None)); // No contributions yet assert_eq!(Crowdloan::contribution_get(u32::from(para), &1).0, 0); // User 1 contributes to their own crowdloan - assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 49, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None)); // User 1 has spent some funds to do this, transfer fees **are** taken assert_eq!(Balances::free_balance(1), 950); // Contributions are stored in the trie @@ -1309,7 +1320,7 @@ mod tests { let pubkey = crypto::create_ed25519_pubkey(b"//verifier".to_vec()); // Set up a crowdloan assert_ok!(Crowdloan::create( - Origin::signed(1), + RuntimeOrigin::signed(1), para, 1000, 1, @@ -1323,7 +1334,7 @@ mod tests { // Missing signature assert_noop!( - Crowdloan::contribute(Origin::signed(1), para, 49, None), + Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None), Error::::InvalidSignature ); @@ -1335,23 +1346,33 @@ mod tests { // Invalid signature assert_noop!( - Crowdloan::contribute(Origin::signed(1), para, 49, Some(invalid_signature)), + Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, Some(invalid_signature)), Error::::InvalidSignature ); // Valid signature wrong parameter assert_noop!( - Crowdloan::contribute(Origin::signed(1), para, 50, Some(valid_signature.clone())), + Crowdloan::contribute( + RuntimeOrigin::signed(1), + para, + 50, + Some(valid_signature.clone()) + ), Error::::InvalidSignature ); assert_noop!( - Crowdloan::contribute(Origin::signed(2), para, 49, Some(valid_signature.clone())), + Crowdloan::contribute( + RuntimeOrigin::signed(2), + para, + 49, + Some(valid_signature.clone()) + ), Error::::InvalidSignature ); // Valid signature assert_ok!(Crowdloan::contribute( - Origin::signed(1), + RuntimeOrigin::signed(1), para, 49, Some(valid_signature.clone()) @@ -1359,7 +1380,7 @@ mod tests { // Reuse valid signature assert_noop!( - Crowdloan::contribute(Origin::signed(1), para, 49, Some(valid_signature)), + Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, Some(valid_signature)), Error::::InvalidSignature ); @@ -1367,7 +1388,12 @@ mod tests { let valid_signature_2 = crypto::create_ed25519_signature(&payload_2.encode(), pubkey); // New valid signature - assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 10, Some(valid_signature_2))); + assert_ok!(Crowdloan::contribute( + RuntimeOrigin::signed(1), + para, + 10, + Some(valid_signature_2) + )); // Contributions appear in free balance of crowdloan assert_eq!(Balances::free_balance(Crowdloan::fund_account_id(index)), 59); @@ -1385,22 +1411,22 @@ mod tests { // Cannot contribute to non-existing fund assert_noop!( - Crowdloan::contribute(Origin::signed(1), para, 49, None), + Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None), Error::::InvalidParaId ); // Cannot contribute below minimum contribution assert_noop!( - Crowdloan::contribute(Origin::signed(1), para, 9, None), + Crowdloan::contribute(RuntimeOrigin::signed(1), para, 9, None), Error::::ContributionTooSmall ); // Set up a crowdloan - assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 4, 9, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 101, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 4, 9, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para, 101, None)); // Cannot contribute past the limit assert_noop!( - Crowdloan::contribute(Origin::signed(2), para, 900, None), + Crowdloan::contribute(RuntimeOrigin::signed(2), para, 900, None), Error::::CapExceeded ); @@ -1409,31 +1435,31 @@ mod tests { // Cannot contribute to ended fund assert_noop!( - Crowdloan::contribute(Origin::signed(1), para, 49, None), + Crowdloan::contribute(RuntimeOrigin::signed(1), para, 49, None), Error::::ContributionPeriodOver ); // If a crowdloan has already won, it should not allow contributions. let para_2 = new_para(); let index = NextFundIndex::::get(); - assert_ok!(Crowdloan::create(Origin::signed(1), para_2, 1000, 1, 4, 40, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_2, 1000, 1, 4, 40, None)); // Emulate a win by leasing out and putting a deposit. Slots pallet would normally do this. let crowdloan_account = Crowdloan::fund_account_id(index); set_winner(para_2, crowdloan_account, true); assert_noop!( - Crowdloan::contribute(Origin::signed(1), para_2, 49, None), + Crowdloan::contribute(RuntimeOrigin::signed(1), para_2, 49, None), Error::::BidOrLeaseActive ); // Move past lease period 1, should not be allowed to have further contributions with a crowdloan // that has starting period 1. let para_3 = new_para(); - assert_ok!(Crowdloan::create(Origin::signed(1), para_3, 1000, 1, 4, 40, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_3, 1000, 1, 4, 40, None)); run_to_block(40); let now = System::block_number(); assert_eq!(TestAuctioneer::lease_period_index(now).unwrap().0, 2); assert_noop!( - Crowdloan::contribute(Origin::signed(1), para_3, 49, None), + Crowdloan::contribute(RuntimeOrigin::signed(1), para_3, 49, None), Error::::ContributionPeriodOver ); }); @@ -1452,7 +1478,7 @@ mod tests { // Set up a crowdloan assert_ok!(Crowdloan::create( - Origin::signed(1), + RuntimeOrigin::signed(1), para, 1000, first_period, @@ -1464,20 +1490,20 @@ mod tests { run_to_block(8); // Can def contribute when auction is running. assert!(TestAuctioneer::auction_status(System::block_number()).is_ending().is_some()); - assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 250, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None)); run_to_block(10); // Can't contribute when auction is in the VRF delay period. assert!(TestAuctioneer::auction_status(System::block_number()).is_vrf()); assert_noop!( - Crowdloan::contribute(Origin::signed(2), para, 250, None), + Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None), Error::::VrfDelayInProgress ); run_to_block(15); // Its fine to contribute when no auction is running. assert!(!TestAuctioneer::auction_status(System::block_number()).is_in_progress()); - assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 250, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None)); }) } @@ -1493,7 +1519,7 @@ mod tests { // Set up a crowdloan assert_ok!(Crowdloan::create( - Origin::signed(1), + RuntimeOrigin::signed(1), para, 1000, first_period, @@ -1505,13 +1531,13 @@ mod tests { // Fund crowdloan run_to_block(1); - assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None)); run_to_block(3); - assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 150, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 150, None)); run_to_block(5); - assert_ok!(Crowdloan::contribute(Origin::signed(4), para, 200, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(4), para, 200, None)); run_to_block(8); - assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 250, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 250, None)); run_to_block(10); assert_eq!( @@ -1535,9 +1561,9 @@ mod tests { let index = NextFundIndex::::get(); // Set up a crowdloan - assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None)); run_to_block(10); let account_id = Crowdloan::fund_account_id(index); @@ -1548,11 +1574,11 @@ mod tests { assert_eq!(Balances::free_balance(2), 1900); assert_eq!(Balances::free_balance(3), 2950); - assert_ok!(Crowdloan::withdraw(Origin::signed(2), 2, para)); + assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para)); assert_eq!(Balances::free_balance(&account_id), 50); assert_eq!(Balances::free_balance(2), 2000); - assert_ok!(Crowdloan::withdraw(Origin::signed(2), 3, para)); + assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 3, para)); assert_eq!(Balances::free_balance(&account_id), 0); assert_eq!(Balances::free_balance(3), 3000); }); @@ -1565,26 +1591,26 @@ mod tests { let index = NextFundIndex::::get(); // Set up a crowdloan - assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None)); run_to_block(10); let account_id = Crowdloan::fund_account_id(index); // user sends the crowdloan funds trying to make an accounting error - assert_ok!(Balances::transfer(Origin::signed(1), account_id, 10)); + assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), account_id, 10)); // overfunded now assert_eq!(Balances::free_balance(&account_id), 110); assert_eq!(Balances::free_balance(2), 1900); - assert_ok!(Crowdloan::withdraw(Origin::signed(2), 2, para)); + assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para)); assert_eq!(Balances::free_balance(2), 2000); // Some funds are left over assert_eq!(Balances::free_balance(&account_id), 10); // They wil be left in the account at the end - assert_ok!(Crowdloan::dissolve(Origin::signed(1), para)); + assert_ok!(Crowdloan::dissolve(RuntimeOrigin::signed(1), para)); assert_eq!(Balances::free_balance(&account_id), 10); }); } @@ -1597,23 +1623,23 @@ mod tests { let account_id = Crowdloan::fund_account_id(index); // Set up a crowdloan ending on 9 - assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None)); // Make some contributions - assert_ok!(Crowdloan::contribute(Origin::signed(1), para, 100, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 200, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 300, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para, 100, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 200, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 300, None)); assert_eq!(Balances::free_balance(account_id), 600); // Can't refund before the crowdloan it has ended assert_noop!( - Crowdloan::refund(Origin::signed(1337), para), + Crowdloan::refund(RuntimeOrigin::signed(1337), para), Error::::FundNotEnded, ); // Move to the end of the crowdloan run_to_block(10); - assert_ok!(Crowdloan::refund(Origin::signed(1337), para)); + assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(1337), para)); // Funds are returned assert_eq!(Balances::free_balance(account_id), 0); @@ -1632,12 +1658,12 @@ mod tests { let account_id = Crowdloan::fund_account_id(index); // Set up a crowdloan ending on 9 - assert_ok!(Crowdloan::create(Origin::signed(1), para, 100000, 1, 1, 9, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 100000, 1, 1, 9, None)); // Make more contributions than our limit for i in 1..=RemoveKeysLimit::get() * 2 { Balances::make_free_balance_be(&i.into(), (1000 * i).into()); assert_ok!(Crowdloan::contribute( - Origin::signed(i.into()), + RuntimeOrigin::signed(i.into()), para, (i * 100).into(), None @@ -1648,7 +1674,7 @@ mod tests { // Move to the end of the crowdloan run_to_block(10); - assert_ok!(Crowdloan::refund(Origin::signed(1337), para)); + assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(1337), para)); assert_eq!( last_event(), super::Event::::PartiallyRefunded { para_id: para }.into() @@ -1658,7 +1684,7 @@ mod tests { assert!(!Balances::free_balance(account_id).is_zero()); // Call again - assert_ok!(Crowdloan::refund(Origin::signed(1337), para)); + assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(1337), para)); assert_eq!(last_event(), super::Event::::AllRefunded { para_id: para }.into()); // Funds are returned @@ -1677,16 +1703,16 @@ mod tests { let issuance = Balances::total_issuance(); // Set up a crowdloan - assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None)); run_to_block(10); // All funds are refunded - assert_ok!(Crowdloan::refund(Origin::signed(2), para)); + assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(2), para)); // Now that `fund.raised` is zero, it can be dissolved. - assert_ok!(Crowdloan::dissolve(Origin::signed(1), para)); + assert_ok!(Crowdloan::dissolve(RuntimeOrigin::signed(1), para)); assert_eq!(Balances::free_balance(1), 1000); assert_eq!(Balances::free_balance(2), 2000); assert_eq!(Balances::free_balance(3), 3000); @@ -1701,13 +1727,13 @@ mod tests { let issuance = Balances::total_issuance(); // Set up a crowdloan - assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None)); // Can't dissolve before it ends assert_noop!( - Crowdloan::dissolve(Origin::signed(1), para), + Crowdloan::dissolve(RuntimeOrigin::signed(1), para), Error::::NotReadyToDissolve ); @@ -1715,22 +1741,22 @@ mod tests { set_winner(para, 1, true); // Can't dissolve when it won. assert_noop!( - Crowdloan::dissolve(Origin::signed(1), para), + Crowdloan::dissolve(RuntimeOrigin::signed(1), para), Error::::NotReadyToDissolve ); set_winner(para, 1, false); // Can't dissolve while it still has user funds assert_noop!( - Crowdloan::dissolve(Origin::signed(1), para), + Crowdloan::dissolve(RuntimeOrigin::signed(1), para), Error::::NotReadyToDissolve ); // All funds are refunded - assert_ok!(Crowdloan::refund(Origin::signed(2), para)); + assert_ok!(Crowdloan::refund(RuntimeOrigin::signed(2), para)); // Now that `fund.raised` is zero, it can be dissolved. - assert_ok!(Crowdloan::dissolve(Origin::signed(1), para)); + assert_ok!(Crowdloan::dissolve(RuntimeOrigin::signed(1), para)); assert_eq!(Balances::free_balance(1), 1000); assert_eq!(Balances::free_balance(2), 2000); assert_eq!(Balances::free_balance(3), 3000); @@ -1746,17 +1772,17 @@ mod tests { let account_id = Crowdloan::fund_account_id(index); // Set up a crowdloan - assert_ok!(Crowdloan::create(Origin::signed(1), para, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para, 1000, 1, 1, 9, None)); // Fund crowdloans. - assert_ok!(Crowdloan::contribute(Origin::signed(2), para, 100, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(3), para, 50, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None)); // simulate the reserving of para's funds. this actually happens in the Slots pallet. assert_ok!(Balances::reserve(&account_id, 150)); run_to_block(19); assert_noop!( - Crowdloan::withdraw(Origin::signed(2), 2, para), + Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para), Error::::BidOrLeaseActive ); @@ -1772,11 +1798,11 @@ mod tests { assert_eq!(Balances::free_balance(2), 1900); assert_eq!(Balances::free_balance(3), 2950); - assert_ok!(Crowdloan::withdraw(Origin::signed(2), 2, para)); + assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 2, para)); assert_eq!(Balances::free_balance(&account_id), 50); assert_eq!(Balances::free_balance(2), 2000); - assert_ok!(Crowdloan::withdraw(Origin::signed(2), 3, para)); + assert_ok!(Crowdloan::withdraw(RuntimeOrigin::signed(2), 3, para)); assert_eq!(Balances::free_balance(&account_id), 0); assert_eq!(Balances::free_balance(3), 3000); }); @@ -1789,11 +1815,11 @@ mod tests { let para_2 = new_para(); // Set up crowdloans - assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None)); - assert_ok!(Crowdloan::create(Origin::signed(1), para_2, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_2, 1000, 1, 1, 9, None)); // Different contributions - assert_ok!(Crowdloan::contribute(Origin::signed(2), para_1, 100, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(3), para_2, 50, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para_1, 100, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para_2, 50, None)); // Original state assert_eq!(Funds::::get(para_1).unwrap().raised, 100); assert_eq!(Funds::::get(para_2).unwrap().raised, 50); @@ -1810,10 +1836,10 @@ mod tests { new_test_ext().execute_with(|| { let para_1 = new_para(); - assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None)); // Cannot create a fund again assert_noop!( - Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None), + Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None), Error::::FundNotEnded, ); }); @@ -1824,11 +1850,11 @@ mod tests { new_test_ext().execute_with(|| { let para_1 = new_para(); - assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None)); - assert_ok!(Crowdloan::contribute(Origin::signed(2), para_1, 100, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para_1, 100, None)); let old_crowdloan = Crowdloan::funds(para_1).unwrap(); - assert_ok!(Crowdloan::edit(Origin::root(), para_1, 1234, 2, 3, 4, None)); + assert_ok!(Crowdloan::edit(RuntimeOrigin::root(), para_1, 1234, 2, 3, 4, None)); let new_crowdloan = Crowdloan::funds(para_1).unwrap(); // Some things stay the same @@ -1848,25 +1874,29 @@ mod tests { new_test_ext().execute_with(|| { let para_1 = new_para(); - assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None)); // Cant add a memo before you have contributed. assert_noop!( - Crowdloan::add_memo(Origin::signed(1), para_1, b"hello, world".to_vec()), + Crowdloan::add_memo(RuntimeOrigin::signed(1), para_1, b"hello, world".to_vec()), Error::::NoContributions, ); // Make a contribution. Initially no memo. - assert_ok!(Crowdloan::contribute(Origin::signed(1), para_1, 100, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para_1, 100, None)); assert_eq!(Crowdloan::contribution_get(0u32, &1), (100, vec![])); // Can't place a memo that is too large. assert_noop!( - Crowdloan::add_memo(Origin::signed(1), para_1, vec![123; 123]), + Crowdloan::add_memo(RuntimeOrigin::signed(1), para_1, vec![123; 123]), Error::::MemoTooLarge, ); // Adding a memo to an existing contribution works - assert_ok!(Crowdloan::add_memo(Origin::signed(1), para_1, b"hello, world".to_vec())); + assert_ok!(Crowdloan::add_memo( + RuntimeOrigin::signed(1), + para_1, + b"hello, world".to_vec() + )); assert_eq!(Crowdloan::contribution_get(0u32, &1), (100, b"hello, world".to_vec())); // Can contribute again and data persists - assert_ok!(Crowdloan::contribute(Origin::signed(1), para_1, 100, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(1), para_1, 100, None)); assert_eq!(Crowdloan::contribution_get(0u32, &1), (200, b"hello, world".to_vec())); }); } @@ -1877,18 +1907,18 @@ mod tests { let para_1 = new_para(); assert_ok!(TestAuctioneer::new_auction(5, 0)); - assert_ok!(Crowdloan::create(Origin::signed(1), para_1, 1000, 1, 1, 9, None)); + assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_1, 1000, 1, 1, 9, None)); // Should fail when no contributions. assert_noop!( - Crowdloan::poke(Origin::signed(1), para_1), + Crowdloan::poke(RuntimeOrigin::signed(1), para_1), Error::::NoContributions ); - assert_ok!(Crowdloan::contribute(Origin::signed(2), para_1, 100, None)); + assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para_1, 100, None)); run_to_block(6); - assert_ok!(Crowdloan::poke(Origin::signed(1), para_1)); + assert_ok!(Crowdloan::poke(RuntimeOrigin::signed(1), para_1)); assert_eq!(Crowdloan::new_raise(), vec![para_1]); assert_noop!( - Crowdloan::poke(Origin::signed(1), para_1), + Crowdloan::poke(RuntimeOrigin::signed(1), para_1), Error::::AlreadyInNewRaise ); }); @@ -1906,9 +1936,9 @@ mod benchmarking { use frame_benchmarking::{account, benchmarks, whitelisted_caller}; - fn assert_last_event(generic_event: ::Event) { + fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(event, &system_event); diff --git a/runtime/common/src/impls.rs b/runtime/common/src/impls.rs index bce847c82a83..939b753092f5 100644 --- a/runtime/common/src/impls.rs +++ b/runtime/common/src/impls.rs @@ -60,7 +60,9 @@ where #[cfg(test)] mod tests { use super::*; - use frame_support::{parameter_types, traits::FindAuthor, weights::DispatchClass, PalletId}; + use frame_support::{ + dispatch::DispatchClass, parameter_types, traits::FindAuthor, weights::Weight, PalletId, + }; use frame_system::limits; use primitives::v2::AccountId; use sp_core::H256; @@ -90,12 +92,12 @@ mod tests { parameter_types! { pub const BlockHashCount: u64 = 250; pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder() - .base_block(10) + .base_block(Weight::from_ref_time(10)) .for_class(DispatchClass::all(), |weight| { - weight.base_extrinsic = 100; + weight.base_extrinsic = Weight::from_ref_time(100); }) .for_class(DispatchClass::non_mandatory(), |weight| { - weight.max_total = Some(1024); + weight.max_total = Some(Weight::from_ref_time(1024).set_proof_size(u64::MAX)); }) .build_or_panic(); pub BlockLength: limits::BlockLength = limits::BlockLength::max(2 * 1024); @@ -104,16 +106,16 @@ mod tests { impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockLength = BlockLength; type BlockWeights = BlockWeights; @@ -131,7 +133,7 @@ mod tests { impl pallet_balances::Config for Test { type Balance = u64; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = (); type AccountStore = System; @@ -150,7 +152,7 @@ mod tests { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type OnSlash = (); type ProposalBond = (); type ProposalBondMinimum = (); diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index 76dc1f4c55b0..eb9c4496e59a 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -25,6 +25,7 @@ use crate::{ use frame_support::{ assert_noop, assert_ok, parameter_types, traits::{Currency, GenesisBuild, KeyOwnerProofSystem, OnFinalize, OnInitialize}, + weights::Weight, PalletId, }; use frame_support_test::TestRandomness; @@ -60,9 +61,9 @@ fn account_id(i: u32) -> AccountId32 { array.into() } -fn signed(i: u32) -> Origin { +fn signed(i: u32) -> RuntimeOrigin { let account_id = account_id(i); - Origin::signed(account_id) + RuntimeOrigin::signed(account_id) } frame_support::construct_runtime!( @@ -92,10 +93,10 @@ frame_support::construct_runtime!( impl frame_system::offchain::SendTransactionTypes for Test where - Call: From, + RuntimeCall: From, { type Extrinsic = UncheckedExtrinsic; - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; } use crate::{auctions::Error as AuctionsError, crowdloan::Error as CrowdloanError}; @@ -103,7 +104,9 @@ use crate::{auctions::Error as AuctionsError, crowdloan::Error as CrowdloanError parameter_types! { pub const BlockHashCount: u32 = 250; pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(4 * 1024 * 1024); + frame_system::limits::BlockWeights::simple_max( + Weight::from_ref_time(4 * 1024 * 1024).set_proof_size(u64::MAX), + ); } impl frame_system::Config for Test { @@ -111,8 +114,8 @@ impl frame_system::Config for Test { type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = BlockNumber; type Hash = H256; @@ -120,7 +123,7 @@ impl frame_system::Config for Test { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -178,7 +181,7 @@ parameter_types! { impl pallet_balances::Config for Test { type MaxLocks = (); type Balance = Balance; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -200,7 +203,7 @@ parameter_types! { } impl paras::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = paras::TestWeightInfo; type UnsignedPriority = ParasUnsignedPriority; type NextSessionRotation = crate::mock::TestNextSessionRotation; @@ -212,12 +215,12 @@ parameter_types! { } impl paras_registrar::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type OnSwap = (Crowdloan, Slots); type ParaDeposit = ParaDeposit; type DataDepositPerByte = DataDepositPerByte; type Currency = Balances; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type WeightInfo = crate::paras_registrar::TestWeightInfo; } @@ -227,7 +230,7 @@ parameter_types! { } impl auctions::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Leaser = Slots; type Registrar = Registrar; type EndingPeriod = EndingPeriod; @@ -243,7 +246,7 @@ parameter_types! { } impl slots::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type Registrar = Registrar; type LeasePeriod = LeasePeriod; @@ -261,7 +264,7 @@ parameter_types! { } impl crowdloan::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type PalletId = CrowdloanId; type SubmissionDeposit = SubmissionDeposit; type MinContribution = MinContribution; @@ -342,11 +345,11 @@ fn run_to_session(n: u32) { run_to_block(block_number); } -fn last_event() -> Event { - System::events().pop().expect("Event expected").event +fn last_event() -> RuntimeEvent { + System::events().pop().expect("RuntimeEvent expected").event } -fn contains_event(event: Event) -> bool { +fn contains_event(event: RuntimeEvent) -> bool { System::events().iter().any(|x| x.event == event) } @@ -388,7 +391,11 @@ fn basic_end_to_end_works() { // Start a new auction in the future let duration = 99u32 + offset; let lease_period_index_start = 4u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + assert_ok!(Auctions::new_auction( + RuntimeOrigin::root(), + duration, + lease_period_index_start + )); // 2 sessions later they are parathreads run_to_session(2); @@ -556,7 +563,11 @@ fn basic_errors_fail() { // Start an auction let duration = 99u32; let lease_period_index_start = 4u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + assert_ok!(Auctions::new_auction( + RuntimeOrigin::root(), + duration, + lease_period_index_start + )); // Cannot create a crowdloan if you do not own the para assert_noop!( @@ -599,7 +610,11 @@ fn competing_slots() { // Start a new auction in the future let duration = 149u32; let lease_period_index_start = 4u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + assert_ok!(Auctions::new_auction( + RuntimeOrigin::root(), + duration, + lease_period_index_start + )); // Paras should be onboarded run_to_block(20); // session 2 @@ -696,7 +711,11 @@ fn competing_bids() { let starting_block = System::block_number(); let duration = 99u32; let lease_period_index_start = 4u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + assert_ok!(Auctions::new_auction( + RuntimeOrigin::root(), + duration, + lease_period_index_start + )); for n in 1..=3 { // Create a crowdloan for each para @@ -798,7 +817,11 @@ fn basic_swap_works() { // Start a new auction in the future let duration = 99u32; let lease_period_index_start = 4u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + assert_ok!(Auctions::new_auction( + RuntimeOrigin::root(), + duration, + lease_period_index_start + )); // 2 sessions later they are parathreads run_to_session(2); @@ -954,7 +977,11 @@ fn parachain_swap_works() { let unique_id = winner - 1999u32; let starting_block = System::block_number(); let duration = 99u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + assert_ok!(Auctions::new_auction( + RuntimeOrigin::root(), + duration, + lease_period_index_start + )); // 2 sessions later they are parathreads run_to_block(starting_block + 20); @@ -1105,7 +1132,11 @@ fn crowdloan_ending_period_bid() { // Start a new auction in the future let duration = 99u32; let lease_period_index_start = 4u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + assert_ok!(Auctions::new_auction( + RuntimeOrigin::root(), + duration, + lease_period_index_start + )); // 2 sessions later they are parathreads run_to_session(2); @@ -1181,7 +1212,11 @@ fn auction_bid_requires_registered_para() { // Start a new auction in the future let duration = 99u32; let lease_period_index_start = 4u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + assert_ok!(Auctions::new_auction( + RuntimeOrigin::root(), + duration, + lease_period_index_start + )); // Can't bid with non-registered paras Balances::make_free_balance_be(&account_id(1), 1_000_000_000); @@ -1243,7 +1278,11 @@ fn gap_bids_work() { // Start a new auction in the future let duration = 99u32; let lease_period_index_start = 4u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + assert_ok!(Auctions::new_auction( + RuntimeOrigin::root(), + duration, + lease_period_index_start + )); Balances::make_free_balance_be(&account_id(1), 1_000_000_000); Balances::make_free_balance_be(&account_id(2), 1_000_000_000); @@ -1431,7 +1470,11 @@ fn cant_bid_on_existing_lease_periods() { let starting_block = System::block_number(); let duration = 99u32; let lease_period_index_start = 4u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + assert_ok!(Auctions::new_auction( + RuntimeOrigin::root(), + duration, + lease_period_index_start + )); // 2 sessions later they are parathreads run_to_session(2); @@ -1479,7 +1522,11 @@ fn cant_bid_on_existing_lease_periods() { let starting_block = System::block_number(); let duration = 99u32; let lease_period_index_start = 4u32; - assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + assert_ok!(Auctions::new_auction( + RuntimeOrigin::root(), + duration, + lease_period_index_start + )); // Poke the crowdloan into `NewRaise` assert_ok!(Crowdloan::poke(signed(1), ParaId::from(2000))); @@ -1491,7 +1538,7 @@ fn cant_bid_on_existing_lease_periods() { // Bids cannot be made which intersect assert_noop!( Auctions::bid( - Origin::signed(crowdloan_account.clone()), + RuntimeOrigin::signed(crowdloan_account.clone()), ParaId::from(2000), 2, lease_period_index_start + 0, @@ -1503,7 +1550,7 @@ fn cant_bid_on_existing_lease_periods() { assert_noop!( Auctions::bid( - Origin::signed(crowdloan_account.clone()), + RuntimeOrigin::signed(crowdloan_account.clone()), ParaId::from(2000), 2, lease_period_index_start + 1, @@ -1515,7 +1562,7 @@ fn cant_bid_on_existing_lease_periods() { assert_noop!( Auctions::bid( - Origin::signed(crowdloan_account.clone()), + RuntimeOrigin::signed(crowdloan_account.clone()), ParaId::from(2000), 2, lease_period_index_start - 1, @@ -1527,7 +1574,7 @@ fn cant_bid_on_existing_lease_periods() { assert_noop!( Auctions::bid( - Origin::signed(crowdloan_account.clone()), + RuntimeOrigin::signed(crowdloan_account.clone()), ParaId::from(2000), 2, lease_period_index_start + 0, @@ -1539,7 +1586,7 @@ fn cant_bid_on_existing_lease_periods() { assert_noop!( Auctions::bid( - Origin::signed(crowdloan_account.clone()), + RuntimeOrigin::signed(crowdloan_account.clone()), ParaId::from(2000), 2, lease_period_index_start + 1, @@ -1551,7 +1598,7 @@ fn cant_bid_on_existing_lease_periods() { assert_noop!( Auctions::bid( - Origin::signed(crowdloan_account.clone()), + RuntimeOrigin::signed(crowdloan_account.clone()), ParaId::from(2000), 2, lease_period_index_start - 1, @@ -1563,7 +1610,7 @@ fn cant_bid_on_existing_lease_periods() { // Will work when not overlapping assert_ok!(Auctions::bid( - Origin::signed(crowdloan_account.clone()), + RuntimeOrigin::signed(crowdloan_account.clone()), ParaId::from(2000), 2, lease_period_index_start + 2, diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 8424b930e6af..ac5fc69a28e4 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -43,7 +43,7 @@ use frame_support::{ weights::{constants::WEIGHT_PER_SECOND, Weight}, }; use frame_system::limits; -use primitives::v2::{AssignmentId, Balance, BlockNumber, ValidatorId}; +use primitives::v2::{AssignmentId, Balance, BlockNumber, ValidatorId, MAX_POV_SIZE}; use sp_runtime::{FixedPointNumber, Perbill, Perquintill}; use static_assertions::const_assert; @@ -52,6 +52,7 @@ pub use pallet_balances::Call as BalancesCall; pub use pallet_staking::StakerStatus; pub use pallet_timestamp::Call as TimestampCall; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; +pub use sp_runtime::traits::Bounded; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -68,14 +69,15 @@ pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(1); /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used /// by Operational extrinsics. pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); -/// We allow for 2 seconds of compute with a 6 second average block time. -pub const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND; +/// The storage proof size is not limited so far. +pub const MAXIMUM_BLOCK_WEIGHT: Weight = + WEIGHT_PER_SECOND.saturating_mul(2).set_proof_size(MAX_POV_SIZE as u64); const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct()); // Common constants used in all runtimes. parameter_types! { - pub const BlockHashCount: BlockNumber = 2400; + pub const BlockHashCount: BlockNumber = 4096; /// The portion of the `NORMAL_DISPATCH_RATIO` that we adjust the fees with. Blocks filled less /// than this will decrease the weight and more will increase. pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); @@ -86,6 +88,8 @@ parameter_types! { /// that combined with `AdjustmentVariable`, we can recover from the minimum. /// See `multiplier_can_grow_from_zero`. pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 10u128); + /// The maximum amount of the multiplier. + pub MaximumMultiplier: Multiplier = Bounded::max_value(); /// Maximum length of block. Up to 5MB. pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); @@ -93,8 +97,13 @@ parameter_types! { /// Parameterized slow adjusting fee updated based on /// https://research.web3.foundation/en/latest/polkadot/overview/2-token-economics.html#-2.-slow-adjusting-mechanism -pub type SlowAdjustingFeeUpdate = - TargetedFeeAdjustment; +pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment< + R, + TargetBlockFullness, + AdjustmentVariable, + MinimumMultiplier, + MaximumMultiplier, +>; /// Implements the weight types for a runtime. /// It expects the passed runtime constants to contain a `weights` module. @@ -103,7 +112,7 @@ pub type SlowAdjustingFeeUpdate = #[macro_export] macro_rules! impl_runtime_weights { ($runtime:ident) => { - use frame_support::weights::{DispatchClass, Weight}; + use frame_support::{dispatch::DispatchClass, weights::Weight}; use frame_system::limits; use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment}; pub use runtime_common::{ diff --git a/runtime/common/src/mock.rs b/runtime/common/src/mock.rs index 7f4c9ad937ff..54cac99146e7 100644 --- a/runtime/common/src/mock.rs +++ b/runtime/common/src/mock.rs @@ -224,10 +224,10 @@ impl frame_support::traits::EstimateNextSessionRotation for TestNextSession } fn estimate_current_session_progress(_now: u32) -> (Option, Weight) { - (None, 0) + (None, Weight::zero()) } fn estimate_next_session_rotation(_now: u32) -> (Option, Weight) { - (None, 0) + (None, Weight::zero()) } } diff --git a/runtime/common/src/paras_registrar.rs b/runtime/common/src/paras_registrar.rs index 7631914b9992..7245cd92d304 100644 --- a/runtime/common/src/paras_registrar.rs +++ b/runtime/common/src/paras_registrar.rs @@ -60,24 +60,32 @@ pub trait WeightInfo { fn force_register() -> Weight; fn deregister() -> Weight; fn swap() -> Weight; + fn schedule_code_upgrade(b: u32) -> Weight; + fn set_current_head(b: u32) -> Weight; } pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn reserve() -> Weight { - 0 + Weight::zero() } fn register() -> Weight { - 0 + Weight::zero() } fn force_register() -> Weight { - 0 + Weight::zero() } fn deregister() -> Weight { - 0 + Weight::zero() } fn swap() -> Weight { - 0 + Weight::zero() + } + fn schedule_code_upgrade(_b: u32) -> Weight { + Weight::zero() + } + fn set_current_head(_b: u32) -> Weight { + Weight::zero() } } @@ -96,14 +104,14 @@ pub mod pallet { #[pallet::disable_frame_system_supertrait_check] pub trait Config: configuration::Config + paras::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The aggregated origin type must support the `parachains` origin. We require that we can /// infallibly convert between this origin and the system origin, but in reality, they're the /// same type, we just can't express that to the Rust type system without writing a `where` /// clause everywhere. - type Origin: From<::Origin> - + Into::Origin>>; + type RuntimeOrigin: From<::RuntimeOrigin> + + Into::RuntimeOrigin>>; /// The system's currency for parathread payment. type Currency: ReservableCurrency; @@ -318,11 +326,11 @@ pub mod pallet { /// Remove a manager lock from a para. This will allow the manager of a /// previously locked para to deregister or swap a para without using governance. /// - /// Can only be called by the Root origin. + /// Can only be called by the Root origin or the parachain. #[pallet::weight(T::DbWeight::get().reads_writes(1, 1))] - pub fn force_remove_lock(origin: OriginFor, para: ParaId) -> DispatchResult { - ensure_root(origin)?; - Self::remove_lock(para); + pub fn remove_lock(origin: OriginFor, para: ParaId) -> DispatchResult { + Self::ensure_root_or_para(origin, para)?; + ::remove_lock(para); Ok(()) } @@ -348,6 +356,45 @@ pub mod pallet { NextFreeParaId::::set(id + 1); Ok(()) } + + /// Add a manager lock from a para. This will prevent the manager of a + /// para to deregister or swap a para. + /// + /// Can be called by Root, the parachain, or the parachain manager if the parachain is unlocked. + #[pallet::weight(T::DbWeight::get().reads_writes(1, 1))] + pub fn add_lock(origin: OriginFor, para: ParaId) -> DispatchResult { + Self::ensure_root_para_or_owner(origin, para)?; + ::apply_lock(para); + Ok(()) + } + + /// Schedule a parachain upgrade. + /// + /// Can be called by Root, the parachain, or the parachain manager if the parachain is unlocked. + #[pallet::weight(::WeightInfo::schedule_code_upgrade(new_code.0.len() as u32))] + pub fn schedule_code_upgrade( + origin: OriginFor, + para: ParaId, + new_code: ValidationCode, + ) -> DispatchResult { + Self::ensure_root_para_or_owner(origin, para)?; + runtime_parachains::schedule_code_upgrade::(para, new_code)?; + Ok(()) + } + + /// Set the parachain's current head. + /// + /// Can be called by Root, the parachain, or the parachain manager if the parachain is unlocked. + #[pallet::weight(::WeightInfo::set_current_head(new_head.0.len() as u32))] + pub fn set_current_head( + origin: OriginFor, + para: ParaId, + new_head: HeadData, + ) -> DispatchResult { + Self::ensure_root_para_or_owner(origin, para)?; + runtime_parachains::set_current_head::(para, new_head); + Ok(()) + } } } @@ -379,7 +426,7 @@ impl Registrar for Pallet { Paras::::mutate(id, |x| x.as_mut().map(|mut info| info.locked = true)); } - // Apply a lock to the parachain. + // Remove a lock from the parachain. fn remove_lock(id: ParaId) { Paras::::mutate(id, |x| x.as_mut().map(|mut info| info.locked = false)); } @@ -456,7 +503,7 @@ impl Pallet { /// Ensure the origin is one of Root, the `para` owner, or the `para` itself. /// If the origin is the `para` owner, the `para` must be unlocked. fn ensure_root_para_or_owner( - origin: ::Origin, + origin: ::RuntimeOrigin, id: ParaId, ) -> DispatchResult { ensure_signed(origin.clone()) @@ -467,16 +514,23 @@ impl Pallet { ensure!(para_info.manager == who, Error::::NotOwner); Ok(()) }) - .or_else(|_| -> DispatchResult { - // Else check if para origin... - let caller_id = ensure_parachain(::Origin::from(origin.clone()))?; - ensure!(caller_id == id, Error::::NotOwner); - Ok(()) - }) - .or_else(|_| -> DispatchResult { - // Check if root... - ensure_root(origin.clone()).map_err(|e| e.into()) - }) + .or_else(|_| -> DispatchResult { Self::ensure_root_or_para(origin, id) }) + } + + /// Ensure the origin is one of Root or the `para` itself. + fn ensure_root_or_para( + origin: ::RuntimeOrigin, + id: ParaId, + ) -> DispatchResult { + if let Ok(caller_id) = ensure_parachain(::RuntimeOrigin::from(origin.clone())) + { + // Check if matching para id... + ensure!(caller_id == id, Error::::NotOwner); + } else { + // Check if root... + ensure_root(origin.clone())?; + } + Ok(()) } fn do_reserve( @@ -631,25 +685,27 @@ mod tests { impl frame_system::offchain::SendTransactionTypes for Test where - Call: From, + RuntimeCall: From, { type Extrinsic = UncheckedExtrinsic; - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; } const NORMAL_RATIO: Perbill = Perbill::from_percent(75); parameter_types! { pub const BlockHashCount: u32 = 250; pub BlockWeights: limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max( + Weight::from_ref_time(1024).set_proof_size(u64::MAX), + ); pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio(4 * 1024 * 1024, NORMAL_RATIO); } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = BlockNumber; type Hash = H256; @@ -657,7 +713,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); type BlockWeights = BlockWeights; @@ -680,7 +736,7 @@ mod tests { impl pallet_balances::Config for Test { type Balance = u128; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type MaxLocks = (); @@ -698,7 +754,7 @@ mod tests { } impl paras::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = paras::TestWeightInfo; type UnsignedPriority = ParasUnsignedPriority; type NextSessionRotation = crate::mock::TestNextSessionRotation; @@ -715,8 +771,8 @@ mod tests { } impl Config for Test { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type OnSwap = MockSwap; type ParaDeposit = ParaDeposit; @@ -800,7 +856,7 @@ mod tests { ValidationCode(validation_code) } - fn para_origin(id: ParaId) -> Origin { + fn para_origin(id: ParaId) -> RuntimeOrigin { runtime_parachains::Origin::Parachain(id).into() } @@ -828,9 +884,9 @@ mod tests { // first para is not yet registered assert!(!Parachains::is_parathread(para_id)); // We register the Para ID - assert_ok!(Registrar::reserve(Origin::signed(1))); + assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1))); assert_ok!(Registrar::register( - Origin::signed(1), + RuntimeOrigin::signed(1), para_id, test_genesis_head(32), test_validation_code(32), @@ -851,7 +907,7 @@ mod tests { assert!(Parachains::is_parathread(para_id)); assert!(!Parachains::is_parachain(para_id)); // Deregister it - assert_ok!(Registrar::deregister(Origin::root(), para_id,)); + assert_ok!(Registrar::deregister(RuntimeOrigin::root(), para_id,)); run_to_session(8); // It is nothing assert!(!Parachains::is_parathread(para_id)); @@ -865,10 +921,10 @@ mod tests { run_to_block(1); let para_id = LOWEST_PUBLIC_ID; assert!(!Parachains::is_parathread(para_id)); - assert_ok!(Registrar::reserve(Origin::signed(1))); + assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1))); assert_eq!(Balances::reserved_balance(&1), ::ParaDeposit::get()); assert_ok!(Registrar::register( - Origin::signed(1), + RuntimeOrigin::signed(1), para_id, test_genesis_head(32), test_validation_code(32), @@ -890,7 +946,7 @@ mod tests { assert_noop!( Registrar::register( - Origin::signed(1), + RuntimeOrigin::signed(1), para_id, test_genesis_head(max_head_size() as usize), test_validation_code(max_code_size() as usize), @@ -899,11 +955,11 @@ mod tests { ); // Successfully register para - assert_ok!(Registrar::reserve(Origin::signed(1))); + assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1))); assert_noop!( Registrar::register( - Origin::signed(2), + RuntimeOrigin::signed(2), para_id, test_genesis_head(max_head_size() as usize), test_validation_code(max_code_size() as usize), @@ -912,7 +968,7 @@ mod tests { ); assert_ok!(Registrar::register( - Origin::signed(1), + RuntimeOrigin::signed(1), para_id, test_genesis_head(max_head_size() as usize), test_validation_code(max_code_size() as usize), @@ -920,12 +976,12 @@ mod tests { run_to_session(2); - assert_ok!(Registrar::deregister(Origin::root(), para_id)); + assert_ok!(Registrar::deregister(RuntimeOrigin::root(), para_id)); // Can't do it again assert_noop!( Registrar::register( - Origin::signed(1), + RuntimeOrigin::signed(1), para_id, test_genesis_head(max_head_size() as usize), test_validation_code(max_code_size() as usize), @@ -934,10 +990,10 @@ mod tests { ); // Head Size Check - assert_ok!(Registrar::reserve(Origin::signed(2))); + assert_ok!(Registrar::reserve(RuntimeOrigin::signed(2))); assert_noop!( Registrar::register( - Origin::signed(2), + RuntimeOrigin::signed(2), para_id + 1, test_genesis_head((max_head_size() + 1) as usize), test_validation_code(max_code_size() as usize), @@ -948,7 +1004,7 @@ mod tests { // Code Size Check assert_noop!( Registrar::register( - Origin::signed(2), + RuntimeOrigin::signed(2), para_id + 1, test_genesis_head(max_head_size() as usize), test_validation_code((max_code_size() + 1) as usize), @@ -958,7 +1014,7 @@ mod tests { // Needs enough funds for deposit assert_noop!( - Registrar::reserve(Origin::signed(1337)), + Registrar::reserve(RuntimeOrigin::signed(1337)), BalancesError::::InsufficientBalance ); }); @@ -970,16 +1026,16 @@ mod tests { run_to_block(1); let para_id = LOWEST_PUBLIC_ID; assert!(!Parachains::is_parathread(para_id)); - assert_ok!(Registrar::reserve(Origin::signed(1))); + assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1))); assert_ok!(Registrar::register( - Origin::signed(1), + RuntimeOrigin::signed(1), para_id, test_genesis_head(32), test_validation_code(32), )); run_to_session(2); assert!(Parachains::is_parathread(para_id)); - assert_ok!(Registrar::deregister(Origin::root(), para_id,)); + assert_ok!(Registrar::deregister(RuntimeOrigin::root(), para_id,)); run_to_session(4); assert!(paras::Pallet::::lifecycle(para_id).is_none()); assert_eq!(Balances::reserved_balance(&1), 0); @@ -992,9 +1048,9 @@ mod tests { run_to_block(1); let para_id = LOWEST_PUBLIC_ID; assert!(!Parachains::is_parathread(para_id)); - assert_ok!(Registrar::reserve(Origin::signed(1))); + assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1))); assert_ok!(Registrar::register( - Origin::signed(1), + RuntimeOrigin::signed(1), para_id, test_genesis_head(32), test_validation_code(32), @@ -1002,12 +1058,12 @@ mod tests { run_to_session(2); assert!(Parachains::is_parathread(para_id)); // Owner check - assert_noop!(Registrar::deregister(Origin::signed(2), para_id,), BadOrigin); + assert_noop!(Registrar::deregister(RuntimeOrigin::signed(2), para_id,), BadOrigin); assert_ok!(Registrar::make_parachain(para_id)); run_to_session(4); // Cant directly deregister parachain assert_noop!( - Registrar::deregister(Origin::root(), para_id,), + Registrar::deregister(RuntimeOrigin::root(), para_id,), Error::::NotParathread ); }); @@ -1019,16 +1075,16 @@ mod tests { // Successfully register first two parachains let para_1 = LOWEST_PUBLIC_ID; let para_2 = LOWEST_PUBLIC_ID + 1; - assert_ok!(Registrar::reserve(Origin::signed(1))); + assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1))); assert_ok!(Registrar::register( - Origin::signed(1), + RuntimeOrigin::signed(1), para_1, test_genesis_head(max_head_size() as usize), test_validation_code(max_code_size() as usize), )); - assert_ok!(Registrar::reserve(Origin::signed(2))); + assert_ok!(Registrar::reserve(RuntimeOrigin::signed(2))); assert_ok!(Registrar::register( - Origin::signed(2), + RuntimeOrigin::signed(2), para_2, test_genesis_head(max_head_size() as usize), test_validation_code(max_code_size() as usize), @@ -1075,27 +1131,29 @@ mod tests { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Registrar::reserve(Origin::signed(1))); + assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1))); let para_id = LOWEST_PUBLIC_ID; assert_ok!(Registrar::register( - Origin::signed(1), + RuntimeOrigin::signed(1), para_id, vec![1; 3].into(), vec![1, 2, 3].into(), )); - // Owner can call swap - assert_ok!(Registrar::swap(Origin::signed(1), para_id, para_id + 1)); - - // 2 session changes to fully onboard. - run_to_session(2); - assert_eq!(Parachains::lifecycle(para_id), Some(ParaLifecycle::Parathread)); - + assert_noop!(Registrar::add_lock(RuntimeOrigin::signed(2), para_id), BadOrigin); // Once they begin onboarding, we lock them in. - assert_ok!(Registrar::make_parachain(para_id)); - - // Owner cannot call swap anymore - assert_noop!(Registrar::swap(Origin::signed(1), para_id, para_id + 2), BadOrigin); + assert_ok!(Registrar::add_lock(RuntimeOrigin::signed(1), para_id)); + // Owner cannot pass origin check when checking lock + assert_noop!( + Registrar::ensure_root_para_or_owner(RuntimeOrigin::signed(1), para_id), + BadOrigin + ); + // Owner cannot remove lock. + assert_noop!(Registrar::remove_lock(RuntimeOrigin::signed(1), para_id), BadOrigin); + // Para can. + assert_ok!(Registrar::remove_lock(para_origin(para_id), para_id)); + // Owner can pass origin check again + assert_ok!(Registrar::ensure_root_para_or_owner(RuntimeOrigin::signed(1), para_id)); }); } @@ -1111,30 +1169,30 @@ mod tests { // Cannot even start a swap assert_noop!( - Registrar::swap(Origin::root(), para_1, para_2), + Registrar::swap(RuntimeOrigin::root(), para_1, para_2), Error::::NotRegistered ); // We register Paras 1 and 2 - assert_ok!(Registrar::reserve(Origin::signed(1))); - assert_ok!(Registrar::reserve(Origin::signed(2))); + assert_ok!(Registrar::reserve(RuntimeOrigin::signed(1))); + assert_ok!(Registrar::reserve(RuntimeOrigin::signed(2))); assert_ok!(Registrar::register( - Origin::signed(1), + RuntimeOrigin::signed(1), para_1, test_genesis_head(32), test_validation_code(32), )); assert_ok!(Registrar::register( - Origin::signed(2), + RuntimeOrigin::signed(2), para_2, test_genesis_head(32), test_validation_code(32), )); // Cannot swap - assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); + assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2)); assert_noop!( - Registrar::swap(Origin::root(), para_2, para_1), + Registrar::swap(RuntimeOrigin::root(), para_2, para_1), Error::::CannotSwap ); @@ -1145,9 +1203,9 @@ mod tests { assert!(Parachains::is_parathread(para_2)); // Cannot swap - assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); + assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2)); assert_noop!( - Registrar::swap(Origin::root(), para_2, para_1), + Registrar::swap(RuntimeOrigin::root(), para_2, para_1), Error::::CannotSwap ); @@ -1155,18 +1213,18 @@ mod tests { assert_ok!(Registrar::make_parachain(para_1)); // Cannot swap - assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); + assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2)); assert_noop!( - Registrar::swap(Origin::root(), para_2, para_1), + Registrar::swap(RuntimeOrigin::root(), para_2, para_1), Error::::CannotSwap ); run_to_session(3); // Cannot swap - assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); + assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2)); assert_noop!( - Registrar::swap(Origin::root(), para_2, para_1), + Registrar::swap(RuntimeOrigin::root(), para_2, para_1), Error::::CannotSwap ); @@ -1177,15 +1235,15 @@ mod tests { assert!(Parachains::is_parathread(para_2)); // Swap works here. - assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); - assert_ok!(Registrar::swap(Origin::root(), para_2, para_1)); + assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2)); + assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_2, para_1)); run_to_session(5); // Cannot swap - assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); + assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2)); assert_noop!( - Registrar::swap(Origin::root(), para_2, para_1), + Registrar::swap(RuntimeOrigin::root(), para_2, para_1), Error::::CannotSwap ); @@ -1201,9 +1259,9 @@ mod tests { run_to_session(7); // Cannot swap - assert_ok!(Registrar::swap(Origin::root(), para_1, para_2)); + assert_ok!(Registrar::swap(RuntimeOrigin::root(), para_1, para_2)); assert_noop!( - Registrar::swap(Origin::root(), para_2, para_1), + Registrar::swap(RuntimeOrigin::root(), para_2, para_1), Error::::CannotSwap ); @@ -1221,14 +1279,15 @@ mod benchmarking { use crate::traits::Registrar as RegistrarT; use frame_support::assert_ok; use frame_system::RawOrigin; + use primitives::v2::{MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE}; use runtime_parachains::{paras, shared, Origin as ParaOrigin}; use sp_runtime::traits::Bounded; use frame_benchmarking::{account, benchmarks, whitelisted_caller}; - fn assert_last_event(generic_event: ::Event) { + fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(event, &system_event); @@ -1261,7 +1320,7 @@ mod benchmarking { } benchmarks! { - where_clause { where ParaOrigin: Into<::Origin> } + where_clause { where ParaOrigin: Into<::RuntimeOrigin> } reserve { let caller: T::AccountId = whitelisted_caller(); @@ -1337,6 +1396,18 @@ mod benchmarking { assert_eq!(paras::Pallet::::lifecycle(parathread), Some(ParaLifecycle::Parachain)); } + schedule_code_upgrade { + let b in 1 .. MAX_CODE_SIZE; + let new_code = ValidationCode(vec![0; b as usize]); + let para_id = ParaId::from(1000); + }: _(RawOrigin::Root, para_id, new_code) + + set_current_head { + let b in 1 .. MAX_HEAD_DATA_SIZE; + let new_head = HeadData(vec![0; b as usize]); + let para_id = ParaId::from(1000); + }: _(RawOrigin::Root, para_id, new_head) + impl_benchmark_test_suite!( Registrar, crate::integration_tests::new_test_ext(), diff --git a/runtime/common/src/purchase.rs b/runtime/common/src/purchase.rs index 3900f6edb318..52ad22bec2fb 100644 --- a/runtime/common/src/purchase.rs +++ b/runtime/common/src/purchase.rs @@ -98,7 +98,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Balances Pallet type Currency: Currency; @@ -111,10 +111,10 @@ pub mod pallet { >; /// The origin allowed to set account status. - type ValidityOrigin: EnsureOrigin; + type ValidityOrigin: EnsureOrigin; /// The origin allowed to make configurations to the pallet. - type ConfigurationOrigin: EnsureOrigin; + type ConfigurationOrigin: EnsureOrigin; /// The maximum statement length for the statement users to sign when creating an account. #[pallet::constant] @@ -195,7 +195,7 @@ pub mod pallet { /// We check that the account does not exist at this stage. /// /// Origin must match the `ValidityOrigin`. - #[pallet::weight(200_000_000 + T::DbWeight::get().reads_writes(4, 1))] + #[pallet::weight(Weight::from_ref_time(200_000_000) + T::DbWeight::get().reads_writes(4, 1))] pub fn create_account( origin: OriginFor, who: T::AccountId, @@ -474,8 +474,10 @@ mod tests { // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. use crate::purchase; use frame_support::{ - assert_noop, assert_ok, dispatch::DispatchError::BadOrigin, ord_parameter_types, - parameter_types, traits::Currency, + assert_noop, assert_ok, + dispatch::DispatchError::BadOrigin, + ord_parameter_types, parameter_types, + traits::{Currency, WithdrawReasons}, }; use pallet_balances::Error as BalancesError; use sp_runtime::{ @@ -510,8 +512,8 @@ mod tests { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -519,7 +521,7 @@ mod tests { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -538,7 +540,7 @@ mod tests { impl pallet_balances::Config for Test { type Balance = u64; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -550,14 +552,17 @@ mod tests { parameter_types! { pub const MinVestedTransfer: u64 = 1; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } impl pallet_vesting::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BlockNumberToBalance = Identity; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = (); + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; const MAX_VESTING_SCHEDULES: u32 = 28; } @@ -574,7 +579,7 @@ mod tests { } impl Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type VestingSchedule = Vesting; type ValidityOrigin = frame_system::EnsureSignedBy; @@ -596,10 +601,14 @@ mod tests { fn setup() { let statement = b"Hello, World".to_vec(); let unlock_block = 100; - Purchase::set_statement(Origin::signed(configuration_origin()), statement).unwrap(); - Purchase::set_unlock_block(Origin::signed(configuration_origin()), unlock_block).unwrap(); - Purchase::set_payment_account(Origin::signed(configuration_origin()), payment_account()) + Purchase::set_statement(RuntimeOrigin::signed(configuration_origin()), statement).unwrap(); + Purchase::set_unlock_block(RuntimeOrigin::signed(configuration_origin()), unlock_block) .unwrap(); + Purchase::set_payment_account( + RuntimeOrigin::signed(configuration_origin()), + payment_account(), + ) + .unwrap(); Balances::make_free_balance_be(&payment_account(), 100_000); } @@ -665,18 +674,21 @@ mod tests { let statement = b"Test Set Statement".to_vec(); // Invalid origin assert_noop!( - Purchase::set_statement(Origin::signed(alice()), statement.clone()), + Purchase::set_statement(RuntimeOrigin::signed(alice()), statement.clone()), BadOrigin, ); // Too Long let long_statement = [0u8; 10_000].to_vec(); assert_noop!( - Purchase::set_statement(Origin::signed(configuration_origin()), long_statement), + Purchase::set_statement( + RuntimeOrigin::signed(configuration_origin()), + long_statement + ), Error::::InvalidStatement, ); // Just right... assert_ok!(Purchase::set_statement( - Origin::signed(configuration_origin()), + RuntimeOrigin::signed(configuration_origin()), statement.clone() )); assert_eq!(Statement::::get(), statement); @@ -689,7 +701,7 @@ mod tests { let unlock_block = 69; // Invalid origin assert_noop!( - Purchase::set_unlock_block(Origin::signed(alice()), unlock_block), + Purchase::set_unlock_block(RuntimeOrigin::signed(alice()), unlock_block), BadOrigin, ); // Block Number in Past @@ -697,14 +709,14 @@ mod tests { System::set_block_number(bad_unlock_block); assert_noop!( Purchase::set_unlock_block( - Origin::signed(configuration_origin()), + RuntimeOrigin::signed(configuration_origin()), bad_unlock_block ), Error::::InvalidUnlockBlock, ); // Just right... assert_ok!(Purchase::set_unlock_block( - Origin::signed(configuration_origin()), + RuntimeOrigin::signed(configuration_origin()), unlock_block )); assert_eq!(UnlockBlock::::get(), unlock_block); @@ -717,12 +729,15 @@ mod tests { let payment_account: AccountId = [69u8; 32].into(); // Invalid Origin assert_noop!( - Purchase::set_payment_account(Origin::signed(alice()), payment_account.clone()), + Purchase::set_payment_account( + RuntimeOrigin::signed(alice()), + payment_account.clone() + ), BadOrigin, ); // Just right... assert_ok!(Purchase::set_payment_account( - Origin::signed(configuration_origin()), + RuntimeOrigin::signed(configuration_origin()), payment_account.clone() )); assert_eq!(PaymentAccount::::get(), Some(payment_account)); @@ -753,7 +768,7 @@ mod tests { new_test_ext().execute_with(|| { assert!(!Accounts::::contains_key(alice())); assert_ok!(Purchase::create_account( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), alice_signature().to_vec(), )); @@ -776,7 +791,7 @@ mod tests { // Wrong Origin assert_noop!( Purchase::create_account( - Origin::signed(alice()), + RuntimeOrigin::signed(alice()), alice(), alice_signature().to_vec() ), @@ -786,7 +801,7 @@ mod tests { // Wrong Account/Signature assert_noop!( Purchase::create_account( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), bob_signature().to_vec() ), @@ -802,7 +817,7 @@ mod tests { )); assert_noop!( Purchase::create_account( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), alice_signature().to_vec() ), @@ -811,13 +826,13 @@ mod tests { // Duplicate Purchasing Account assert_ok!(Purchase::create_account( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), bob(), bob_signature().to_vec() )); assert_noop!( Purchase::create_account( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), bob(), bob_signature().to_vec() ), @@ -831,19 +846,19 @@ mod tests { new_test_ext().execute_with(|| { // Alice account is created. assert_ok!(Purchase::create_account( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), alice_signature().to_vec(), )); // She submits KYC, and we update the status to `Pending`. assert_ok!(Purchase::update_validity_status( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), AccountValidity::Pending, )); // KYC comes back negative, so we mark the account invalid. assert_ok!(Purchase::update_validity_status( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), AccountValidity::Invalid, )); @@ -859,7 +874,7 @@ mod tests { ); // She fixes it, we mark her account valid. assert_ok!(Purchase::update_validity_status( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), AccountValidity::ValidLow, )); @@ -882,7 +897,7 @@ mod tests { // Wrong Origin assert_noop!( Purchase::update_validity_status( - Origin::signed(alice()), + RuntimeOrigin::signed(alice()), alice(), AccountValidity::Pending, ), @@ -891,7 +906,7 @@ mod tests { // Inactive Account assert_noop!( Purchase::update_validity_status( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), AccountValidity::Pending, ), @@ -899,18 +914,18 @@ mod tests { ); // Already Completed assert_ok!(Purchase::create_account( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), alice_signature().to_vec(), )); assert_ok!(Purchase::update_validity_status( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), AccountValidity::Completed, )); assert_noop!( Purchase::update_validity_status( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), AccountValidity::Pending, ), @@ -924,19 +939,19 @@ mod tests { new_test_ext().execute_with(|| { // Alice account is created assert_ok!(Purchase::create_account( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), alice_signature().to_vec() )); // And approved for basic contribution assert_ok!(Purchase::update_validity_status( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), AccountValidity::ValidLow, )); // We set a balance on the user based on the payment they made. 50 locked, 50 free. assert_ok!(Purchase::update_balance( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), 50, 50, @@ -954,7 +969,7 @@ mod tests { ); // We can update the balance based on new information. assert_ok!(Purchase::update_balance( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), 25, 50, @@ -978,13 +993,19 @@ mod tests { new_test_ext().execute_with(|| { // Wrong Origin assert_noop!( - Purchase::update_balance(Origin::signed(alice()), alice(), 50, 50, Permill::zero(),), + Purchase::update_balance( + RuntimeOrigin::signed(alice()), + alice(), + 50, + 50, + Permill::zero(), + ), BadOrigin ); // Inactive Account assert_noop!( Purchase::update_balance( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), 50, 50, @@ -995,7 +1016,7 @@ mod tests { // Overflow assert_noop!( Purchase::update_balance( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), u64::MAX, u64::MAX, @@ -1011,45 +1032,45 @@ mod tests { new_test_ext().execute_with(|| { // Alice and Bob accounts are created assert_ok!(Purchase::create_account( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), alice_signature().to_vec() )); assert_ok!(Purchase::create_account( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), bob(), bob_signature().to_vec() )); // Alice is approved for basic contribution assert_ok!(Purchase::update_validity_status( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), AccountValidity::ValidLow, )); // Bob is approved for high contribution assert_ok!(Purchase::update_validity_status( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), bob(), AccountValidity::ValidHigh, )); // We set a balance on the users based on the payment they made. 50 locked, 50 free. assert_ok!(Purchase::update_balance( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), 50, 50, Permill::zero(), )); assert_ok!(Purchase::update_balance( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), bob(), 100, 150, Permill::zero(), )); // Now we call payout for Alice and Bob. - assert_ok!(Purchase::payout(Origin::signed(payment_account()), alice(),)); - assert_ok!(Purchase::payout(Origin::signed(payment_account()), bob(),)); + assert_ok!(Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),)); + assert_ok!(Purchase::payout(RuntimeOrigin::signed(payment_account()), bob(),)); // Payment is made. assert_eq!(::Currency::free_balance(&payment_account()), 99_650); assert_eq!(::Currency::free_balance(&alice()), 100); @@ -1081,14 +1102,14 @@ mod tests { ); // Vesting lock is removed in whole on block 101 (100 blocks after block 1) System::set_block_number(100); - let vest_call = Call::Vesting(pallet_vesting::Call::::vest {}); - assert_ok!(vest_call.clone().dispatch(Origin::signed(alice()))); - assert_ok!(vest_call.clone().dispatch(Origin::signed(bob()))); + let vest_call = RuntimeCall::Vesting(pallet_vesting::Call::::vest {}); + assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(alice()))); + assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(bob()))); assert_eq!(::VestingSchedule::vesting_balance(&alice()), Some(45)); assert_eq!(::VestingSchedule::vesting_balance(&bob()), Some(140)); System::set_block_number(101); - assert_ok!(vest_call.clone().dispatch(Origin::signed(alice()))); - assert_ok!(vest_call.clone().dispatch(Origin::signed(bob()))); + assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(alice()))); + assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(bob()))); assert_eq!(::VestingSchedule::vesting_balance(&alice()), None); assert_eq!(::VestingSchedule::vesting_balance(&bob()), None); }); @@ -1098,45 +1119,45 @@ mod tests { fn payout_handles_basic_errors() { new_test_ext().execute_with(|| { // Wrong Origin - assert_noop!(Purchase::payout(Origin::signed(alice()), alice(),), BadOrigin); + assert_noop!(Purchase::payout(RuntimeOrigin::signed(alice()), alice(),), BadOrigin); // Account with Existing Vesting Schedule assert_ok!( ::VestingSchedule::add_vesting_schedule(&bob(), 100, 1, 50,) ); assert_noop!( - Purchase::payout(Origin::signed(payment_account()), bob(),), + Purchase::payout(RuntimeOrigin::signed(payment_account()), bob(),), Error::::VestingScheduleExists ); // Invalid Account (never created) assert_noop!( - Purchase::payout(Origin::signed(payment_account()), alice(),), + Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),), Error::::InvalidAccount ); // Invalid Account (created, but not valid) assert_ok!(Purchase::create_account( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), alice_signature().to_vec() )); assert_noop!( - Purchase::payout(Origin::signed(payment_account()), alice(),), + Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),), Error::::InvalidAccount ); // Not enough funds in payment account assert_ok!(Purchase::update_validity_status( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), AccountValidity::ValidHigh, )); assert_ok!(Purchase::update_balance( - Origin::signed(validity_origin()), + RuntimeOrigin::signed(validity_origin()), alice(), 100_000, 100_000, Permill::zero(), )); assert_noop!( - Purchase::payout(Origin::signed(payment_account()), alice(),), + Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),), BalancesError::::InsufficientBalance ); }); diff --git a/runtime/common/src/slots/migration.rs b/runtime/common/src/slots/migration.rs index b995ace2306e..33d221b209d5 100644 --- a/runtime/common/src/slots/migration.rs +++ b/runtime/common/src/slots/migration.rs @@ -51,7 +51,7 @@ pub mod slots_crowdloan_index_migration { } pub fn migrate() -> frame_support::weights::Weight { - let mut weight = 0; + let mut weight = Weight::zero(); for (para_id, mut leases) in Leases::::iter() { weight = weight.saturating_add(T::DbWeight::get().reads(2)); diff --git a/runtime/common/src/slots/mod.rs b/runtime/common/src/slots/mod.rs index 76054ac989f9..673d9f86e1bd 100644 --- a/runtime/common/src/slots/mod.rs +++ b/runtime/common/src/slots/mod.rs @@ -49,16 +49,16 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn force_lease() -> Weight { - 0 + Weight::zero() } fn manage_lease_period_start(_c: u32, _t: u32) -> Weight { - 0 + Weight::zero() } fn clear_all_leases() -> Weight { - 0 + Weight::zero() } fn trigger_onboard() -> Weight { - 0 + Weight::zero() } } @@ -74,7 +74,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency type used for bidding. type Currency: ReservableCurrency; @@ -91,7 +91,7 @@ pub mod pallet { type LeaseOffset: Get; /// The origin which may forcibly create or clear leases. Root can always do this. - type ForceOrigin: EnsureOrigin<::Origin>; + type ForceOrigin: EnsureOrigin<::RuntimeOrigin>; /// Weight Information for the Extrinsics in the Pallet type WeightInfo: WeightInfo; @@ -155,7 +155,7 @@ pub mod pallet { } // We didn't return early above, so we didn't do anything. - 0 + Weight::zero() } } @@ -529,8 +529,8 @@ mod tests { type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); type BlockLength = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = BlockNumber; type Hash = H256; @@ -538,7 +538,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); @@ -558,7 +558,7 @@ mod tests { impl pallet_balances::Config for Test { type Balance = u64; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -575,7 +575,7 @@ mod tests { } impl Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type Registrar = TestRegistrar; type LeasePeriod = LeasePeriod; @@ -847,7 +847,7 @@ mod tests { assert_eq!(Balances::reserved_balance(j), j * 10); } - assert_ok!(Slots::clear_all_leases(Origin::root(), 1.into())); + assert_ok!(Slots::clear_all_leases(RuntimeOrigin::root(), 1.into())); // Balances cleaned up correctly for i in 1u32..=max_num { @@ -925,21 +925,21 @@ mod tests { // Para 1 should fail cause they don't have any leases assert_noop!( - Slots::trigger_onboard(Origin::signed(1), 1.into()), + Slots::trigger_onboard(RuntimeOrigin::signed(1), 1.into()), Error::::ParaNotOnboarding ); // Para 2 should succeed - assert_ok!(Slots::trigger_onboard(Origin::signed(1), 2.into())); + assert_ok!(Slots::trigger_onboard(RuntimeOrigin::signed(1), 2.into())); // Para 3 should fail cause their lease is in the future assert_noop!( - Slots::trigger_onboard(Origin::signed(1), 3.into()), + Slots::trigger_onboard(RuntimeOrigin::signed(1), 3.into()), Error::::ParaNotOnboarding ); // Trying Para 2 again should fail cause they are not currently a parathread - assert!(Slots::trigger_onboard(Origin::signed(1), 2.into()).is_err()); + assert!(Slots::trigger_onboard(RuntimeOrigin::signed(1), 2.into()).is_err()); assert_eq!(TestRegistrar::::operations(), vec![(2.into(), 1, true),]); }); @@ -988,9 +988,9 @@ mod benchmarking { use crate::slots::Pallet as Slots; - fn assert_last_event(generic_event: ::Event) { + fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(event, &system_event); @@ -1025,7 +1025,7 @@ mod benchmarking { let period_begin = 69u32.into(); let period_count = 3u32.into(); let origin = T::ForceOrigin::successful_origin(); - }: _(origin, para, leaser.clone(), amount, period_begin, period_count) + }: _(origin, para, leaser.clone(), amount, period_begin, period_count) verify { assert_last_event::(Event::::Leased { para_id: para, @@ -1119,7 +1119,7 @@ mod benchmarking { } let origin = T::ForceOrigin::successful_origin(); - }: _(origin, para) + }: _(origin, para) verify { for i in 0 .. max_people { let leaser = account("lease_deposit", i, 0); diff --git a/runtime/kusama/Cargo.toml b/runtime/kusama/Cargo.toml index 173a5975e3c7..63acb94e3e05 100644 --- a/runtime/kusama/Cargo.toml +++ b/runtime/kusama/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kusama-runtime" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" build = "build.rs" @@ -16,77 +16,82 @@ serde_derive = { version = "1.0.117", optional = true } static_assertions = "1.1.0" smallvec = "1.8.0" -authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } kusama-runtime-constants = { package = "kusama-runtime-constants", path = "./constants", default-features = false } -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-arithmetic = { package = "sp-arithmetic", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-npos-elections = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-arithmetic = { package = "sp-arithmetic", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-npos-elections = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } -pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-bags-list = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-child-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-gilt = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-im-online = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-indices = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-membership = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-nomination-pools = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-offences = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-recovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-society = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-staking-reward-fn = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-system = {git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-tips = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-bags-list = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-child-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-conviction-voting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-fast-unstake = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-gilt = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-im-online = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-indices = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-membership = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-nomination-pools = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-offences = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-ranked-collective = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-recovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-referenda = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-society = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-staking-reward-fn = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system = {git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-tips = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-whitelist = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false } pallet-xcm-benchmarks = { path = "../../xcm/pallet-xcm-benchmarks", default-features = false, optional = true } -frame-election-provider-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +frame-election-provider-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-election-provider-support-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-election-provider-support-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } hex-literal = { version = "0.3.4", optional = true } runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false } @@ -100,16 +105,16 @@ xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default [dev-dependencies] hex-literal = "0.3.4" tiny-keccak = { version = "2.0.2", features = ["keccak"] } -keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } separator = "0.4.1" serde_json = "1.0.81" -remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } tokio = { version = "1.19.2", features = ["macros"] } -sp-tracing = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-tracing = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] default = ["std"] @@ -141,8 +146,10 @@ std = [ "pallet-transaction-payment/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-collective/std", + "pallet-conviction-voting/std", "pallet-elections-phragmen/std", "pallet-election-provider-multi-phase/std", + "pallet-fast-unstake/std", "pallet-democracy/std", "pallet-gilt/std", "pallet-grandpa/std", @@ -156,7 +163,9 @@ std = [ "pallet-offences/std", "pallet-preimage/std", "pallet-proxy/std", + "pallet-ranked-collective/std", "pallet-recovery/std", + "pallet-referenda/std", "pallet-scheduler/std", "pallet-session/std", "pallet-society/std", @@ -167,6 +176,7 @@ std = [ "pallet-treasury/std", "pallet-utility/std", "pallet-vesting/std", + "pallet-whitelist/std", "pallet-babe/std", "pallet-xcm/std", "sp-mmr-primitives/std", @@ -202,10 +212,12 @@ runtime-benchmarks = [ "pallet-bounties/runtime-benchmarks", "pallet-child-bounties/runtime-benchmarks", "pallet-collective/runtime-benchmarks", + "pallet-conviction-voting/runtime-benchmarks", "pallet-democracy/runtime-benchmarks", "pallet-elections-phragmen/runtime-benchmarks", "pallet-election-provider-multi-phase/runtime-benchmarks", "pallet-election-provider-support-benchmarking/runtime-benchmarks", + "pallet-fast-unstake/runtime-benchmarks", "pallet-gilt/runtime-benchmarks", "pallet-grandpa/runtime-benchmarks", "pallet-identity/runtime-benchmarks", @@ -214,9 +226,11 @@ runtime-benchmarks = [ "pallet-membership/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", "pallet-nomination-pools/runtime-benchmarks", - "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-benchmarking/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", + "pallet-ranked-collective/runtime-benchmarks", + "pallet-referenda/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", "pallet-society/runtime-benchmarks", "pallet-recovery/runtime-benchmarks", @@ -226,16 +240,17 @@ runtime-benchmarks = [ "pallet-treasury/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", - "pallet-offences-benchmarking", - "pallet-session-benchmarking", + "pallet-offences-benchmarking/runtime-benchmarks", + "pallet-session-benchmarking/runtime-benchmarks", + "pallet-whitelist/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", - "frame-system-benchmarking", + "frame-system-benchmarking/runtime-benchmarks", "hex-literal", "xcm-builder/runtime-benchmarks", "frame-election-provider-support/runtime-benchmarks", "pallet-bags-list/runtime-benchmarks", "runtime-parachains/runtime-benchmarks", - "pallet-xcm-benchmarks", + "pallet-xcm-benchmarks/runtime-benchmarks", ] try-runtime = [ "frame-executive/try-runtime", @@ -243,15 +258,18 @@ try-runtime = [ "frame-system/try-runtime", "pallet-authority-discovery/try-runtime", "pallet-authorship/try-runtime", - "pallet-balances/try-runtime", "pallet-bags-list/try-runtime", + "pallet-balances/try-runtime", "pallet-bounties/try-runtime", "pallet-child-bounties/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-collective/try-runtime", + "pallet-conviction-voting/try-runtime", "pallet-elections-phragmen/try-runtime", "pallet-election-provider-multi-phase/try-runtime", + "pallet-fast-unstake/try-runtime", "pallet-democracy/try-runtime", + "pallet-gilt/try-runtime", "pallet-grandpa/try-runtime", "pallet-identity/try-runtime", "pallet-im-online/try-runtime", @@ -262,7 +280,9 @@ try-runtime = [ "pallet-offences/try-runtime", "pallet-preimage/try-runtime", "pallet-proxy/try-runtime", + "pallet-ranked-collective/try-runtime", "pallet-recovery/try-runtime", + "pallet-referenda/try-runtime", "pallet-scheduler/try-runtime", "pallet-session/try-runtime", "pallet-society/try-runtime", @@ -272,7 +292,9 @@ try-runtime = [ "pallet-treasury/try-runtime", "pallet-utility/try-runtime", "pallet-vesting/try-runtime", + "pallet-whitelist/try-runtime", "pallet-babe/try-runtime", + "pallet-xcm/try-runtime", "runtime-common/try-runtime", ] # When enabled, the runtime API will not be build. diff --git a/runtime/kusama/constants/Cargo.toml b/runtime/kusama/constants/Cargo.toml index c7a32f27aa55..7d8913f0025a 100644 --- a/runtime/kusama/constants/Cargo.toml +++ b/runtime/kusama/constants/Cargo.toml @@ -1,19 +1,23 @@ [package] name = "kusama-runtime-constants" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] smallvec = "1.8.0" -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } primitives = { package = "polkadot-primitives", path = "../../../primitives", default-features = false } runtime-common = { package = "polkadot-runtime-common", path = "../../common", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } [features] default = ["std"] std = [ - "sp-runtime/std" + "sp-core/std", + "sp-runtime/std", + "sp-weights/std" ] diff --git a/runtime/kusama/constants/src/lib.rs b/runtime/kusama/constants/src/lib.rs index 00e429cff568..a8d047241b24 100644 --- a/runtime/kusama/constants/src/lib.rs +++ b/runtime/kusama/constants/src/lib.rs @@ -27,7 +27,8 @@ pub mod currency { pub const UNITS: Balance = 1_000_000_000_000; pub const CENTS: Balance = UNITS / 30_000; - pub const GRAND: Balance = CENTS * 100_000; + pub const QUID: Balance = CENTS * 100; + pub const GRAND: Balance = QUID * 1_000; pub const MILLICENTS: Balance = CENTS / 1_000; pub const fn deposit(items: u32, bytes: u32) -> Balance { @@ -50,6 +51,9 @@ pub mod time { pub const WEEKS: BlockNumber = DAYS * 7; // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. + // The choice of is done in accordance to the slot duration and expected target + // block time, for safely resisting network delays of maximum two seconds. + // pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); } @@ -82,7 +86,7 @@ pub mod fee { fn polynomial() -> WeightToFeeCoefficients { // in Kusama, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: let p = super::currency::CENTS; - let q = 10 * Balance::from(ExtrinsicBaseWeight::get()); + let q = 10 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); smallvec![WeightToFeeCoefficient { degree: 1, negative: false, diff --git a/runtime/kusama/constants/src/weights/block_weights.rs b/runtime/kusama/constants/src/weights/block_weights.rs index 62040e22b956..cbe644d95629 100644 --- a/runtime/kusama/constants/src/weights/block_weights.rs +++ b/runtime/kusama/constants/src/weights/block_weights.rs @@ -1,28 +1,26 @@ -// This file is part of Substrate. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// 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. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// 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 . //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19 (Y/M/D) +//! DATE: 2022-10-25 (Y/M/D) //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Development` //! WARMUPS: `10`, REPEAT: `100` //! WEIGHT-PATH: `runtime/kusama/constants/src/weights/` -//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1`, WEIGHT-ADD: `0` +//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` // Executed Command: // ./target/production/polkadot @@ -34,32 +32,31 @@ // --weight-path=runtime/kusama/constants/src/weights/ // --warmup=10 // --repeat=100 +// --header=./file_header.txt -use frame_support::{ - parameter_types, - weights::{constants::WEIGHT_PER_NANOS, Weight}, -}; +use sp_core::parameter_types; +use sp_weights::{constants::WEIGHT_PER_NANOS, Weight}; parameter_types! { /// Time to execute an empty block. - /// Calculated by multiplying the *Average* with `1` and adding `0`. + /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 6_094_385, 6_351_993 - /// Average: 6_192_341 - /// Median: 6_193_838 - /// Std-Dev: 63893.84 + /// Min, Max: 6_336_696, 6_629_376 + /// Average: 6_435_161 + /// Median: 6_432_853 + /// Std-Dev: 60191.34 /// /// Percentiles nanoseconds: - /// 99th: 6_332_047 - /// 95th: 6_308_225 - /// 75th: 6_236_204 - pub const BlockExecutionWeight: Weight = 6_192_341 * WEIGHT_PER_NANOS; + /// 99th: 6_588_459 + /// 95th: 6_521_973 + /// 75th: 6_477_748 + pub const BlockExecutionWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(6_435_161); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; + use sp_weights::constants; /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, @@ -69,8 +66,14 @@ mod test_weights { let w = super::BlockExecutionWeight::get(); // At least 100 µs. - assert!(w >= 100 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs."); + assert!( + w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(), + "Weight should be at least 100 µs." + ); // At most 50 ms. - assert!(w <= 50 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); + assert!( + w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(), + "Weight should be at most 50 ms." + ); } } diff --git a/runtime/kusama/constants/src/weights/extrinsic_weights.rs b/runtime/kusama/constants/src/weights/extrinsic_weights.rs index 4bd59b9f56da..ee8c6b2fa50f 100644 --- a/runtime/kusama/constants/src/weights/extrinsic_weights.rs +++ b/runtime/kusama/constants/src/weights/extrinsic_weights.rs @@ -1,27 +1,26 @@ -// This file is part of Substrate. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// 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. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// 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 . //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-04-20 (Y/M/D) +//! DATE: 2022-10-25 (Y/M/D) +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Development` //! WARMUPS: `10`, REPEAT: `100` //! WEIGHT-PATH: `runtime/kusama/constants/src/weights/` -//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1`, WEIGHT-ADD: `0` +//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` // Executed Command: // ./target/production/polkadot @@ -33,32 +32,31 @@ // --weight-path=runtime/kusama/constants/src/weights/ // --warmup=10 // --repeat=100 +// --header=./file_header.txt -use frame_support::{ - parameter_types, - weights::{constants::WEIGHT_PER_NANOS, Weight}, -}; +use sp_core::parameter_types; +use sp_weights::{constants::WEIGHT_PER_NANOS, Weight}; parameter_types! { /// Time to execute a NO-OP extrinsic, for example `System::remark`. - /// Calculated by multiplying the *Average* with `1` and adding `0`. + /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// - /// Stats [NS]: - /// Min, Max: 85_946, 88_408 - /// Average: 86_309 - /// Median: 86_213 - /// Std-Dev: 345.03 + /// Stats nanoseconds: + /// Min, Max: 95_139, 96_661 + /// Average: 95_578 + /// Median: 95_507 + /// Std-Dev: 279.89 /// - /// Percentiles [NS]: - /// 99th: 87_527 - /// 95th: 86_901 - /// 75th: 86_308 - pub const ExtrinsicBaseWeight: Weight = 86_309 * WEIGHT_PER_NANOS; + /// Percentiles nanoseconds: + /// 99th: 96_641 + /// 95th: 96_239 + /// 75th: 95_630 + pub const ExtrinsicBaseWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(95_578); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; + use sp_weights::constants; /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, @@ -68,8 +66,14 @@ mod test_weights { let w = super::ExtrinsicBaseWeight::get(); // At least 10 µs. - assert!(w >= 10 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); + assert!( + w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(), + "Weight should be at least 10 µs." + ); // At most 1 ms. - assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); + assert!( + w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), + "Weight should be at most 1 ms." + ); } } diff --git a/runtime/kusama/constants/src/weights/paritydb_weights.rs b/runtime/kusama/constants/src/weights/paritydb_weights.rs index 843823c1bf30..dca7d348310c 100644 --- a/runtime/kusama/constants/src/weights/paritydb_weights.rs +++ b/runtime/kusama/constants/src/weights/paritydb_weights.rs @@ -25,8 +25,8 @@ pub mod constants { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 8_000 * constants::WEIGHT_PER_NANOS, - write: 50_000 * constants::WEIGHT_PER_NANOS, + read: 8_000 * constants::WEIGHT_PER_NANOS.ref_time(), + write: 50_000 * constants::WEIGHT_PER_NANOS.ref_time(), }; } @@ -42,20 +42,20 @@ pub mod constants { fn sane() { // At least 1 µs. assert!( - W::get().reads(1) >= constants::WEIGHT_PER_MICROS, + W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Read weight should be at least 1 µs." ); assert!( - W::get().writes(1) >= constants::WEIGHT_PER_MICROS, + W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Write weight should be at least 1 µs." ); // At most 1 ms. assert!( - W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, + W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Read weight should be at most 1 ms." ); assert!( - W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, + W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Write weight should be at most 1 ms." ); } diff --git a/runtime/kusama/constants/src/weights/rocksdb_weights.rs b/runtime/kusama/constants/src/weights/rocksdb_weights.rs index 05e06b0eabe3..87867ebfe177 100644 --- a/runtime/kusama/constants/src/weights/rocksdb_weights.rs +++ b/runtime/kusama/constants/src/weights/rocksdb_weights.rs @@ -25,8 +25,8 @@ pub mod constants { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 25_000 * constants::WEIGHT_PER_NANOS, - write: 100_000 * constants::WEIGHT_PER_NANOS, + read: 25_000 * constants::WEIGHT_PER_NANOS.ref_time(), + write: 100_000 * constants::WEIGHT_PER_NANOS.ref_time(), }; } @@ -42,20 +42,20 @@ pub mod constants { fn sane() { // At least 1 µs. assert!( - W::get().reads(1) >= constants::WEIGHT_PER_MICROS, + W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Read weight should be at least 1 µs." ); assert!( - W::get().writes(1) >= constants::WEIGHT_PER_MICROS, + W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Write weight should be at least 1 µs." ); // At most 1 ms. assert!( - W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, + W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Read weight should be at most 1 ms." ); assert!( - W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, + W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Write weight should be at most 1 ms." ); } diff --git a/runtime/kusama/src/governance/fellowship.rs b/runtime/kusama/src/governance/fellowship.rs new file mode 100644 index 000000000000..52ab8d0bebc8 --- /dev/null +++ b/runtime/kusama/src/governance/fellowship.rs @@ -0,0 +1,369 @@ +// Copyright 2022 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 . + +//! Elements of governance concerning the Polkadot Fellowship. This is only a temporary arrangement +//! since the Polkadot Fellowship belongs under the Polkadot Relay. However, that is not yet in +//! place, so until then it will need to live here. Once it is in place and there exists a bridge +//! between Polkadot/Kusama then this code can be removed. + +use frame_support::traits::{MapSuccess, TryMapSuccess}; +use sp_arithmetic::traits::CheckedSub; +use sp_runtime::{ + morph_types, + traits::{ConstU16, Replace, TypedGet}, +}; + +use super::*; +use crate::{DAYS, QUID}; + +parameter_types! { + pub const AlarmInterval: BlockNumber = 1; + pub const SubmissionDeposit: Balance = 0; + pub const UndecidingTimeout: BlockNumber = 7 * DAYS; +} + +pub struct TracksInfo; +impl pallet_referenda::TracksInfo for TracksInfo { + type Id = u16; + type RuntimeOrigin = ::PalletsOrigin; + fn tracks() -> &'static [(Self::Id, pallet_referenda::TrackInfo)] { + static DATA: [(u16, pallet_referenda::TrackInfo); 10] = [ + ( + 0u16, + pallet_referenda::TrackInfo { + name: "candidates", + max_deciding: 10, + decision_deposit: 100 * QUID, + prepare_period: 30 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 30 * MINUTES, + min_enactment_period: 4, + min_approval: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(50), + ceil: Perbill::from_percent(100), + }, + min_support: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(0), + ceil: Perbill::from_percent(50), + }, + }, + ), + ( + 1u16, + pallet_referenda::TrackInfo { + name: "members", + max_deciding: 10, + decision_deposit: 10 * QUID, + prepare_period: 30 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 30 * MINUTES, + min_enactment_period: 4, + min_approval: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(50), + ceil: Perbill::from_percent(100), + }, + min_support: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(0), + ceil: Perbill::from_percent(50), + }, + }, + ), + ( + 2u16, + pallet_referenda::TrackInfo { + name: "proficients", + max_deciding: 10, + decision_deposit: 10 * QUID, + prepare_period: 30 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 30 * MINUTES, + min_enactment_period: 4, + min_approval: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(50), + ceil: Perbill::from_percent(100), + }, + min_support: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(0), + ceil: Perbill::from_percent(50), + }, + }, + ), + ( + 3u16, + pallet_referenda::TrackInfo { + name: "fellows", + max_deciding: 10, + decision_deposit: 10 * QUID, + prepare_period: 30 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 30 * MINUTES, + min_enactment_period: 1 * MINUTES, + min_approval: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(50), + ceil: Perbill::from_percent(100), + }, + min_support: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(0), + ceil: Perbill::from_percent(50), + }, + }, + ), + ( + 4u16, + pallet_referenda::TrackInfo { + name: "senior fellows", + max_deciding: 10, + decision_deposit: 10 * QUID, + prepare_period: 30 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 30 * MINUTES, + min_enactment_period: 4, + min_approval: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(50), + ceil: Perbill::from_percent(100), + }, + min_support: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(0), + ceil: Perbill::from_percent(50), + }, + }, + ), + ( + 5u16, + pallet_referenda::TrackInfo { + name: "experts", + max_deciding: 10, + decision_deposit: 1 * QUID, + prepare_period: 30 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 30 * MINUTES, + min_enactment_period: 4, + min_approval: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(50), + ceil: Perbill::from_percent(100), + }, + min_support: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(0), + ceil: Perbill::from_percent(50), + }, + }, + ), + ( + 6u16, + pallet_referenda::TrackInfo { + name: "senior experts", + max_deciding: 10, + decision_deposit: 1 * QUID, + prepare_period: 30 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 30 * MINUTES, + min_enactment_period: 4, + min_approval: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(50), + ceil: Perbill::from_percent(100), + }, + min_support: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(0), + ceil: Perbill::from_percent(50), + }, + }, + ), + ( + 7u16, + pallet_referenda::TrackInfo { + name: "masters", + max_deciding: 10, + decision_deposit: 1 * QUID, + prepare_period: 30 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 30 * MINUTES, + min_enactment_period: 4, + min_approval: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(50), + ceil: Perbill::from_percent(100), + }, + min_support: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(0), + ceil: Perbill::from_percent(50), + }, + }, + ), + ( + 8u16, + pallet_referenda::TrackInfo { + name: "senior masters", + max_deciding: 10, + decision_deposit: 1 * QUID, + prepare_period: 30 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 30 * MINUTES, + min_enactment_period: 4, + min_approval: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(50), + ceil: Perbill::from_percent(100), + }, + min_support: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(0), + ceil: Perbill::from_percent(50), + }, + }, + ), + ( + 9u16, + pallet_referenda::TrackInfo { + name: "grand masters", + max_deciding: 10, + decision_deposit: 1 * QUID, + prepare_period: 30 * MINUTES, + decision_period: 7 * DAYS, + confirm_period: 30 * MINUTES, + min_enactment_period: 4, + min_approval: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(50), + ceil: Perbill::from_percent(100), + }, + min_support: pallet_referenda::Curve::LinearDecreasing { + length: Perbill::from_percent(100), + floor: Perbill::from_percent(0), + ceil: Perbill::from_percent(50), + }, + }, + ), + ]; + &DATA[..] + } + fn track_for(id: &Self::RuntimeOrigin) -> Result { + use super::origins::Origin; + + #[cfg(feature = "runtime-benchmarks")] + { + // For benchmarks, we enable a root origin. + // It is important that this is not available in production! + let root: Self::RuntimeOrigin = frame_system::RawOrigin::Root.into(); + if &root == id { + return Ok(9) + } + } + + match Origin::try_from(id.clone()) { + Ok(Origin::FellowshipInitiates) => Ok(0), + Ok(Origin::Fellowship1Dan) => Ok(1), + Ok(Origin::Fellowship2Dan) => Ok(2), + Ok(Origin::Fellowship3Dan) | Ok(Origin::Fellows) => Ok(3), + Ok(Origin::Fellowship4Dan) => Ok(4), + Ok(Origin::Fellowship5Dan) | Ok(Origin::FellowshipExperts) => Ok(5), + Ok(Origin::Fellowship6Dan) => Ok(6), + Ok(Origin::Fellowship7Dan | Origin::FellowshipMasters) => Ok(7), + Ok(Origin::Fellowship8Dan) => Ok(8), + Ok(Origin::Fellowship9Dan) => Ok(9), + _ => Err(()), + } + } +} +pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber); + +pub type FellowshipReferendaInstance = pallet_referenda::Instance2; + +impl pallet_referenda::Config for Runtime { + type WeightInfo = weights::pallet_referenda_fellowship_referenda::WeightInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type Scheduler = Scheduler; + type Currency = Balances; + type SubmitOrigin = + pallet_ranked_collective::EnsureMember; + type CancelOrigin = FellowshipExperts; + type KillOrigin = FellowshipMasters; + type Slash = Treasury; + type Votes = pallet_ranked_collective::Votes; + type Tally = pallet_ranked_collective::TallyOf; + type SubmissionDeposit = SubmissionDeposit; + type MaxQueued = ConstU32<100>; + type UndecidingTimeout = UndecidingTimeout; + type AlarmInterval = AlarmInterval; + type Tracks = TracksInfo; + type Preimages = Preimage; +} + +pub type FellowshipCollectiveInstance = pallet_ranked_collective::Instance1; + +morph_types! { + /// A `TryMorph` implementation to reduce a scalar by a particular amount, checking for + /// underflow. + pub type CheckedReduceBy: TryMorph = |r: N::Type| -> Result { + r.checked_sub(&N::get()).ok_or(()) + } where N::Type: CheckedSub; +} + +impl pallet_ranked_collective::Config for Runtime { + type WeightInfo = weights::pallet_ranked_collective::WeightInfo; + type RuntimeEvent = RuntimeEvent; + // Promotion is by any of: + // - Root can demote arbitrarily. + // - the FellowshipAdmin origin (i.e. token holder referendum); + // - a vote by the rank *above* the new rank. + type PromoteOrigin = EitherOf< + EitherOf< + frame_system::EnsureRootWithSuccess>, + MapSuccess< + pallet_collective::EnsureProportionAtLeast< + Self::AccountId, + super::old::TechnicalCollective, + 2, + 3, + >, + Replace>, + >, + >, + EitherOf< + MapSuccess>>, + TryMapSuccess>>, + >, + >; + // Demotion is by any of: + // - Root can demote arbitrarily. + // - the FellowshipAdmin origin (i.e. token holder referendum); + // - a vote by the rank two above the current rank. + type DemoteOrigin = EitherOf< + frame_system::EnsureRootWithSuccess>, + EitherOf< + MapSuccess>>, + TryMapSuccess>>, + >, + >; + type Polls = FellowshipReferenda; + type MinRankOfClass = sp_runtime::traits::Identity; + type VoteWeight = pallet_ranked_collective::Geometric; +} diff --git a/runtime/kusama/src/governance/mod.rs b/runtime/kusama/src/governance/mod.rs index 27aa07a4795b..87cbfd7eea2f 100644 --- a/runtime/kusama/src/governance/mod.rs +++ b/runtime/kusama/src/governance/mod.rs @@ -14,7 +14,82 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -//! Governance configurations for the Kusama runtime. +//! New governance configurations for the Kusama runtime. + +use super::*; +use frame_support::{ + parameter_types, + traits::{ConstU16, EitherOf}, +}; +use frame_system::EnsureRootWithSuccess; // Old governance configurations. pub mod old; + +mod origins; +pub use origins::{ + pallet_custom_origins, AuctionAdmin, Fellows, FellowshipAdmin, FellowshipExperts, + FellowshipInitiates, FellowshipMasters, GeneralAdmin, LeaseAdmin, ReferendumCanceller, + ReferendumKiller, Spender, StakingAdmin, WhitelistedCaller, +}; +mod tracks; +pub use tracks::TracksInfo; +mod fellowship; +pub use fellowship::{FellowshipCollectiveInstance, FellowshipReferendaInstance}; + +parameter_types! { + pub const VoteLockingPeriod: BlockNumber = 7 * DAYS; +} + +impl pallet_conviction_voting::Config for Runtime { + type WeightInfo = weights::pallet_conviction_voting::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type VoteLockingPeriod = VoteLockingPeriod; + type MaxVotes = ConstU32<512>; + type MaxTurnout = frame_support::traits::TotalIssuanceOf; + type Polls = Referenda; +} + +parameter_types! { + pub const AlarmInterval: BlockNumber = 1; + pub const SubmissionDeposit: Balance = 100 * UNITS; + pub const UndecidingTimeout: BlockNumber = 28 * DAYS; +} + +parameter_types! { + pub const MaxBalance: Balance = Balance::max_value(); +} +pub type TreasurySpender = EitherOf, Spender>; + +impl origins::pallet_custom_origins::Config for Runtime {} + +impl pallet_whitelist::Config for Runtime { + type WeightInfo = weights::pallet_whitelist::WeightInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type WhitelistOrigin = + EitherOf>, Fellows>; + type DispatchWhitelistedOrigin = EitherOf, WhitelistedCaller>; + type PreimageProvider = Preimage; +} + +impl pallet_referenda::Config for Runtime { + type WeightInfo = weights::pallet_referenda_referenda::WeightInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type Scheduler = Scheduler; + type Currency = Balances; + type SubmitOrigin = frame_system::EnsureSigned; + type CancelOrigin = ReferendumCanceller; + type KillOrigin = ReferendumKiller; + type Slash = Treasury; + type Votes = pallet_conviction_voting::VotesOf; + type Tally = pallet_conviction_voting::TallyOf; + type SubmissionDeposit = SubmissionDeposit; + type MaxQueued = ConstU32<100>; + type UndecidingTimeout = UndecidingTimeout; + type AlarmInterval = AlarmInterval; + type Tracks = TracksInfo; + type Preimages = Preimage; +} diff --git a/runtime/kusama/src/governance/old.rs b/runtime/kusama/src/governance/old.rs index a87ddf6ec1fc..9365c903198a 100644 --- a/runtime/kusama/src/governance/old.rs +++ b/runtime/kusama/src/governance/old.rs @@ -32,8 +32,7 @@ parameter_types! { } impl pallet_democracy::Config for Runtime { - type Proposal = Call; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type EnactmentPeriod = EnactmentPeriod; type VoteLockingPeriod = EnactmentPeriod; @@ -74,14 +73,15 @@ impl pallet_democracy::Config for Runtime { // only do it once and it lasts only for the cooloff period. type VetoOrigin = pallet_collective::EnsureMember; type CooloffPeriod = CooloffPeriod; - type PreimageByteDeposit = PreimageByteDeposit; - type OperationalPreimageOrigin = pallet_collective::EnsureMember; type Slash = Treasury; type Scheduler = Scheduler; type PalletsOrigin = OriginCaller; type MaxVotes = MaxVotes; type WeightInfo = weights::pallet_democracy::WeightInfo; type MaxProposals = MaxProposals; + type Preimages = Preimage; + type MaxDeposits = ConstU32<100>; + type MaxBlacklisted = ConstU32<100>; } parameter_types! { @@ -92,9 +92,9 @@ parameter_types! { pub type CouncilCollective = pallet_collective::Instance1; impl pallet_collective::Config for Runtime { - type Origin = Origin; - type Proposal = Call; - type Event = Event; + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; type MotionDuration = CouncilMotionDuration; type MaxProposals = CouncilMaxProposals; type MaxMembers = CouncilMaxMembers; @@ -121,7 +121,7 @@ parameter_types! { const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); impl pallet_elections_phragmen::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ChangeMembers = Council; type InitializeMembers = Council; @@ -148,9 +148,9 @@ parameter_types! { pub type TechnicalCollective = pallet_collective::Instance2; impl pallet_collective::Config for Runtime { - type Origin = Origin; - type Proposal = Call; - type Event = Event; + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; type MotionDuration = TechnicalMotionDuration; type MaxProposals = TechnicalMaxProposals; type MaxMembers = TechnicalMaxMembers; @@ -159,12 +159,12 @@ impl pallet_collective::Config for Runtime { } impl pallet_membership::Config for Runtime { - type Event = Event; - type AddOrigin = MoreThanHalfCouncil; - type RemoveOrigin = MoreThanHalfCouncil; - type SwapOrigin = MoreThanHalfCouncil; - type ResetOrigin = MoreThanHalfCouncil; - type PrimeOrigin = MoreThanHalfCouncil; + type RuntimeEvent = RuntimeEvent; + type AddOrigin = EnsureRoot; + type RemoveOrigin = EnsureRoot; + type SwapOrigin = EnsureRoot; + type ResetOrigin = EnsureRoot; + type PrimeOrigin = EnsureRoot; type MembershipInitialized = TechnicalCommittee; type MembershipChanged = TechnicalCommittee; type MaxMembers = TechnicalMaxMembers; diff --git a/runtime/kusama/src/governance/origins.rs b/runtime/kusama/src/governance/origins.rs new file mode 100644 index 000000000000..be8c44430f46 --- /dev/null +++ b/runtime/kusama/src/governance/origins.rs @@ -0,0 +1,192 @@ +// Copyright 2022 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 . + +//! Custom origins for governance interventions. + +pub use pallet_custom_origins::*; + +#[frame_support::pallet] +pub mod pallet_custom_origins { + use crate::{Balance, GRAND, QUID}; + use frame_support::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config {} + + #[pallet::pallet] + pub struct Pallet(_); + + #[derive(PartialEq, Eq, Clone, MaxEncodedLen, Encode, Decode, TypeInfo, RuntimeDebug)] + #[pallet::origin] + pub enum Origin { + /// Origin for cancelling slashes. + StakingAdmin, + /// Origin for spending (any amount of) funds. + Treasurer, + /// Origin for managing the composition of the fellowship. + FellowshipAdmin, + /// Origin for managing the registrar. + GeneralAdmin, + /// Origin for starting auctions. + AuctionAdmin, + /// Origin able to force slot leases. + LeaseAdmin, + /// Origin able to cancel referenda. + ReferendumCanceller, + /// Origin able to kill referenda. + ReferendumKiller, + /// Origin able to spend up to 1 KSM from the treasury at once. + SmallTipper, + /// Origin able to spend up to 5 KSM from the treasury at once. + BigTipper, + /// Origin able to spend up to 50 KSM from the treasury at once. + SmallSpender, + /// Origin able to spend up to 500 KSM from the treasury at once. + MediumSpender, + /// Origin able to spend up to 5,000 KSM from the treasury at once. + BigSpender, + /// Origin able to dispatch a whitelisted call. + WhitelistedCaller, + /// Origin commanded by any members of the Polkadot Fellowship (no Dan grade needed). + FellowshipInitiates, + /// Origin commanded by Polkadot Fellows (3rd Dan fellows or greater). + Fellows, + /// Origin commanded by Polkadot Experts (5th Dan fellows or greater). + FellowshipExperts, + /// Origin commanded by Polkadot Masters (7th Dan fellows of greater). + FellowshipMasters, + /// Origin commanded by rank 1 of the Polkadot Fellowship and with a success of 1. + Fellowship1Dan, + /// Origin commanded by rank 2 of the Polkadot Fellowship and with a success of 2. + Fellowship2Dan, + /// Origin commanded by rank 3 of the Polkadot Fellowship and with a success of 3. + Fellowship3Dan, + /// Origin commanded by rank 4 of the Polkadot Fellowship and with a success of 4. + Fellowship4Dan, + /// Origin commanded by rank 5 of the Polkadot Fellowship and with a success of 5. + Fellowship5Dan, + /// Origin commanded by rank 6 of the Polkadot Fellowship and with a success of 6. + Fellowship6Dan, + /// Origin commanded by rank 7 of the Polkadot Fellowship and with a success of 7. + Fellowship7Dan, + /// Origin commanded by rank 8 of the Polkadot Fellowship and with a success of 8. + Fellowship8Dan, + /// Origin commanded by rank 9 of the Polkadot Fellowship and with a success of 9. + Fellowship9Dan, + } + + macro_rules! decl_unit_ensures { + ( $name:ident: $success_type:ty = $success:expr ) => { + pub struct $name; + impl> + From> + EnsureOrigin for $name + { + type Success = $success_type; + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + Origin::$name => Ok($success), + r => Err(O::from(r)), + }) + } + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin() -> Result { + Ok(O::from(Origin::$name)) + } + } + }; + ( $name:ident ) => { decl_unit_ensures! { $name : () = () } }; + ( $name:ident: $success_type:ty = $success:expr, $( $rest:tt )* ) => { + decl_unit_ensures! { $name: $success_type = $success } + decl_unit_ensures! { $( $rest )* } + }; + ( $name:ident, $( $rest:tt )* ) => { + decl_unit_ensures! { $name } + decl_unit_ensures! { $( $rest )* } + }; + () => {} + } + decl_unit_ensures!( + StakingAdmin, + FellowshipAdmin, + GeneralAdmin, + AuctionAdmin, + LeaseAdmin, + ReferendumCanceller, + ReferendumKiller, + WhitelistedCaller, + FellowshipInitiates: u16 = 0, + Fellows: u16 = 3, + FellowshipExperts: u16 = 5, + FellowshipMasters: u16 = 7, + ); + + macro_rules! decl_ensure { + ( + $vis:vis type $name:ident: EnsureOrigin { + $( $item:ident = $success:expr, )* + } + ) => { + $vis struct $name; + impl> + From> + EnsureOrigin for $name + { + type Success = $success_type; + fn try_origin(o: O) -> Result { + o.into().and_then(|o| match o { + $( + Origin::$item => Ok($success), + )* + r => Err(O::from(r)), + }) + } + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin() -> Result { + // By convention the more privileged origins go later, so for greatest chance + // of success, we want the last one. + let _result: Result = Err(()); + $( + let _result: Result = Ok(O::from(Origin::$item)); + )* + _result + } + } + } + } + + decl_ensure! { + pub type Spender: EnsureOrigin { + SmallTipper = 250 * QUID, + BigTipper = 1 * GRAND, + SmallSpender = 10 * GRAND, + MediumSpender = 100 * GRAND, + BigSpender = 1_000 * GRAND, + } + } + + decl_ensure! { + pub type EnsureFellowship: EnsureOrigin { + Fellowship1Dan = 1, + Fellowship2Dan = 2, + Fellowship3Dan = 3, + Fellowship4Dan = 4, + Fellowship5Dan = 5, + Fellowship6Dan = 6, + Fellowship7Dan = 7, + Fellowship8Dan = 8, + Fellowship9Dan = 9, + } + } +} diff --git a/runtime/kusama/src/governance/tracks.rs b/runtime/kusama/src/governance/tracks.rs new file mode 100644 index 000000000000..fd1c94118507 --- /dev/null +++ b/runtime/kusama/src/governance/tracks.rs @@ -0,0 +1,320 @@ +// Copyright 2022 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 . + +//! Track configurations for governance. + +use super::*; + +const fn percent(x: i32) -> sp_arithmetic::FixedI64 { + sp_arithmetic::FixedI64::from_rational(x as u128, 100) +} +use pallet_referenda::Curve; +const APP_ROOT: Curve = Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100)); +const SUP_ROOT: Curve = Curve::make_linear(28, 28, percent(0), percent(50)); +const APP_STAKING_ADMIN: Curve = Curve::make_linear(17, 28, percent(50), percent(100)); +const SUP_STAKING_ADMIN: Curve = + Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50)); +const APP_TREASURER: Curve = Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100)); +const SUP_TREASURER: Curve = Curve::make_linear(28, 28, percent(0), percent(50)); +const APP_FELLOWSHIP_ADMIN: Curve = Curve::make_linear(17, 28, percent(50), percent(100)); +const SUP_FELLOWSHIP_ADMIN: Curve = + Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50)); +const APP_GENERAL_ADMIN: Curve = + Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100)); +const SUP_GENERAL_ADMIN: Curve = + Curve::make_reciprocal(7, 28, percent(10), percent(0), percent(50)); +const APP_AUCTION_ADMIN: Curve = + Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100)); +const SUP_AUCTION_ADMIN: Curve = + Curve::make_reciprocal(7, 28, percent(10), percent(0), percent(50)); +const APP_LEASE_ADMIN: Curve = Curve::make_linear(17, 28, percent(50), percent(100)); +const SUP_LEASE_ADMIN: Curve = Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50)); +const APP_REFERENDUM_CANCELLER: Curve = Curve::make_linear(17, 28, percent(50), percent(100)); +const SUP_REFERENDUM_CANCELLER: Curve = + Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50)); +const APP_REFERENDUM_KILLER: Curve = Curve::make_linear(17, 28, percent(50), percent(100)); +const SUP_REFERENDUM_KILLER: Curve = + Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50)); +const APP_SMALL_TIPPER: Curve = Curve::make_linear(10, 28, percent(50), percent(100)); +const SUP_SMALL_TIPPER: Curve = Curve::make_reciprocal(1, 28, percent(4), percent(0), percent(50)); +const APP_BIG_TIPPER: Curve = Curve::make_linear(10, 28, percent(50), percent(100)); +const SUP_BIG_TIPPER: Curve = Curve::make_reciprocal(8, 28, percent(1), percent(0), percent(50)); +const APP_SMALL_SPENDER: Curve = Curve::make_linear(17, 28, percent(50), percent(100)); +const SUP_SMALL_SPENDER: Curve = + Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50)); +const APP_MEDIUM_SPENDER: Curve = Curve::make_linear(23, 28, percent(50), percent(100)); +const SUP_MEDIUM_SPENDER: Curve = + Curve::make_reciprocal(16, 28, percent(1), percent(0), percent(50)); +const APP_BIG_SPENDER: Curve = Curve::make_linear(28, 28, percent(50), percent(100)); +const SUP_BIG_SPENDER: Curve = Curve::make_reciprocal(20, 28, percent(1), percent(0), percent(50)); +const APP_WHITELISTED_CALLER: Curve = + Curve::make_reciprocal(16, 28 * 24, percent(96), percent(50), percent(100)); +const SUP_WHITELISTED_CALLER: Curve = + Curve::make_reciprocal(1, 28, percent(20), percent(10), percent(50)); + +const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 15] = [ + ( + 0, + pallet_referenda::TrackInfo { + name: "root", + max_deciding: 1, + decision_deposit: 1_000 * GRAND, + prepare_period: 3 * HOURS, + decision_period: 28 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 3 * HOURS, + min_approval: APP_ROOT, + min_support: SUP_ROOT, + }, + ), + ( + 1, + pallet_referenda::TrackInfo { + name: "whitelisted_caller", + max_deciding: 10, + decision_deposit: 10_000 * GRAND, + prepare_period: 3 * HOURS, + decision_period: 28 * DAYS, + confirm_period: 10 * MINUTES, + min_enactment_period: 30 * MINUTES, + min_approval: APP_WHITELISTED_CALLER, + min_support: SUP_WHITELISTED_CALLER, + }, + ), + ( + 10, + pallet_referenda::TrackInfo { + name: "staking_admin", + max_deciding: 10, + decision_deposit: 5 * GRAND, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 2 * DAYS, + min_approval: APP_STAKING_ADMIN, + min_support: SUP_STAKING_ADMIN, + }, + ), + ( + 11, + pallet_referenda::TrackInfo { + name: "treasurer", + max_deciding: 10, + decision_deposit: 5 * GRAND, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 2 * DAYS, + min_approval: APP_TREASURER, + min_support: SUP_TREASURER, + }, + ), + ( + 12, + pallet_referenda::TrackInfo { + name: "lease_admin", + max_deciding: 10, + decision_deposit: 5 * GRAND, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 2 * DAYS, + min_approval: APP_LEASE_ADMIN, + min_support: SUP_LEASE_ADMIN, + }, + ), + ( + 13, + pallet_referenda::TrackInfo { + name: "fellowship_admin", + max_deciding: 10, + decision_deposit: 5 * GRAND, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 2 * DAYS, + min_approval: APP_FELLOWSHIP_ADMIN, + min_support: SUP_FELLOWSHIP_ADMIN, + }, + ), + ( + 14, + pallet_referenda::TrackInfo { + name: "general_admin", + max_deciding: 10, + decision_deposit: 5 * GRAND, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 2 * DAYS, + min_approval: APP_GENERAL_ADMIN, + min_support: SUP_GENERAL_ADMIN, + }, + ), + ( + 15, + pallet_referenda::TrackInfo { + name: "auction_admin", + max_deciding: 10, + decision_deposit: 5 * GRAND, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 2 * DAYS, + min_approval: APP_AUCTION_ADMIN, + min_support: SUP_AUCTION_ADMIN, + }, + ), + ( + 20, + pallet_referenda::TrackInfo { + name: "referendum_canceller", + max_deciding: 1_000, + decision_deposit: 50 * GRAND, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 10 * MINUTES, + min_approval: APP_REFERENDUM_CANCELLER, + min_support: SUP_REFERENDUM_CANCELLER, + }, + ), + ( + 21, + pallet_referenda::TrackInfo { + name: "referendum_killer", + max_deciding: 1_000, + decision_deposit: 50 * GRAND, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 10 * MINUTES, + min_approval: APP_REFERENDUM_KILLER, + min_support: SUP_REFERENDUM_KILLER, + }, + ), + ( + 30, + pallet_referenda::TrackInfo { + name: "small_tipper", + max_deciding: 200, + decision_deposit: 5 * QUID, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 3 * HOURS, + min_enactment_period: 28 * DAYS, + min_approval: APP_SMALL_TIPPER, + min_support: SUP_SMALL_TIPPER, + }, + ), + ( + 31, + pallet_referenda::TrackInfo { + name: "big_tipper", + max_deciding: 100, + decision_deposit: 50 * QUID, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 6 * HOURS, + min_enactment_period: 28 * DAYS, + min_approval: APP_BIG_TIPPER, + min_support: SUP_BIG_TIPPER, + }, + ), + ( + 32, + pallet_referenda::TrackInfo { + name: "small_spender", + max_deciding: 50, + decision_deposit: 500 * QUID, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 12 * HOURS, + min_enactment_period: 28 * DAYS, + min_approval: APP_SMALL_SPENDER, + min_support: SUP_SMALL_SPENDER, + }, + ), + ( + 33, + pallet_referenda::TrackInfo { + name: "medium_spender", + max_deciding: 20, + decision_deposit: 1_500 * QUID, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 24 * HOURS, + min_enactment_period: 28 * DAYS, + min_approval: APP_MEDIUM_SPENDER, + min_support: SUP_MEDIUM_SPENDER, + }, + ), + ( + 34, + pallet_referenda::TrackInfo { + name: "big_spender", + max_deciding: 10, + decision_deposit: 5 * GRAND, + prepare_period: 4, + decision_period: 28 * DAYS, + confirm_period: 48 * HOURS, + min_enactment_period: 28 * DAYS, + min_approval: APP_BIG_SPENDER, + min_support: SUP_BIG_SPENDER, + }, + ), +]; + +pub struct TracksInfo; +impl pallet_referenda::TracksInfo for TracksInfo { + type Id = u16; + type RuntimeOrigin = ::PalletsOrigin; + fn tracks() -> &'static [(Self::Id, pallet_referenda::TrackInfo)] { + &TRACKS_DATA[..] + } + fn track_for(id: &Self::RuntimeOrigin) -> Result { + if let Ok(system_origin) = frame_system::RawOrigin::try_from(id.clone()) { + match system_origin { + frame_system::RawOrigin::Root => Ok(0), + _ => Err(()), + } + } else if let Ok(custom_origin) = origins::Origin::try_from(id.clone()) { + match custom_origin { + origins::Origin::WhitelistedCaller => Ok(1), + // General admin + origins::Origin::StakingAdmin => Ok(10), + origins::Origin::Treasurer => Ok(11), + origins::Origin::LeaseAdmin => Ok(12), + origins::Origin::FellowshipAdmin => Ok(13), + origins::Origin::GeneralAdmin => Ok(14), + origins::Origin::AuctionAdmin => Ok(15), + // Referendum admins + origins::Origin::ReferendumCanceller => Ok(20), + origins::Origin::ReferendumKiller => Ok(21), + // Limited treasury spenders + origins::Origin::SmallTipper => Ok(30), + origins::Origin::BigTipper => Ok(31), + origins::Origin::SmallSpender => Ok(32), + origins::Origin::MediumSpender => Ok(33), + origins::Origin::BigSpender => Ok(34), + _ => Err(()), + } + } else { + Err(()) + } + } +} +pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber); diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 13c0044d801f..96ca53f680a6 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -20,14 +20,12 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] -use pallet_transaction_payment::CurrencyAdapter; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::v2::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId, - InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, - PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, - ValidationCodeHash, ValidatorId, ValidatorIndex, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, + CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, + Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, + SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, }; use runtime_common::{ auctions, claims, crowdloan, impl_runtime_weights, impls::DealWithFees, paras_registrar, @@ -53,8 +51,8 @@ use frame_election_provider_support::{ use frame_support::{ construct_runtime, parameter_types, traits::{ - ConstU32, Contains, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, - PrivilegeCmp, + ConstU32, Contains, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, + LockIdentifier, PrivilegeCmp, WithdrawReasons, }, weights::ConstantMultiplier, PalletId, RuntimeDebug, @@ -63,7 +61,7 @@ use frame_system::EnsureRoot; use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId}; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_session::historical as session_historical; -use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; +use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo}; use sp_core::OpaqueMetadata; use sp_mmr_primitives as mmr; use sp_runtime::{ @@ -86,7 +84,8 @@ pub use pallet_balances::Call as BalancesCall; pub use pallet_election_provider_multi_phase::Call as EPMCall; #[cfg(feature = "std")] pub use pallet_staking::StakerStatus; -pub use pallet_timestamp::Call as TimestampCall; +use pallet_staking::UseValidatorsMap; +use sp_runtime::traits::Get; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -104,7 +103,10 @@ pub mod xcm_config; // Governance configurations. pub mod governance; -use governance::old::CouncilCollective; +use governance::{ + old::CouncilCollective, pallet_custom_origins, AuctionAdmin, GeneralAdmin, LeaseAdmin, + StakingAdmin, TreasurySpender, +}; #[cfg(test)] mod tests; @@ -121,13 +123,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("kusama"), impl_name: create_runtime_str!("parity-kusama"), authoring_version: 2, - spec_version: 9280, + spec_version: 9310, impl_version: 0, #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS, #[cfg(feature = "disable-runtime-api")] apis: sp_version::create_apis_vec![[]], - transaction_version: 12, + transaction_version: 15, state_version: 0, }; @@ -146,28 +148,23 @@ pub fn native_version() -> NativeVersion { /// We currently allow all calls. pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(_c: &Call) -> bool { +impl Contains for BaseFilter { + fn contains(_c: &RuntimeCall) -> bool { true } } -type MoreThanHalfCouncil = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionMoreThan, ->; - parameter_types! { pub const Version: RuntimeVersion = VERSION; pub const SS58Prefix: u8 = 2; } impl frame_system::Config for Runtime { - type BaseCallFilter = BaseFilter; + type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = BlockWeights; type BlockLength = BlockLength; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = Nonce; type BlockNumber = BlockNumber; type Hash = Hash; @@ -175,7 +172,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = AccountIdLookup; type Header = generic::Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = RocksDbWeight; type Version = Version; @@ -190,17 +187,11 @@ impl frame_system::Config for Runtime { } parameter_types! { - pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * - BlockWeights::get().max_block; + pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block; pub const MaxScheduledPerBlock: u32 = 50; pub const NoPreimagePostponement: Option = Some(10); } -type ScheduleOrigin = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionAtLeast, ->; - /// Used the compare the privilege of an origin inside the scheduler. pub struct OriginPrivilegeCmp; @@ -225,31 +216,28 @@ impl PrivilegeCmp for OriginPrivilegeCmp { } impl pallet_scheduler::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type PalletsOrigin = OriginCaller; - type Call = Call; + type RuntimeCall = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = ScheduleOrigin; + type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = weights::pallet_scheduler::WeightInfo; type OriginPrivilegeCmp = OriginPrivilegeCmp; - type PreimageProvider = Preimage; - type NoPreimagePostponement = NoPreimagePostponement; + type Preimages = Preimage; } parameter_types! { - pub const PreimageMaxSize: u32 = 4096 * 1024; pub const PreimageBaseDeposit: Balance = deposit(2, 64); pub const PreimageByteDeposit: Balance = deposit(0, 1); } impl pallet_preimage::Config for Runtime { type WeightInfo = weights::pallet_preimage::WeightInfo; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; - type MaxSize = PreimageMaxSize; type BaseDeposit = PreimageBaseDeposit; type ByteDeposit = PreimageByteDeposit; } @@ -302,7 +290,7 @@ impl pallet_indices::Config for Runtime { type AccountIndex = AccountIndex; type Currency = Balances; type Deposit = IndexDeposit; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::pallet_indices::WeightInfo; } @@ -315,7 +303,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type Balance = Balance; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type MaxLocks = MaxLocks; @@ -332,7 +320,7 @@ parameter_types! { } impl pallet_transaction_payment::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter>; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = WeightToFee; @@ -361,11 +349,6 @@ impl pallet_authorship::Config for Runtime { type EventHandler = (Staking, ImOnline); } -parameter_types! { - pub const Period: BlockNumber = 10 * MINUTES; - pub const Offset: BlockNumber = 0; -} - impl_opaque_keys! { pub struct SessionKeys { pub grandpa: Grandpa, @@ -378,7 +361,7 @@ impl_opaque_keys! { } impl pallet_session::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = pallet_staking::StashOf; type ShouldEndSession = Babe; @@ -425,6 +408,8 @@ parameter_types! { /// ... and all of the validators as electable targets. Whilst this is the case, we cannot and /// shall not increase the size of the validator intentions. pub const MaxElectableTargets: u16 = u16::MAX; + pub NposSolutionPriority: TransactionPriority = + Perbill::from_percent(90) * TransactionPriority::max_value(); } generate_solution_type!( @@ -468,7 +453,7 @@ impl pallet_election_provider_multi_phase::MinerConfig for Runtime { } impl pallet_election_provider_multi_phase::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type EstimateCallFee = TransactionPayment; type UnsignedPhase = UnsignedPhase; @@ -489,6 +474,9 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type OffchainRepeat = OffchainRepeat; type MinerTxPriority = NposSolutionPriority; type DataProvider = Staking; + #[cfg(feature = "fast-runtime")] + type Fallback = onchain::UnboundedExecution; + #[cfg(not(feature = "fast-runtime"))] type Fallback = pallet_election_provider_multi_phase::NoFallback; type GovernanceFallback = onchain::UnboundedExecution; type Solver = SequentialPhragmen< @@ -497,10 +485,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { (), >; type BenchmarkingConfig = runtime_common::elections::BenchmarkConfig; - type ForceOrigin = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionAtLeast, - >; + type ForceOrigin = StakingAdmin; type WeightInfo = weights::pallet_election_provider_multi_phase::WeightInfo; type MaxElectingVoters = MaxElectingVoters; type MaxElectableTargets = MaxElectableTargets; @@ -510,8 +495,9 @@ parameter_types! { pub const BagThresholds: &'static [u64] = &bag_thresholds::THRESHOLDS; } -impl pallet_bags_list::Config for Runtime { - type Event = Event; +type VoterBagsListInstance = pallet_bags_list::Instance1; +impl pallet_bags_list::Config for Runtime { + type RuntimeEvent = RuntimeEvent; type ScoreProvider = Staking; type WeightInfo = weights::pallet_bags_list::WeightInfo; type BagThresholds = BagThresholds; @@ -582,7 +568,7 @@ impl pallet_staking::EraPayout for EraPayout { parameter_types! { // Six sessions in an era (6 hours). - pub const SessionsPerEra: SessionIndex = 6; + pub const SessionsPerEra: SessionIndex = prod_or_fast!(6, 1); // 28 eras for unbonding (7 days). pub const BondingDuration: sp_staking::EraIndex = 28; // 27 eras in which slashes can be cancelled (slightly less than 7 days). @@ -593,11 +579,6 @@ parameter_types! { pub const MaxNominations: u32 = ::LIMIT as u32; } -type SlashCancelOrigin = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionAtLeast, ->; - impl pallet_staking::Config for Runtime { type MaxNominations = MaxNominations; type Currency = Balances; @@ -607,26 +588,39 @@ impl pallet_staking::Config for Runtime { type ElectionProvider = ElectionProviderMultiPhase; type GenesisElectionProvider = onchain::UnboundedExecution; type RewardRemainder = Treasury; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Slash = Treasury; type Reward = (); type SessionsPerEra = SessionsPerEra; type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; - // A majority of the council or root can cancel the slash. - type SlashCancelOrigin = SlashCancelOrigin; + // The staking admin or root can cancel the slash. + type SlashCancelOrigin = EitherOf, StakingAdmin>; type SessionInterface = Self; type EraPayout = EraPayout; type NextNewSession = Session; type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; type OffendingValidatorsThreshold = OffendingValidatorsThreshold; type VoterList = VoterList; + type TargetList = UseValidatorsMap; type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; + type HistoryDepth = frame_support::traits::ConstU32<84>; type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; type OnStakerSlash = NominationPools; type WeightInfo = weights::pallet_staking::WeightInfo; } +impl pallet_fast_unstake::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type DepositCurrency = Balances; + type Deposit = frame_support::traits::ConstU128<{ CENTS * 100 }>; + type ControlOrigin = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, + >; + type WeightInfo = weights::pallet_fast_unstake::WeightInfo; +} + parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); pub const ProposalBondMinimum: Balance = 2000 * CENTS; @@ -646,17 +640,12 @@ parameter_types! { pub const MaxPeerDataEncodingSize: u32 = 1_000; } -type ApproveOrigin = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionAtLeast, ->; - impl pallet_treasury::Config for Runtime { type PalletId = TreasuryPalletId; type Currency = Balances; - type ApproveOrigin = ApproveOrigin; - type RejectOrigin = MoreThanHalfCouncil; - type Event = Event; + type ApproveOrigin = EnsureRoot; + type RejectOrigin = EnsureRoot; + type RuntimeEvent = RuntimeEvent; type OnSlash = Treasury; type ProposalBond = ProposalBond; type ProposalBondMinimum = ProposalBondMinimum; @@ -667,7 +656,7 @@ impl pallet_treasury::Config for Runtime { type MaxApprovals = MaxApprovals; type WeightInfo = weights::pallet_treasury::WeightInfo; type SpendFunds = Bounties; - type SpendOrigin = frame_support::traits::NeverEnsureOrigin; + type SpendOrigin = TreasurySpender; } parameter_types! { @@ -691,7 +680,7 @@ impl pallet_bounties::Config for Runtime { type BountyValueMinimum = BountyValueMinimum; type ChildBountyManager = ChildBounties; type DataDepositPerByte = DataDepositPerByte; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaximumReasonLength = MaximumReasonLength; type WeightInfo = weights::pallet_bounties::WeightInfo; } @@ -702,7 +691,7 @@ parameter_types! { } impl pallet_child_bounties::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaxActiveChildBountyCount = MaxActiveChildBountyCount; type ChildBountyValueMinimum = ChildBountyValueMinimum; type WeightInfo = weights::pallet_child_bounties::WeightInfo; @@ -715,12 +704,12 @@ impl pallet_tips::Config for Runtime { type TipCountdown = TipCountdown; type TipFindersFee = TipFindersFee; type TipReportDepositBase = TipReportDepositBase; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::pallet_tips::WeightInfo; } impl pallet_offences::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } @@ -730,14 +719,12 @@ impl pallet_authority_discovery::Config for Runtime { } parameter_types! { - pub NposSolutionPriority: TransactionPriority = - Perbill::from_percent(90) * TransactionPriority::max_value(); pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); } impl pallet_im_online::Config for Runtime { type AuthorityId = ImOnlineId; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorSet = Historical; type NextSessionRotation = Babe; type ReportUnresponsiveness = Offences; @@ -749,8 +736,7 @@ impl pallet_im_online::Config for Runtime { } impl pallet_grandpa::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; type KeyOwnerProof = >::Proof; @@ -776,14 +762,14 @@ impl pallet_grandpa::Config for Runtime { /// format of the chain. impl frame_system::offchain::CreateSignedTransaction for Runtime where - Call: From, + RuntimeCall: From, { fn create_transaction>( - call: Call, + call: RuntimeCall, public: ::Signer, account: AccountId, nonce: ::Index, - ) -> Option<(Call, ::SignaturePayload)> { + ) -> Option<(RuntimeCall, ::SignaturePayload)> { use sp_runtime::traits::StaticLookup; // take the biggest period possible. let period = @@ -827,10 +813,10 @@ impl frame_system::offchain::SigningTypes for Runtime { impl frame_system::offchain::SendTransactionTypes for Runtime where - Call: From, + RuntimeCall: From, { type Extrinsic = UncheckedExtrinsic; - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; } parameter_types! { @@ -838,11 +824,10 @@ parameter_types! { } impl claims::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type VestingSchedule = Vesting; type Prefix = Prefix; - type MoveClaimOrigin = - pallet_collective::EnsureProportionMoreThan; + type MoveClaimOrigin = EnsureRoot; type WeightInfo = weights::runtime_common_claims::WeightInfo; } @@ -857,7 +842,7 @@ parameter_types! { } impl pallet_identity::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BasicDeposit = BasicDeposit; type FieldDeposit = FieldDeposit; @@ -866,14 +851,14 @@ impl pallet_identity::Config for Runtime { type MaxAdditionalFields = MaxAdditionalFields; type MaxRegistrars = MaxRegistrars; type Slashed = Treasury; - type ForceOrigin = MoreThanHalfCouncil; - type RegistrarOrigin = MoreThanHalfCouncil; + type ForceOrigin = GeneralAdmin; + type RegistrarOrigin = GeneralAdmin; type WeightInfo = weights::pallet_identity::WeightInfo; } impl pallet_utility::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = weights::pallet_utility::WeightInfo; } @@ -887,8 +872,8 @@ parameter_types! { } impl pallet_multisig::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; @@ -904,9 +889,9 @@ parameter_types! { } impl pallet_recovery::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; @@ -915,11 +900,11 @@ impl pallet_recovery::Config for Runtime { } parameter_types! { - pub const CandidateDeposit: Balance = 1000 * CENTS; - pub const WrongSideDeduction: Balance = 200 * CENTS; + pub const CandidateDeposit: Balance = 10 * QUID; + pub const WrongSideDeduction: Balance = 2 * QUID; pub const MaxStrikes: u32 = 10; pub const RotationPeriod: BlockNumber = 7 * DAYS; - pub const PeriodSpend: Balance = 50000 * CENTS; + pub const PeriodSpend: Balance = 500 * QUID; pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS; pub const ChallengePeriod: BlockNumber = 7 * DAYS; pub const MaxCandidateIntake: u32 = 1; @@ -927,7 +912,7 @@ parameter_types! { } impl pallet_society::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type Randomness = pallet_babe::RandomnessFromOneEpochAgo; type CandidateDeposit = CandidateDeposit; @@ -937,8 +922,7 @@ impl pallet_society::Config for Runtime { type MembershipChanged = (); type RotationPeriod = RotationPeriod; type MaxLockDuration = MaxLockDuration; - type FounderSetOrigin = - pallet_collective::EnsureProportionMoreThan; + type FounderSetOrigin = EnsureRoot; type SuspensionJudgementOrigin = pallet_society::EnsureFounder; type ChallengePeriod = ChallengePeriod; type MaxCandidateIntake = MaxCandidateIntake; @@ -947,14 +931,17 @@ impl pallet_society::Config for Runtime { parameter_types! { pub const MinVestedTransfer: Balance = 100 * CENTS; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } impl pallet_vesting::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BlockNumberToBalance = ConvertInto; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = weights::pallet_vesting::WeightInfo; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; const MAX_VESTING_SCHEDULES: u32 = 28; } @@ -1000,86 +987,98 @@ impl Default for ProxyType { } } -impl InstanceFilter for ProxyType { - fn filter(&self, c: &Call) -> bool { +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { match self { ProxyType::Any => true, ProxyType::NonTransfer => matches!( c, - Call::System(..) | - Call::Babe(..) | - Call::Timestamp(..) | - Call::Indices(pallet_indices::Call::claim {..}) | - Call::Indices(pallet_indices::Call::free {..}) | - Call::Indices(pallet_indices::Call::freeze {..}) | + RuntimeCall::System(..) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(pallet_indices::Call::claim {..}) | + RuntimeCall::Indices(pallet_indices::Call::free {..}) | + RuntimeCall::Indices(pallet_indices::Call::freeze {..}) | // Specifically omitting Indices `transfer`, `force_transfer` // Specifically omitting the entire Balances pallet - Call::Authorship(..) | - Call::Staking(..) | - Call::Session(..) | - Call::Grandpa(..) | - Call::ImOnline(..) | - Call::Democracy(..) | - Call::Council(..) | - Call::TechnicalCommittee(..) | - Call::PhragmenElection(..) | - Call::TechnicalMembership(..) | - Call::Treasury(..) | - Call::Bounties(..) | - Call::ChildBounties(..) | - Call::Tips(..) | - Call::Claims(..) | - Call::Utility(..) | - Call::Identity(..) | - Call::Society(..) | - Call::Recovery(pallet_recovery::Call::as_recovered {..}) | - Call::Recovery(pallet_recovery::Call::vouch_recovery {..}) | - Call::Recovery(pallet_recovery::Call::claim_recovery {..}) | - Call::Recovery(pallet_recovery::Call::close_recovery {..}) | - Call::Recovery(pallet_recovery::Call::remove_recovery {..}) | - Call::Recovery(pallet_recovery::Call::cancel_recovered {..}) | + RuntimeCall::Authorship(..) | + RuntimeCall::Staking(..) | + RuntimeCall::Session(..) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy(..) | + RuntimeCall::Council(..) | + RuntimeCall::TechnicalCommittee(..) | + RuntimeCall::PhragmenElection(..) | + RuntimeCall::TechnicalMembership(..) | + RuntimeCall::Treasury(..) | + RuntimeCall::Bounties(..) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::Tips(..) | + RuntimeCall::Claims(..) | + RuntimeCall::Utility(..) | + RuntimeCall::Identity(..) | + RuntimeCall::Society(..) | + RuntimeCall::Recovery(pallet_recovery::Call::as_recovered {..}) | + RuntimeCall::Recovery(pallet_recovery::Call::vouch_recovery {..}) | + RuntimeCall::Recovery(pallet_recovery::Call::claim_recovery {..}) | + RuntimeCall::Recovery(pallet_recovery::Call::close_recovery {..}) | + RuntimeCall::Recovery(pallet_recovery::Call::remove_recovery {..}) | + RuntimeCall::Recovery(pallet_recovery::Call::cancel_recovered {..}) | // Specifically omitting Recovery `create_recovery`, `initiate_recovery` - Call::Vesting(pallet_vesting::Call::vest {..}) | - Call::Vesting(pallet_vesting::Call::vest_other {..}) | + RuntimeCall::Vesting(pallet_vesting::Call::vest {..}) | + RuntimeCall::Vesting(pallet_vesting::Call::vest_other {..}) | // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` - Call::Scheduler(..) | - Call::Proxy(..) | - Call::Multisig(..) | - Call::Gilt(..) | - Call::Registrar(paras_registrar::Call::register {..}) | - Call::Registrar(paras_registrar::Call::deregister {..}) | + RuntimeCall::Scheduler(..) | + RuntimeCall::Proxy(..) | + RuntimeCall::Multisig(..) | + RuntimeCall::Gilt(..) | + RuntimeCall::Registrar(paras_registrar::Call::register {..}) | + RuntimeCall::Registrar(paras_registrar::Call::deregister {..}) | // Specifically omitting Registrar `swap` - Call::Registrar(paras_registrar::Call::reserve {..}) | - Call::Crowdloan(..) | - Call::Slots(..) | - Call::Auctions(..) | // Specifically omitting the entire XCM Pallet - Call::VoterList(..) | - Call::NominationPools(..) - ), - ProxyType::Governance => matches!( - c, - Call::Democracy(..) | - Call::Council(..) | Call::TechnicalCommittee(..) | - Call::PhragmenElection(..) | - Call::Treasury(..) | Call::Bounties(..) | - Call::Tips(..) | Call::Utility(..) | - Call::ChildBounties(..) + RuntimeCall::Registrar(paras_registrar::Call::reserve {..}) | + RuntimeCall::Crowdloan(..) | + RuntimeCall::Slots(..) | + RuntimeCall::Auctions(..) | // Specifically omitting the entire XCM Pallet + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools(..) | + RuntimeCall::FastUnstake(..) ), + ProxyType::Governance => + matches!( + c, + RuntimeCall::Democracy(..) | + RuntimeCall::Council(..) | RuntimeCall::TechnicalCommittee(..) | + RuntimeCall::PhragmenElection(..) | + RuntimeCall::Treasury(..) | + RuntimeCall::Bounties(..) | + RuntimeCall::Tips(..) | RuntimeCall::Utility(..) | + RuntimeCall::ChildBounties(..) + ), ProxyType::Staking => { - matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)) + matches!( + c, + RuntimeCall::Staking(..) | + RuntimeCall::Session(..) | RuntimeCall::Utility(..) | + RuntimeCall::FastUnstake(..) + ) }, ProxyType::IdentityJudgement => matches!( c, - Call::Identity(pallet_identity::Call::provide_judgement { .. }) | Call::Utility(..) + RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) | + RuntimeCall::Utility(..) ), ProxyType::CancelProxy => { - matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })) + matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })) }, ProxyType::Auction => matches!( c, - Call::Auctions(..) | Call::Crowdloan(..) | Call::Registrar(..) | Call::Slots(..) + RuntimeCall::Auctions(..) | + RuntimeCall::Crowdloan(..) | + RuntimeCall::Registrar(..) | + RuntimeCall::Slots(..) ), - ProxyType::Society => matches!(c, Call::Society(..)), + ProxyType::Society => matches!(c, RuntimeCall::Society(..)), } } fn is_superset(&self, o: &Self) -> bool { @@ -1094,8 +1093,8 @@ impl InstanceFilter for ProxyType { } impl pallet_proxy::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; @@ -1121,7 +1120,7 @@ impl parachains_session_info::Config for Runtime { } impl parachains_inclusion::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DisputesHandler = ParasDisputes; type RewardValidators = parachains_reward_points::RewardValidatorsWithEraPoints; } @@ -1131,7 +1130,7 @@ parameter_types! { } impl parachains_paras::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::runtime_parachains_paras::WeightInfo; type UnsignedPriority = ParasUnsignedPriority; type NextSessionRotation = Babe; @@ -1142,7 +1141,7 @@ parameter_types! { } impl parachains_ump::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type UmpSink = crate::parachains_ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; @@ -1153,10 +1152,10 @@ impl parachains_ump::Config for Runtime { impl parachains_dmp::Config for Runtime {} impl parachains_hrmp::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; - type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo; + type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo; } impl parachains_paras_inherent::Config for Runtime { @@ -1172,9 +1171,9 @@ impl parachains_initializer::Config for Runtime { } impl parachains_disputes::Config for Runtime { - type Event = Event; - type RewardValidators = (); - type PunishValidators = (); + type RuntimeEvent = RuntimeEvent; + type RewardValidators = parachains_reward_points::RewardValidatorsWithEraPoints; + type SlashingHandler = (); type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } @@ -1183,8 +1182,8 @@ parameter_types! { } impl paras_registrar::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type OnSwap = (Crowdloan, Slots); type ParaDeposit = ParaDeposit; @@ -1198,18 +1197,18 @@ parameter_types! { } impl slots::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type Registrar = Registrar; type LeasePeriod = LeasePeriod; type LeaseOffset = (); - type ForceOrigin = MoreThanHalfCouncil; + type ForceOrigin = LeaseAdmin; type WeightInfo = weights::runtime_common_slots::WeightInfo; } parameter_types! { pub const CrowdloanId: PalletId = PalletId(*b"py/cfund"); - pub const SubmissionDeposit: Balance = 3 * GRAND; // ~ 10 KSM + pub const OldSubmissionDeposit: Balance = 3 * GRAND; // ~ 10 KSM pub const MinContribution: Balance = 3_000 * CENTS; // ~ .1 KSM pub const RemoveKeysLimit: u32 = 1000; // Allow 32 bytes for an additional memo to a crowdloan. @@ -1217,9 +1216,9 @@ parameter_types! { } impl crowdloan::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type PalletId = CrowdloanId; - type SubmissionDeposit = SubmissionDeposit; + type SubmissionDeposit = OldSubmissionDeposit; type MinContribution = MinContribution; type RemoveKeysLimit = RemoveKeysLimit; type Registrar = Registrar; @@ -1236,19 +1235,14 @@ parameter_types! { pub const SampleLength: BlockNumber = 2 * MINUTES; } -type AuctionInitiate = EitherOfDiverse< - EnsureRoot, - pallet_collective::EnsureProportionAtLeast, ->; - impl auctions::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Leaser = Slots; type Registrar = Registrar; type EndingPeriod = EndingPeriod; type SampleLength = SampleLength; type Randomness = pallet_babe::RandomnessFromOneEpochAgo; - type InitiateOrigin = AuctionInitiate; + type InitiateOrigin = AuctionAdmin; type WeightInfo = weights::runtime_common_auctions::WeightInfo; } @@ -1264,10 +1258,10 @@ parameter_types! { } impl pallet_gilt::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type CurrencyBalance = Balance; - type AdminOrigin = MoreThanHalfCouncil; + type AdminOrigin = EnsureRoot; type Deficit = (); // Mint type Surplus = (); // Burn type IgnoredIssuance = IgnoredIssuance; @@ -1287,7 +1281,7 @@ parameter_types! { } impl pallet_nomination_pools::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::pallet_nomination_pools::WeightInfo; type Currency = Balances; type CurrencyBalance = Balance; @@ -1332,7 +1326,7 @@ construct_runtime! { ImOnline: pallet_im_online::{Pallet, Call, Storage, Event, ValidateUnsigned, Config} = 11, AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 12, - // Governance stuff; uncallable initially. + // Governance stuff. Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event} = 13, Council: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 14, TechnicalCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 15, @@ -1340,6 +1334,18 @@ construct_runtime! { TechnicalMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 17, Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event} = 18, + ConvictionVoting: pallet_conviction_voting::{Pallet, Call, Storage, Event} = 20, + Referenda: pallet_referenda::{Pallet, Call, Storage, Event} = 21, +// pub type FellowshipCollectiveInstance = pallet_ranked_collective::Instance1; + FellowshipCollective: pallet_ranked_collective::::{ + Pallet, Call, Storage, Event + } = 22, +// pub type FellowshipReferendaInstance = pallet_referenda::Instance2; + FellowshipReferenda: pallet_referenda::::{ + Pallet, Call, Storage, Event + } = 23, + Origins: pallet_custom_origins::{Origin} = 43, + Whitelist: pallet_whitelist::{Pallet, Call, Storage, Event} = 44, // Claims. Usable initially. Claims: claims::{Pallet, Call, Storage, Event, Config, ValidateUnsigned} = 19, @@ -1385,11 +1391,14 @@ construct_runtime! { Gilt: pallet_gilt::{Pallet, Call, Storage, Event, Config} = 38, // Provides a semi-sorted list of nominators for staking. - VoterList: pallet_bags_list::{Pallet, Call, Storage, Event} = 39, + VoterList: pallet_bags_list::::{Pallet, Call, Storage, Event} = 39, // nomination pools: extension to staking. NominationPools: pallet_nomination_pools::{Pallet, Call, Storage, Event, Config} = 41, + // Fast unstake pallet: extension to staking. + FastUnstake: pallet_fast_unstake = 42, + // Parachains pallets. Start indices at 50 to leave room. ParachainsOrigin: parachains_origin::{Pallet, Origin} = 50, Configuration: parachains_configuration::{Pallet, Call, Storage, Config} = 51, @@ -1397,7 +1406,7 @@ construct_runtime! { ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event} = 53, ParaInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 54, ParaScheduler: parachains_scheduler::{Pallet, Storage} = 55, - Paras: parachains_paras::{Pallet, Call, Storage, Event, Config} = 56, + Paras: parachains_paras::{Pallet, Call, Storage, Event, Config, ValidateUnsigned} = 56, Initializer: parachains_initializer::{Pallet, Call, Storage} = 57, Dmp: parachains_dmp::{Pallet, Call, Storage} = 58, Ump: parachains_ump::{Pallet, Call, Storage, Event} = 59, @@ -1437,8 +1446,17 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, ); + +pub struct StakingMigrationV11OldPallet; +impl Get<&'static str> for StakingMigrationV11OldPallet { + fn get() -> &'static str { + "VoterList" + } +} + /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = + generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -1446,10 +1464,18 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - (), + ( + // "Bound uses of call" + pallet_preimage::migration::v1::Migration, + pallet_scheduler::migration::v3::MigrateToV4, + pallet_democracy::migrations::v1::Migration, + pallet_multisig::migrations::v1::MigrateToV1, + // "Properly migrate weights to v2" + parachains_configuration::migration::v3::MigrateToV3, + ), >; /// The payload being signed in the transactions. -pub type SignedPayload = generic::SignedPayload; +pub type SignedPayload = generic::SignedPayload; #[cfg(feature = "runtime-benchmarks")] #[macro_use] @@ -1481,10 +1507,12 @@ mod benches { [pallet_child_bounties, ChildBounties] [pallet_collective, Council] [pallet_collective, TechnicalCommittee] + [pallet_conviction_voting, ConvictionVoting] [pallet_democracy, Democracy] [pallet_elections_phragmen, PhragmenElection] [pallet_election_provider_multi_phase, ElectionProviderMultiPhase] [frame_election_provider_support, ElectionProviderBench::] + [pallet_fast_unstake, FastUnstake] [pallet_gilt, Gilt] [pallet_identity, Identity] [pallet_im_online, ImOnline] @@ -1495,7 +1523,10 @@ mod benches { [pallet_offences, OffencesBench::] [pallet_preimage, Preimage] [pallet_proxy, Proxy] + [pallet_ranked_collective, FellowshipCollective] [pallet_recovery, Recovery] + [pallet_referenda, Referenda] + [pallet_referenda, FellowshipReferenda] [pallet_scheduler, Scheduler] [pallet_session, SessionBench::] [pallet_staking, Staking] @@ -1505,6 +1536,7 @@ mod benches { [pallet_treasury, Treasury] [pallet_utility, Utility] [pallet_vesting, Vesting] + [pallet_whitelist, Whitelist] // XCM [pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::] [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::] @@ -1621,7 +1653,7 @@ sp_api::impl_runtime_apis! { fn candidate_events() -> Vec> { parachains_runtime_api_impl::candidate_events::(|ev| { match ev { - Event::ParaInclusion(ev) => { + RuntimeEvent::ParaInclusion(ev) => { Some(ev) } _ => None, @@ -1667,10 +1699,6 @@ sp_api::impl_runtime_apis! { { parachains_runtime_api_impl::validation_code_hash::(para_id, assumption) } - - fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { - unimplemented!() - } } impl beefy_primitives::BeefyApi for Runtime { @@ -1680,8 +1708,8 @@ sp_api::impl_runtime_apis! { } } - impl mmr::MmrApi for Runtime { - fn generate_proof(_leaf_index: u64) + impl mmr::MmrApi for Runtime { + fn generate_proof(_block_number: BlockNumber) -> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof), mmr::Error> { Err(mmr::Error::PalletNotIncluded) @@ -1705,12 +1733,19 @@ sp_api::impl_runtime_apis! { Err(mmr::Error::PalletNotIncluded) } - fn generate_batch_proof(_leaf_indices: Vec) + fn generate_batch_proof(_block_numbers: Vec) -> Result<(Vec, mmr::BatchProof), mmr::Error> { Err(mmr::Error::PalletNotIncluded) } + fn generate_historical_batch_proof( + _block_numbers: Vec, + _best_known_block_number: BlockNumber, + ) -> Result<(Vec, mmr::BatchProof), mmr::Error> { + Err(mmr::Error::PalletNotIncluded) + } + fn verify_batch_proof(_leaves: Vec, _proof: mmr::BatchProof) -> Result<(), mmr::Error> { @@ -1763,19 +1798,15 @@ sp_api::impl_runtime_apis! { } impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeGenesisConfiguration { - // The choice of `c` parameter (where `1 - c` represents the - // probability of a slot being empty), is done in accordance to the - // slot duration and expected target block time, for safely - // resisting network delays of maximum two seconds. - // - babe_primitives::BabeGenesisConfiguration { + fn configuration() -> babe_primitives::BabeConfiguration { + let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG); + babe_primitives::BabeConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDuration::get(), - c: BABE_GENESIS_EPOCH_CONFIG.c, - genesis_authorities: Babe::authorities().to_vec(), + c: epoch_config.c, + authorities: Babe::authorities().to_vec(), randomness: Babe::randomness(), - allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots, + allowed_slots: epoch_config.allowed_slots, } } @@ -1851,13 +1882,13 @@ sp_api::impl_runtime_apis! { } } - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi for Runtime { - fn query_call_info(call: Call, len: u32) -> RuntimeDispatchInfo { + fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo { TransactionPayment::query_call_info(call, len) } - fn query_call_fee_details(call: Call, len: u32) -> FeeDetails { + fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails { TransactionPayment::query_call_fee_details(call, len) } } @@ -1868,7 +1899,7 @@ sp_api::impl_runtime_apis! { Balance, > for Runtime { fn pending_rewards(member: AccountId) -> Balance { - NominationPools::pending_rewards(member) + NominationPools::pending_rewards(member).unwrap_or_default() } } @@ -1879,8 +1910,16 @@ sp_api::impl_runtime_apis! { let weight = Executive::try_runtime_upgrade().unwrap(); (weight, BlockWeights::get().max_block) } - fn execute_block_no_check(block: Block) -> Weight { - Executive::execute_block_no_check(block) + + fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight { + log::info!( + target: "runtime::kusama", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}", + block.header.number, + block.header.hash(), + state_root_check, + select, + ); + Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed") } } @@ -1923,7 +1962,7 @@ sp_api::impl_runtime_apis! { use pallet_nomination_pools_benchmarking::Pallet as NominationPoolsBench; use frame_benchmarking::baseline::Pallet as Baseline; use xcm::latest::prelude::*; - use xcm_config::{CheckAccount, SovereignAccountOf, Statemine, TokenLocation, XcmConfig}; + use xcm_config::{CheckAccount, KsmLocation, SovereignAccountOf, Statemine, XcmConfig}; impl pallet_session_benchmarking::Config for Runtime {} impl pallet_offences_benchmarking::Config for Runtime {} @@ -1938,10 +1977,10 @@ sp_api::impl_runtime_apis! { fn valid_destination() -> Result { Ok(Statemine::get()) } - fn worst_case_holding(_depositable_count: u32) -> MultiAssets { + fn worst_case_holding() -> MultiAssets { // Kusama only knows about KSM. vec![MultiAsset{ - id: Concrete(TokenLocation::get()), + id: Concrete(KsmLocation::get()), fun: Fungible(1_000_000 * UNITS), }].into() } @@ -1950,7 +1989,11 @@ sp_api::impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( Statemine::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmLocation::get()) }, + )); + pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( + Statemine::get(), + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmLocation::get()) }, )); } @@ -1959,32 +2002,23 @@ sp_api::impl_runtime_apis! { type CheckedAccount = CheckAccount; type TrustedTeleporter = TrustedTeleporter; + type TrustedReserve = TrustedReserve; fn get_multi_asset() -> MultiAsset { MultiAsset { - id: Concrete(TokenLocation::get()), + id: Concrete(KsmLocation::get()), fun: Fungible(1 * UNITS), } } } impl pallet_xcm_benchmarks::generic::Config for Runtime { - type Call = Call; + type RuntimeCall = RuntimeCall; fn worst_case_response() -> (u64, Response) { (0u64, Response::Version(Default::default())) } - fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> { - // Kusama doesn't support asset exchanges - Err(BenchmarkError::Skip) - } - - fn universal_alias() -> Result { - // The XCM executor of Kusama doesn't have a configured `UniversalAliases` - Err(BenchmarkError::Skip) - } - fn transact_origin() -> Result { Ok(Statemine::get()) } @@ -1995,15 +2029,10 @@ sp_api::impl_runtime_apis! { fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { let origin = Statemine::get(); - let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into(); + let assets: MultiAssets = (Concrete(KsmLocation::get()), 1_000 * UNITS).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) } - - fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> { - // Kusama doesn't support asset locking - Err(BenchmarkError::Skip) - } } let whitelist: Vec = vec![ @@ -2078,7 +2107,7 @@ mod multiplier_tests { BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap(); // if the min is too small, then this will not change, and we are doomed forever. // the weight is 1/100th bigger than target. - run_with_system_weight(target * 101 / 100, || { + run_with_system_weight(target.saturating_mul(101) / 100, || { let next = SlowAdjustingFeeUpdate::::convert(minimum_multiplier); assert!(next > minimum_multiplier, "{:?} !>= {:?}", next, minimum_multiplier); }) @@ -2096,14 +2125,14 @@ mod multiplier_tests { let call = frame_system::Call::::fill_block { ratio: Perbill::from_rational( - block_weight, - BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap(), + block_weight.ref_time(), + BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap().ref_time(), ), }; println!("calling {:?}", call); let info = call.get_dispatch_info(); // convert to outer call. - let call = Call::System(call); + let call = RuntimeCall::System(call); let len = call.using_encoded(|e| e.len()) as u32; let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::default() diff --git a/runtime/kusama/src/tests.rs b/runtime/kusama/src/tests.rs index 891aebe060ba..12d02da131f8 100644 --- a/runtime/kusama/src/tests.rs +++ b/runtime/kusama/src/tests.rs @@ -17,7 +17,7 @@ //! Tests for the Kusama Runtime Configuration use crate::*; -use frame_support::weights::{GetDispatchInfo, WeightToFee as WeightToFeeT}; +use frame_support::{dispatch::GetDispatchInfo, weights::WeightToFee as WeightToFeeT}; use keyring::Sr25519Keyring::Charlie; use pallet_transaction_payment::Multiplier; use parity_scale_codec::Encode; @@ -30,7 +30,7 @@ fn remove_keys_weight_is_sensible() { use runtime_common::crowdloan::WeightInfo; let max_weight = ::WeightInfo::refund(RemoveKeysLimit::get()); // Max remove keys limit should be no more than half the total block weight. - assert!(max_weight * 2 < BlockWeights::get().max_block); + assert!((max_weight * 2).all_lt(BlockWeights::get().max_block)); } #[test] @@ -40,20 +40,20 @@ fn sample_size_is_sensible() { let samples: BlockNumber = EndingPeriod::get() / SampleLength::get(); let max_weight: Weight = RocksDbWeight::get().reads_writes(samples.into(), samples.into()); // Max sample cleanup should be no more than half the total block weight. - assert!(max_weight * 2 < BlockWeights::get().max_block); - assert!( - ::WeightInfo::on_initialize() * 2 < - BlockWeights::get().max_block - ); + assert!((max_weight * 2).all_lt(BlockWeights::get().max_block)); + assert!((::WeightInfo::on_initialize() * 2) + .all_lt(BlockWeights::get().max_block)); } #[test] fn payout_weight_portion() { use pallet_staking::WeightInfo; - let payout_weight = ::WeightInfo::payout_stakers_alive_staked( - MaxNominatorRewardedPerValidator::get(), - ) as f64; - let block_weight = BlockWeights::get().max_block as f64; + let payout_weight = + ::WeightInfo::payout_stakers_alive_staked( + MaxNominatorRewardedPerValidator::get(), + ) + .ref_time() as f64; + let block_weight = BlockWeights::get().max_block.ref_time() as f64; println!( "a full payout takes {:.2} of the block weight [{} / {}]", @@ -87,7 +87,7 @@ fn transfer_cost_min_multiplier() { }; let info = call.get_dispatch_info(); // convert to outer call. - let call = Call::Balances(call); + let call = RuntimeCall::Balances(call); let len = call.using_encoded(|e| e.len()) as u32; let mut ext = sp_io::TestExternalities::new_empty(); @@ -97,7 +97,7 @@ fn transfer_cost_min_multiplier() { let fee = TransactionPayment::compute_fee(len, &info, 0); println!( "weight = {:?} // multiplier = {:?} // full transfer fee = {:?}", - info.weight.separated_string(), + info.weight.ref_time().separated_string(), pallet_transaction_payment::NextFeeMultiplier::::get(), fee.separated_string(), ); @@ -130,7 +130,7 @@ fn nominator_limit() { }; let mut active = 1; - while weight_with(active) <= OffchainSolutionWeightLimit::get() || active == all_voters { + while weight_with(active).all_lte(OffchainSolutionWeightLimit::get()) || active == all_voters { active += 1; } @@ -173,5 +173,5 @@ fn era_payout_should_give_sensible_results() { #[test] fn call_size() { - Call::assert_size_under(230); + RuntimeCall::assert_size_under(230); } diff --git a/runtime/kusama/src/weights/frame_benchmarking_baseline.rs b/runtime/kusama/src/weights/frame_benchmarking_baseline.rs index 4aeaa3815e42..510238204622 100644 --- a/runtime/kusama/src/weights/frame_benchmarking_baseline.rs +++ b/runtime/kusama/src/weights/frame_benchmarking_baseline.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `frame_benchmarking::baseline` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -46,44 +46,54 @@ pub struct WeightInfo(PhantomData); impl frame_benchmarking::baseline::WeightInfo for WeightInfo { /// The range of component `i` is `[0, 1000000]`. fn addition(_i: u32, ) -> Weight { - (123_000 as Weight) + // Minimum execution time: 86 nanoseconds. + Weight::from_ref_time(102_920 as u64) } /// The range of component `i` is `[0, 1000000]`. fn subtraction(_i: u32, ) -> Weight { - (110_000 as Weight) + // Minimum execution time: 93 nanoseconds. + Weight::from_ref_time(110_716 as u64) } /// The range of component `i` is `[0, 1000000]`. fn multiplication(_i: u32, ) -> Weight { - (124_000 as Weight) + // Minimum execution time: 97 nanoseconds. + Weight::from_ref_time(121_613 as u64) } /// The range of component `i` is `[0, 1000000]`. fn division(_i: u32, ) -> Weight { - (120_000 as Weight) + // Minimum execution time: 85 nanoseconds. + Weight::from_ref_time(108_770 as u64) } /// The range of component `i` is `[0, 100]`. - fn hashing(_i: u32, ) -> Weight { - (19_606_352_000 as Weight) + fn hashing(i: u32, ) -> Weight { + // Minimum execution time: 19_096_918 nanoseconds. + Weight::from_ref_time(19_341_958_891 as u64) + // Standard Error: 136_508 + .saturating_add(Weight::from_ref_time(347_531 as u64).saturating_mul(i as u64)) } - /// The range of component `i` is `[1, 100]`. + /// The range of component `i` is `[0, 100]`. fn sr25519_verification(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 38_000 - .saturating_add((47_929_000 as Weight).saturating_mul(i as Weight)) + // Minimum execution time: 111 nanoseconds. + Weight::from_ref_time(118_000 as u64) + // Standard Error: 16_773 + .saturating_add(Weight::from_ref_time(47_757_384 as u64).saturating_mul(i as u64)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `i` is `[0, 1000]`. fn storage_read(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 4_000 - .saturating_add((2_101_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 94 nanoseconds. + Weight::from_ref_time(97_000 as u64) + // Standard Error: 3_564 + .saturating_add(Weight::from_ref_time(1_832_717 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `i` is `[0, 1000]`. fn storage_write(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((330_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 111 nanoseconds. + Weight::from_ref_time(119_000 as u64) + // Standard Error: 812 + .saturating_add(Weight::from_ref_time(320_377 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } } diff --git a/runtime/kusama/src/weights/frame_election_provider_support.rs b/runtime/kusama/src/weights/frame_election_provider_support.rs index e8aad69db283..82bf4f3cfa20 100644 --- a/runtime/kusama/src/weights/frame_election_provider_support.rs +++ b/runtime/kusama/src/weights/frame_election_provider_support.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `frame_election_provider_support` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/frame_election_provider_support.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -48,20 +48,22 @@ impl frame_election_provider_support::WeightInfo for We /// The range of component `t` is `[500, 1000]`. /// The range of component `d` is `[5, 16]`. fn phragmen(v: u32, _t: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 87_000 - .saturating_add((22_196_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 7_520_000 - .saturating_add((3_555_366_000 as Weight).saturating_mul(d as Weight)) + // Minimum execution time: 5_442_855 nanoseconds. + Weight::from_ref_time(5_493_581_000 as u64) + // Standard Error: 137_072 + .saturating_add(Weight::from_ref_time(5_644_474 as u64).saturating_mul(v as u64)) + // Standard Error: 14_013_799 + .saturating_add(Weight::from_ref_time(1_560_631_740 as u64).saturating_mul(d as u64)) } /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. /// The range of component `d` is `[5, 16]`. fn phragmms(v: u32, _t: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 74_000 - .saturating_add((15_098_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 6_402_000 - .saturating_add((2_580_118_000 as Weight).saturating_mul(d as Weight)) + // Minimum execution time: 4_312_432 nanoseconds. + Weight::from_ref_time(4_352_242_000 as u64) + // Standard Error: 147_368 + .saturating_add(Weight::from_ref_time(5_532_148 as u64).saturating_mul(v as u64)) + // Standard Error: 15_066_445 + .saturating_add(Weight::from_ref_time(1_788_360_934 as u64).saturating_mul(d as u64)) } } diff --git a/runtime/kusama/src/weights/frame_system.rs b/runtime/kusama/src/weights/frame_system.rs index 1f166accd724..d3797e9c2a4c 100644 --- a/runtime/kusama/src/weights/frame_system.rs +++ b/runtime/kusama/src/weights/frame_system.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `frame_system` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/frame_system.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,45 +46,51 @@ pub struct WeightInfo(PhantomData); impl frame_system::WeightInfo for WeightInfo { /// The range of component `b` is `[0, 3932160]`. fn remark(b: u32, ) -> Weight { - (0 as Weight) + // Minimum execution time: 3_048 nanoseconds. + Weight::from_ref_time(3_101_000 as u64) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(411 as u64).saturating_mul(b as u64)) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { - (0 as Weight) + // Minimum execution time: 11_933 nanoseconds. + Weight::from_ref_time(12_021_000 as u64) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(1_728 as u64).saturating_mul(b as u64)) } // Storage: System Digest (r:1 w:1) // Storage: unknown [0x3a686561707061676573] (r:0 w:1) fn set_heap_pages() -> Weight { - (4_767_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 7_187 nanoseconds. + Weight::from_ref_time(7_397_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[1, 1000]`. + /// The range of component `i` is `[0, 1000]`. fn set_storage(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((550_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 2_999 nanoseconds. + Weight::from_ref_time(3_090_000 as u64) + // Standard Error: 2_241 + .saturating_add(Weight::from_ref_time(608_495 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[1, 1000]`. + /// The range of component `i` is `[0, 1000]`. fn kill_storage(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((441_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 3_015 nanoseconds. + Weight::from_ref_time(3_067_000 as u64) + // Standard Error: 934 + .saturating_add(Weight::from_ref_time(436_860 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `p` is `[1, 1000]`. + /// The range of component `p` is `[0, 1000]`. fn kill_prefix(p: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((955_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + // Minimum execution time: 4_577 nanoseconds. + Weight::from_ref_time(4_711_000 as u64) + // Standard Error: 1_234 + .saturating_add(Weight::from_ref_time(935_778 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } } diff --git a/runtime/kusama/src/weights/mod.rs b/runtime/kusama/src/weights/mod.rs index 165f068a4b1c..2f9e2d35c211 100644 --- a/runtime/kusama/src/weights/mod.rs +++ b/runtime/kusama/src/weights/mod.rs @@ -23,9 +23,11 @@ pub mod pallet_bounties; pub mod pallet_child_bounties; pub mod pallet_collective_council; pub mod pallet_collective_technical_committee; +pub mod pallet_conviction_voting; pub mod pallet_democracy; pub mod pallet_election_provider_multi_phase; pub mod pallet_elections_phragmen; +pub mod pallet_fast_unstake; pub mod pallet_gilt; pub mod pallet_identity; pub mod pallet_im_online; @@ -35,6 +37,9 @@ pub mod pallet_multisig; pub mod pallet_nomination_pools; pub mod pallet_preimage; pub mod pallet_proxy; +pub mod pallet_ranked_collective; +pub mod pallet_referenda_fellowship_referenda; +pub mod pallet_referenda_referenda; pub mod pallet_scheduler; pub mod pallet_session; pub mod pallet_staking; @@ -43,6 +48,7 @@ pub mod pallet_tips; pub mod pallet_treasury; pub mod pallet_utility; pub mod pallet_vesting; +pub mod pallet_whitelist; pub mod runtime_common_auctions; pub mod runtime_common_claims; pub mod runtime_common_crowdloan; diff --git a/runtime/kusama/src/weights/pallet_bags_list.rs b/runtime/kusama/src/weights/pallet_bags_list.rs index 73acee116dab..bc230a6226ec 100644 --- a/runtime/kusama/src/weights/pallet_bags_list.rs +++ b/runtime/kusama/src/weights/pallet_bags_list.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_bags_list` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_bags_list.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -49,18 +49,20 @@ impl pallet_bags_list::WeightInfo for WeightInfo { // Storage: VoterList ListNodes (r:4 w:4) // Storage: VoterList ListBags (r:1 w:1) fn rebag_non_terminal() -> Weight { - (50_938_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 59_649 nanoseconds. + Weight::from_ref_time(60_237_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn rebag_terminal() -> Weight { - (49_843_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 59_000 nanoseconds. + Weight::from_ref_time(60_766_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: VoterList ListNodes (r:4 w:4) // Storage: Staking Bonded (r:2 w:0) @@ -68,8 +70,9 @@ impl pallet_bags_list::WeightInfo for WeightInfo { // Storage: VoterList CounterForListNodes (r:1 w:1) // Storage: VoterList ListBags (r:1 w:1) fn put_in_front_of() -> Weight { - (51_965_000 as Weight) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 58_720 nanoseconds. + Weight::from_ref_time(59_461_000 as u64) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_balances.rs b/runtime/kusama/src/weights/pallet_balances.rs index 0b74fea4a227..79cc02b8bce0 100644 --- a/runtime/kusama/src/weights/pallet_balances.rs +++ b/runtime/kusama/src/weights/pallet_balances.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_balances.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,44 +46,51 @@ pub struct WeightInfo(PhantomData); impl pallet_balances::WeightInfo for WeightInfo { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (38_958_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 38_597 nanoseconds. + Weight::from_ref_time(39_341_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (30_030_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 30_016 nanoseconds. + Weight::from_ref_time(30_522_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (19_591_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 22_114 nanoseconds. + Weight::from_ref_time(22_750_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (22_871_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_939 nanoseconds. + Weight::from_ref_time(25_606_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (39_215_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 38_778 nanoseconds. + Weight::from_ref_time(39_589_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (34_799_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 34_069 nanoseconds. + Weight::from_ref_time(34_876_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn force_unreserve() -> Weight { - (17_925_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 19_270 nanoseconds. + Weight::from_ref_time(19_675_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_bounties.rs b/runtime/kusama/src/weights/pallet_bounties.rs index 59384e0cd785..1a4e849fc9a5 100644 --- a/runtime/kusama/src/weights/pallet_bounties.rs +++ b/runtime/kusama/src/weights/pallet_bounties.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_bounties` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_bounties.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,90 +50,101 @@ impl pallet_bounties::WeightInfo for WeightInfo { // Storage: Bounties Bounties (r:0 w:1) /// The range of component `d` is `[0, 16384]`. fn propose_bounty(d: u32, ) -> Weight { - (26_654_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 27_271 nanoseconds. + Weight::from_ref_time(28_531_233 as u64) + // Standard Error: 5 + .saturating_add(Weight::from_ref_time(826 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: Bounties BountyApprovals (r:1 w:1) fn approve_bounty() -> Weight { - (9_776_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 11_154 nanoseconds. + Weight::from_ref_time(11_491_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Bounties Bounties (r:1 w:1) fn propose_curator() -> Weight { - (8_350_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 10_607 nanoseconds. + Weight::from_ref_time(10_991_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn unassign_curator() -> Weight { - (34_804_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 37_916 nanoseconds. + Weight::from_ref_time(38_882_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn accept_curator() -> Weight { - (23_414_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 26_984 nanoseconds. + Weight::from_ref_time(27_792_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) fn award_bounty() -> Weight { - (20_148_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 22_831 nanoseconds. + Weight::from_ref_time(23_228_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:3 w:3) // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) // Storage: Bounties BountyDescriptions (r:0 w:1) fn claim_bounty() -> Weight { - (64_115_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 64_649 nanoseconds. + Weight::from_ref_time(65_727_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: Bounties BountyDescriptions (r:0 w:1) fn close_bounty_proposed() -> Weight { - (39_628_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 41_426 nanoseconds. + Weight::from_ref_time(41_831_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) // Storage: System Account (r:2 w:2) // Storage: Bounties BountyDescriptions (r:0 w:1) fn close_bounty_active() -> Weight { - (47_429_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 50_735 nanoseconds. + Weight::from_ref_time(51_454_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Bounties Bounties (r:1 w:1) fn extend_bounty_expiry() -> Weight { - (17_322_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 20_006 nanoseconds. + Weight::from_ref_time(20_537_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Bounties BountyApprovals (r:1 w:1) - // Storage: Bounties Bounties (r:1 w:1) - // Storage: System Account (r:2 w:2) - /// The range of component `b` is `[1, 100]`. + // Storage: Bounties Bounties (r:2 w:2) + // Storage: System Account (r:4 w:4) + /// The range of component `b` is `[0, 100]`. fn spend_funds(b: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 30_000 - .saturating_add((30_775_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(b as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight))) + // Minimum execution time: 6_675 nanoseconds. + Weight::from_ref_time(8_384_780 as u64) + // Standard Error: 24_756 + .saturating_add(Weight::from_ref_time(24_193_834 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(b as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(b as u64))) } } diff --git a/runtime/kusama/src/weights/pallet_child_bounties.rs b/runtime/kusama/src/weights/pallet_child_bounties.rs index b22034f6d873..2b191a5fef6b 100644 --- a/runtime/kusama/src/weights/pallet_child_bounties.rs +++ b/runtime/kusama/src/weights/pallet_child_bounties.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_child_bounties` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_child_bounties.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -52,51 +52,57 @@ impl pallet_child_bounties::WeightInfo for WeightInfo Weight { - (48_890_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 50_962 nanoseconds. + Weight::from_ref_time(52_811_248 as u64) + // Standard Error: 13 + .saturating_add(Weight::from_ref_time(762 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) fn propose_curator() -> Weight { - (14_114_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 18_238 nanoseconds. + Weight::from_ref_time(18_635_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn accept_curator() -> Weight { - (26_807_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 32_611 nanoseconds. + Weight::from_ref_time(33_181_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: Bounties Bounties (r:1 w:0) // Storage: System Account (r:1 w:1) fn unassign_curator() -> Weight { - (39_640_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 44_073 nanoseconds. + Weight::from_ref_time(44_577_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) fn award_child_bounty() -> Weight { - (21_445_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 27_800 nanoseconds. + Weight::from_ref_time(28_099_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: System Account (r:3 w:3) // Storage: ChildBounties ParentChildBounties (r:1 w:1) // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) fn claim_child_bounty() -> Weight { - (65_771_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 65_470 nanoseconds. + Weight::from_ref_time(67_848_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) @@ -105,9 +111,10 @@ impl pallet_child_bounties::WeightInfo for WeightInfo Weight { - (46_230_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 52_072 nanoseconds. + Weight::from_ref_time(52_649_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) @@ -116,8 +123,9 @@ impl pallet_child_bounties::WeightInfo for WeightInfo Weight { - (56_148_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 61_516 nanoseconds. + Weight::from_ref_time(62_160_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_collective_council.rs b/runtime/kusama/src/weights/pallet_collective_council.rs index 4ffa6f5cda03..2b867ffce399 100644 --- a/runtime/kusama/src/weights/pallet_collective_council.rs +++ b/runtime/kusama/src/weights/pallet_collective_council.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2021 Parity Technologies (UK) Ltd. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. // This file is part of Polkadot. // Polkadot is free software: you can redistribute it and/or modify @@ -16,12 +16,14 @@ //! Autogenerated weights for `pallet_collective` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-08-27, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128 +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 // Executed Command: -// target/release/polkadot +// ./target/production/polkadot // benchmark +// pallet // --chain=kusama-dev // --steps=50 // --repeat=20 @@ -29,11 +31,9 @@ // --extrinsic=* // --execution=wasm // --wasm-execution=compiled -// --heap-pages=4096 // --header=./file_header.txt // --output=./runtime/kusama/src/weights/ - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -44,133 +44,185 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_collective`. pub struct WeightInfo(PhantomData); impl pallet_collective::WeightInfo for WeightInfo { - // Storage: Instance1Collective Members (r:1 w:1) - // Storage: Instance1Collective Proposals (r:1 w:0) - // Storage: Instance1Collective Voting (r:100 w:100) - // Storage: Instance1Collective Prime (r:0 w:1) - fn set_members(m: u32, n: u32, p: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 6_000 - .saturating_add((14_448_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 6_000 - .saturating_add((85_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 6_000 - .saturating_add((19_620_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + // Storage: Council Members (r:1 w:1) + // Storage: Council Proposals (r:1 w:0) + // Storage: Council Prime (r:0 w:1) + // Storage: Council Voting (r:100 w:100) + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { + // Minimum execution time: 16_031 nanoseconds. + Weight::from_ref_time(16_157_000 as u64) + // Standard Error: 48_159 + .saturating_add(Weight::from_ref_time(5_423_008 as u64).saturating_mul(m as u64)) + // Standard Error: 48_159 + .saturating_add(Weight::from_ref_time(7_456_856 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } - // Storage: Instance1Collective Members (r:1 w:0) + // Storage: Council Members (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { - (22_536_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((84_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + // Minimum execution time: 19_309 nanoseconds. + Weight::from_ref_time(18_691_751 as u64) + // Standard Error: 24 + .saturating_add(Weight::from_ref_time(1_683 as u64).saturating_mul(b as u64)) + // Standard Error: 255 + .saturating_add(Weight::from_ref_time(15_820 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective ProposalOf (r:1 w:0) + // Storage: Council Members (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { - (27_600_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((161_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) + // Minimum execution time: 21_473 nanoseconds. + Weight::from_ref_time(20_706_971 as u64) + // Standard Error: 28 + .saturating_add(Weight::from_ref_time(1_622 as u64).saturating_mul(b as u64)) + // Standard Error: 297 + .saturating_add(Weight::from_ref_time(22_480 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) } - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective ProposalOf (r:1 w:1) - // Storage: Instance1Collective Proposals (r:1 w:1) - // Storage: Instance1Collective ProposalCount (r:1 w:1) - // Storage: Instance1Collective Voting (r:0 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:1) + // Storage: Council Proposals (r:1 w:1) + // Storage: Council ProposalCount (r:1 w:1) + // Storage: Council Voting (r:0 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (42_192_000 as Weight) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((87_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((361_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 26_708 nanoseconds. + Weight::from_ref_time(27_050_120 as u64) + // Standard Error: 70 + .saturating_add(Weight::from_ref_time(3_338 as u64).saturating_mul(b as u64)) + // Standard Error: 737 + .saturating_add(Weight::from_ref_time(20_326 as u64).saturating_mul(m as u64)) + // Standard Error: 727 + .saturating_add(Weight::from_ref_time(106_723 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council Voting (r:1 w:1) + /// The range of component `m` is `[5, 100]`. + /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { - (32_307_000 as Weight) - // Standard Error: 0 - .saturating_add((199_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_639 nanoseconds. + Weight::from_ref_time(27_611_311 as u64) + // Standard Error: 380 + .saturating_add(Weight::from_ref_time(35_933 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: Instance1Collective Voting (r:1 w:1) - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective Proposals (r:1 w:1) - // Storage: Instance1Collective ProposalOf (r:0 w:1) + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council Proposals (r:1 w:1) + // Storage: Council ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (41_436_000 as Weight) - // Standard Error: 0 - .saturating_add((170_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((333_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 29_178 nanoseconds. + Weight::from_ref_time(31_739_247 as u64) + // Standard Error: 557 + .saturating_add(Weight::from_ref_time(21_928 as u64).saturating_mul(m as u64)) + // Standard Error: 543 + .saturating_add(Weight::from_ref_time(83_446 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance1Collective Voting (r:1 w:1) - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective ProposalOf (r:1 w:1) - // Storage: Instance1Collective Proposals (r:1 w:1) + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:1) + // Storage: Council Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (57_836_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((170_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((339_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 39_173 nanoseconds. + Weight::from_ref_time(40_382_726 as u64) + // Standard Error: 58 + .saturating_add(Weight::from_ref_time(1_584 as u64).saturating_mul(b as u64)) + // Standard Error: 623 + .saturating_add(Weight::from_ref_time(24_345 as u64).saturating_mul(m as u64)) + // Standard Error: 607 + .saturating_add(Weight::from_ref_time(97_786 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance1Collective Voting (r:1 w:1) - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective Prime (r:1 w:0) - // Storage: Instance1Collective Proposals (r:1 w:1) - // Storage: Instance1Collective ProposalOf (r:0 w:1) + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council Prime (r:1 w:0) + // Storage: Council Proposals (r:1 w:1) + // Storage: Council ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { - (45_551_000 as Weight) - // Standard Error: 0 - .saturating_add((172_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((338_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 32_457 nanoseconds. + Weight::from_ref_time(33_681_509 as u64) + // Standard Error: 502 + .saturating_add(Weight::from_ref_time(26_118 as u64).saturating_mul(m as u64)) + // Standard Error: 489 + .saturating_add(Weight::from_ref_time(82_917 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance1Collective Voting (r:1 w:1) - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective Prime (r:1 w:0) - // Storage: Instance1Collective ProposalOf (r:1 w:1) - // Storage: Instance1Collective Proposals (r:1 w:1) + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council Prime (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:1) + // Storage: Council Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (61_497_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((171_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((343_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 41_311 nanoseconds. + Weight::from_ref_time(42_427_105 as u64) + // Standard Error: 62 + .saturating_add(Weight::from_ref_time(1_552 as u64).saturating_mul(b as u64)) + // Standard Error: 661 + .saturating_add(Weight::from_ref_time(25_634 as u64).saturating_mul(m as u64)) + // Standard Error: 644 + .saturating_add(Weight::from_ref_time(100_022 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance1Collective Proposals (r:1 w:1) - // Storage: Instance1Collective Voting (r:0 w:1) - // Storage: Instance1Collective ProposalOf (r:0 w:1) + // Storage: Council Proposals (r:1 w:1) + // Storage: Council Voting (r:0 w:1) + // Storage: Council ProposalOf (r:0 w:1) + /// The range of component `p` is `[1, 100]`. + /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { - (25_573_000 as Weight) - // Standard Error: 0 - .saturating_add((335_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 18_211 nanoseconds. + Weight::from_ref_time(21_526_337 as u64) + // Standard Error: 690 + .saturating_add(Weight::from_ref_time(94_777 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_collective_technical_committee.rs b/runtime/kusama/src/weights/pallet_collective_technical_committee.rs index d61bb433c99e..2205878f32a7 100644 --- a/runtime/kusama/src/weights/pallet_collective_technical_committee.rs +++ b/runtime/kusama/src/weights/pallet_collective_technical_committee.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2021 Parity Technologies (UK) Ltd. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. // This file is part of Polkadot. // Polkadot is free software: you can redistribute it and/or modify @@ -16,12 +16,14 @@ //! Autogenerated weights for `pallet_collective` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-08-27, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128 +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 // Executed Command: -// target/release/polkadot +// ./target/production/polkadot // benchmark +// pallet // --chain=kusama-dev // --steps=50 // --repeat=20 @@ -29,11 +31,9 @@ // --extrinsic=* // --execution=wasm // --wasm-execution=compiled -// --heap-pages=4096 // --header=./file_header.txt // --output=./runtime/kusama/src/weights/ - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -44,133 +44,185 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_collective`. pub struct WeightInfo(PhantomData); impl pallet_collective::WeightInfo for WeightInfo { - // Storage: Instance2Collective Members (r:1 w:1) - // Storage: Instance2Collective Proposals (r:1 w:0) - // Storage: Instance2Collective Voting (r:100 w:100) - // Storage: Instance2Collective Prime (r:0 w:1) - fn set_members(m: u32, n: u32, p: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 6_000 - .saturating_add((14_473_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 6_000 - .saturating_add((73_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 6_000 - .saturating_add((19_551_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + // Storage: TechnicalCommittee Members (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:0) + // Storage: TechnicalCommittee Prime (r:0 w:1) + // Storage: TechnicalCommittee Voting (r:100 w:100) + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { + // Minimum execution time: 16_692 nanoseconds. + Weight::from_ref_time(16_827_000 as u64) + // Standard Error: 47_952 + .saturating_add(Weight::from_ref_time(5_446_193 as u64).saturating_mul(m as u64)) + // Standard Error: 47_952 + .saturating_add(Weight::from_ref_time(7_583_650 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } - // Storage: Instance2Collective Members (r:1 w:0) + // Storage: TechnicalCommittee Members (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { - (22_690_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((80_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + // Minimum execution time: 19_628 nanoseconds. + Weight::from_ref_time(18_949_624 as u64) + // Standard Error: 18 + .saturating_add(Weight::from_ref_time(1_709 as u64).saturating_mul(b as u64)) + // Standard Error: 186 + .saturating_add(Weight::from_ref_time(15_119 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective ProposalOf (r:1 w:0) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { - (27_473_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((159_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) + // Minimum execution time: 22_068 nanoseconds. + Weight::from_ref_time(21_218_874 as u64) + // Standard Error: 25 + .saturating_add(Weight::from_ref_time(1_678 as u64).saturating_mul(b as u64)) + // Standard Error: 258 + .saturating_add(Weight::from_ref_time(19_871 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) } - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective ProposalOf (r:1 w:1) - // Storage: Instance2Collective Proposals (r:1 w:1) - // Storage: Instance2Collective ProposalCount (r:1 w:1) - // Storage: Instance2Collective Voting (r:0 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee ProposalCount (r:1 w:1) + // Storage: TechnicalCommittee Voting (r:0 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (42_047_000 as Weight) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((85_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((360_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 27_450 nanoseconds. + Weight::from_ref_time(28_212_498 as u64) + // Standard Error: 65 + .saturating_add(Weight::from_ref_time(3_512 as u64).saturating_mul(b as u64)) + // Standard Error: 686 + .saturating_add(Weight::from_ref_time(17_294 as u64).saturating_mul(m as u64)) + // Standard Error: 678 + .saturating_add(Weight::from_ref_time(111_953 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Voting (r:1 w:1) + /// The range of component `m` is `[5, 100]`. + /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { - (32_023_000 as Weight) - // Standard Error: 0 - .saturating_add((199_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 27_739 nanoseconds. + Weight::from_ref_time(29_171_519 as u64) + // Standard Error: 442 + .saturating_add(Weight::from_ref_time(36_814 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: Instance2Collective Voting (r:1 w:1) - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective Proposals (r:1 w:1) - // Storage: Instance2Collective ProposalOf (r:0 w:1) + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (41_107_000 as Weight) - // Standard Error: 0 - .saturating_add((171_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((332_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 31_027 nanoseconds. + Weight::from_ref_time(32_482_964 as u64) + // Standard Error: 447 + .saturating_add(Weight::from_ref_time(22_380 as u64).saturating_mul(m as u64)) + // Standard Error: 436 + .saturating_add(Weight::from_ref_time(81_863 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance2Collective Voting (r:1 w:1) - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective ProposalOf (r:1 w:1) - // Storage: Instance2Collective Proposals (r:1 w:1) + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (57_783_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((167_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((336_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 40_591 nanoseconds. + Weight::from_ref_time(40_989_302 as u64) + // Standard Error: 56 + .saturating_add(Weight::from_ref_time(1_669 as u64).saturating_mul(b as u64)) + // Standard Error: 593 + .saturating_add(Weight::from_ref_time(25_242 as u64).saturating_mul(m as u64)) + // Standard Error: 578 + .saturating_add(Weight::from_ref_time(98_234 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance2Collective Voting (r:1 w:1) - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective Prime (r:1 w:0) - // Storage: Instance2Collective Proposals (r:1 w:1) - // Storage: Instance2Collective ProposalOf (r:0 w:1) + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Prime (r:1 w:0) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { - (45_646_000 as Weight) - // Standard Error: 0 - .saturating_add((170_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((335_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 33_392 nanoseconds. + Weight::from_ref_time(34_332_427 as u64) + // Standard Error: 455 + .saturating_add(Weight::from_ref_time(27_395 as u64).saturating_mul(m as u64)) + // Standard Error: 443 + .saturating_add(Weight::from_ref_time(81_538 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance2Collective Voting (r:1 w:1) - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective Prime (r:1 w:0) - // Storage: Instance2Collective ProposalOf (r:1 w:1) - // Storage: Instance2Collective Proposals (r:1 w:1) + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Prime (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (61_376_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((172_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((339_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 42_095 nanoseconds. + Weight::from_ref_time(42_979_139 as u64) + // Standard Error: 57 + .saturating_add(Weight::from_ref_time(1_593 as u64).saturating_mul(b as u64)) + // Standard Error: 607 + .saturating_add(Weight::from_ref_time(25_966 as u64).saturating_mul(m as u64)) + // Standard Error: 591 + .saturating_add(Weight::from_ref_time(100_252 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance2Collective Proposals (r:1 w:1) - // Storage: Instance2Collective Voting (r:0 w:1) - // Storage: Instance2Collective ProposalOf (r:0 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee Voting (r:0 w:1) + // Storage: TechnicalCommittee ProposalOf (r:0 w:1) + /// The range of component `p` is `[1, 100]`. + /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { - (25_286_000 as Weight) - // Standard Error: 0 - .saturating_add((336_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 18_749 nanoseconds. + Weight::from_ref_time(22_120_550 as u64) + // Standard Error: 692 + .saturating_add(Weight::from_ref_time(95_583 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_conviction_voting.rs b/runtime/kusama/src/weights/pallet_conviction_voting.rs new file mode 100644 index 000000000000..d5e1568efb20 --- /dev/null +++ b/runtime/kusama/src/weights/pallet_conviction_voting.rs @@ -0,0 +1,125 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_conviction_voting` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_conviction_voting +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_conviction_voting`. +pub struct WeightInfo(PhantomData); +impl pallet_conviction_voting::WeightInfo for WeightInfo { + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: ConvictionVoting VotingFor (r:1 w:1) + // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn vote_new() -> Weight { + // Minimum execution time: 125_577 nanoseconds. + Weight::from_ref_time(128_422_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: ConvictionVoting VotingFor (r:1 w:1) + // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn vote_existing() -> Weight { + // Minimum execution time: 153_040 nanoseconds. + Weight::from_ref_time(155_995_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: ConvictionVoting VotingFor (r:1 w:1) + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn remove_vote() -> Weight { + // Minimum execution time: 130_240 nanoseconds. + Weight::from_ref_time(133_249_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: ConvictionVoting VotingFor (r:1 w:1) + // Storage: Referenda ReferendumInfoFor (r:1 w:0) + fn remove_other_vote() -> Weight { + // Minimum execution time: 70_042 nanoseconds. + Weight::from_ref_time(72_074_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ConvictionVoting VotingFor (r:2 w:2) + // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Referenda ReferendumInfoFor (r:10 w:10) + // Storage: Scheduler Agenda (r:2 w:2) + /// The range of component `r` is `[0, 512]`. + fn delegate(r: u32, ) -> Weight { + // Minimum execution time: 76_733 nanoseconds. + Weight::from_ref_time(707_216_284 as u64) + // Standard Error: 60_799 + .saturating_add(Weight::from_ref_time(28_505_942 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) + } + // Storage: ConvictionVoting VotingFor (r:2 w:2) + // Storage: Referenda ReferendumInfoFor (r:10 w:10) + // Storage: Scheduler Agenda (r:2 w:2) + /// The range of component `r` is `[0, 512]`. + fn undelegate(r: u32, ) -> Weight { + // Minimum execution time: 52_748 nanoseconds. + Weight::from_ref_time(683_979_746 as u64) + // Standard Error: 61_513 + .saturating_add(Weight::from_ref_time(28_523_157 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) + } + // Storage: ConvictionVoting VotingFor (r:1 w:1) + // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + fn unlock() -> Weight { + // Minimum execution time: 87_809 nanoseconds. + Weight::from_ref_time(90_514_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } +} diff --git a/runtime/kusama/src/weights/pallet_democracy.rs b/runtime/kusama/src/weights/pallet_democracy.rs index 95c26f3f55b3..9ed911379aff 100644 --- a/runtime/kusama/src/weights/pallet_democracy.rs +++ b/runtime/kusama/src/weights/pallet_democracy.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_democracy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_democracy.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -49,251 +49,214 @@ impl pallet_democracy::WeightInfo for WeightInfo { // Storage: Democracy Blacklist (r:1 w:0) // Storage: Democracy DepositOf (r:0 w:1) fn propose() -> Weight { - (37_453_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 41_759 nanoseconds. + Weight::from_ref_time(42_405_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy DepositOf (r:1 w:1) - /// The range of component `s` is `[0, 100]`. - fn second(s: u32, ) -> Weight { - (27_807_000 as Weight) - // Standard Error: 0 - .saturating_add((69_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn second() -> Weight { + // Minimum execution time: 38_699 nanoseconds. + Weight::from_ref_time(39_568_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - /// The range of component `r` is `[1, 99]`. - fn vote_new(r: u32, ) -> Weight { - (35_336_000 as Weight) - // Standard Error: 1_000 - .saturating_add((120_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn vote_new() -> Weight { + // Minimum execution time: 48_618 nanoseconds. + Weight::from_ref_time(49_513_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - /// The range of component `r` is `[1, 99]`. - fn vote_existing(r: u32, ) -> Weight { - (35_107_000 as Weight) - // Standard Error: 1_000 - .saturating_add((123_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn vote_existing() -> Weight { + // Minimum execution time: 48_709 nanoseconds. + Weight::from_ref_time(49_737_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy Cancellations (r:1 w:1) fn emergency_cancel() -> Weight { - (17_752_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 20_352 nanoseconds. + Weight::from_ref_time(20_676_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Democracy PublicProps (r:1 w:1) + // Storage: Democracy DepositOf (r:1 w:1) + // Storage: System Account (r:1 w:1) // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy Blacklist (r:0 w:1) - // Storage: Democracy DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) - /// The range of component `p` is `[1, 100]`. - fn blacklist(p: u32, ) -> Weight { - (52_116_000 as Weight) - // Standard Error: 6_000 - .saturating_add((194_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + fn blacklist() -> Weight { + // Minimum execution time: 75_042 nanoseconds. + Weight::from_ref_time(76_607_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:0) - /// The range of component `v` is `[1, 100]`. - fn external_propose(v: u32, ) -> Weight { - (10_194_000 as Weight) - // Standard Error: 0 - .saturating_add((10_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn external_propose() -> Weight { + // Minimum execution time: 15_470 nanoseconds. + Weight::from_ref_time(16_352_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_majority() -> Weight { - (3_700_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_297 nanoseconds. + Weight::from_ref_time(4_450_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_default() -> Weight { - (3_713_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_074 nanoseconds. + Weight::from_ref_time(4_261_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:1) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn fast_track() -> Weight { - (17_441_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 20_016 nanoseconds. + Weight::from_ref_time(20_413_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:1) - /// The range of component `v` is `[0, 100]`. - fn veto_external(v: u32, ) -> Weight { - (18_536_000 as Weight) - // Standard Error: 0 - .saturating_add((42_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn veto_external() -> Weight { + // Minimum execution time: 24_906 nanoseconds. + Weight::from_ref_time(25_500_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) - /// The range of component `p` is `[1, 100]`. - fn cancel_proposal(p: u32, ) -> Weight { - (42_174_000 as Weight) - // Standard Error: 1_000 - .saturating_add((164_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn cancel_proposal() -> Weight { + // Minimum execution time: 63_398 nanoseconds. + Weight::from_ref_time(64_382_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn cancel_referendum() -> Weight { - (11_892_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - /// The range of component `r` is `[1, 99]`. - fn cancel_queued(r: u32, ) -> Weight { - (23_252_000 as Weight) - // Standard Error: 5_000 - .saturating_add((2_242_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 12_688 nanoseconds. + Weight::from_ref_time(13_056_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:1 w:0) - /// The range of component `r` is `[1, 99]`. + // Storage: Democracy ReferendumInfoOf (r:2 w:0) + /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { - (1_457_000 as Weight) - // Standard Error: 3_000 - .saturating_add((2_956_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 5_838 nanoseconds. + Weight::from_ref_time(9_062_912 as u64) + // Standard Error: 3_860 + .saturating_add(Weight::from_ref_time(2_072_063 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) // Storage: Democracy LastTabledWasExternal (r:1 w:0) // Storage: Democracy NextExternal (r:1 w:0) // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:1 w:0) - /// The range of component `r` is `[1, 99]`. + // Storage: Democracy ReferendumInfoOf (r:2 w:0) + /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - (6_240_000 as Weight) - // Standard Error: 3_000 - .saturating_add((2_963_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_322 nanoseconds. + Weight::from_ref_time(11_779_246 as u64) + // Standard Error: 4_107 + .saturating_add(Weight::from_ref_time(2_078_653 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:3 w:3) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + // Storage: Democracy ReferendumInfoOf (r:2 w:2) + /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { - (34_480_000 as Weight) - // Standard Error: 5_000 - .saturating_add((3_908_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight))) + // Minimum execution time: 40_236 nanoseconds. + Weight::from_ref_time(47_071_432 as u64) + // Standard Error: 5_329 + .saturating_add(Weight::from_ref_time(2_956_656 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) } // Storage: Democracy VotingOf (r:2 w:2) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + // Storage: Democracy ReferendumInfoOf (r:2 w:2) + /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { - (17_446_000 as Weight) - // Standard Error: 6_000 - .saturating_add((3_917_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight))) + // Minimum execution time: 23_757 nanoseconds. + Weight::from_ref_time(27_469_795 as u64) + // Standard Error: 4_678 + .saturating_add(Weight::from_ref_time(2_979_545 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) } // Storage: Democracy PublicProps (r:0 w:1) fn clear_public_proposals() -> Weight { - (3_727_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Democracy Preimages (r:1 w:1) - /// The range of component `b` is `[0, 16384]`. - fn note_preimage(b: u32, ) -> Weight { - (25_720_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Democracy Preimages (r:1 w:1) - /// The range of component `b` is `[0, 16384]`. - fn note_imminent_preimage(b: u32, ) -> Weight { - (17_884_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Democracy Preimages (r:1 w:1) - // Storage: System Account (r:1 w:0) - /// The range of component `b` is `[0, 16384]`. - fn reap_preimage(b: u32, ) -> Weight { - (24_695_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_993 nanoseconds. + Weight::from_ref_time(5_073_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { - (22_207_000 as Weight) - // Standard Error: 0 - .saturating_add((36_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 23_394 nanoseconds. + Weight::from_ref_time(30_461_547 as u64) + // Standard Error: 1_584 + .saturating_add(Weight::from_ref_time(32_550 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { - (21_561_000 as Weight) - // Standard Error: 0 - .saturating_add((110_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 28_280 nanoseconds. + Weight::from_ref_time(30_149_111 as u64) + // Standard Error: 726 + .saturating_add(Weight::from_ref_time(67_624 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { - (13_204_000 as Weight) - // Standard Error: 0 - .saturating_add((105_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 15_288 nanoseconds. + Weight::from_ref_time(17_863_090 as u64) + // Standard Error: 824 + .saturating_add(Weight::from_ref_time(69_037 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { - (12_994_000 as Weight) - // Standard Error: 0 - .saturating_add((106_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 15_235 nanoseconds. + Weight::from_ref_time(17_900_284 as u64) + // Standard Error: 847 + .saturating_add(Weight::from_ref_time(68_753 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_election_provider_multi_phase.rs b/runtime/kusama/src/weights/pallet_election_provider_multi_phase.rs index df67964a2eb6..1b6c20565fe0 100644 --- a/runtime/kusama/src/weights/pallet_election_provider_multi_phase.rs +++ b/runtime/kusama/src/weights/pallet_election_provider_multi_phase.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_election_provider_multi_phase` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_election_provider_multi_phase.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -53,48 +53,52 @@ impl pallet_election_provider_multi_phase::WeightInfo f // Storage: Staking ForceEra (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) fn on_initialize_nothing() -> Weight { - (13_511_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) + // Minimum execution time: 15_107 nanoseconds. + Weight::from_ref_time(15_366_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn on_initialize_open_signed() -> Weight { - (12_448_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 14_010 nanoseconds. + Weight::from_ref_time(14_784_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn on_initialize_open_unsigned() -> Weight { - (12_497_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 13_853 nanoseconds. + Weight::from_ref_time(14_445_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) // Storage: ElectionProviderMultiPhase QueuedSolution (r:0 w:1) fn finalize_signed_phase_accept_solution() -> Weight { - (26_220_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 28_285 nanoseconds. + Weight::from_ref_time(28_639_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: System Account (r:1 w:1) fn finalize_signed_phase_reject_solution() -> Weight { - (20_222_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 22_109 nanoseconds. + Weight::from_ref_time(22_587_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:0 w:1) // Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) // Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. - fn create_snapshot_internal(v: u32, t: u32, ) -> Weight { - (37_912_000 as Weight) - // Standard Error: 2_000 - .saturating_add((549_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 5_000 - .saturating_add((69_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn create_snapshot_internal(v: u32, _t: u32, ) -> Weight { + // Minimum execution time: 622_518 nanoseconds. + Weight::from_ref_time(647_402_000 as u64) + // Standard Error: 4_839 + .saturating_add(Weight::from_ref_time(375_965 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) @@ -108,14 +112,13 @@ impl pallet_election_provider_multi_phase::WeightInfo f // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. - fn elect_queued(a: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 13_000 - .saturating_add((1_310_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 20_000 - .saturating_add((246_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(9 as Weight)) + fn elect_queued(a: u32, _d: u32, ) -> Weight { + // Minimum execution time: 369_213 nanoseconds. + Weight::from_ref_time(373_298_000 as u64) + // Standard Error: 8_881 + .saturating_add(Weight::from_ref_time(578_551 as u64).saturating_mul(a as u64)) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) @@ -124,9 +127,10 @@ impl pallet_election_provider_multi_phase::WeightInfo f // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) // Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:0 w:1) fn submit() -> Weight { - (48_687_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 50_173 nanoseconds. + Weight::from_ref_time(51_434_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: ElectionProviderMultiPhase Round (r:1 w:0) @@ -139,16 +143,13 @@ impl pallet_election_provider_multi_phase::WeightInfo f /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. - fn submit_unsigned(v: u32, _t: u32, a: u32, d: u32, ) -> Weight { - (196_420_000 as Weight) - // Standard Error: 7_000 - .saturating_add((887_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 24_000 - .saturating_add((10_943_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 36_000 - .saturating_add((1_604_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn submit_unsigned(_v: u32, _t: u32, a: u32, _d: u32, ) -> Weight { + // Minimum execution time: 6_771_975 nanoseconds. + Weight::from_ref_time(6_832_732_000 as u64) + // Standard Error: 58_044 + .saturating_add(Weight::from_ref_time(6_976_679 as u64).saturating_mul(a as u64)) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) @@ -158,16 +159,13 @@ impl pallet_election_provider_multi_phase::WeightInfo f /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. - fn feasibility_check(v: u32, t: u32, a: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 5_000 - .saturating_add((907_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 11_000 - .saturating_add((64_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 19_000 - .saturating_add((8_768_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 29_000 - .saturating_add((912_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) + fn feasibility_check(v: u32, _t: u32, a: u32, _d: u32, ) -> Weight { + // Minimum execution time: 5_640_118 nanoseconds. + Weight::from_ref_time(5_681_788_000 as u64) + // Standard Error: 18_489 + .saturating_add(Weight::from_ref_time(82_866 as u64).saturating_mul(v as u64)) + // Standard Error: 54_791 + .saturating_add(Weight::from_ref_time(5_418_533 as u64).saturating_mul(a as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_elections_phragmen.rs b/runtime/kusama/src/weights/pallet_elections_phragmen.rs index f20c1db2e287..55f4aebda844 100644 --- a/runtime/kusama/src/weights/pallet_elections_phragmen.rs +++ b/runtime/kusama/src/weights/pallet_elections_phragmen.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_elections_phragmen` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_elections_phragmen.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -51,11 +51,12 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[1, 16]`. fn vote_equal(v: u32, ) -> Weight { - (24_107_000 as Weight) - // Standard Error: 2_000 - .saturating_add((184_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 31_085 nanoseconds. + Weight::from_ref_time(32_736_954 as u64) + // Standard Error: 3_845 + .saturating_add(Weight::from_ref_time(168_838 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Candidates (r:1 w:0) // Storage: PhragmenElection Members (r:1 w:0) @@ -64,11 +65,12 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[2, 16]`. fn vote_more(v: u32, ) -> Weight { - (36_869_000 as Weight) - // Standard Error: 5_000 - .saturating_add((165_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 41_132 nanoseconds. + Weight::from_ref_time(42_303_475 as u64) + // Standard Error: 5_730 + .saturating_add(Weight::from_ref_time(208_484 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Candidates (r:1 w:0) // Storage: PhragmenElection Members (r:1 w:0) @@ -77,38 +79,42 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[2, 16]`. fn vote_less(v: u32, ) -> Weight { - (36_445_000 as Weight) - // Standard Error: 4_000 - .saturating_add((199_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 41_877 nanoseconds. + Weight::from_ref_time(42_421_665 as u64) + // Standard Error: 4_617 + .saturating_add(Weight::from_ref_time(186_992 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Voting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn remove_voter() -> Weight { - (33_035_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 39_668 nanoseconds. + Weight::from_ref_time(40_061_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Candidates (r:1 w:1) // Storage: PhragmenElection Members (r:1 w:0) // Storage: PhragmenElection RunnersUp (r:1 w:0) /// The range of component `c` is `[1, 1000]`. fn submit_candidacy(c: u32, ) -> Weight { - (25_946_000 as Weight) - // Standard Error: 0 - .saturating_add((101_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 36_292 nanoseconds. + Weight::from_ref_time(28_441_584 as u64) + // Standard Error: 999 + .saturating_add(Weight::from_ref_time(92_295 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: PhragmenElection Candidates (r:1 w:1) /// The range of component `c` is `[1, 1000]`. fn renounce_candidacy_candidate(c: u32, ) -> Weight { - (22_945_000 as Weight) - // Standard Error: 0 - .saturating_add((69_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 32_157 nanoseconds. + Weight::from_ref_time(23_445_460 as u64) + // Standard Error: 1_039 + .saturating_add(Weight::from_ref_time(73_470 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: PhragmenElection Members (r:1 w:1) // Storage: PhragmenElection RunnersUp (r:1 w:1) @@ -116,19 +122,22 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Council Proposals (r:1 w:0) // Storage: Council Members (r:0 w:1) fn renounce_candidacy_members() -> Weight { - (41_502_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 45_300 nanoseconds. + Weight::from_ref_time(47_067_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: PhragmenElection RunnersUp (r:1 w:1) fn renounce_candidacy_runners_up() -> Weight { - (30_791_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 34_427 nanoseconds. + Weight::from_ref_time(35_301_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Benchmark Override (r:0 w:0) fn remove_member_without_replacement() -> Weight { - (2_000_000_000_000 as Weight) + // Minimum execution time: 2_000_000_000 nanoseconds. + Weight::from_ref_time(2_000_000_000_000 as u64) } // Storage: PhragmenElection Members (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -137,9 +146,10 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Council Proposals (r:1 w:0) // Storage: Council Members (r:0 w:1) fn remove_member_with_replacement() -> Weight { - (57_184_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 59_116 nanoseconds. + Weight::from_ref_time(60_245_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: PhragmenElection Voting (r:5001 w:5000) // Storage: PhragmenElection Members (r:1 w:0) @@ -148,14 +158,15 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Balances Locks (r:5000 w:5000) // Storage: System Account (r:5000 w:5000) /// The range of component `v` is `[5000, 10000]`. - /// The range of component `d` is `[1, 5000]`. + /// The range of component `d` is `[0, 5000]`. fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 85_000 - .saturating_add((61_507_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + // Minimum execution time: 277_672_844 nanoseconds. + Weight::from_ref_time(278_514_899_000 as u64) + // Standard Error: 241_305 + .saturating_add(Weight::from_ref_time(34_329_964 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(v as u64))) } // Storage: PhragmenElection Candidates (r:1 w:1) // Storage: PhragmenElection Members (r:1 w:1) @@ -170,14 +181,16 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn /// The range of component `v` is `[1, 10000]`. /// The range of component `e` is `[10000, 160000]`. fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_864_000 - .saturating_add((167_385_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 124_000 - .saturating_add((9_721_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(265 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 28_457_507 nanoseconds. + Weight::from_ref_time(28_618_929_000 as u64) + // Standard Error: 542_445 + .saturating_add(Weight::from_ref_time(45_671_268 as u64).saturating_mul(v as u64)) + // Standard Error: 34_810 + .saturating_add(Weight::from_ref_time(2_339_767 as u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(265 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) } } diff --git a/runtime/kusama/src/weights/pallet_fast_unstake.rs b/runtime/kusama/src/weights/pallet_fast_unstake.rs new file mode 100644 index 000000000000..a79fa732abe0 --- /dev/null +++ b/runtime/kusama/src/weights/pallet_fast_unstake.rs @@ -0,0 +1,120 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_fast_unstake` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_fast_unstake +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_fast_unstake`. +pub struct WeightInfo(PhantomData); +impl pallet_fast_unstake::WeightInfo for WeightInfo { + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + // Storage: FastUnstake Head (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking Payee (r:0 w:1) + fn on_idle_unstake() -> Weight { + // Minimum execution time: 70_698 nanoseconds. + Weight::from_ref_time(71_645_000 as u64) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + // Storage: FastUnstake Head (r:1 w:1) + // Storage: FastUnstake Queue (r:2 w:1) + // Storage: FastUnstake CounterForQueue (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking ErasStakers (r:56 w:0) + /// The range of component `x` is `[28, 3584]`. + fn on_idle_check(x: u32, ) -> Weight { + // Minimum execution time: 425_735 nanoseconds. + Weight::from_ref_time(428_188_000 as u64) + // Standard Error: 19_127 + .saturating_add(Weight::from_ref_time(11_434_878 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(22 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: FastUnstake Queue (r:1 w:1) + // Storage: FastUnstake Head (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking CounterForNominators (r:1 w:1) + // Storage: VoterList ListNodes (r:1 w:1) + // Storage: VoterList ListBags (r:1 w:1) + // Storage: VoterList CounterForListNodes (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: FastUnstake CounterForQueue (r:1 w:1) + fn register_fast_unstake() -> Weight { + // Minimum execution time: 93_096 nanoseconds. + Weight::from_ref_time(93_867_000 as u64) + .saturating_add(T::DbWeight::get().reads(13 as u64)) + .saturating_add(T::DbWeight::get().writes(9 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: FastUnstake Queue (r:1 w:1) + // Storage: FastUnstake Head (r:1 w:0) + // Storage: FastUnstake CounterForQueue (r:1 w:1) + fn deregister() -> Weight { + // Minimum execution time: 40_468 nanoseconds. + Weight::from_ref_time(41_354_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1) + fn control() -> Weight { + // Minimum execution time: 3_682 nanoseconds. + Weight::from_ref_time(3_845_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } +} diff --git a/runtime/kusama/src/weights/pallet_gilt.rs b/runtime/kusama/src/weights/pallet_gilt.rs index b56f50fb9fda..ee4c85d4f57a 100644 --- a/runtime/kusama/src/weights/pallet_gilt.rs +++ b/runtime/kusama/src/weights/pallet_gilt.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_gilt` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_gilt.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -48,72 +48,80 @@ impl pallet_gilt::WeightInfo for WeightInfo { // Storage: Gilt QueueTotals (r:1 w:1) /// The range of component `l` is `[0, 999]`. fn place_bid(l: u32, ) -> Weight { - (36_767_000 as Weight) - // Standard Error: 0 - .saturating_add((115_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 35_662 nanoseconds. + Weight::from_ref_time(33_310_341 as u64) + // Standard Error: 699 + .saturating_add(Weight::from_ref_time(70_825 as u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) fn place_bid_max() -> Weight { - (119_333_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 98_299 nanoseconds. + Weight::from_ref_time(99_875_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Gilt Queues (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) /// The range of component `l` is `[1, 1000]`. fn retract_bid(l: u32, ) -> Weight { - (37_108_000 as Weight) - // Standard Error: 0 - .saturating_add((94_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 36_914 nanoseconds. + Weight::from_ref_time(33_609_132 as u64) + // Standard Error: 688 + .saturating_add(Weight::from_ref_time(61_346 as u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Gilt ActiveTotal (r:1 w:1) fn set_target() -> Weight { - (5_188_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 6_346 nanoseconds. + Weight::from_ref_time(6_537_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Gilt Active (r:1 w:1) // Storage: Gilt ActiveTotal (r:1 w:1) fn thaw() -> Weight { - (43_654_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 45_145 nanoseconds. + Weight::from_ref_time(45_983_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Gilt ActiveTotal (r:1 w:0) fn pursue_target_noop() -> Weight { - (1_584_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + // Minimum execution time: 2_703 nanoseconds. + Weight::from_ref_time(2_853_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } // Storage: Gilt ActiveTotal (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) // Storage: Gilt Queues (r:1 w:1) - // Storage: Gilt Active (r:0 w:1) - /// The range of component `b` is `[1, 1000]`. + // Storage: Gilt Active (r:0 w:20) + /// The range of component `b` is `[0, 1000]`. fn pursue_target_per_item(b: u32, ) -> Weight { - (21_464_000 as Weight) - // Standard Error: 2_000 - .saturating_add((4_387_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(b as Weight))) + // Minimum execution time: 27_077 nanoseconds. + Weight::from_ref_time(31_097_279 as u64) + // Standard Error: 2_945 + .saturating_add(Weight::from_ref_time(3_841_676 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(b as u64))) } // Storage: Gilt ActiveTotal (r:1 w:1) // Storage: Gilt QueueTotals (r:1 w:1) - // Storage: Gilt Queues (r:1 w:1) - // Storage: Gilt Active (r:0 w:1) - /// The range of component `q` is `[1, 300]`. + // Storage: Gilt Queues (r:6 w:6) + // Storage: Gilt Active (r:0 w:6) + /// The range of component `q` is `[0, 300]`. fn pursue_target_per_queue(q: u32, ) -> Weight { - (12_881_000 as Weight) - // Standard Error: 8_000 - .saturating_add((8_285_000 as Weight).saturating_mul(q as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(q as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(q as Weight))) + // Minimum execution time: 27_042 nanoseconds. + Weight::from_ref_time(26_820_692 as u64) + // Standard Error: 6_645 + .saturating_add(Weight::from_ref_time(6_471_496 as u64).saturating_mul(q as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(q as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(q as u64))) } } diff --git a/runtime/kusama/src/weights/pallet_identity.rs b/runtime/kusama/src/weights/pallet_identity.rs index f7709235f029..f702a223acbf 100644 --- a/runtime/kusama/src/weights/pallet_identity.rs +++ b/runtime/kusama/src/weights/pallet_identity.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_identity` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_identity.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,187 +47,207 @@ impl pallet_identity::WeightInfo for WeightInfo { // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn add_registrar(r: u32, ) -> Weight { - (16_146_000 as Weight) - // Standard Error: 2_000 - .saturating_add((164_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 16_040 nanoseconds. + Weight::from_ref_time(17_245_202 as u64) + // Standard Error: 2_979 + .saturating_add(Weight::from_ref_time(153_233 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn set_identity(r: u32, x: u32, ) -> Weight { - (28_556_000 as Weight) - // Standard Error: 7_000 - .saturating_add((208_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 1_000 - .saturating_add((371_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 34_388 nanoseconds. + Weight::from_ref_time(33_517_449 as u64) + // Standard Error: 3_495 + .saturating_add(Weight::from_ref_time(114_197 as u64).saturating_mul(r as u64)) + // Standard Error: 682 + .saturating_add(Weight::from_ref_time(304_413 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity SuperOf (r:1 w:1) - /// The range of component `s` is `[1, 100]`. + // Storage: Identity SuperOf (r:2 w:2) + /// The range of component `s` is `[0, 100]`. fn set_subs_new(s: u32, ) -> Weight { - (25_214_000 as Weight) - // Standard Error: 6_000 - .saturating_add((3_032_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 9_735 nanoseconds. + Weight::from_ref_time(27_554_907 as u64) + // Standard Error: 4_993 + .saturating_add(Weight::from_ref_time(2_147_723 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity SuperOf (r:0 w:1) - /// The range of component `p` is `[1, 100]`. + // Storage: Identity SuperOf (r:0 w:2) + /// The range of component `p` is `[0, 100]`. fn set_subs_old(p: u32, ) -> Weight { - (26_402_000 as Weight) - // Standard Error: 1_000 - .saturating_add((916_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + // Minimum execution time: 9_763 nanoseconds. + Weight::from_ref_time(27_412_160 as u64) + // Standard Error: 4_153 + .saturating_add(Weight::from_ref_time(931_626 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity SuperOf (r:0 w:100) /// The range of component `r` is `[1, 20]`. - /// The range of component `s` is `[1, 100]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `s` is `[0, 100]`. + /// The range of component `x` is `[0, 100]`. fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { - (32_822_000 as Weight) - // Standard Error: 5_000 - .saturating_add((74_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 1_000 - .saturating_add((909_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 1_000 - .saturating_add((166_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 50_615 nanoseconds. + Weight::from_ref_time(35_426_490 as u64) + // Standard Error: 5_633 + .saturating_add(Weight::from_ref_time(102_541 as u64).saturating_mul(r as u64)) + // Standard Error: 1_100 + .saturating_add(Weight::from_ref_time(900_269 as u64).saturating_mul(s as u64)) + // Standard Error: 1_100 + .saturating_add(Weight::from_ref_time(162_883 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn request_judgement(r: u32, x: u32, ) -> Weight { - (30_696_000 as Weight) - // Standard Error: 4_000 - .saturating_add((163_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 0 - .saturating_add((377_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 36_689 nanoseconds. + Weight::from_ref_time(34_440_440 as u64) + // Standard Error: 4_297 + .saturating_add(Weight::from_ref_time(157_407 as u64).saturating_mul(r as u64)) + // Standard Error: 838 + .saturating_add(Weight::from_ref_time(322_563 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn cancel_request(r: u32, x: u32, ) -> Weight { - (28_144_000 as Weight) - // Standard Error: 4_000 - .saturating_add((144_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 0 - .saturating_add((363_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 32_677 nanoseconds. + Weight::from_ref_time(32_904_285 as u64) + // Standard Error: 7_174 + .saturating_add(Weight::from_ref_time(53_862 as u64).saturating_mul(r as u64)) + // Standard Error: 1_399 + .saturating_add(Weight::from_ref_time(326_172 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_fee(r: u32, ) -> Weight { - (7_135_000 as Weight) - // Standard Error: 1_000 - .saturating_add((135_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_883 nanoseconds. + Weight::from_ref_time(9_085_857 as u64) + // Standard Error: 2_860 + .saturating_add(Weight::from_ref_time(116_017 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_account_id(r: u32, ) -> Weight { - (6_861_000 as Weight) - // Standard Error: 1_000 - .saturating_add((140_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_203 nanoseconds. + Weight::from_ref_time(9_318_119 as u64) + // Standard Error: 2_242 + .saturating_add(Weight::from_ref_time(117_787 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_fields(r: u32, ) -> Weight { - (7_143_000 as Weight) - // Standard Error: 1_000 - .saturating_add((133_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_037 nanoseconds. + Weight::from_ref_time(9_045_757 as u64) + // Standard Error: 2_484 + .saturating_add(Weight::from_ref_time(128_923 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 19]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn provide_judgement(r: u32, x: u32, ) -> Weight { - (21_902_000 as Weight) - // Standard Error: 6_000 - .saturating_add((109_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 1_000 - .saturating_add((378_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_988 nanoseconds. + Weight::from_ref_time(27_210_149 as u64) + // Standard Error: 13_954 + .saturating_add(Weight::from_ref_time(60_196 as u64).saturating_mul(r as u64)) + // Standard Error: 2_581 + .saturating_add(Weight::from_ref_time(542_227 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: Identity SuperOf (r:0 w:100) /// The range of component `r` is `[1, 20]`. - /// The range of component `s` is `[1, 100]`. - /// The range of component `x` is `[1, 100]`. - fn kill_identity(_r: u32, s: u32, _x: u32, ) -> Weight { - (48_712_000 as Weight) - // Standard Error: 0 - .saturating_add((903_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + /// The range of component `s` is `[0, 100]`. + /// The range of component `x` is `[0, 100]`. + fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight { + // Minimum execution time: 61_245 nanoseconds. + Weight::from_ref_time(46_208_772 as u64) + // Standard Error: 8_712 + .saturating_add(Weight::from_ref_time(137_988 as u64).saturating_mul(r as u64)) + // Standard Error: 1_701 + .saturating_add(Weight::from_ref_time(901_893 as u64).saturating_mul(s as u64)) + // Standard Error: 1_701 + .saturating_add(Weight::from_ref_time(167_735 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) - /// The range of component `s` is `[1, 99]`. + /// The range of component `s` is `[0, 99]`. fn add_sub(s: u32, ) -> Weight { - (33_860_000 as Weight) - // Standard Error: 0 - .saturating_add((97_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 30_192 nanoseconds. + Weight::from_ref_time(36_327_198 as u64) + // Standard Error: 1_699 + .saturating_add(Weight::from_ref_time(74_349 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn rename_sub(s: u32, ) -> Weight { - (12_063_000 as Weight) - // Standard Error: 0 - .saturating_add((27_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 13_068 nanoseconds. + Weight::from_ref_time(15_455_367 as u64) + // Standard Error: 739 + .saturating_add(Weight::from_ref_time(28_463 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn remove_sub(s: u32, ) -> Weight { - (34_418_000 as Weight) - // Standard Error: 0 - .saturating_add((84_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 34_231 nanoseconds. + Weight::from_ref_time(38_092_727 as u64) + // Standard Error: 1_309 + .saturating_add(Weight::from_ref_time(63_495 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) - /// The range of component `s` is `[1, 99]`. + /// The range of component `s` is `[0, 99]`. fn quit_sub(s: u32, ) -> Weight { - (24_186_000 as Weight) - // Standard Error: 0 - .saturating_add((77_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 23_731 nanoseconds. + Weight::from_ref_time(27_777_697 as u64) + // Standard Error: 1_324 + .saturating_add(Weight::from_ref_time(64_783 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_im_online.rs b/runtime/kusama/src/weights/pallet_im_online.rs index acdffcb50479..40452133a58e 100644 --- a/runtime/kusama/src/weights/pallet_im_online.rs +++ b/runtime/kusama/src/weights/pallet_im_online.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_im_online` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_im_online.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -52,12 +52,13 @@ impl pallet_im_online::WeightInfo for WeightInfo { /// The range of component `k` is `[1, 1000]`. /// The range of component `e` is `[1, 100]`. fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight { - (76_307_000 as Weight) - // Standard Error: 0 - .saturating_add((25_000 as Weight).saturating_mul(k as Weight)) - // Standard Error: 4_000 - .saturating_add((339_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 95_669 nanoseconds. + Weight::from_ref_time(76_845_572 as u64) + // Standard Error: 336 + .saturating_add(Weight::from_ref_time(23_690 as u64).saturating_mul(k as u64)) + // Standard Error: 3_386 + .saturating_add(Weight::from_ref_time(301_052 as u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_indices.rs b/runtime/kusama/src/weights/pallet_indices.rs index 3114e280f863..eebbd8d9062c 100644 --- a/runtime/kusama/src/weights/pallet_indices.rs +++ b/runtime/kusama/src/weights/pallet_indices.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_indices` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_indices.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,34 +46,39 @@ pub struct WeightInfo(PhantomData); impl pallet_indices::WeightInfo for WeightInfo { // Storage: Indices Accounts (r:1 w:1) fn claim() -> Weight { - (23_807_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_874 nanoseconds. + Weight::from_ref_time(25_267_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (27_946_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 31_488 nanoseconds. + Weight::from_ref_time(32_416_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Indices Accounts (r:1 w:1) fn free() -> Weight { - (23_882_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_255 nanoseconds. + Weight::from_ref_time(26_765_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn force_transfer() -> Weight { - (24_029_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 26_642 nanoseconds. + Weight::from_ref_time(27_208_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Indices Accounts (r:1 w:1) fn freeze() -> Weight { - (27_122_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 31_472 nanoseconds. + Weight::from_ref_time(32_156_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_membership.rs b/runtime/kusama/src/weights/pallet_membership.rs index 3115c7cce83d..178470fe3aab 100644 --- a/runtime/kusama/src/weights/pallet_membership.rs +++ b/runtime/kusama/src/weights/pallet_membership.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_membership` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_membership.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,11 +50,12 @@ impl pallet_membership::WeightInfo for WeightInfo { // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 99]`. fn add_member(m: u32, ) -> Weight { - (17_986_000 as Weight) - // Standard Error: 0 - .saturating_add((61_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 19_804 nanoseconds. + Weight::from_ref_time(20_453_376 as u64) + // Standard Error: 437 + .saturating_add(Weight::from_ref_time(35_454 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -63,11 +64,12 @@ impl pallet_membership::WeightInfo for WeightInfo { // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[2, 100]`. fn remove_member(m: u32, ) -> Weight { - (20_684_000 as Weight) - // Standard Error: 0 - .saturating_add((49_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 21_784 nanoseconds. + Weight::from_ref_time(22_823_055 as u64) + // Standard Error: 643 + .saturating_add(Weight::from_ref_time(32_651 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -76,11 +78,12 @@ impl pallet_membership::WeightInfo for WeightInfo { // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[2, 100]`. fn swap_member(m: u32, ) -> Weight { - (20_694_000 as Weight) - // Standard Error: 0 - .saturating_add((61_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 22_019 nanoseconds. + Weight::from_ref_time(23_226_698 as u64) + // Standard Error: 521 + .saturating_add(Weight::from_ref_time(44_518 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -89,11 +92,12 @@ impl pallet_membership::WeightInfo for WeightInfo { // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn reset_member(m: u32, ) -> Weight { - (19_769_000 as Weight) - // Standard Error: 1_000 - .saturating_add((186_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 21_565 nanoseconds. + Weight::from_ref_time(22_510_625 as u64) + // Standard Error: 651 + .saturating_add(Weight::from_ref_time(154_739 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -102,30 +106,33 @@ impl pallet_membership::WeightInfo for WeightInfo { // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn change_key(m: u32, ) -> Weight { - (20_908_000 as Weight) - // Standard Error: 0 - .saturating_add((58_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 22_059 nanoseconds. + Weight::from_ref_time(23_596_851 as u64) + // Standard Error: 634 + .saturating_add(Weight::from_ref_time(44_536 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: TechnicalMembership Members (r:1 w:0) // Storage: TechnicalMembership Prime (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn set_prime(m: u32, ) -> Weight { - (7_054_000 as Weight) - // Standard Error: 0 - .saturating_add((10_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 7_791 nanoseconds. + Weight::from_ref_time(8_349_224 as u64) + // Standard Error: 209 + .saturating_add(Weight::from_ref_time(8_473 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: TechnicalMembership Prime (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn clear_prime(m: u32, ) -> Weight { - (3_942_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 4_290 nanoseconds. + Weight::from_ref_time(4_687_392 as u64) + // Standard Error: 160 + .saturating_add(Weight::from_ref_time(288 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_multisig.rs b/runtime/kusama/src/weights/pallet_multisig.rs index 4b479907c2ed..b034fafcd8cc 100644 --- a/runtime/kusama/src/weights/pallet_multisig.rs +++ b/runtime/kusama/src/weights/pallet_multisig.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_multisig` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 // Executed Command: @@ -28,11 +28,11 @@ // --steps=50 // --repeat=20 // --pallet=pallet_multisig -// --extrinsic=* +// --extrinsic= // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_multisig.rs +// --output=runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,115 +46,81 @@ pub struct WeightInfo(PhantomData); impl pallet_multisig::WeightInfo for WeightInfo { /// The range of component `z` is `[0, 10000]`. fn as_multi_threshold_1(z: u32, ) -> Weight { - (15_530_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) + // Minimum execution time: 14_233 nanoseconds. + Weight::from_ref_time(14_763_390 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(479 as u64).saturating_mul(z as u64)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_create(s: u32, z: u32, ) -> Weight { - (32_158_000 as Weight) - // Standard Error: 0 - .saturating_add((100_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) - /// The range of component `s` is `[2, 100]`. - /// The range of component `z` is `[0, 10000]`. - fn as_multi_create_store(s: u32, z: u32, ) -> Weight { - (35_654_000 as Weight) - // Standard Error: 0 - .saturating_add((103_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 42_837 nanoseconds. + Weight::from_ref_time(34_846_149 as u64) + // Standard Error: 646 + .saturating_add(Weight::from_ref_time(89_482 as u64).saturating_mul(s as u64)) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(1_465 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) /// The range of component `s` is `[3, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_approve(s: u32, z: u32, ) -> Weight { - (21_105_000 as Weight) - // Standard Error: 0 - .saturating_add((100_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 32_269 nanoseconds. + Weight::from_ref_time(25_447_784 as u64) + // Standard Error: 499 + .saturating_add(Weight::from_ref_time(74_525 as u64).saturating_mul(s as u64)) + // Standard Error: 4 + .saturating_add(Weight::from_ref_time(1_457 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - /// The range of component `s` is `[3, 100]`. - /// The range of component `z` is `[0, 10000]`. - fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { - (33_427_000 as Weight) - // Standard Error: 0 - .saturating_add((117_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_complete(s: u32, z: u32, ) -> Weight { - (43_547_000 as Weight) - // Standard Error: 0 - .saturating_add((129_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 46_096 nanoseconds. + Weight::from_ref_time(37_139_587 as u64) + // Standard Error: 602 + .saturating_add(Weight::from_ref_time(104_199 as u64).saturating_mul(s as u64)) + // Standard Error: 5 + .saturating_add(Weight::from_ref_time(1_478 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_create(s: u32, ) -> Weight { - (31_185_000 as Weight) - // Standard Error: 0 - .saturating_add((114_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 31_572 nanoseconds. + Weight::from_ref_time(33_475_485 as u64) + // Standard Error: 972 + .saturating_add(Weight::from_ref_time(91_041 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:0) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_approve(s: u32, ) -> Weight { - (20_549_000 as Weight) - // Standard Error: 1_000 - .saturating_add((107_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - // Storage: System Account (r:1 w:1) - /// The range of component `s` is `[2, 100]`. - fn approve_as_multi_complete(s: u32, ) -> Weight { - (65_686_000 as Weight) - // Standard Error: 1_000 - .saturating_add((130_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 21_861 nanoseconds. + Weight::from_ref_time(23_986_670 as u64) + // Standard Error: 660 + .saturating_add(Weight::from_ref_time(79_765 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) /// The range of component `s` is `[2, 100]`. fn cancel_as_multi(s: u32, ) -> Weight { - (47_339_000 as Weight) - // Standard Error: 0 - .saturating_add((112_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 31_375 nanoseconds. + Weight::from_ref_time(33_657_765 as u64) + // Standard Error: 931 + .saturating_add(Weight::from_ref_time(84_177 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_nomination_pools.rs b/runtime/kusama/src/weights/pallet_nomination_pools.rs index f7c145312ba3..57e4a54f3584 100644 --- a/runtime/kusama/src/weights/pallet_nomination_pools.rs +++ b/runtime/kusama/src/weights/pallet_nomination_pools.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_nomination_pools` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_nomination_pools.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -58,9 +58,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn join() -> Weight { - (125_069_000 as Weight) - .saturating_add(T::DbWeight::get().reads(17 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) + // Minimum execution time: 138_890 nanoseconds. + Weight::from_ref_time(139_862_000 as u64) + .saturating_add(T::DbWeight::get().reads(17 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -72,9 +73,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn bond_extra_transfer() -> Weight { - (120_122_000 as Weight) - .saturating_add(T::DbWeight::get().reads(14 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) + // Minimum execution time: 138_685 nanoseconds. + Weight::from_ref_time(139_666_000 as u64) + .saturating_add(T::DbWeight::get().reads(14 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -86,18 +88,20 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListNodes (r:2 w:2) // Storage: VoterList ListBags (r:2 w:2) fn bond_extra_reward() -> Weight { - (126_951_000 as Weight) - .saturating_add(T::DbWeight::get().reads(13 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) + // Minimum execution time: 138_114 nanoseconds. + Weight::from_ref_time(141_132_000 as u64) + .saturating_add(T::DbWeight::get().reads(13 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) // Storage: NominationPools RewardPools (r:1 w:1) // Storage: System Account (r:1 w:1) fn claim_payout() -> Weight { - (48_376_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 54_174 nanoseconds. + Weight::from_ref_time(54_785_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -114,9 +118,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools SubPoolsStorage (r:1 w:1) // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) fn unbond() -> Weight { - (126_870_000 as Weight) - .saturating_add(T::DbWeight::get().reads(18 as Weight)) - .saturating_add(T::DbWeight::get().writes(13 as Weight)) + // Minimum execution time: 137_752 nanoseconds. + Weight::from_ref_time(139_045_000 as u64) + .saturating_add(T::DbWeight::get().reads(18 as u64)) + .saturating_add(T::DbWeight::get().writes(13 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -124,11 +129,12 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: Balances Locks (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn pool_withdraw_unbonded(s: u32, ) -> Weight { - (40_979_000 as Weight) - // Standard Error: 0 - .saturating_add((31_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 49_665 nanoseconds. + Weight::from_ref_time(51_537_967 as u64) + // Standard Error: 937 + .saturating_add(Weight::from_ref_time(19_269 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -140,11 +146,12 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools CounterForPoolMembers (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - (79_501_000 as Weight) - // Standard Error: 0 - .saturating_add((41_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 89_456 nanoseconds. + Weight::from_ref_time(92_464_998 as u64) + // Standard Error: 1_616 + .saturating_add(Weight::from_ref_time(21_615 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -163,15 +170,15 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools RewardPools (r:1 w:1) // Storage: NominationPools CounterForRewardPools (r:1 w:1) // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) + // Storage: NominationPools Metadata (r:1 w:1) // Storage: NominationPools CounterForBondedPools (r:1 w:1) // Storage: Staking Payee (r:0 w:1) /// The range of component `s` is `[0, 100]`. - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (139_080_000 as Weight) - // Standard Error: 1_000 - .saturating_add((7_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(19 as Weight)) - .saturating_add(T::DbWeight::get().writes(16 as Weight)) + fn withdraw_unbonded_kill(_s: u32, ) -> Weight { + // Minimum execution time: 142_468 nanoseconds. + Weight::from_ref_time(145_865_382 as u64) + .saturating_add(T::DbWeight::get().reads(20 as u64)) + .saturating_add(T::DbWeight::get().writes(17 as u64)) } // Storage: Staking MinNominatorBond (r:1 w:0) // Storage: NominationPools MinCreateBond (r:1 w:0) @@ -187,7 +194,6 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: Staking Ledger (r:1 w:1) // Storage: Staking Bonded (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: NominationPools RewardPools (r:1 w:1) // Storage: NominationPools CounterForRewardPools (r:1 w:1) @@ -196,9 +202,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools BondedPools (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn create() -> Weight { - (131_822_000 as Weight) - .saturating_add(T::DbWeight::get().reads(22 as Weight)) - .saturating_add(T::DbWeight::get().writes(15 as Weight)) + // Minimum execution time: 126_922 nanoseconds. + Weight::from_ref_time(128_840_000 as u64) + .saturating_add(T::DbWeight::get().reads(21 as u64)) + .saturating_add(T::DbWeight::get().writes(15 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -214,30 +221,33 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: Staking CounterForNominators (r:1 w:1) /// The range of component `n` is `[1, 24]`. fn nominate(n: u32, ) -> Weight { - (50_212_000 as Weight) - // Standard Error: 4_000 - .saturating_add((2_152_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 62_487 nanoseconds. + Weight::from_ref_time(62_210_788 as u64) + // Standard Error: 4_540 + .saturating_add(Weight::from_ref_time(995_413 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: NominationPools BondedPools (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) fn set_state() -> Weight { - (25_448_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 34_398 nanoseconds. + Weight::from_ref_time(34_691_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: NominationPools Metadata (r:1 w:1) // Storage: NominationPools CounterForMetadata (r:1 w:1) /// The range of component `n` is `[1, 256]`. fn set_metadata(n: u32, ) -> Weight { - (14_203_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 16_304 nanoseconds. + Weight::from_ref_time(17_385_094 as u64) + // Standard Error: 695 + .saturating_add(Weight::from_ref_time(451 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: NominationPools MinJoinBond (r:0 w:1) // Storage: NominationPools MaxPoolMembers (r:0 w:1) @@ -245,14 +255,16 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools MinCreateBond (r:0 w:1) // Storage: NominationPools MaxPools (r:0 w:1) fn set_configs() -> Weight { - (6_899_000 as Weight) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 7_357 nanoseconds. + Weight::from_ref_time(7_670_000 as u64) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: NominationPools BondedPools (r:1 w:1) fn update_roles() -> Weight { - (21_715_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_355 nanoseconds. + Weight::from_ref_time(26_659_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -263,8 +275,9 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - (49_057_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 60_060 nanoseconds. + Weight::from_ref_time(61_928_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_preimage.rs b/runtime/kusama/src/weights/pallet_preimage.rs index 45f407984e96..ac32acb41730 100644 --- a/runtime/kusama/src/weights/pallet_preimage.rs +++ b/runtime/kusama/src/weights/pallet_preimage.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_preimage` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_preimage.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -44,92 +44,103 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_preimage`. pub struct WeightInfo(PhantomData); impl pallet_preimage::WeightInfo for WeightInfo { - // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) /// The range of component `s` is `[0, 4194304]`. fn note_preimage(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 28_176 nanoseconds. + Weight::from_ref_time(28_451_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_294 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) /// The range of component `s` is `[0, 4194304]`. fn note_requested_preimage(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 19_071 nanoseconds. + Weight::from_ref_time(19_336_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_293 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) /// The range of component `s` is `[0, 4194304]`. fn note_no_deposit_preimage(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 17_392 nanoseconds. + Weight::from_ref_time(17_712_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_294 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_preimage() -> Weight { - (35_236_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 37_996 nanoseconds. + Weight::from_ref_time(39_555_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_no_deposit_preimage() -> Weight { - (23_396_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 27_044 nanoseconds. + Weight::from_ref_time(28_069_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_preimage() -> Weight { - (33_944_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_233 nanoseconds. + Weight::from_ref_time(27_659_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_no_deposit_preimage() -> Weight { - (22_151_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 14_540 nanoseconds. + Weight::from_ref_time(16_040_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_unnoted_preimage() -> Weight { - (16_617_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 16_930 nanoseconds. + Weight::from_ref_time(17_887_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_requested_preimage() -> Weight { - (6_552_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_707 nanoseconds. + Weight::from_ref_time(8_173_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_preimage() -> Weight { - (23_787_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 26_963 nanoseconds. + Weight::from_ref_time(28_167_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_unnoted_preimage() -> Weight { - (16_327_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 7_845 nanoseconds. + Weight::from_ref_time(8_128_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn unrequest_multi_referenced_preimage() -> Weight { - (6_289_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_894 nanoseconds. + Weight::from_ref_time(8_185_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_proxy.rs b/runtime/kusama/src/weights/pallet_proxy.rs index 39e9134d504c..e950db5bce6d 100644 --- a/runtime/kusama/src/weights/pallet_proxy.rs +++ b/runtime/kusama/src/weights/pallet_proxy.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_proxy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_proxy.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,10 +47,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Storage: Proxy Proxies (r:1 w:0) /// The range of component `p` is `[1, 31]`. fn proxy(p: u32, ) -> Weight { - (17_720_000 as Weight) - // Standard Error: 1_000 - .saturating_add((70_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + // Minimum execution time: 19_551 nanoseconds. + Weight::from_ref_time(20_748_848 as u64) + // Standard Error: 1_568 + .saturating_add(Weight::from_ref_time(54_200 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) @@ -58,39 +59,38 @@ impl pallet_proxy::WeightInfo for WeightInfo { /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn proxy_announced(a: u32, p: u32, ) -> Weight { - (33_323_000 as Weight) - // Standard Error: 1_000 - .saturating_add((187_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((49_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 37_257 nanoseconds. + Weight::from_ref_time(37_245_921 as u64) + // Standard Error: 1_877 + .saturating_add(Weight::from_ref_time(116_373 as u64).saturating_mul(a as u64)) + // Standard Error: 1_939 + .saturating_add(Weight::from_ref_time(40_239 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. - fn remove_announcement(a: u32, p: u32, ) -> Weight { - (22_697_000 as Weight) - // Standard Error: 1_000 - .saturating_add((170_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((12_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn remove_announcement(a: u32, _p: u32, ) -> Weight { + // Minimum execution time: 25_864 nanoseconds. + Weight::from_ref_time(26_440_498 as u64) + // Standard Error: 1_682 + .saturating_add(Weight::from_ref_time(114_225 as u64).saturating_mul(a as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. - fn reject_announcement(a: u32, p: u32, ) -> Weight { - (22_575_000 as Weight) - // Standard Error: 1_000 - .saturating_add((177_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((6_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn reject_announcement(a: u32, _p: u32, ) -> Weight { + // Minimum execution time: 25_392 nanoseconds. + Weight::from_ref_time(26_349_515 as u64) + // Standard Error: 1_456 + .saturating_add(Weight::from_ref_time(113_602 as u64).saturating_mul(a as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) @@ -98,58 +98,64 @@ impl pallet_proxy::WeightInfo for WeightInfo { /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn announce(a: u32, p: u32, ) -> Weight { - (30_349_000 as Weight) - // Standard Error: 1_000 - .saturating_add((168_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((41_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 33_187 nanoseconds. + Weight::from_ref_time(34_423_105 as u64) + // Standard Error: 1_973 + .saturating_add(Weight::from_ref_time(104_655 as u64).saturating_mul(a as u64)) + // Standard Error: 2_039 + .saturating_add(Weight::from_ref_time(27_773 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn add_proxy(p: u32, ) -> Weight { - (25_144_000 as Weight) - // Standard Error: 1_000 - .saturating_add((105_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 27_189 nanoseconds. + Weight::from_ref_time(28_582_470 as u64) + // Standard Error: 2_064 + .saturating_add(Weight::from_ref_time(63_883 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn remove_proxy(p: u32, ) -> Weight { - (24_770_000 as Weight) - // Standard Error: 1_000 - .saturating_add((131_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_366 nanoseconds. + Weight::from_ref_time(28_374_822 as u64) + // Standard Error: 2_182 + .saturating_add(Weight::from_ref_time(82_251 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn remove_proxies(p: u32, ) -> Weight { - (20_974_000 as Weight) - // Standard Error: 1_000 - .saturating_add((72_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 22_910 nanoseconds. + Weight::from_ref_time(25_215_950 as u64) + // Standard Error: 3_028 + .saturating_add(Weight::from_ref_time(25_900 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. - fn anonymous(p: u32, ) -> Weight { - (28_658_000 as Weight) - // Standard Error: 1_000 - .saturating_add((30_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn create_pure(p: u32, ) -> Weight { + // Minimum execution time: 30_126 nanoseconds. + Weight::from_ref_time(31_650_457 as u64) + // Standard Error: 1_924 + .saturating_add(Weight::from_ref_time(21_491 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[0, 30]`. - fn kill_anonymous(p: u32, ) -> Weight { - (22_082_000 as Weight) - // Standard Error: 1_000 - .saturating_add((56_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn kill_pure(p: u32, ) -> Weight { + // Minimum execution time: 24_510 nanoseconds. + Weight::from_ref_time(25_823_835 as u64) + // Standard Error: 1_747 + .saturating_add(Weight::from_ref_time(46_717 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_ranked_collective.rs b/runtime/kusama/src/weights/pallet_ranked_collective.rs new file mode 100644 index 000000000000..0f7a13150b82 --- /dev/null +++ b/runtime/kusama/src/weights/pallet_ranked_collective.rs @@ -0,0 +1,120 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_ranked_collective` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_ranked_collective +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_ranked_collective`. +pub struct WeightInfo(PhantomData); +impl pallet_ranked_collective::WeightInfo for WeightInfo { + // Storage: FellowshipCollective Members (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:1) + // Storage: FellowshipCollective IndexToId (r:0 w:1) + // Storage: FellowshipCollective IdToIndex (r:0 w:1) + fn add_member() -> Weight { + // Minimum execution time: 18_900 nanoseconds. + Weight::from_ref_time(19_302_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: FellowshipCollective Members (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:1) + // Storage: FellowshipCollective IdToIndex (r:1 w:1) + // Storage: FellowshipCollective IndexToId (r:1 w:1) + /// The range of component `r` is `[0, 10]`. + fn remove_member(r: u32, ) -> Weight { + // Minimum execution time: 29_913 nanoseconds. + Weight::from_ref_time(32_149_860 as u64) + // Standard Error: 25_258 + .saturating_add(Weight::from_ref_time(9_512_553 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(r as u64))) + } + // Storage: FellowshipCollective Members (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:1) + // Storage: FellowshipCollective IndexToId (r:0 w:1) + // Storage: FellowshipCollective IdToIndex (r:0 w:1) + /// The range of component `r` is `[0, 10]`. + fn promote_member(r: u32, ) -> Weight { + // Minimum execution time: 21_327 nanoseconds. + Weight::from_ref_time(22_411_852 as u64) + // Standard Error: 3_902 + .saturating_add(Weight::from_ref_time(457_216 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: FellowshipCollective Members (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:1) + // Storage: FellowshipCollective IdToIndex (r:1 w:1) + // Storage: FellowshipCollective IndexToId (r:1 w:1) + /// The range of component `r` is `[0, 10]`. + fn demote_member(r: u32, ) -> Weight { + // Minimum execution time: 29_563 nanoseconds. + Weight::from_ref_time(32_287_027 as u64) + // Standard Error: 15_398 + .saturating_add(Weight::from_ref_time(639_177 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: FellowshipCollective Members (r:1 w:0) + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipCollective Voting (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn vote() -> Weight { + // Minimum execution time: 45_461 nanoseconds. + Weight::from_ref_time(46_094_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:0) + // Storage: FellowshipCollective VotingCleanup (r:1 w:0) + // Storage: FellowshipCollective Voting (r:0 w:2) + /// The range of component `n` is `[0, 100]`. + fn cleanup_poll(n: u32, ) -> Weight { + // Minimum execution time: 14_374 nanoseconds. + Weight::from_ref_time(18_663_988 as u64) + // Standard Error: 1_622 + .saturating_add(Weight::from_ref_time(866_964 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(n as u64))) + } +} diff --git a/runtime/kusama/src/weights/pallet_referenda_fellowship_referenda.rs b/runtime/kusama/src/weights/pallet_referenda_fellowship_referenda.rs new file mode 100644 index 000000000000..07f201334a84 --- /dev/null +++ b/runtime/kusama/src/weights/pallet_referenda_fellowship_referenda.rs @@ -0,0 +1,289 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_referenda` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_referenda +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_referenda`. +pub struct WeightInfo(PhantomData); +impl pallet_referenda::WeightInfo for WeightInfo { + // Storage: FellowshipCollective Members (r:1 w:0) + // Storage: FellowshipReferenda ReferendumCount (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + // Storage: FellowshipReferenda ReferendumInfoFor (r:0 w:1) + fn submit() -> Weight { + // Minimum execution time: 32_180 nanoseconds. + Weight::from_ref_time(32_746_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn place_decision_deposit_preparing() -> Weight { + // Minimum execution time: 47_785 nanoseconds. + Weight::from_ref_time(48_489_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipReferenda DecidingCount (r:1 w:0) + // Storage: FellowshipReferenda TrackQueue (r:1 w:1) + fn place_decision_deposit_queued() -> Weight { + // Minimum execution time: 83_684 nanoseconds. + Weight::from_ref_time(87_530_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipReferenda DecidingCount (r:1 w:0) + // Storage: FellowshipReferenda TrackQueue (r:1 w:1) + fn place_decision_deposit_not_queued() -> Weight { + // Minimum execution time: 84_154 nanoseconds. + Weight::from_ref_time(87_244_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipReferenda DecidingCount (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + // Storage: Scheduler Agenda (r:2 w:2) + fn place_decision_deposit_passing() -> Weight { + // Minimum execution time: 185_392 nanoseconds. + Weight::from_ref_time(197_854_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipReferenda DecidingCount (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + fn place_decision_deposit_failing() -> Weight { + // Minimum execution time: 43_545 nanoseconds. + Weight::from_ref_time(44_652_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + fn refund_decision_deposit() -> Weight { + // Minimum execution time: 31_072 nanoseconds. + Weight::from_ref_time(31_477_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn cancel() -> Weight { + // Minimum execution time: 38_167 nanoseconds. + Weight::from_ref_time(38_765_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn kill() -> Weight { + // Minimum execution time: 67_286 nanoseconds. + Weight::from_ref_time(69_089_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: FellowshipReferenda TrackQueue (r:1 w:0) + // Storage: FellowshipReferenda DecidingCount (r:1 w:1) + fn one_fewer_deciding_queue_empty() -> Weight { + // Minimum execution time: 11_019 nanoseconds. + Weight::from_ref_time(11_370_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: FellowshipReferenda TrackQueue (r:1 w:1) + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + // Storage: Scheduler Agenda (r:2 w:2) + fn one_fewer_deciding_failing() -> Weight { + // Minimum execution time: 120_874 nanoseconds. + Weight::from_ref_time(123_568_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: FellowshipReferenda TrackQueue (r:1 w:1) + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + // Storage: Scheduler Agenda (r:2 w:2) + fn one_fewer_deciding_passing() -> Weight { + // Minimum execution time: 121_845 nanoseconds. + Weight::from_ref_time(125_055_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipReferenda TrackQueue (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:0) + fn nudge_referendum_requeued_insertion() -> Weight { + // Minimum execution time: 88_879 nanoseconds. + Weight::from_ref_time(91_415_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipReferenda TrackQueue (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:0) + fn nudge_referendum_requeued_slide() -> Weight { + // Minimum execution time: 87_283 nanoseconds. + Weight::from_ref_time(90_994_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipReferenda DecidingCount (r:1 w:0) + // Storage: FellowshipReferenda TrackQueue (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:0) + fn nudge_referendum_queued() -> Weight { + // Minimum execution time: 91_243 nanoseconds. + Weight::from_ref_time(93_680_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipReferenda DecidingCount (r:1 w:0) + // Storage: FellowshipReferenda TrackQueue (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:0) + fn nudge_referendum_not_queued() -> Weight { + // Minimum execution time: 90_166 nanoseconds. + Weight::from_ref_time(93_331_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_no_deposit() -> Weight { + // Minimum execution time: 29_373 nanoseconds. + Weight::from_ref_time(30_186_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_preparing() -> Weight { + // Minimum execution time: 30_715 nanoseconds. + Weight::from_ref_time(31_405_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + fn nudge_referendum_timed_out() -> Weight { + // Minimum execution time: 22_200 nanoseconds. + Weight::from_ref_time(23_053_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipReferenda DecidingCount (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_begin_deciding_failing() -> Weight { + // Minimum execution time: 41_344 nanoseconds. + Weight::from_ref_time(42_020_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipReferenda DecidingCount (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_begin_deciding_passing() -> Weight { + // Minimum execution time: 86_079 nanoseconds. + Weight::from_ref_time(89_646_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_begin_confirming() -> Weight { + // Minimum execution time: 146_594 nanoseconds. + Weight::from_ref_time(167_523_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_end_confirming() -> Weight { + // Minimum execution time: 163_366 nanoseconds. + Weight::from_ref_time(169_474_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_continue_not_confirming() -> Weight { + // Minimum execution time: 157_952 nanoseconds. + Weight::from_ref_time(163_326_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_continue_confirming() -> Weight { + // Minimum execution time: 81_994 nanoseconds. + Weight::from_ref_time(83_855_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + // Storage: Scheduler Agenda (r:2 w:2) + // Storage: Scheduler Lookup (r:1 w:1) + fn nudge_referendum_approved() -> Weight { + // Minimum execution time: 173_094 nanoseconds. + Weight::from_ref_time(178_850_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: FellowshipReferenda ReferendumInfoFor (r:1 w:1) + // Storage: FellowshipCollective MemberCount (r:1 w:0) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_rejected() -> Weight { + // Minimum execution time: 162_813 nanoseconds. + Weight::from_ref_time(167_908_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } +} diff --git a/runtime/kusama/src/weights/pallet_referenda_referenda.rs b/runtime/kusama/src/weights/pallet_referenda_referenda.rs new file mode 100644 index 000000000000..b74656db71bb --- /dev/null +++ b/runtime/kusama/src/weights/pallet_referenda_referenda.rs @@ -0,0 +1,276 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_referenda` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_referenda +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_referenda`. +pub struct WeightInfo(PhantomData); +impl pallet_referenda::WeightInfo for WeightInfo { + // Storage: Referenda ReferendumCount (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + // Storage: Referenda ReferendumInfoFor (r:0 w:1) + fn submit() -> Weight { + // Minimum execution time: 36_837 nanoseconds. + Weight::from_ref_time(37_648_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn place_decision_deposit_preparing() -> Weight { + // Minimum execution time: 46_630 nanoseconds. + Weight::from_ref_time(47_953_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Referenda DecidingCount (r:1 w:0) + // Storage: Referenda TrackQueue (r:1 w:1) + fn place_decision_deposit_queued() -> Weight { + // Minimum execution time: 48_191 nanoseconds. + Weight::from_ref_time(49_124_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Referenda DecidingCount (r:1 w:0) + // Storage: Referenda TrackQueue (r:1 w:1) + fn place_decision_deposit_not_queued() -> Weight { + // Minimum execution time: 47_992 nanoseconds. + Weight::from_ref_time(48_678_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Referenda DecidingCount (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn place_decision_deposit_passing() -> Weight { + // Minimum execution time: 59_996 nanoseconds. + Weight::from_ref_time(62_060_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Referenda DecidingCount (r:1 w:1) + fn place_decision_deposit_failing() -> Weight { + // Minimum execution time: 42_021 nanoseconds. + Weight::from_ref_time(43_451_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + fn refund_decision_deposit() -> Weight { + // Minimum execution time: 30_016 nanoseconds. + Weight::from_ref_time(30_902_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn cancel() -> Weight { + // Minimum execution time: 37_205 nanoseconds. + Weight::from_ref_time(38_401_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn kill() -> Weight { + // Minimum execution time: 77_049 nanoseconds. + Weight::from_ref_time(79_005_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Referenda TrackQueue (r:1 w:0) + // Storage: Referenda DecidingCount (r:1 w:1) + fn one_fewer_deciding_queue_empty() -> Weight { + // Minimum execution time: 11_084 nanoseconds. + Weight::from_ref_time(11_351_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Referenda TrackQueue (r:1 w:1) + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn one_fewer_deciding_failing() -> Weight { + // Minimum execution time: 77_869 nanoseconds. + Weight::from_ref_time(78_497_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: Referenda TrackQueue (r:1 w:1) + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + fn one_fewer_deciding_passing() -> Weight { + // Minimum execution time: 79_673 nanoseconds. + Weight::from_ref_time(80_484_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Referenda TrackQueue (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:0) + fn nudge_referendum_requeued_insertion() -> Weight { + // Minimum execution time: 54_937 nanoseconds. + Weight::from_ref_time(55_487_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Referenda TrackQueue (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:0) + fn nudge_referendum_requeued_slide() -> Weight { + // Minimum execution time: 54_611 nanoseconds. + Weight::from_ref_time(55_654_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Referenda DecidingCount (r:1 w:0) + // Storage: Referenda TrackQueue (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:0) + fn nudge_referendum_queued() -> Weight { + // Minimum execution time: 56_264 nanoseconds. + Weight::from_ref_time(57_243_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Referenda DecidingCount (r:1 w:0) + // Storage: Referenda TrackQueue (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:0) + fn nudge_referendum_not_queued() -> Weight { + // Minimum execution time: 56_176 nanoseconds. + Weight::from_ref_time(56_931_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_no_deposit() -> Weight { + // Minimum execution time: 28_851 nanoseconds. + Weight::from_ref_time(29_181_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_preparing() -> Weight { + // Minimum execution time: 29_924 nanoseconds. + Weight::from_ref_time(30_481_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + fn nudge_referendum_timed_out() -> Weight { + // Minimum execution time: 21_555 nanoseconds. + Weight::from_ref_time(22_338_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Referenda DecidingCount (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_begin_deciding_failing() -> Weight { + // Minimum execution time: 40_675 nanoseconds. + Weight::from_ref_time(41_190_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Referenda DecidingCount (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_begin_deciding_passing() -> Weight { + // Minimum execution time: 42_598 nanoseconds. + Weight::from_ref_time(43_416_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_begin_confirming() -> Weight { + // Minimum execution time: 38_642 nanoseconds. + Weight::from_ref_time(39_467_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_end_confirming() -> Weight { + // Minimum execution time: 40_249 nanoseconds. + Weight::from_ref_time(41_288_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_continue_not_confirming() -> Weight { + // Minimum execution time: 36_822 nanoseconds. + Weight::from_ref_time(38_169_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_continue_confirming() -> Weight { + // Minimum execution time: 36_981 nanoseconds. + Weight::from_ref_time(37_999_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + // Storage: Scheduler Lookup (r:1 w:1) + fn nudge_referendum_approved() -> Weight { + // Minimum execution time: 48_632 nanoseconds. + Weight::from_ref_time(50_397_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn nudge_referendum_rejected() -> Weight { + // Minimum execution time: 38_784 nanoseconds. + Weight::from_ref_time(39_377_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } +} diff --git a/runtime/kusama/src/weights/pallet_scheduler.rs b/runtime/kusama/src/weights/pallet_scheduler.rs index 975e0714376d..b1bf4322bc1e 100644 --- a/runtime/kusama/src/weights/pallet_scheduler.rs +++ b/runtime/kusama/src/weights/pallet_scheduler.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_scheduler` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_scheduler.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -44,164 +44,97 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_scheduler`. pub struct WeightInfo(PhantomData); impl pallet_scheduler::WeightInfo for WeightInfo { - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic_named_resolved(s: u32, ) -> Weight { - (1_256_000 as Weight) - // Standard Error: 42_000 - .saturating_add((26_925_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(s as Weight))) + // Storage: Scheduler IncompleteSince (r:1 w:1) + fn service_agendas_base() -> Weight { + // Minimum execution time: 4_349 nanoseconds. + Weight::from_ref_time(4_501_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_named_resolved(s: u32, ) -> Weight { - (921_000 as Weight) - // Standard Error: 35_000 - .saturating_add((21_922_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + /// The range of component `s` is `[0, 50]`. + fn service_agenda_base(s: u32, ) -> Weight { + // Minimum execution time: 3_640 nanoseconds. + Weight::from_ref_time(7_035_134 as u64) + // Standard Error: 1_932 + .saturating_add(Weight::from_ref_time(580_489 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic_resolved(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 62_000 - .saturating_add((24_926_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + fn service_task_base() -> Weight { + // Minimum execution time: 9_361 nanoseconds. + Weight::from_ref_time(9_558_000 as u64) } - // Storage: Scheduler Agenda (r:1 w:1) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_resolved(s: u32, ) -> Weight { - (10_674_000 as Weight) - // Standard Error: 31_000 - .saturating_add((20_631_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) + /// The range of component `s` is `[128, 4194304]`. + fn service_task_fetched(s: u32, ) -> Weight { + // Minimum execution time: 19_984 nanoseconds. + Weight::from_ref_time(20_103_000 as u64) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(1_284 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:0) // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_named_aborted(s: u32, ) -> Weight { - (2_607_000 as Weight) - // Standard Error: 20_000 - .saturating_add((10_009_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:0) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_aborted(s: u32, ) -> Weight { - (3_381_000 as Weight) - // Standard Error: 17_000 - .saturating_add((7_945_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn service_task_named() -> Weight { + // Minimum execution time: 10_456 nanoseconds. + Weight::from_ref_time(10_829_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic_named(s: u32, ) -> Weight { - (6_676_000 as Weight) - // Standard Error: 25_000 - .saturating_add((16_966_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) - } - // Storage: Scheduler Agenda (r:2 w:2) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic(s: u32, ) -> Weight { - (8_899_000 as Weight) - // Standard Error: 24_000 - .saturating_add((14_630_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + fn service_task_periodic() -> Weight { + // Minimum execution time: 9_309 nanoseconds. + Weight::from_ref_time(9_674_000 as u64) } - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_named(s: u32, ) -> Weight { - (8_583_000 as Weight) - // Standard Error: 19_000 - .saturating_add((12_228_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + fn execute_dispatch_signed() -> Weight { + // Minimum execution time: 3_707 nanoseconds. + Weight::from_ref_time(3_887_000 as u64) } - // Storage: Scheduler Agenda (r:1 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize(s: u32, ) -> Weight { - (8_544_000 as Weight) - // Standard Error: 19_000 - .saturating_add((11_364_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn execute_dispatch_unsigned() -> Weight { + // Minimum execution time: 3_719 nanoseconds. + Weight::from_ref_time(3_822_000 as u64) } // Storage: Scheduler Agenda (r:1 w:1) - /// The range of component `s` is `[0, 50]`. + /// The range of component `s` is `[0, 49]`. fn schedule(s: u32, ) -> Weight { - (19_060_000 as Weight) - // Standard Error: 1_000 - .saturating_add((46_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 15_995 nanoseconds. + Weight::from_ref_time(21_056_607 as u64) + // Standard Error: 2_901 + .saturating_add(Weight::from_ref_time(610_726 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) /// The range of component `s` is `[1, 50]`. fn cancel(s: u32, ) -> Weight { - (17_694_000 as Weight) - // Standard Error: 7_000 - .saturating_add((2_368_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 19_043 nanoseconds. + Weight::from_ref_time(21_275_923 as u64) + // Standard Error: 2_470 + .saturating_add(Weight::from_ref_time(599_926 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) - /// The range of component `s` is `[0, 50]`. + /// The range of component `s` is `[0, 49]`. fn schedule_named(s: u32, ) -> Weight { - (22_258_000 as Weight) - // Standard Error: 1_000 - .saturating_add((60_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 19_152 nanoseconds. + Weight::from_ref_time(24_767_793 as u64) + // Standard Error: 3_638 + .saturating_add(Weight::from_ref_time(618_722 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) /// The range of component `s` is `[1, 50]`. fn cancel_named(s: u32, ) -> Weight { - (18_882_000 as Weight) - // Standard Error: 7_000 - .saturating_add((2_379_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 20_512 nanoseconds. + Weight::from_ref_time(22_833_394 as u64) + // Standard Error: 2_323 + .saturating_add(Weight::from_ref_time(620_445 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_session.rs b/runtime/kusama/src/weights/pallet_session.rs index 12b68e2de730..2ff4766f160e 100644 --- a/runtime/kusama/src/weights/pallet_session.rs +++ b/runtime/kusama/src/weights/pallet_session.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_session` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_session.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -48,16 +48,18 @@ impl pallet_session::WeightInfo for WeightInfo { // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:6 w:6) fn set_keys() -> Weight { - (44_090_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 49_769 nanoseconds. + Weight::from_ref_time(51_736_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:0 w:6) fn purge_keys() -> Weight { - (27_160_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 37_515 nanoseconds. + Weight::from_ref_time(38_874_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_staking.rs b/runtime/kusama/src/weights/pallet_staking.rs index 12b60e9b29ef..608eedb79262 100644 --- a/runtime/kusama/src/weights/pallet_staking.rs +++ b/runtime/kusama/src/weights/pallet_staking.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_staking.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,13 +47,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn bond() -> Weight { - (39_601_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 43_104 nanoseconds. + Weight::from_ref_time(44_132_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -61,9 +61,10 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn bond_extra() -> Weight { - (69_967_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 79_519 nanoseconds. + Weight::from_ref_time(80_713_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) @@ -75,9 +76,10 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking Bonded (r:1 w:0) // Storage: VoterList ListBags (r:2 w:2) fn unbond() -> Weight { - (78_585_000 as Weight) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + // Minimum execution time: 86_781 nanoseconds. + Weight::from_ref_time(87_699_000 as u64) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -85,11 +87,12 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: System Account (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - (32_006_000 as Weight) - // Standard Error: 0 - .saturating_add((27_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 38_383 nanoseconds. + Weight::from_ref_time(40_391_884 as u64) + // Standard Error: 1_926 + .saturating_add(Weight::from_ref_time(13_869 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -105,10 +108,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Balances Locks (r:1 w:1) // Storage: Staking Payee (r:0 w:1) /// The range of component `s` is `[0, 100]`. - fn withdraw_unbonded_kill(_s: u32, ) -> Weight { - (60_841_000 as Weight) - .saturating_add(T::DbWeight::get().reads(13 as Weight)) - .saturating_add(T::DbWeight::get().writes(11 as Weight)) + fn withdraw_unbonded_kill(s: u32, ) -> Weight { + // Minimum execution time: 72_726 nanoseconds. + Weight::from_ref_time(74_449_922 as u64) + // Standard Error: 1_212 + .saturating_add(Weight::from_ref_time(2_788 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(13 as u64)) + .saturating_add(T::DbWeight::get().writes(11 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinValidatorBond (r:1 w:0) @@ -122,20 +128,22 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList CounterForListNodes (r:1 w:1) // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { - (49_177_000 as Weight) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 58_309 nanoseconds. + Weight::from_ref_time(59_475_000 as u64) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) /// The range of component `k` is `[1, 128]`. fn kick(k: u32, ) -> Weight { - (11_581_000 as Weight) - // Standard Error: 11_000 - .saturating_add((8_835_000 as Weight).saturating_mul(k as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) + // Minimum execution time: 33_254 nanoseconds. + Weight::from_ref_time(29_388_895 as u64) + // Standard Error: 11_549 + .saturating_add(Weight::from_ref_time(6_414_781 as u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(k as u64))) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinNominatorBond (r:1 w:0) @@ -150,12 +158,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking CounterForNominators (r:1 w:1) /// The range of component `n` is `[1, 24]`. fn nominate(n: u32, ) -> Weight { - (52_135_000 as Weight) - // Standard Error: 5_000 - .saturating_add((3_209_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 60_454 nanoseconds. + Weight::from_ref_time(59_639_286 as u64) + // Standard Error: 7_738 + .saturating_add(Weight::from_ref_time(2_394_179 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Validators (r:1 w:0) @@ -165,51 +174,59 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - (46_813_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 56_822 nanoseconds. + Weight::from_ref_time(57_376_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Payee (r:0 w:1) fn set_payee() -> Weight { - (9_568_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 14_896 nanoseconds. + Weight::from_ref_time(15_201_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (16_922_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 22_255 nanoseconds. + Weight::from_ref_time(22_833_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Staking ValidatorCount (r:0 w:1) fn set_validator_count() -> Weight { - (3_455_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_940 nanoseconds. + Weight::from_ref_time(4_374_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking ForceEra (r:0 w:1) fn force_no_eras() -> Weight { - (3_461_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_897 nanoseconds. + Weight::from_ref_time(4_113_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era() -> Weight { - (3_505_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_954 nanoseconds. + Weight::from_ref_time(4_130_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (3_509_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_944 nanoseconds. + Weight::from_ref_time(4_107_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking Invulnerables (r:0 w:1) /// The range of component `v` is `[0, 1000]`. fn set_invulnerables(v: u32, ) -> Weight { - (3_866_000 as Weight) - // Standard Error: 0 - .saturating_add((10_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_262 nanoseconds. + Weight::from_ref_time(4_644_196 as u64) + // Standard Error: 29 + .saturating_add(Weight::from_ref_time(10_165 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking SlashingSpans (r:1 w:0) @@ -226,62 +243,64 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking SpanSlash (r:0 w:2) /// The range of component `s` is `[0, 100]`. fn force_unstake(s: u32, ) -> Weight { - (58_815_000 as Weight) - // Standard Error: 2_000 - .saturating_add((904_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 69_465 nanoseconds. + Weight::from_ref_time(72_255_081 as u64) + // Standard Error: 2_127 + .saturating_add(Weight::from_ref_time(868_173 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Staking UnappliedSlashes (r:1 w:1) /// The range of component `s` is `[1, 1000]`. fn cancel_deferred_slash(s: u32, ) -> Weight { - (3_402_940_000 as Weight) - // Standard Error: 237_000 - .saturating_add((19_758_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 119_457 nanoseconds. + Weight::from_ref_time(1_336_120_543 as u64) + // Standard Error: 87_691 + .saturating_add(Weight::from_ref_time(7_429_607 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Payee (r:2 w:0) - // Storage: System Account (r:2 w:2) - /// The range of component `n` is `[1, 256]`. + // Storage: Staking Payee (r:1 w:0) + // Storage: System Account (r:1 w:1) + /// The range of component `n` is `[0, 256]`. fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (73_127_000 as Weight) - // Standard Error: 22_000 - .saturating_add((26_095_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + // Minimum execution time: 92_948 nanoseconds. + Weight::from_ref_time(130_397_907 as u64) + // Standard Error: 14_923 + .saturating_add(Weight::from_ref_time(19_907_210 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(n as u64))) } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking Ledger (r:2 w:2) + // Storage: Staking Bonded (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Payee (r:2 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Balances Locks (r:2 w:2) - /// The range of component `n` is `[1, 256]`. + // Storage: Staking Payee (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + /// The range of component `n` is `[0, 256]`. fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (80_071_000 as Weight) - // Standard Error: 25_000 - .saturating_add((34_679_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) + // Minimum execution time: 108_497 nanoseconds. + Weight::from_ref_time(162_756_589 as u64) + // Standard Error: 30_079 + .saturating_add(Weight::from_ref_time(27_543_828 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(n as u64))) } // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -291,29 +310,12 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListBags (r:2 w:2) /// The range of component `l` is `[1, 32]`. fn rebond(l: u32, ) -> Weight { - (69_288_000 as Weight) - // Standard Error: 2_000 - .saturating_add((51_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) - } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:1) - // Storage: Staking ErasStakersClipped (r:0 w:2) - // Storage: Staking ErasValidatorPrefs (r:0 w:2) - // Storage: Staking ErasValidatorReward (r:0 w:1) - // Storage: Staking ErasRewardPoints (r:0 w:1) - // Storage: Staking ErasStakers (r:0 w:2) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - /// The range of component `e` is `[1, 100]`. - fn set_history_depth(e: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 83_000 - .saturating_add((21_591_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) + // Minimum execution time: 78_279 nanoseconds. + Weight::from_ref_time(80_070_464 as u64) + // Standard Error: 4_979 + .saturating_add(Weight::from_ref_time(49_821 as u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } // Storage: System Account (r:1 w:1) // Storage: Staking Bonded (r:1 w:1) @@ -330,12 +332,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking SpanSlash (r:0 w:1) /// The range of component `s` is `[1, 100]`. fn reap_stash(s: u32, ) -> Weight { - (64_446_000 as Weight) - // Standard Error: 1_000 - .saturating_add((899_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 77_611 nanoseconds. + Weight::from_ref_time(79_448_315 as u64) + // Standard Error: 2_582 + .saturating_add(Weight::from_ref_time(862_567 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: VoterList CounterForListNodes (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0) @@ -350,25 +353,25 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking ValidatorCount (r:1 w:0) // Storage: Staking MinimumValidatorCount (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasStakersClipped (r:0 w:1) // Storage: Staking ErasValidatorPrefs (r:0 w:1) // Storage: Staking ErasStakers (r:0 w:1) // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) /// The range of component `v` is `[1, 10]`. - /// The range of component `n` is `[1, 100]`. + /// The range of component `n` is `[0, 100]`. fn new_era(v: u32, n: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_296_000 - .saturating_add((286_045_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 125_000 - .saturating_add((37_667_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(192 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + // Minimum execution time: 441_741 nanoseconds. + Weight::from_ref_time(444_325_000 as u64) + // Standard Error: 1_735_478 + .saturating_add(Weight::from_ref_time(58_700_922 as u64).saturating_mul(v as u64)) + // Standard Error: 172_930 + .saturating_add(Weight::from_ref_time(12_724_841 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(191 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().reads((4 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(v as u64))) } // Storage: VoterList CounterForListNodes (r:1 w:0) // Storage: Staking SlashingSpans (r:21 w:0) @@ -383,29 +386,30 @@ impl pallet_staking::WeightInfo for WeightInfo { /// The range of component `n` is `[500, 1000]`. /// The range of component `s` is `[1, 20]`. fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 108_000 - .saturating_add((24_629_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 108_000 - .saturating_add((22_598_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 2_778_000 - .saturating_add((59_951_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(186 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_700_092 nanoseconds. + Weight::from_ref_time(25_792_272_000 as u64) + // Standard Error: 477_913 + .saturating_add(Weight::from_ref_time(11_545_647 as u64).saturating_mul(v as u64)) + // Standard Error: 477_913 + .saturating_add(Weight::from_ref_time(11_116_420 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(186 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().reads((4 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } + // Storage: Staking CounterForValidators (r:1 w:0) // Storage: Staking Validators (r:501 w:0) // Storage: System BlockWeight (r:1 w:1) /// The range of component `v` is `[500, 1000]`. fn get_npos_targets(v: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 40_000 - .saturating_add((7_752_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_338_127 nanoseconds. + Weight::from_ref_time(3_386_919_000 as u64) + // Standard Error: 39_447 + .saturating_add(Weight::from_ref_time(2_627_920 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking MinCommission (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) @@ -414,8 +418,9 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_set() -> Weight { - (6_388_000 as Weight) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 7_335 nanoseconds. + Weight::from_ref_time(7_692_000 as u64) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking MinCommission (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) @@ -424,8 +429,9 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_remove() -> Weight { - (6_064_000 as Weight) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 6_297 nanoseconds. + Weight::from_ref_time(6_555_000 as u64) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) @@ -438,15 +444,17 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill_other() -> Weight { - (55_742_000 as Weight) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 65_691 nanoseconds. + Weight::from_ref_time(66_805_000 as u64) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking MinCommission (r:1 w:0) // Storage: Staking Validators (r:1 w:1) fn force_apply_min_commission() -> Weight { - (10_749_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 14_328 nanoseconds. + Weight::from_ref_time(14_698_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_timestamp.rs b/runtime/kusama/src/weights/pallet_timestamp.rs index 28cf1a976ebf..a8fec2a86353 100644 --- a/runtime/kusama/src/weights/pallet_timestamp.rs +++ b/runtime/kusama/src/weights/pallet_timestamp.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_timestamp.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,11 +47,13 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Storage: Timestamp Now (r:1 w:1) // Storage: Babe CurrentSlot (r:1 w:0) fn set() -> Weight { - (7_545_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 9_131 nanoseconds. + Weight::from_ref_time(9_364_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } fn on_finalize() -> Weight { - (2_089_000 as Weight) + // Minimum execution time: 3_891 nanoseconds. + Weight::from_ref_time(4_039_000 as u64) } } diff --git a/runtime/kusama/src/weights/pallet_tips.rs b/runtime/kusama/src/weights/pallet_tips.rs index c62f354d989f..76a83f8d482c 100644 --- a/runtime/kusama/src/weights/pallet_tips.rs +++ b/runtime/kusama/src/weights/pallet_tips.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_tips` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_tips.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -48,18 +48,20 @@ impl pallet_tips::WeightInfo for WeightInfo { // Storage: Tips Tips (r:1 w:1) /// The range of component `r` is `[0, 16384]`. fn report_awesome(r: u32, ) -> Weight { - (28_045_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 28_001 nanoseconds. + Weight::from_ref_time(29_838_155 as u64) + // Standard Error: 5 + .saturating_add(Weight::from_ref_time(1_786 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn retract_tip() -> Weight { - (26_017_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 28_123 nanoseconds. + Weight::from_ref_time(28_778_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Members (r:1 w:0) // Storage: Tips Reasons (r:1 w:1) @@ -67,23 +69,25 @@ impl pallet_tips::WeightInfo for WeightInfo { /// The range of component `r` is `[0, 16384]`. /// The range of component `t` is `[1, 19]`. fn tip_new(r: u32, t: u32, ) -> Weight { - (19_125_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 2_000 - .saturating_add((41_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 21_821 nanoseconds. + Weight::from_ref_time(18_615_217 as u64) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(1_707 as u64).saturating_mul(r as u64)) + // Standard Error: 5_686 + .saturating_add(Weight::from_ref_time(246_831 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Members (r:1 w:0) // Storage: Tips Tips (r:1 w:1) /// The range of component `t` is `[1, 19]`. fn tip(t: u32, ) -> Weight { - (10_895_000 as Weight) - // Standard Error: 1_000 - .saturating_add((158_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 14_824 nanoseconds. + Weight::from_ref_time(15_649_583 as u64) + // Standard Error: 2_623 + .saturating_add(Weight::from_ref_time(79_250 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Tips Tips (r:1 w:1) // Storage: PhragmenElection Members (r:1 w:0) @@ -91,20 +95,22 @@ impl pallet_tips::WeightInfo for WeightInfo { // Storage: Tips Reasons (r:0 w:1) /// The range of component `t` is `[1, 19]`. fn close_tip(t: u32, ) -> Weight { - (42_301_000 as Weight) - // Standard Error: 4_000 - .saturating_add((154_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 43_497 nanoseconds. + Weight::from_ref_time(45_852_110 as u64) + // Standard Error: 9_116 + .saturating_add(Weight::from_ref_time(107_417 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) /// The range of component `t` is `[1, 19]`. fn slash_tip(t: u32, ) -> Weight { - (16_548_000 as Weight) - // Standard Error: 1_000 - .saturating_add((21_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 18_025 nanoseconds. + Weight::from_ref_time(18_866_498 as u64) + // Standard Error: 1_476 + .saturating_add(Weight::from_ref_time(49_648 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_treasury.rs b/runtime/kusama/src/weights/pallet_treasury.rs index 807d581545fc..a64f02def78e 100644 --- a/runtime/kusama/src/weights/pallet_treasury.rs +++ b/runtime/kusama/src/weights/pallet_treasury.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_treasury` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_treasury.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -44,38 +44,48 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_treasury`. pub struct WeightInfo(PhantomData); impl pallet_treasury::WeightInfo for WeightInfo { + // Storage: Treasury ProposalCount (r:1 w:1) + // Storage: Treasury Approvals (r:1 w:1) + // Storage: Treasury Proposals (r:0 w:1) fn spend() -> Weight { - (153_000 as Weight) + // Minimum execution time: 18_027 nanoseconds. + Weight::from_ref_time(18_673_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Treasury ProposalCount (r:1 w:1) // Storage: Treasury Proposals (r:0 w:1) fn propose_spend() -> Weight { - (25_149_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 26_125 nanoseconds. + Weight::from_ref_time(26_944_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Treasury Proposals (r:1 w:1) // Storage: System Account (r:1 w:1) fn reject_proposal() -> Weight { - (35_748_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 36_779 nanoseconds. + Weight::from_ref_time(37_555_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Treasury Proposals (r:1 w:0) // Storage: Treasury Approvals (r:1 w:1) /// The range of component `p` is `[0, 99]`. fn approve_proposal(p: u32, ) -> Weight { - (10_082_000 as Weight) - // Standard Error: 0 - .saturating_add((36_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 9_601 nanoseconds. + Weight::from_ref_time(12_969_695 as u64) + // Standard Error: 1_086 + .saturating_add(Weight::from_ref_time(48_117 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Treasury Approvals (r:1 w:1) fn remove_approval() -> Weight { - (5_612_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_382 nanoseconds. + Weight::from_ref_time(7_715_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Treasury Approvals (r:1 w:1) // Storage: Bounties BountyApprovals (r:1 w:1) @@ -83,12 +93,13 @@ impl pallet_treasury::WeightInfo for WeightInfo { // Storage: Treasury Proposals (r:2 w:2) /// The range of component `p` is `[0, 100]`. fn on_initialize_proposals(p: u32, ) -> Weight { - (36_270_000 as Weight) - // Standard Error: 32_000 - .saturating_add((30_142_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(p as Weight))) + // Minimum execution time: 48_096 nanoseconds. + Weight::from_ref_time(53_729_903 as u64) + // Standard Error: 26_120 + .saturating_add(Weight::from_ref_time(24_134_288 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(p as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(p as u64))) } } diff --git a/runtime/kusama/src/weights/pallet_utility.rs b/runtime/kusama/src/weights/pallet_utility.rs index 711fec6b9dd3..639c99640f60 100644 --- a/runtime/kusama/src/weights/pallet_utility.rs +++ b/runtime/kusama/src/weights/pallet_utility.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_utility.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,26 +46,31 @@ pub struct WeightInfo(PhantomData); impl pallet_utility::WeightInfo for WeightInfo { /// The range of component `c` is `[0, 1000]`. fn batch(c: u32, ) -> Weight { - (12_531_000 as Weight) - // Standard Error: 3_000 - .saturating_add((4_931_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 11_138 nanoseconds. + Weight::from_ref_time(15_220_146 as u64) + // Standard Error: 2_737 + .saturating_add(Weight::from_ref_time(3_434_990 as u64).saturating_mul(c as u64)) } fn as_derivative() -> Weight { - (5_661_000 as Weight) + // Minimum execution time: 5_429 nanoseconds. + Weight::from_ref_time(5_578_000 as u64) } /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32, ) -> Weight { - (14_076_000 as Weight) - // Standard Error: 3_000 - .saturating_add((5_323_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 11_082 nanoseconds. + Weight::from_ref_time(20_839_520 as u64) + // Standard Error: 2_688 + .saturating_add(Weight::from_ref_time(3_559_955 as u64).saturating_mul(c as u64)) } fn dispatch_as() -> Weight { - (13_176_000 as Weight) + // Minimum execution time: 13_275 nanoseconds. + Weight::from_ref_time(13_601_000 as u64) } /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32, ) -> Weight { - (20_747_000 as Weight) - // Standard Error: 3_000 - .saturating_add((4_917_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 11_090 nanoseconds. + Weight::from_ref_time(14_265_371 as u64) + // Standard Error: 2_953 + .saturating_add(Weight::from_ref_time(3_419_726 as u64).saturating_mul(c as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_vesting.rs b/runtime/kusama/src/weights/pallet_vesting.rs index 67cfbf7483d2..b447032df4a7 100644 --- a/runtime/kusama/src/weights/pallet_vesting.rs +++ b/runtime/kusama/src/weights/pallet_vesting.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `pallet_vesting` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/pallet_vesting.rs +// --output=./runtime/kusama/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -49,26 +49,28 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_locked(l: u32, s: u32, ) -> Weight { - (29_030_000 as Weight) - // Standard Error: 0 - .saturating_add((75_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((162_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 36_840 nanoseconds. + Weight::from_ref_time(36_369_202 as u64) + // Standard Error: 1_658 + .saturating_add(Weight::from_ref_time(44_590 as u64).saturating_mul(l as u64)) + // Standard Error: 2_951 + .saturating_add(Weight::from_ref_time(63_226 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_unlocked(l: u32, s: u32, ) -> Weight { - (29_535_000 as Weight) - // Standard Error: 1_000 - .saturating_add((69_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 2_000 - .saturating_add((113_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 36_868 nanoseconds. + Weight::from_ref_time(36_145_466 as u64) + // Standard Error: 1_169 + .saturating_add(Weight::from_ref_time(35_637 as u64).saturating_mul(l as u64)) + // Standard Error: 2_080 + .saturating_add(Weight::from_ref_time(55_928 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -76,13 +78,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_other_locked(l: u32, s: u32, ) -> Weight { - (29_237_000 as Weight) - // Standard Error: 0 - .saturating_add((75_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((160_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 36_351 nanoseconds. + Weight::from_ref_time(35_746_232 as u64) + // Standard Error: 1_101 + .saturating_add(Weight::from_ref_time(45_710 as u64).saturating_mul(l as u64)) + // Standard Error: 1_959 + .saturating_add(Weight::from_ref_time(75_325 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -90,13 +93,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_other_unlocked(l: u32, s: u32, ) -> Weight { - (29_750_000 as Weight) - // Standard Error: 3_000 - .saturating_add((84_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 5_000 - .saturating_add((109_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 36_232 nanoseconds. + Weight::from_ref_time(36_409_437 as u64) + // Standard Error: 1_344 + .saturating_add(Weight::from_ref_time(22_680 as u64).saturating_mul(l as u64)) + // Standard Error: 2_391 + .saturating_add(Weight::from_ref_time(53_105 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -104,13 +108,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. fn vested_transfer(l: u32, s: u32, ) -> Weight { - (44_092_000 as Weight) - // Standard Error: 2_000 - .saturating_add((71_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 4_000 - .saturating_add((134_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 50_119 nanoseconds. + Weight::from_ref_time(50_184_800 as u64) + // Standard Error: 2_011 + .saturating_add(Weight::from_ref_time(39_460 as u64).saturating_mul(l as u64)) + // Standard Error: 3_579 + .saturating_add(Weight::from_ref_time(51_047 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:2 w:2) @@ -118,13 +123,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. fn force_vested_transfer(l: u32, s: u32, ) -> Weight { - (44_003_000 as Weight) - // Standard Error: 2_000 - .saturating_add((72_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 4_000 - .saturating_add((119_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 49_510 nanoseconds. + Weight::from_ref_time(49_839_835 as u64) + // Standard Error: 1_678 + .saturating_add(Weight::from_ref_time(39_770 as u64).saturating_mul(l as u64)) + // Standard Error: 2_985 + .saturating_add(Weight::from_ref_time(33_950 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -132,13 +138,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - (29_853_000 as Weight) - // Standard Error: 0 - .saturating_add((77_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((153_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 38_167 nanoseconds. + Weight::from_ref_time(37_606_228 as u64) + // Standard Error: 1_669 + .saturating_add(Weight::from_ref_time(47_567 as u64).saturating_mul(l as u64)) + // Standard Error: 3_083 + .saturating_add(Weight::from_ref_time(48_620 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -146,12 +153,13 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - (29_466_000 as Weight) - // Standard Error: 0 - .saturating_add((81_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((158_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 37_719 nanoseconds. + Weight::from_ref_time(36_893_012 as u64) + // Standard Error: 886 + .saturating_add(Weight::from_ref_time(45_584 as u64).saturating_mul(l as u64)) + // Standard Error: 1_636 + .saturating_add(Weight::from_ref_time(71_780 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/kusama/src/weights/pallet_whitelist.rs b/runtime/kusama/src/weights/pallet_whitelist.rs new file mode 100644 index 000000000000..1d46a0cf278d --- /dev/null +++ b/runtime/kusama/src/weights/pallet_whitelist.rs @@ -0,0 +1,83 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_whitelist` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_whitelist +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_whitelist`. +pub struct WeightInfo(PhantomData); +impl pallet_whitelist::WeightInfo for WeightInfo { + // Storage: Whitelist WhitelistedCall (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + fn whitelist_call() -> Weight { + // Minimum execution time: 21_348 nanoseconds. + Weight::from_ref_time(21_955_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Whitelist WhitelistedCall (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + fn remove_whitelisted_call() -> Weight { + // Minimum execution time: 20_057 nanoseconds. + Weight::from_ref_time(20_459_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Whitelist WhitelistedCall (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:1 w:1) + fn dispatch_whitelisted_call() -> Weight { + // Minimum execution time: 5_241_064 nanoseconds. + Weight::from_ref_time(5_341_341_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Whitelist WhitelistedCall (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + /// The range of component `n` is `[1, 10000]`. + fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight { + // Minimum execution time: 23_639 nanoseconds. + Weight::from_ref_time(24_381_717 as u64) + // Standard Error: 4 + .saturating_add(Weight::from_ref_time(1_552 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } +} diff --git a/runtime/kusama/src/weights/runtime_common_auctions.rs b/runtime/kusama/src/weights/runtime_common_auctions.rs index 6813cefeec87..ce19ebe29b85 100644 --- a/runtime/kusama/src/weights/runtime_common_auctions.rs +++ b/runtime/kusama/src/weights/runtime_common_auctions.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_common::auctions` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -47,9 +47,10 @@ impl runtime_common::auctions::WeightInfo for WeightInf // Storage: Auctions AuctionInfo (r:1 w:1) // Storage: Auctions AuctionCounter (r:1 w:1) fn new_auction() -> Weight { - (16_252_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 16_030 nanoseconds. + Weight::from_ref_time(16_442_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Paras ParaLifecycles (r:1 w:0) // Storage: Auctions AuctionCounter (r:1 w:0) @@ -59,9 +60,10 @@ impl runtime_common::auctions::WeightInfo for WeightInf // Storage: Auctions ReservedAmounts (r:2 w:2) // Storage: System Account (r:1 w:1) fn bid() -> Weight { - (71_286_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 70_405 nanoseconds. + Weight::from_ref_time(71_429_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Auctions AuctionInfo (r:1 w:1) // Storage: Babe NextRandomness (r:1 w:0) @@ -76,17 +78,19 @@ impl runtime_common::auctions::WeightInfo for WeightInf // Storage: Paras ActionsQueue (r:1 w:1) // Storage: Registrar Paras (r:1 w:1) fn on_initialize() -> Weight { - (15_586_491_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3688 as Weight)) - .saturating_add(T::DbWeight::get().writes(3683 as Weight)) + // Minimum execution time: 14_537_408 nanoseconds. + Weight::from_ref_time(14_840_472_000 as u64) + .saturating_add(T::DbWeight::get().reads(3688 as u64)) + .saturating_add(T::DbWeight::get().writes(3683 as u64)) } // Storage: Auctions ReservedAmounts (r:37 w:36) // Storage: System Account (r:36 w:36) // Storage: Auctions Winning (r:0 w:3600) // Storage: Auctions AuctionInfo (r:0 w:1) fn cancel_auction() -> Weight { - (4_628_531_000 as Weight) - .saturating_add(T::DbWeight::get().reads(73 as Weight)) - .saturating_add(T::DbWeight::get().writes(3673 as Weight)) + // Minimum execution time: 4_592_707 nanoseconds. + Weight::from_ref_time(4_691_301_000 as u64) + .saturating_add(T::DbWeight::get().reads(73 as u64)) + .saturating_add(T::DbWeight::get().writes(3673 as u64)) } } diff --git a/runtime/kusama/src/weights/runtime_common_claims.rs b/runtime/kusama/src/weights/runtime_common_claims.rs index ad6409bbcdd7..b1b8fc140d7e 100644 --- a/runtime/kusama/src/weights/runtime_common_claims.rs +++ b/runtime/kusama/src/weights/runtime_common_claims.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_common::claims` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -52,18 +52,20 @@ impl runtime_common::claims::WeightInfo for WeightInfo< // Storage: System Account (r:1 w:0) // Storage: Balances Locks (r:1 w:1) fn claim() -> Weight { - (139_399_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 142_908 nanoseconds. + Weight::from_ref_time(144_759_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Claims Total (r:1 w:1) // Storage: Claims Vesting (r:0 w:1) // Storage: Claims Claims (r:0 w:1) // Storage: Claims Signing (r:0 w:1) fn mint_claim() -> Weight { - (9_284_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 11_398 nanoseconds. + Weight::from_ref_time(11_589_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Claims Claims (r:1 w:1) // Storage: Claims Signing (r:1 w:1) @@ -73,9 +75,10 @@ impl runtime_common::claims::WeightInfo for WeightInfo< // Storage: System Account (r:1 w:0) // Storage: Balances Locks (r:1 w:1) fn claim_attest() -> Weight { - (143_329_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 145_042 nanoseconds. + Weight::from_ref_time(147_273_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Claims Preclaims (r:1 w:1) // Storage: Claims Signing (r:1 w:1) @@ -86,17 +89,19 @@ impl runtime_common::claims::WeightInfo for WeightInfo< // Storage: System Account (r:1 w:0) // Storage: Balances Locks (r:1 w:1) fn attest() -> Weight { - (63_456_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 66_318 nanoseconds. + Weight::from_ref_time(67_665_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Claims Claims (r:1 w:2) // Storage: Claims Vesting (r:1 w:2) // Storage: Claims Signing (r:1 w:2) // Storage: Claims Preclaims (r:1 w:1) fn move_claim() -> Weight { - (19_434_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 21_013 nanoseconds. + Weight::from_ref_time(21_745_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } } diff --git a/runtime/kusama/src/weights/runtime_common_crowdloan.rs b/runtime/kusama/src/weights/runtime_common_crowdloan.rs index 2859bff57469..6ccff4eeb214 100644 --- a/runtime/kusama/src/weights/runtime_common_crowdloan.rs +++ b/runtime/kusama/src/weights/runtime_common_crowdloan.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_common::crowdloan` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -49,9 +49,10 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: Paras ParaLifecycles (r:1 w:0) // Storage: Crowdloan NextFundIndex (r:1 w:1) fn create() -> Weight { - (43_109_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 45_380 nanoseconds. + Weight::from_ref_time(47_704_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: Slots Leases (r:1 w:0) @@ -61,55 +62,62 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: Crowdloan NewRaise (r:1 w:1) // Storage: unknown [0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291] (r:1 w:1) fn contribute() -> Weight { - (113_745_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 114_903 nanoseconds. + Weight::from_ref_time(116_612_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: System Account (r:2 w:2) // Storage: unknown [0xc85982571aa615c788ef9b2c16f54f25773fd439e8ee1ed2aa3ae43d48e880f0] (r:1 w:1) fn withdraw() -> Weight { - (51_061_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 53_804 nanoseconds. + Weight::from_ref_time(54_387_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `k` is `[0, 1000]`. fn refund(k: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 17_000 - .saturating_add((19_652_000 as Weight).saturating_mul(k as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(k as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(k as Weight))) + // Minimum execution time: 47_160 nanoseconds. + Weight::from_ref_time(62_090_000 as u64) + // Standard Error: 13_181 + .saturating_add(Weight::from_ref_time(17_394_035 as u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(k as u64))) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: System Account (r:1 w:1) fn dissolve() -> Weight { - (32_094_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 35_082 nanoseconds. + Weight::from_ref_time(35_672_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) fn edit() -> Weight { - (21_360_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 23_638 nanoseconds. + Weight::from_ref_time(24_680_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Funds (r:1 w:0) // Storage: unknown [0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291] (r:1 w:1) fn add_memo() -> Weight { - (27_303_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 31_235 nanoseconds. + Weight::from_ref_time(32_150_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Funds (r:1 w:0) // Storage: Crowdloan NewRaise (r:1 w:1) fn poke() -> Weight { - (22_441_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_980 nanoseconds. + Weight::from_ref_time(26_297_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Auctions AuctionInfo (r:1 w:0) // Storage: Crowdloan EndingsCount (r:1 w:1) @@ -123,12 +131,13 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: System Account (r:2 w:2) /// The range of component `n` is `[2, 100]`. fn on_initialize(n: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 43_000 - .saturating_add((51_696_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(n as Weight))) + // Minimum execution time: 101_764 nanoseconds. + Weight::from_ref_time(14_626_691 as u64) + // Standard Error: 39_547 + .saturating_add(Weight::from_ref_time(39_618_827 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(n as u64))) } } diff --git a/runtime/kusama/src/weights/runtime_common_paras_registrar.rs b/runtime/kusama/src/weights/runtime_common_paras_registrar.rs index a4aae658ce72..371d40009737 100644 --- a/runtime/kusama/src/weights/runtime_common_paras_registrar.rs +++ b/runtime/kusama/src/weights/runtime_common_paras_registrar.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_common::paras_registrar` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -48,9 +48,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:0) fn reserve() -> Weight { - (28_294_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 30_030 nanoseconds. + Weight::from_ref_time(30_491_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -62,9 +63,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras CurrentCodeHash (r:0 w:1) // Storage: Paras UpcomingParasGenesis (r:0 w:1) fn register() -> Weight { - (8_981_293_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 7_287_004 nanoseconds. + Weight::from_ref_time(7_413_198_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -76,9 +78,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras CurrentCodeHash (r:0 w:1) // Storage: Paras UpcomingParasGenesis (r:0 w:1) fn force_register() -> Weight { - (8_918_597_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 7_287_206 nanoseconds. + Weight::from_ref_time(7_394_740_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -87,9 +90,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras ActionsQueue (r:1 w:1) // Storage: Registrar PendingSwap (r:0 w:1) fn deregister() -> Weight { - (42_792_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 47_643 nanoseconds. + Weight::from_ref_time(48_704_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Registrar Paras (r:1 w:0) // Storage: Paras ParaLifecycles (r:2 w:2) @@ -99,8 +103,37 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Crowdloan Funds (r:2 w:2) // Storage: Slots Leases (r:2 w:2) fn swap() -> Weight { - (36_942_000 as Weight) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + // Minimum execution time: 42_640 nanoseconds. + Weight::from_ref_time(44_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) + } + // Storage: Paras FutureCodeHash (r:1 w:1) + // Storage: Paras UpgradeRestrictionSignal (r:1 w:1) + // Storage: Paras CurrentCodeHash (r:1 w:0) + // Storage: Paras UpgradeCooldowns (r:1 w:1) + // Storage: Paras PvfActiveVoteMap (r:1 w:0) + // Storage: Paras CodeByHash (r:1 w:1) + // Storage: Paras UpcomingUpgrades (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras FutureCodeUpgrades (r:0 w:1) + /// The range of component `b` is `[1, 3145728]`. + fn schedule_code_upgrade(b: u32, ) -> Weight { + // Minimum execution time: 41_757 nanoseconds. + Weight::from_ref_time(42_119_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_290 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) + } + // Storage: Paras Heads (r:0 w:1) + /// The range of component `b` is `[1, 1048576]`. + fn set_current_head(b: u32, ) -> Weight { + // Minimum execution time: 12_623 nanoseconds. + Weight::from_ref_time(12_795_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(909 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/runtime_common_slots.rs b/runtime/kusama/src/weights/runtime_common_slots.rs index d13a1e46dded..e085ebc165eb 100644 --- a/runtime/kusama/src/weights/runtime_common_slots.rs +++ b/runtime/kusama/src/weights/runtime_common_slots.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_common::slots` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -47,9 +47,10 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (28_926_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 30_486 nanoseconds. + Weight::from_ref_time(31_175_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Paras Parachains (r:1 w:0) // Storage: Slots Leases (r:101 w:100) @@ -60,24 +61,26 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (0 as Weight) - // Standard Error: 30_000 - .saturating_add((6_882_000 as Weight).saturating_mul(c as Weight)) - // Standard Error: 30_000 - .saturating_add((17_866_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(t as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(t as Weight))) + // Minimum execution time: 546_918 nanoseconds. + Weight::from_ref_time(550_885_000 as u64) + // Standard Error: 71_051 + .saturating_add(Weight::from_ref_time(2_051_562 as u64).saturating_mul(c as u64)) + // Standard Error: 71_051 + .saturating_add(Weight::from_ref_time(11_603_107 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(t as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(t as u64))) } // Storage: Slots Leases (r:1 w:1) // Storage: System Account (r:8 w:8) fn clear_all_leases() -> Weight { - (92_846_000 as Weight) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(9 as Weight)) + // Minimum execution time: 89_987 nanoseconds. + Weight::from_ref_time(91_954_000 as u64) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: Slots Leases (r:1 w:0) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -85,8 +88,9 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (21_081_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 28_117 nanoseconds. + Weight::from_ref_time(29_284_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/kusama/src/weights/runtime_parachains_configuration.rs b/runtime/kusama/src/weights/runtime_parachains_configuration.rs index c524e820a4bb..d8ca6f3c3700 100644 --- a/runtime/kusama/src/weights/runtime_parachains_configuration.rs +++ b/runtime/kusama/src/weights/runtime_parachains_configuration.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_parachains::configuration` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -48,44 +48,50 @@ impl runtime_parachains::configuration::WeightInfo for // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_block_number() -> Weight { - (9_052_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 11_808 nanoseconds. + Weight::from_ref_time(12_113_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_u32() -> Weight { - (9_242_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 11_818 nanoseconds. + Weight::from_ref_time(12_074_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_option_u32() -> Weight { - (9_372_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 11_703 nanoseconds. + Weight::from_ref_time(11_940_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_weight() -> Weight { - (9_436_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 11_865 nanoseconds. + Weight::from_ref_time(12_334_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Benchmark Override (r:0 w:0) fn set_hrmp_open_request_ttl() -> Weight { - (2_000_000_000_000 as Weight) + // Minimum execution time: 2_000_000_000 nanoseconds. + Weight::from_ref_time(2_000_000_000_000 as u64) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_balance() -> Weight { - (9_373_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 11_715 nanoseconds. + Weight::from_ref_time(11_895_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/runtime_parachains_disputes.rs b/runtime/kusama/src/weights/runtime_parachains_disputes.rs index b509bc42ea65..e5dac5d6b05f 100644 --- a/runtime/kusama/src/weights/runtime_parachains_disputes.rs +++ b/runtime/kusama/src/weights/runtime_parachains_disputes.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_parachains::disputes` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -46,7 +46,8 @@ pub struct WeightInfo(PhantomData); impl runtime_parachains::disputes::WeightInfo for WeightInfo { // Storage: ParasDisputes Frozen (r:0 w:1) fn force_unfreeze() -> Weight { - (3_180_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_802 nanoseconds. + Weight::from_ref_time(3_998_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/runtime_parachains_hrmp.rs b/runtime/kusama/src/weights/runtime_parachains_hrmp.rs index d079f0eee336..45d9835bef9d 100644 --- a/runtime/kusama/src/weights/runtime_parachains_hrmp.rs +++ b/runtime/kusama/src/weights/runtime_parachains_hrmp.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_parachains::hrmp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -53,9 +53,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_init_open_channel() -> Weight { - (38_011_000 as Weight) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 40_635 nanoseconds. + Weight::from_ref_time(41_119_000 as u64) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:0) @@ -64,9 +65,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_accept_open_channel() -> Weight { - (33_575_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 39_603 nanoseconds. + Weight::from_ref_time(39_921_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Hrmp HrmpChannels (r:1 w:0) // Storage: Hrmp HrmpCloseChannelRequests (r:1 w:1) @@ -74,9 +76,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_close_channel() -> Weight { - (31_589_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 36_362 nanoseconds. + Weight::from_ref_time(37_028_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Hrmp HrmpIngressChannelsIndex (r:128 w:127) // Storage: Hrmp HrmpEgressChannelsIndex (r:1 w:1) @@ -87,17 +90,18 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf /// The range of component `i` is `[0, 127]`. /// The range of component `e` is `[0, 127]`. fn force_clean_hrmp(i: u32, e: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 22_000 - .saturating_add((9_971_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 22_000 - .saturating_add((9_951_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(i as Weight))) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(e as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(i as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(e as Weight))) + // Minimum execution time: 856_131 nanoseconds. + Weight::from_ref_time(862_826_000 as u64) + // Standard Error: 78_515 + .saturating_add(Weight::from_ref_time(2_683_043 as u64).saturating_mul(i as u64)) + // Standard Error: 78_515 + .saturating_add(Weight::from_ref_time(2_703_843 as u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(i as u64))) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(e as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(i as u64))) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(e as u64))) } // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:0) // Storage: Hrmp HrmpOpenChannelRequests (r:2 w:2) @@ -109,13 +113,14 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Hrmp HrmpChannels (r:0 w:2) /// The range of component `c` is `[0, 128]`. fn force_process_hrmp_open(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 35_000 - .saturating_add((23_340_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((7 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((6 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 8_813 nanoseconds. + Weight::from_ref_time(301_248 as u64) + // Standard Error: 21_023 + .saturating_add(Weight::from_ref_time(15_715_851 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((7 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((6 as u64).saturating_mul(c as u64))) } // Storage: Hrmp HrmpCloseChannelRequestsList (r:1 w:0) // Storage: Hrmp HrmpChannels (r:2 w:2) @@ -125,35 +130,54 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Hrmp HrmpChannelContents (r:0 w:2) /// The range of component `c` is `[0, 128]`. fn force_process_hrmp_close(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 23_000 - .saturating_add((13_159_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((5 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 5_575 nanoseconds. + Weight::from_ref_time(5_698_000 as u64) + // Standard Error: 6_879 + .saturating_add(Weight::from_ref_time(9_448_190 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((5 as u64).saturating_mul(c as u64))) } // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequestCount (r:1 w:1) /// The range of component `c` is `[0, 128]`. fn hrmp_cancel_open_request(c: u32, ) -> Weight { - (26_400_000 as Weight) - // Standard Error: 1_000 - .saturating_add((51_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 24_071 nanoseconds. + Weight::from_ref_time(30_055_240 as u64) + // Standard Error: 1_352 + .saturating_add(Weight::from_ref_time(92_467 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequests (r:2 w:2) /// The range of component `c` is `[0, 128]`. fn clean_open_channel_requests(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 7_000 - .saturating_add((3_786_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 4_101 nanoseconds. + Weight::from_ref_time(1_309_391 as u64) + // Standard Error: 4_811 + .saturating_add(Weight::from_ref_time(2_588_597 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + } + // Storage: Paras ParaLifecycles (r:2 w:0) + // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) + // Storage: Hrmp HrmpChannels (r:1 w:0) + // Storage: Hrmp HrmpEgressChannelsIndex (r:1 w:0) + // Storage: Hrmp HrmpOpenChannelRequestCount (r:1 w:1) + // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:2 w:2) + // Storage: Dmp DownwardMessageQueues (r:2 w:2) + // Storage: Hrmp HrmpIngressChannelsIndex (r:1 w:0) + // Storage: Hrmp HrmpAcceptedChannelRequestCount (r:1 w:1) + fn force_open_hrmp_channel() -> Weight { + // Minimum execution time: 51_466 nanoseconds. + Weight::from_ref_time(52_179_000 as u64) + .saturating_add(T::DbWeight::get().reads(13 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } } diff --git a/runtime/kusama/src/weights/runtime_parachains_initializer.rs b/runtime/kusama/src/weights/runtime_parachains_initializer.rs index 7306fcbcb524..650bfb8729fb 100644 --- a/runtime/kusama/src/weights/runtime_parachains_initializer.rs +++ b/runtime/kusama/src/weights/runtime_parachains_initializer.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_parachains::initializer` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -47,10 +47,11 @@ impl runtime_parachains::initializer::WeightInfo for We // Storage: System Digest (r:1 w:1) /// The range of component `d` is `[0, 65536]`. fn force_approve(d: u32, ) -> Weight { - (6_367_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_505 nanoseconds. + Weight::from_ref_time(10_074_391 as u64) + // Standard Error: 7 + .saturating_add(Weight::from_ref_time(1_331 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/runtime_parachains_paras.rs b/runtime/kusama/src/weights/runtime_parachains_paras.rs index 1be28f194308..8e7e0fff2171 100644 --- a/runtime/kusama/src/weights/runtime_parachains_paras.rs +++ b/runtime/kusama/src/weights/runtime_parachains_paras.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_parachains::paras` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -52,19 +52,21 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras CodeByHash (r:0 w:1) /// The range of component `c` is `[1, 3145728]`. fn force_set_current_code(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 35_301 nanoseconds. + Weight::from_ref_time(35_709_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_275 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Paras Heads (r:0 w:1) /// The range of component `s` is `[1, 1048576]`. fn force_set_current_head(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 12_484 nanoseconds. + Weight::from_ref_time(12_861_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(909 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Paras FutureCodeHash (r:1 w:1) // Storage: Paras CurrentCodeHash (r:1 w:0) @@ -78,54 +80,60 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras UpgradeRestrictionSignal (r:0 w:1) /// The range of component `c` is `[1, 3145728]`. fn force_schedule_code_upgrade(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + // Minimum execution time: 59_066 nanoseconds. + Weight::from_ref_time(59_476_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_297 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } // Storage: Paras FutureCodeUpgrades (r:1 w:0) // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) /// The range of component `s` is `[1, 1048576]`. fn force_note_new_head(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 18_117 nanoseconds. + Weight::from_ref_time(18_425_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(910 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras ActionsQueue (r:1 w:1) fn force_queue_action() -> Weight { - (19_558_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 22_620 nanoseconds. + Weight::from_ref_time(23_273_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Paras PvfActiveVoteMap (r:1 w:0) // Storage: Paras CodeByHash (r:1 w:1) /// The range of component `c` is `[1, 3145728]`. fn add_trusted_validation_code(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_879 nanoseconds. + Weight::from_ref_time(7_958_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_283 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Paras CodeByHashRefs (r:1 w:0) // Storage: Paras CodeByHash (r:0 w:1) fn poke_unused_validation_code() -> Weight { - (4_740_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 6_269 nanoseconds. + Weight::from_ref_time(6_409_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras PvfActiveVoteMap (r:1 w:1) fn include_pvf_check_statement() -> Weight { - (90_598_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 93_105 nanoseconds. + Weight::from_ref_time(94_985_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) @@ -135,9 +143,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: System Digest (r:1 w:1) // Storage: Paras FutureCodeUpgrades (r:0 w:100) fn include_pvf_check_statement_finalize_upgrade_accept() -> Weight { - (687_743_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(104 as Weight)) + // Minimum execution time: 609_441 nanoseconds. + Weight::from_ref_time(615_952_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(104 as u64)) } // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) @@ -148,9 +157,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras UpgradeGoAheadSignal (r:0 w:100) // Storage: Paras FutureCodeHash (r:0 w:100) fn include_pvf_check_statement_finalize_upgrade_reject() -> Weight { - (643_066_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(204 as Weight)) + // Minimum execution time: 582_378 nanoseconds. + Weight::from_ref_time(585_955_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(204 as u64)) } // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) @@ -158,9 +168,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras PvfActiveVoteList (r:1 w:1) // Storage: Paras ActionsQueue (r:1 w:1) fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight { - (545_691_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 478_258 nanoseconds. + Weight::from_ref_time(485_575_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) @@ -172,8 +183,9 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras CurrentCodeHash (r:0 w:100) // Storage: Paras UpcomingParasGenesis (r:0 w:100) fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight { - (722_173_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(304 as Weight)) + // Minimum execution time: 644_795 nanoseconds. + Weight::from_ref_time(651_549_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(304 as u64)) } } diff --git a/runtime/kusama/src/weights/runtime_parachains_paras_inherent.rs b/runtime/kusama/src/weights/runtime_parachains_paras_inherent.rs index e8449296b51f..c4cb58f3b0eb 100644 --- a/runtime/kusama/src/weights/runtime_parachains_paras_inherent.rs +++ b/runtime/kusama/src/weights/runtime_parachains_paras_inherent.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_parachains::paras_inherent` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -53,14 +53,15 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: ParasDisputes Included (r:1 w:1) // Storage: ParasDisputes SpamSlots (r:1 w:1) // Storage: ParaScheduler AvailabilityCores (r:1 w:1) + // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) + // Storage: Staking ActiveEra (r:1 w:0) + // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: ParasDisputes Frozen (r:1 w:0) // Storage: ParaInclusion PendingAvailability (r:2 w:1) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: Paras Parachains (r:1 w:0) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) - // Storage: ParaSessionInfo AccountKeys (r:1 w:0) - // Storage: Staking ActiveEra (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) // Storage: Hrmp HrmpChannelDigests (r:1 w:1) // Storage: Paras FutureCodeUpgrades (r:1 w:0) @@ -76,11 +77,12 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) /// The range of component `v` is `[10, 200]`. fn enter_variable_disputes(v: u32, ) -> Weight { - (382_740_000 as Weight) - // Standard Error: 25_000 - .saturating_add((48_643_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(28 as Weight)) - .saturating_add(T::DbWeight::get().writes(18 as Weight)) + // Minimum execution time: 808_425 nanoseconds. + Weight::from_ref_time(344_310_798 as u64) + // Standard Error: 21_870 + .saturating_add(Weight::from_ref_time(48_449_591 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(29 as u64)) + .saturating_add(T::DbWeight::get().writes(18 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -93,6 +95,7 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: ParaInclusion PendingAvailability (r:2 w:1) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) // Storage: Staking ActiveEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) @@ -112,9 +115,10 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn enter_bitfields() -> Weight { - (375_411_000 as Weight) - .saturating_add(T::DbWeight::get().reads(25 as Weight)) - .saturating_add(T::DbWeight::get().writes(17 as Weight)) + // Minimum execution time: 325_574 nanoseconds. + Weight::from_ref_time(332_360_000 as u64) + .saturating_add(T::DbWeight::get().reads(26 as u64)) + .saturating_add(T::DbWeight::get().writes(17 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -127,6 +131,7 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: ParaInclusion PendingAvailability (r:2 w:1) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) // Storage: Staking ActiveEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) @@ -148,11 +153,12 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) /// The range of component `v` is `[101, 200]`. fn enter_backed_candidates_variable(v: u32, ) -> Weight { - (1_067_738_000 as Weight) - // Standard Error: 48_000 - .saturating_add((47_926_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(28 as Weight)) - .saturating_add(T::DbWeight::get().writes(16 as Weight)) + // Minimum execution time: 5_648_731 nanoseconds. + Weight::from_ref_time(876_233_814 as u64) + // Standard Error: 46_671 + .saturating_add(Weight::from_ref_time(48_048_616 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(29 as u64)) + .saturating_add(T::DbWeight::get().writes(16 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -165,6 +171,7 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: ParaInclusion PendingAvailability (r:2 w:1) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) // Storage: Staking ActiveEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) @@ -187,8 +194,9 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn enter_backed_candidate_code_upgrade() -> Weight { - (45_676_661_000 as Weight) - .saturating_add(T::DbWeight::get().reads(30 as Weight)) - .saturating_add(T::DbWeight::get().writes(16 as Weight)) + // Minimum execution time: 38_109_414 nanoseconds. + Weight::from_ref_time(38_345_799_000 as u64) + .saturating_add(T::DbWeight::get().reads(31 as u64)) + .saturating_add(T::DbWeight::get().writes(16 as u64)) } } diff --git a/runtime/kusama/src/weights/runtime_parachains_ump.rs b/runtime/kusama/src/weights/runtime_parachains_ump.rs index f551a06936f4..2fbad5020b19 100644 --- a/runtime/kusama/src/weights/runtime_parachains_ump.rs +++ b/runtime/kusama/src/weights/runtime_parachains_ump.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_parachains::ump` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 @@ -46,23 +46,26 @@ pub struct WeightInfo(PhantomData); impl runtime_parachains::ump::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 51200]`. fn process_upward_message(s: u32, ) -> Weight { - (5_919_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) + // Minimum execution time: 9_700 nanoseconds. + Weight::from_ref_time(4_619_927 as u64) + // Standard Error: 12 + .saturating_add(Weight::from_ref_time(1_885 as u64).saturating_mul(s as u64)) } // Storage: Ump NeedsDispatch (r:1 w:1) // Storage: Ump NextDispatchRoundStartWith (r:1 w:1) // Storage: Ump RelayDispatchQueues (r:0 w:1) // Storage: Ump RelayDispatchQueueSize (r:0 w:1) fn clean_ump_after_outgoing() -> Weight { - (6_895_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 9_144 nanoseconds. + Weight::from_ref_time(9_352_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Ump Overweight (r:1 w:1) fn service_overweight() -> Weight { - (22_805_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_777 nanoseconds. + Weight::from_ref_time(25_125_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/kusama/src/weights/xcm/mod.rs b/runtime/kusama/src/weights/xcm/mod.rs index 83010487e522..64c19a79edfd 100644 --- a/runtime/kusama/src/weights/xcm/mod.rs +++ b/runtime/kusama/src/weights/xcm/mod.rs @@ -4,7 +4,10 @@ mod pallet_xcm_benchmarks_generic; use crate::Runtime; use frame_support::weights::Weight; use sp_std::prelude::*; -use xcm::{latest::prelude::*, DoubleEncoded}; +use xcm::{ + latest::{prelude::*, Weight as XCMWeight}, + DoubleEncoded, +}; use pallet_xcm_benchmarks_fungible::WeightInfo as XcmBalancesWeight; use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; @@ -28,15 +31,15 @@ impl From<&MultiAsset> for AssetTypes { } trait WeighMultiAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight; + fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight; } // Kusama only knows about one asset, the balances pallet. const MAX_ASSETS: u32 = 1; impl WeighMultiAssets for MultiAssetFilter { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { - match self { + fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { + let weight = match self { Self::Definite(assets) => assets .inner() .into_iter() @@ -45,34 +48,41 @@ impl WeighMultiAssets for MultiAssetFilter { AssetTypes::Balances => balances_weight, AssetTypes::Unknown => Weight::MAX, }) - .fold(0, |acc, x| acc.saturating_add(x)), - Self::Wild(_) => (MAX_ASSETS as Weight).saturating_mul(balances_weight), - } + .fold(Weight::zero(), |acc, x| acc.saturating_add(x)), + Self::Wild(AllOf { .. } | AllOfCounted { .. }) => balances_weight, + Self::Wild(AllCounted(count)) => balances_weight.saturating_mul(*count as u64), + Self::Wild(All) => balances_weight.saturating_mul(MAX_ASSETS as u64), + }; + + weight.ref_time() } } impl WeighMultiAssets for MultiAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { - self.inner() + fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { + let weight = self + .inner() .into_iter() .map(|m| >::from(m)) .map(|t| match t { AssetTypes::Balances => balances_weight, AssetTypes::Unknown => Weight::MAX, }) - .fold(0, |acc, x| acc.saturating_add(x)) + .fold(Weight::zero(), |acc, x| acc.saturating_add(x)); + + weight.ref_time() } } -pub struct KusamaXcmWeight(core::marker::PhantomData); -impl XcmWeightInfo for KusamaXcmWeight { - fn withdraw_asset(assets: &MultiAssets) -> Weight { +pub struct KusamaXcmWeight(core::marker::PhantomData); +impl XcmWeightInfo for KusamaXcmWeight { + fn withdraw_asset(assets: &MultiAssets) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::withdraw_asset()) } - fn reserve_asset_deposited(assets: &MultiAssets) -> Weight { + fn reserve_asset_deposited(assets: &MultiAssets) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::reserve_asset_deposited()) } - fn receive_teleported_asset(assets: &MultiAssets) -> Weight { + fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::receive_teleported_asset()) } fn query_response( @@ -80,124 +90,128 @@ impl XcmWeightInfo for KusamaXcmWeight { _response: &Response, _max_weight: &u64, _querier: &Option, - ) -> Weight { - XcmGeneric::::query_response() + ) -> XCMWeight { + XcmGeneric::::query_response().ref_time() } - fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight { + fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_asset()) } fn transfer_reserve_asset( assets: &MultiAssets, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> Weight { + ) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_reserve_asset()) } fn transact( _origin_type: &OriginKind, _require_weight_at_most: &u64, - _call: &DoubleEncoded, - ) -> Weight { - XcmGeneric::::transact() + _call: &DoubleEncoded, + ) -> XCMWeight { + XcmGeneric::::transact().ref_time() } fn hrmp_new_channel_open_request( _sender: &u32, _max_message_size: &u32, _max_capacity: &u32, - ) -> Weight { + ) -> XCMWeight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX + Weight::MAX.ref_time() } - fn hrmp_channel_accepted(_recipient: &u32) -> Weight { + fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX + Weight::MAX.ref_time() } - fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight { + fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX + Weight::MAX.ref_time() } - fn clear_origin() -> Weight { - XcmGeneric::::clear_origin() + fn clear_origin() -> XCMWeight { + XcmGeneric::::clear_origin().ref_time() } - fn descend_origin(_who: &InteriorMultiLocation) -> Weight { - XcmGeneric::::descend_origin() + fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight { + XcmGeneric::::descend_origin().ref_time() } - fn report_error(_query_response_info: &QueryResponseInfo) -> Weight { - XcmGeneric::::report_error() + fn report_error(_query_response_info: &QueryResponseInfo) -> XCMWeight { + XcmGeneric::::report_error().ref_time() } - fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { + fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_asset()) } fn deposit_reserve_asset( assets: &MultiAssetFilter, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> Weight { + ) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } - fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { + fn exchange_asset( + _give: &MultiAssetFilter, + _receive: &MultiAssets, + _maximal: &bool, + ) -> XCMWeight { // Kusama does not currently support exchange asset operations - Weight::MAX + Weight::MAX.ref_time() } fn initiate_reserve_withdraw( assets: &MultiAssetFilter, _reserve: &MultiLocation, _xcm: &Xcm<()>, - ) -> Weight { + ) -> XCMWeight { assets.weigh_multi_assets(XcmGeneric::::initiate_reserve_withdraw()) } fn initiate_teleport( assets: &MultiAssetFilter, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> Weight { + ) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) } - fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight { - XcmGeneric::::report_holding() + fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> XCMWeight { + XcmGeneric::::report_holding().ref_time() } - fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight { - XcmGeneric::::buy_execution() + fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight { + XcmGeneric::::buy_execution().ref_time() } - fn refund_surplus() -> Weight { - XcmGeneric::::refund_surplus() + fn refund_surplus() -> XCMWeight { + XcmGeneric::::refund_surplus().ref_time() } - fn set_error_handler(_xcm: &Xcm) -> Weight { - XcmGeneric::::set_error_handler() + fn set_error_handler(_xcm: &Xcm) -> XCMWeight { + XcmGeneric::::set_error_handler().ref_time() } - fn set_appendix(_xcm: &Xcm) -> Weight { - XcmGeneric::::set_appendix() + fn set_appendix(_xcm: &Xcm) -> XCMWeight { + XcmGeneric::::set_appendix().ref_time() } - fn clear_error() -> Weight { - XcmGeneric::::clear_error() + fn clear_error() -> XCMWeight { + XcmGeneric::::clear_error().ref_time() } - fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight { - XcmGeneric::::claim_asset() + fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight { + XcmGeneric::::claim_asset().ref_time() } - fn trap(_code: &u64) -> Weight { - XcmGeneric::::trap() + fn trap(_code: &u64) -> XCMWeight { + XcmGeneric::::trap().ref_time() } - fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> Weight { - XcmGeneric::::subscribe_version() + fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight { + XcmGeneric::::subscribe_version().ref_time() } - fn unsubscribe_version() -> Weight { - XcmGeneric::::unsubscribe_version() + fn unsubscribe_version() -> XCMWeight { + XcmGeneric::::unsubscribe_version().ref_time() } - fn burn_asset(assets: &MultiAssets) -> Weight { + fn burn_asset(assets: &MultiAssets) -> XCMWeight { assets.weigh_multi_assets(XcmGeneric::::burn_asset()) } - fn expect_asset(assets: &MultiAssets) -> Weight { + fn expect_asset(assets: &MultiAssets) -> XCMWeight { assets.weigh_multi_assets(XcmGeneric::::expect_asset()) } - fn expect_origin(_origin: &Option) -> Weight { - XcmGeneric::::expect_origin() + fn expect_origin(_origin: &Option) -> XCMWeight { + XcmGeneric::::expect_origin().ref_time() } - fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight { - XcmGeneric::::expect_error() + fn expect_error(_error: &Option<(u32, XcmError)>) -> XCMWeight { + XcmGeneric::::expect_error().ref_time() } - fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> Weight { - XcmGeneric::::query_pallet() + fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> XCMWeight { + XcmGeneric::::query_pallet().ref_time() } fn expect_pallet( _index: &u32, @@ -205,52 +219,52 @@ impl XcmWeightInfo for KusamaXcmWeight { _module_name: &Vec, _crate_major: &u32, _min_crate_minor: &u32, - ) -> Weight { - XcmGeneric::::expect_pallet() + ) -> XCMWeight { + XcmGeneric::::expect_pallet().ref_time() } - fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight { - XcmGeneric::::report_transact_status() + fn report_transact_status(_response_info: &QueryResponseInfo) -> XCMWeight { + XcmGeneric::::report_transact_status().ref_time() } - fn clear_transact_status() -> Weight { - XcmGeneric::::clear_transact_status() + fn clear_transact_status() -> XCMWeight { + XcmGeneric::::clear_transact_status().ref_time() } - fn universal_origin(_: &Junction) -> Weight { + fn universal_origin(_: &Junction) -> XCMWeight { // Kusama does not currently support universal origin operations - Weight::MAX + Weight::MAX.ref_time() } - fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { - Weight::MAX // todo fix + fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> XCMWeight { + Weight::MAX.ref_time() // todo fix } - fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { + fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { // Kusama does not currently support asset locking operations - Weight::MAX + Weight::MAX.ref_time() } - fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { + fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { // Kusama does not currently support asset locking operations - Weight::MAX + Weight::MAX.ref_time() } - fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight { + fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { // Kusama does not currently support asset locking operations - Weight::MAX + Weight::MAX.ref_time() } - fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight { + fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { // Kusama does not currently support asset locking operations - Weight::MAX + Weight::MAX.ref_time() } - fn set_fees_mode(_: &bool) -> Weight { - XcmGeneric::::set_fees_mode() + fn set_fees_mode(_: &bool) -> XCMWeight { + XcmGeneric::::set_fees_mode().ref_time() } - fn set_topic(_topic: &[u8; 32]) -> Weight { - XcmGeneric::::set_topic() + fn set_topic(_topic: &[u8; 32]) -> XCMWeight { + XcmGeneric::::set_topic().ref_time() } - fn clear_topic() -> Weight { - XcmGeneric::::clear_topic() + fn clear_topic() -> XCMWeight { + XcmGeneric::::clear_topic().ref_time() } - fn alias_origin(_: &MultiLocation) -> Weight { + fn alias_origin(_: &MultiLocation) -> XCMWeight { // XCM Executor does not currently support alias origin operations - Weight::MAX + Weight::MAX.ref_time() } - fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { - Weight::MAX + fn unpaid_execution(_: &WeightLimit, _: &Option) -> XCMWeight { + XcmGeneric::::unpaid_execution().ref_time() } } diff --git a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 2528c0a491dc..a9907a70a250 100644 --- a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -47,15 +47,15 @@ pub struct WeightInfo(PhantomData); impl WeightInfo { // Storage: System Account (r:1 w:1) pub(crate) fn withdraw_asset() -> Weight { - (20_385_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(20_385_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:2 w:2) pub(crate) fn transfer_asset() -> Weight { - (32_756_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_756_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: System Account (r:2 w:2) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -65,25 +65,25 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn transfer_reserve_asset() -> Weight { - (50_645_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(50_645_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Benchmark Override (r:0 w:0) pub(crate) fn reserve_asset_deposited() -> Weight { - (2_000_000_000_000 as Weight) + Weight::from_ref_time(2_000_000_000_000 as u64) } // Storage: System Account (r:1 w:1) pub(crate) fn receive_teleported_asset() -> Weight { - (19_595_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_595_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) pub(crate) fn deposit_asset() -> Weight { - (21_763_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(21_763_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -93,9 +93,9 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn deposit_reserve_asset() -> Weight { - (40_930_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(40_930_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: System Account (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -105,8 +105,8 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn initiate_teleport() -> Weight { - (40_788_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(40_788_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } } diff --git a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 21cf6088b319..69421bdb414b 100644 --- a/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/kusama/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -1,4 +1,4 @@ -// Copyright 2021 Parity Technologies (UK) Ltd. +// Copyright 2022 Parity Technologies (UK) Ltd. // This file is part of Polkadot. // Polkadot is free software: you can redistribute it and/or modify @@ -52,38 +52,38 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_holding() -> Weight { - (25_878_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(25_878_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn buy_execution() -> Weight { - (3_697_000 as Weight) + Weight::from_ref_time(3_697_000 as u64) } // Storage: XcmPallet Queries (r:1 w:0) pub(crate) fn query_response() -> Weight { - (13_458_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(13_458_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } pub(crate) fn transact() -> Weight { - (13_597_000 as Weight) + Weight::from_ref_time(13_597_000 as u64) } pub(crate) fn refund_surplus() -> Weight { - (3_839_000 as Weight) + Weight::from_ref_time(3_839_000 as u64) } pub(crate) fn set_error_handler() -> Weight { - (3_657_000 as Weight) + Weight::from_ref_time(3_657_000 as u64) } pub(crate) fn set_appendix() -> Weight { - (3_757_000 as Weight) + Weight::from_ref_time(3_757_000 as u64) } pub(crate) fn clear_error() -> Weight { - (3_651_000 as Weight) + Weight::from_ref_time(3_651_000 as u64) } pub(crate) fn descend_origin() -> Weight { - (4_589_000 as Weight) + Weight::from_ref_time(4_589_000 as u64) } pub(crate) fn clear_origin() -> Weight { - (3_661_000 as Weight) + Weight::from_ref_time(3_661_000 as u64) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -91,18 +91,18 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_error() -> Weight { - (21_351_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(21_351_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: XcmPallet AssetTraps (r:1 w:1) pub(crate) fn claim_asset() -> Weight { - (7_674_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(7_674_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } pub(crate) fn trap() -> Weight { - (3_606_000 as Weight) + Weight::from_ref_time(3_606_000 as u64) } // Storage: XcmPallet VersionNotifyTargets (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -111,14 +111,14 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn subscribe_version() -> Weight { - (30_453_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(30_453_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: XcmPallet VersionNotifyTargets (r:0 w:1) pub(crate) fn unsubscribe_version() -> Weight { - (5_543_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(5_543_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -126,21 +126,21 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn initiate_reserve_withdraw() -> Weight { - (25_464_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(25_464_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn burn_asset() -> Weight { - (5_194_000 as Weight) + Weight::from_ref_time(5_194_000 as u64) } pub(crate) fn expect_asset() -> Weight { - (3_698_000 as Weight) + Weight::from_ref_time(3_698_000 as u64) } pub(crate) fn expect_origin() -> Weight { - (3_786_000 as Weight) + Weight::from_ref_time(3_786_000 as u64) } pub(crate) fn expect_error() -> Weight { - (3_645_000 as Weight) + Weight::from_ref_time(3_645_000 as u64) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -148,12 +148,12 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn query_pallet() -> Weight { - (22_993_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(22_993_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn expect_pallet() -> Weight { - (4_043_000 as Weight) + Weight::from_ref_time(4_043_000 as u64) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -161,20 +161,23 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_transact_status() -> Weight { - (21_668_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(21_668_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn clear_transact_status() -> Weight { - (3_673_000 as Weight) + Weight::from_ref_time(3_673_000 as u64) } pub(crate) fn set_topic() -> Weight { - (3_661_000 as Weight) + Weight::from_ref_time(3_661_000 as u64) } pub(crate) fn clear_topic() -> Weight { - (3_647_000 as Weight) + Weight::from_ref_time(3_647_000 as u64) } pub(crate) fn set_fees_mode() -> Weight { - (3_599_000 as Weight) + Weight::from_ref_time(3_599_000 as u64) + } + pub(crate) fn unpaid_execution() -> Weight { + Weight::from_ref_time(3_111_000 as u64) } } diff --git a/runtime/kusama/src/xcm_config.rs b/runtime/kusama/src/xcm_config.rs index b0ac7ce755ff..b3b15a3443ce 100644 --- a/runtime/kusama/src/xcm_config.rs +++ b/runtime/kusama/src/xcm_config.rs @@ -17,13 +17,12 @@ //! XCM configurations for the Kusama runtime. use super::{ - parachains_origin, AccountId, AllPalletsWithSystem, Balances, Call, CouncilCollective, Event, - Origin, ParaId, Runtime, WeightToFee, XcmPallet, + parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, ParaId, + Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet, }; use frame_support::{ match_types, parameter_types, traits::{Everything, Nothing}, - weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; @@ -80,18 +79,18 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< /// The means that we convert the XCM message origin location into a local dispatch origin. type LocalOriginConverter = ( // A `Signed` origin of the sovereign account that the original location controls. - SovereignSignedViaLocation, + SovereignSignedViaLocation, // A child parachain, natively expressed, has the `Parachain` origin. - ChildParachainAsNative, + ChildParachainAsNative, // The AccountId32 location type can be expressed natively as a `Signed` origin. - SignedAccountId32AsNative, + SignedAccountId32AsNative, // A system child parachain, expressed as a Superuser, converts to the `Root` origin. - ChildSystemParachainAsSuperuser, + ChildSystemParachainAsSuperuser, ); parameter_types! { /// The amount of weight an XCM operation takes. This is a safe overestimate. - pub const BaseXcmWeight: Weight = 1_000_000_000; + pub const BaseXcmWeight: u64 = 1_000_000_000; /// Maximum number of instructions in a single XCM fragment. A sanity check against weight /// calculations getting too crazy. pub const MaxInstructions: u32 = 100; @@ -107,8 +106,9 @@ pub type XcmRouter = ( parameter_types! { pub const Ksm: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); pub const Statemine: MultiLocation = Parachain(1000).into_location(); + pub const Encointer: MultiLocation = Parachain(1001).into_location(); pub const KsmForStatemine: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Statemine::get()); - pub const KsmForEncointer: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Parachain(1001).into_location()); + pub const KsmForEncointer: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Encointer::get()); pub const MaxAssetsIntoHolding: u32 = 64; } pub type TrustedTeleporters = @@ -136,7 +136,7 @@ pub type Barrier = ( pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { - type Call = Call; + type RuntimeCall = RuntimeCall; type XcmSender = XcmRouter; type AssetTransactor = LocalAssetTransactor; type OriginConverter = LocalOriginConverter; @@ -144,8 +144,11 @@ impl xcm_executor::Config for XcmConfig { type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = - WeightInfoBounds, Call, MaxInstructions>; + type Weigher = WeightInfoBounds< + crate::weights::xcm::KusamaXcmWeight, + RuntimeCall, + MaxInstructions, + >; // The weight trader piggybacks on the existing transaction-fee conversion logic. type Trader = UsingComponents>; @@ -161,6 +164,7 @@ impl xcm_executor::Config for XcmConfig { // No bridges yet... type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; } parameter_types! { @@ -169,7 +173,7 @@ parameter_types! { /// Type to convert the council origin to a Plurality `MultiLocation` value. pub type CouncilToPlurality = BackingToPlurality< - Origin, + RuntimeOrigin, pallet_collective::Origin, CouncilBodyId, >; @@ -181,19 +185,19 @@ pub type LocalOriginToLocation = ( // `Unit` body. CouncilToPlurality, // And a usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, + SignedToAccountId32, ); impl pallet_xcm::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; // We only allow the council to send messages. This is basically safe to enable for everyone // (safe the possibility of someone spamming the parachain if they're willing to pay the KSM to // send from the Relay-chain), but it's useless until we bring in XCM v3 which will make // `DescendOrigin` a bit more useful. - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = XcmRouter; // Anyone can execute XCM messages locally. - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; + type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmExecuteFilter = Everything; type XcmExecutor = xcm_executor::XcmExecutor; // Anyone is able to use teleportation regardless of who they are and what they want to teleport. @@ -201,10 +205,10 @@ impl pallet_xcm::Config for Runtime { // Anyone is able to use reserve transfers regardless of who they are and what they want to // transfer. type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type Currency = Balances; diff --git a/runtime/metrics/Cargo.toml b/runtime/metrics/Cargo.toml index a27a3fc72e8f..37069d8ed912 100644 --- a/runtime/metrics/Cargo.toml +++ b/runtime/metrics/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "polkadot-runtime-metrics" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] -sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.28" } -sp-tracing = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.31" } +sp-tracing = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } parity-scale-codec = { version = "3.1.5", default-features = false } primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } diff --git a/runtime/parachains/Cargo.toml b/runtime/parachains/Cargo.toml index e85494221448..929cafeeccbf 100644 --- a/runtime/parachains/Cargo.toml +++ b/runtime/parachains/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-runtime-parachains" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -14,29 +14,29 @@ serde = { version = "1.0.137", features = [ "derive" ], optional = true } derive_more = "0.99.17" bitflags = "1.3.2" -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-keystore = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.28" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -sp-tracing = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-keystore = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.31" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +sp-tracing = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } -pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } xcm = { package = "xcm", path = "../../xcm", default-features = false } xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", default-features = false } @@ -50,11 +50,11 @@ polkadot-runtime-metrics = { path = "../metrics", default-features = false} [dev-dependencies] futures = "0.3.21" hex-literal = "0.3.4" -keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-support-test = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-support-test = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../primitives/test-helpers"} -sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } thousands = "0.2.0" assert_matches = "1" @@ -95,6 +95,7 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "pallet-staking/runtime-benchmarks", "primitives/runtime-benchmarks", "static_assertions", "sp-application-crypto", @@ -109,4 +110,3 @@ try-runtime = [ "pallet-vesting/try-runtime", ] runtime-metrics = ["sp-tracing/with-tracing", "polkadot-runtime-metrics/runtime-metrics"] -vstaging = [] diff --git a/runtime/parachains/src/configuration.rs b/runtime/parachains/src/configuration.rs index bf6e512920dc..2ebaff1b8282 100644 --- a/runtime/parachains/src/configuration.rs +++ b/runtime/parachains/src/configuration.rs @@ -285,7 +285,8 @@ impl> Default for HostConfiguration { impl Pallet { /// Called by the initializer to initialize the configuration pallet. pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { - 0 + Weight::zero() } /// Called by the initializer to finalize the configuration pallet. diff --git a/runtime/parachains/src/configuration/benchmarking.rs b/runtime/parachains/src/configuration/benchmarking.rs index 4b98f22c7f76..71e0c03e696b 100644 --- a/runtime/parachains/src/configuration/benchmarking.rs +++ b/runtime/parachains/src/configuration/benchmarking.rs @@ -26,7 +26,7 @@ benchmarks! { set_config_with_option_u32 {}: set_max_validators(RawOrigin::Root, Some(10)) - set_config_with_weight {}: set_ump_service_total_weight(RawOrigin::Root, 3_000_000) + set_config_with_weight {}: set_ump_service_total_weight(RawOrigin::Root, Weight::from_ref_time(3_000_000)) set_hrmp_open_request_ttl {}: { Err(BenchmarkError::Override( diff --git a/runtime/parachains/src/configuration/migration.rs b/runtime/parachains/src/configuration/migration.rs index 2ee411e65129..d87c98f6ae78 100644 --- a/runtime/parachains/src/configuration/migration.rs +++ b/runtime/parachains/src/configuration/migration.rs @@ -16,10 +16,328 @@ //! A module that is responsible for migration of storage. -use frame_support::traits::StorageVersion; +use crate::configuration::{self, Config, Pallet, Store, MAX_POV_SIZE}; +use frame_support::{ + pallet_prelude::*, + traits::StorageVersion, + weights::{OldWeight, Weight}, +}; +use frame_system::pallet_prelude::BlockNumberFor; /// The current storage version. /// /// v0-v1: /// v1-v2: -pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); +/// v2-v3: +pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(3); + +pub mod v3 { + use super::*; + use frame_support::traits::OnRuntimeUpgrade; + use primitives::v2::{Balance, SessionIndex}; + + // Copied over from configuration.rs @ de9e147695b9f1be8bd44e07861a31e483c8343a and removed + // all the comments, and changed the Weight struct to OldWeight + #[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug)] + pub struct OldHostConfiguration { + pub max_code_size: u32, + pub max_head_data_size: u32, + pub max_upward_queue_count: u32, + pub max_upward_queue_size: u32, + pub max_upward_message_size: u32, + pub max_upward_message_num_per_candidate: u32, + pub hrmp_max_message_num_per_candidate: u32, + pub validation_upgrade_cooldown: BlockNumber, + pub validation_upgrade_delay: BlockNumber, + pub max_pov_size: u32, + pub max_downward_message_size: u32, + pub ump_service_total_weight: OldWeight, + pub hrmp_max_parachain_outbound_channels: u32, + pub hrmp_max_parathread_outbound_channels: u32, + pub hrmp_sender_deposit: Balance, + pub hrmp_recipient_deposit: Balance, + pub hrmp_channel_max_capacity: u32, + pub hrmp_channel_max_total_size: u32, + pub hrmp_max_parachain_inbound_channels: u32, + pub hrmp_max_parathread_inbound_channels: u32, + pub hrmp_channel_max_message_size: u32, + pub code_retention_period: BlockNumber, + pub parathread_cores: u32, + pub parathread_retries: u32, + pub group_rotation_frequency: BlockNumber, + pub chain_availability_period: BlockNumber, + pub thread_availability_period: BlockNumber, + pub scheduling_lookahead: u32, + pub max_validators_per_core: Option, + pub max_validators: Option, + pub dispute_period: SessionIndex, + pub dispute_post_conclusion_acceptance_period: BlockNumber, + pub dispute_max_spam_slots: u32, + pub dispute_conclusion_by_time_out_period: BlockNumber, + pub no_show_slots: u32, + pub n_delay_tranches: u32, + pub zeroth_delay_tranche_width: u32, + pub needed_approvals: u32, + pub relay_vrf_modulo_samples: u32, + pub ump_max_individual_weight: OldWeight, + pub pvf_checking_enabled: bool, + pub pvf_voting_ttl: SessionIndex, + pub minimum_validation_upgrade_delay: BlockNumber, + } + + impl> Default for OldHostConfiguration { + fn default() -> Self { + Self { + group_rotation_frequency: 1u32.into(), + chain_availability_period: 1u32.into(), + thread_availability_period: 1u32.into(), + no_show_slots: 1u32.into(), + validation_upgrade_cooldown: Default::default(), + validation_upgrade_delay: Default::default(), + code_retention_period: Default::default(), + max_code_size: Default::default(), + max_pov_size: Default::default(), + max_head_data_size: Default::default(), + parathread_cores: Default::default(), + parathread_retries: Default::default(), + scheduling_lookahead: Default::default(), + max_validators_per_core: Default::default(), + max_validators: None, + dispute_period: 6, + dispute_post_conclusion_acceptance_period: 100.into(), + dispute_max_spam_slots: 2, + dispute_conclusion_by_time_out_period: 200.into(), + n_delay_tranches: Default::default(), + zeroth_delay_tranche_width: Default::default(), + needed_approvals: Default::default(), + relay_vrf_modulo_samples: Default::default(), + max_upward_queue_count: Default::default(), + max_upward_queue_size: Default::default(), + max_downward_message_size: Default::default(), + ump_service_total_weight: OldWeight(Default::default()), + max_upward_message_size: Default::default(), + max_upward_message_num_per_candidate: Default::default(), + hrmp_sender_deposit: Default::default(), + hrmp_recipient_deposit: Default::default(), + hrmp_channel_max_capacity: Default::default(), + hrmp_channel_max_total_size: Default::default(), + hrmp_max_parachain_inbound_channels: Default::default(), + hrmp_max_parathread_inbound_channels: Default::default(), + hrmp_channel_max_message_size: Default::default(), + hrmp_max_parachain_outbound_channels: Default::default(), + hrmp_max_parathread_outbound_channels: Default::default(), + hrmp_max_message_num_per_candidate: Default::default(), + ump_max_individual_weight: OldWeight( + frame_support::weights::constants::WEIGHT_PER_MILLIS.ref_time() * 20, + ), + pvf_checking_enabled: false, + pvf_voting_ttl: 2u32.into(), + minimum_validation_upgrade_delay: 2.into(), + } + } + } + + pub struct MigrateToV3(sp_std::marker::PhantomData); + impl OnRuntimeUpgrade for MigrateToV3 { + fn on_runtime_upgrade() -> Weight { + if StorageVersion::get::>() == 2 { + let weight_consumed = migrate_to_v3::(); + + log::info!(target: configuration::LOG_TARGET, "MigrateToV3 executed successfully"); + STORAGE_VERSION.put::>(); + + weight_consumed + } else { + log::warn!(target: configuration::LOG_TARGET, "MigrateToV3 should be removed."); + T::DbWeight::get().reads(1) + } + } + } +} + +fn migrate_to_v3() -> Weight { + // Unusual formatting is justified: + // - make it easier to verify that fields assign what they supposed to assign. + // - this code is transient and will be removed after all migrations are done. + // - this code is important enough to optimize for legibility sacrificing consistency. + #[rustfmt::skip] + let translate = + |pre: v3::OldHostConfiguration>| -> +configuration::HostConfiguration> + { + super::HostConfiguration { +max_code_size : pre.max_code_size, +max_head_data_size : pre.max_head_data_size, +max_upward_queue_count : pre.max_upward_queue_count, +max_upward_queue_size : pre.max_upward_queue_size, +max_upward_message_size : pre.max_upward_message_size, +max_upward_message_num_per_candidate : pre.max_upward_message_num_per_candidate, +hrmp_max_message_num_per_candidate : pre.hrmp_max_message_num_per_candidate, +validation_upgrade_cooldown : pre.validation_upgrade_cooldown, +validation_upgrade_delay : pre.validation_upgrade_delay, +max_pov_size : pre.max_pov_size, +max_downward_message_size : pre.max_downward_message_size, +hrmp_max_parachain_outbound_channels : pre.hrmp_max_parachain_outbound_channels, +hrmp_max_parathread_outbound_channels : pre.hrmp_max_parathread_outbound_channels, +hrmp_sender_deposit : pre.hrmp_sender_deposit, +hrmp_recipient_deposit : pre.hrmp_recipient_deposit, +hrmp_channel_max_capacity : pre.hrmp_channel_max_capacity, +hrmp_channel_max_total_size : pre.hrmp_channel_max_total_size, +hrmp_max_parachain_inbound_channels : pre.hrmp_max_parachain_inbound_channels, +hrmp_max_parathread_inbound_channels : pre.hrmp_max_parathread_inbound_channels, +hrmp_channel_max_message_size : pre.hrmp_channel_max_message_size, +code_retention_period : pre.code_retention_period, +parathread_cores : pre.parathread_cores, +parathread_retries : pre.parathread_retries, +group_rotation_frequency : pre.group_rotation_frequency, +chain_availability_period : pre.chain_availability_period, +thread_availability_period : pre.thread_availability_period, +scheduling_lookahead : pre.scheduling_lookahead, +max_validators_per_core : pre.max_validators_per_core, +max_validators : pre.max_validators, +dispute_period : pre.dispute_period, +dispute_post_conclusion_acceptance_period: pre.dispute_post_conclusion_acceptance_period, +dispute_max_spam_slots : pre.dispute_max_spam_slots, +dispute_conclusion_by_time_out_period : pre.dispute_conclusion_by_time_out_period, +no_show_slots : pre.no_show_slots, +n_delay_tranches : pre.n_delay_tranches, +zeroth_delay_tranche_width : pre.zeroth_delay_tranche_width, +needed_approvals : pre.needed_approvals, +relay_vrf_modulo_samples : pre.relay_vrf_modulo_samples, +pvf_checking_enabled : pre.pvf_checking_enabled, +pvf_voting_ttl : pre.pvf_voting_ttl, +minimum_validation_upgrade_delay : pre.minimum_validation_upgrade_delay, + +ump_service_total_weight: Weight::from_ref_time(pre.ump_service_total_weight.0).set_proof_size(MAX_POV_SIZE as u64), +ump_max_individual_weight: Weight::from_ref_time(pre.ump_max_individual_weight.0).set_proof_size(MAX_POV_SIZE as u64), + } + }; + + if let Err(_) = as Store>::ActiveConfig::translate(|pre| pre.map(translate)) { + // `Err` is returned when the pre-migration type cannot be deserialized. This + // cannot happen if the migration runs correctly, i.e. against the expected version. + // + // This happening almost surely will lead to a panic somewhere else. Corruption seems + // to be unlikely to be caused by this. So we just log. Maybe it'll work out still? + log::error!( + target: configuration::LOG_TARGET, + "unexpected error when performing translation of the configuration type during storage upgrade to v2." + ); + } + + T::DbWeight::get().reads_writes(1, 1) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::mock::{new_test_ext, Test}; + + #[test] + fn v2_deserialized_from_actual_data() { + // Fetched at Kusama 14,703,780 (0x3b2c305d01bd4adf1973d32a2d55ca1260a55eea8dfb3168e317c57f2841fdf1) + // + // This exceeds the maximal line width length, but that's fine, since this is not code and + // doesn't need to be read and also leaving it as one line allows to easily copy it. + let raw_config = hex_literal::hex!["0000a000005000000a00000000c8000000c800000a0000000a000000100e0000580200000000500000c8000000e87648170000001e00000000000000005039278c0400000000000000000000005039278c0400000000000000000000e8030000009001001e00000000000000009001008070000000000000000000000a0000000a0000000a00000001000000010500000001c8000000060000005802000002000000580200000200000059000000000000001e0000002800000000c817a804000000000200000014000000"]; + + let v2 = + v3::OldHostConfiguration::::decode(&mut &raw_config[..]) + .unwrap(); + + // We check only a sample of the values here. If we missed any fields or messed up data types + // that would skew all the fields coming after. + assert_eq!(v2.max_code_size, 10_485_760); + assert_eq!(v2.validation_upgrade_cooldown, 3600); + assert_eq!(v2.max_pov_size, 5_242_880); + assert_eq!(v2.hrmp_channel_max_message_size, 102_400); + assert_eq!(v2.dispute_max_spam_slots, 2); + assert_eq!(v2.n_delay_tranches, 89); + assert_eq!(v2.ump_max_individual_weight, OldWeight(20_000_000_000)); + assert_eq!(v2.minimum_validation_upgrade_delay, 20); + } + + #[test] + fn test_migrate_to_v3() { + // Host configuration has lots of fields. However, in this migration we add only a couple of + // fields. The most important part to check are a couple of the last fields. We also pick + // extra fields to check arbitrarily, e.g. depending on their position (i.e. the middle) and + // also their type. + // + // We specify only the picked fields and the rest should be provided by the `Default` + // implementation. That implementation is copied over between the two types and should work + // fine. + let v2 = v3::OldHostConfiguration:: { + ump_max_individual_weight: OldWeight(0x71616e6f6e0au64), + needed_approvals: 69, + thread_availability_period: 55, + hrmp_recipient_deposit: 1337, + max_pov_size: 1111, + chain_availability_period: 33, + minimum_validation_upgrade_delay: 20, + ..Default::default() + }; + + new_test_ext(Default::default()).execute_with(|| { + // Implant the v2 version in the state. + frame_support::storage::unhashed::put_raw( + &configuration::ActiveConfig::::hashed_key(), + &v2.encode(), + ); + + migrate_to_v3::(); + + let v3 = configuration::ActiveConfig::::get(); + + #[rustfmt::skip] + { + assert_eq!(v2.max_code_size , v3.max_code_size); + assert_eq!(v2.max_head_data_size , v3.max_head_data_size); + assert_eq!(v2.max_upward_queue_count , v3.max_upward_queue_count); + assert_eq!(v2.max_upward_queue_size , v3.max_upward_queue_size); + assert_eq!(v2.max_upward_message_size , v3.max_upward_message_size); + assert_eq!(v2.max_upward_message_num_per_candidate , v3.max_upward_message_num_per_candidate); + assert_eq!(v2.hrmp_max_message_num_per_candidate , v3.hrmp_max_message_num_per_candidate); + assert_eq!(v2.validation_upgrade_cooldown , v3.validation_upgrade_cooldown); + assert_eq!(v2.validation_upgrade_delay , v3.validation_upgrade_delay); + assert_eq!(v2.max_pov_size , v3.max_pov_size); + assert_eq!(v2.max_downward_message_size , v3.max_downward_message_size); + assert_eq!(v2.hrmp_max_parachain_outbound_channels , v3.hrmp_max_parachain_outbound_channels); + assert_eq!(v2.hrmp_max_parathread_outbound_channels , v3.hrmp_max_parathread_outbound_channels); + assert_eq!(v2.hrmp_sender_deposit , v3.hrmp_sender_deposit); + assert_eq!(v2.hrmp_recipient_deposit , v3.hrmp_recipient_deposit); + assert_eq!(v2.hrmp_channel_max_capacity , v3.hrmp_channel_max_capacity); + assert_eq!(v2.hrmp_channel_max_total_size , v3.hrmp_channel_max_total_size); + assert_eq!(v2.hrmp_max_parachain_inbound_channels , v3.hrmp_max_parachain_inbound_channels); + assert_eq!(v2.hrmp_max_parathread_inbound_channels , v3.hrmp_max_parathread_inbound_channels); + assert_eq!(v2.hrmp_channel_max_message_size , v3.hrmp_channel_max_message_size); + assert_eq!(v2.code_retention_period , v3.code_retention_period); + assert_eq!(v2.parathread_cores , v3.parathread_cores); + assert_eq!(v2.parathread_retries , v3.parathread_retries); + assert_eq!(v2.group_rotation_frequency , v3.group_rotation_frequency); + assert_eq!(v2.chain_availability_period , v3.chain_availability_period); + assert_eq!(v2.thread_availability_period , v3.thread_availability_period); + assert_eq!(v2.scheduling_lookahead , v3.scheduling_lookahead); + assert_eq!(v2.max_validators_per_core , v3.max_validators_per_core); + assert_eq!(v2.max_validators , v3.max_validators); + assert_eq!(v2.dispute_period , v3.dispute_period); + assert_eq!(v2.dispute_post_conclusion_acceptance_period, v3.dispute_post_conclusion_acceptance_period); + assert_eq!(v2.dispute_max_spam_slots , v3.dispute_max_spam_slots); + assert_eq!(v2.dispute_conclusion_by_time_out_period , v3.dispute_conclusion_by_time_out_period); + assert_eq!(v2.no_show_slots , v3.no_show_slots); + assert_eq!(v2.n_delay_tranches , v3.n_delay_tranches); + assert_eq!(v2.zeroth_delay_tranche_width , v3.zeroth_delay_tranche_width); + assert_eq!(v2.needed_approvals , v3.needed_approvals); + assert_eq!(v2.relay_vrf_modulo_samples , v3.relay_vrf_modulo_samples); + assert_eq!(v2.pvf_checking_enabled , v3.pvf_checking_enabled); + assert_eq!(v2.pvf_voting_ttl , v3.pvf_voting_ttl); + assert_eq!(v2.minimum_validation_upgrade_delay , v3.minimum_validation_upgrade_delay); + + assert_eq!(v2.ump_service_total_weight, OldWeight(v3.ump_service_total_weight.ref_time())); + assert_eq!(v2.ump_max_individual_weight, OldWeight(v3.ump_max_individual_weight.ref_time())); + assert_eq!(v3.ump_service_total_weight.proof_size(), MAX_POV_SIZE as u64); + assert_eq!(v3.ump_max_individual_weight.proof_size(), MAX_POV_SIZE as u64); + }; // ; makes this a statement. `rustfmt::skip` cannot be put on an expression. + }); + } +} diff --git a/runtime/parachains/src/configuration/tests.rs b/runtime/parachains/src/configuration/tests.rs index f4f13b80bf78..6f2faf6cb204 100644 --- a/runtime/parachains/src/configuration/tests.rs +++ b/runtime/parachains/src/configuration/tests.rs @@ -15,7 +15,7 @@ // along with Polkadot. If not, see . use super::*; -use crate::mock::{new_test_ext, Configuration, Origin, ParasShared, Test}; +use crate::mock::{new_test_ext, Configuration, ParasShared, RuntimeOrigin, Test}; use frame_support::{assert_err, assert_ok}; fn on_new_session(session_index: SessionIndex) -> (HostConfiguration, HostConfiguration) { @@ -48,7 +48,7 @@ fn initializer_on_new_session() { new_test_ext(Default::default()).execute_with(|| { let (prev_config, new_config) = on_new_session(1); assert_eq!(prev_config, new_config); - assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); + assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100)); let (prev_config, new_config) = on_new_session(2); assert_eq!(prev_config, new_config); @@ -67,7 +67,7 @@ fn config_changes_after_2_session_boundary() { config.validation_upgrade_delay = 100; assert!(old_config != config); - assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); + assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100)); // Verify that the current configuration has not changed and that there is a scheduled // change for the SESSION_DELAY sessions in advance. @@ -96,8 +96,8 @@ fn consecutive_changes_within_one_session() { config.validation_upgrade_cooldown = 100; assert!(old_config != config); - assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); - assert_ok!(Configuration::set_validation_upgrade_cooldown(Origin::root(), 100)); + assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100)); + assert_ok!(Configuration::set_validation_upgrade_cooldown(RuntimeOrigin::root(), 100)); assert_eq!(Configuration::config(), old_config); assert_eq!(::PendingConfigs::get(), vec![(2, config.clone())]); @@ -125,7 +125,7 @@ fn pending_next_session_but_we_upgrade_once_more() { ..initial_config.clone() }; - assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); + assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100)); assert_eq!(Configuration::config(), initial_config); assert_eq!( ::PendingConfigs::get(), @@ -136,7 +136,7 @@ fn pending_next_session_but_we_upgrade_once_more() { // We are still waiting until the pending configuration is applied and we add another // update. - assert_ok!(Configuration::set_validation_upgrade_cooldown(Origin::root(), 99)); + assert_ok!(Configuration::set_validation_upgrade_cooldown(RuntimeOrigin::root(), 99)); // This should result in yet another configiguration change scheduled. assert_eq!(Configuration::config(), initial_config); @@ -173,7 +173,7 @@ fn scheduled_session_config_update_while_next_session_pending() { ..initial_config.clone() }; - assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); + assert_ok!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 100)); assert_eq!(Configuration::config(), initial_config); assert_eq!( ::PendingConfigs::get(), @@ -184,8 +184,8 @@ fn scheduled_session_config_update_while_next_session_pending() { // The second call should fall into the case where we already have a pending config // update for the scheduled_session, but we want to update it once more. - assert_ok!(Configuration::set_validation_upgrade_cooldown(Origin::root(), 99)); - assert_ok!(Configuration::set_code_retention_period(Origin::root(), 98)); + assert_ok!(Configuration::set_validation_upgrade_cooldown(RuntimeOrigin::root(), 99)); + assert_ok!(Configuration::set_code_retention_period(RuntimeOrigin::root(), 98)); // This should result in yet another configiguration change scheduled. assert_eq!(Configuration::config(), initial_config); @@ -213,30 +213,30 @@ fn scheduled_session_config_update_while_next_session_pending() { fn invariants() { new_test_ext(Default::default()).execute_with(|| { assert_err!( - Configuration::set_max_code_size(Origin::root(), MAX_CODE_SIZE + 1), + Configuration::set_max_code_size(RuntimeOrigin::root(), MAX_CODE_SIZE + 1), Error::::InvalidNewValue ); assert_err!( - Configuration::set_max_pov_size(Origin::root(), MAX_POV_SIZE + 1), + Configuration::set_max_pov_size(RuntimeOrigin::root(), MAX_POV_SIZE + 1), Error::::InvalidNewValue ); assert_err!( - Configuration::set_max_head_data_size(Origin::root(), MAX_HEAD_DATA_SIZE + 1), + Configuration::set_max_head_data_size(RuntimeOrigin::root(), MAX_HEAD_DATA_SIZE + 1), Error::::InvalidNewValue ); assert_err!( - Configuration::set_chain_availability_period(Origin::root(), 0), + Configuration::set_chain_availability_period(RuntimeOrigin::root(), 0), Error::::InvalidNewValue ); assert_err!( - Configuration::set_thread_availability_period(Origin::root(), 0), + Configuration::set_thread_availability_period(RuntimeOrigin::root(), 0), Error::::InvalidNewValue ); assert_err!( - Configuration::set_no_show_slots(Origin::root(), 0), + Configuration::set_no_show_slots(RuntimeOrigin::root(), 0), Error::::InvalidNewValue ); @@ -247,20 +247,20 @@ fn invariants() { ..Default::default() }); assert_err!( - Configuration::set_chain_availability_period(Origin::root(), 12), + Configuration::set_chain_availability_period(RuntimeOrigin::root(), 12), Error::::InvalidNewValue ); assert_err!( - Configuration::set_thread_availability_period(Origin::root(), 12), + Configuration::set_thread_availability_period(RuntimeOrigin::root(), 12), Error::::InvalidNewValue ); assert_err!( - Configuration::set_minimum_validation_upgrade_delay(Origin::root(), 9), + Configuration::set_minimum_validation_upgrade_delay(RuntimeOrigin::root(), 9), Error::::InvalidNewValue ); assert_err!( - Configuration::set_validation_upgrade_delay(Origin::root(), 0), + Configuration::set_validation_upgrade_delay(RuntimeOrigin::root(), 0), Error::::InvalidNewValue ); }); @@ -270,12 +270,12 @@ fn invariants() { fn consistency_bypass_works() { new_test_ext(Default::default()).execute_with(|| { assert_err!( - Configuration::set_max_code_size(Origin::root(), MAX_CODE_SIZE + 1), + Configuration::set_max_code_size(RuntimeOrigin::root(), MAX_CODE_SIZE + 1), Error::::InvalidNewValue ); - assert_ok!(Configuration::set_bypass_consistency_check(Origin::root(), true)); - assert_ok!(Configuration::set_max_code_size(Origin::root(), MAX_CODE_SIZE + 1)); + assert_ok!(Configuration::set_bypass_consistency_check(RuntimeOrigin::root(), true)); + assert_ok!(Configuration::set_max_code_size(RuntimeOrigin::root(), MAX_CODE_SIZE + 1)); assert_eq!( Configuration::config().max_code_size, @@ -319,7 +319,7 @@ fn setting_pending_config_members() { max_upward_queue_count: 1337, max_upward_queue_size: 228, max_downward_message_size: 2048, - ump_service_total_weight: 20000, + ump_service_total_weight: Weight::from_ref_time(20000), max_upward_message_size: 448, max_upward_message_num_per_candidate: 5, hrmp_sender_deposit: 22, @@ -332,172 +332,193 @@ fn setting_pending_config_members() { hrmp_max_parachain_outbound_channels: 10, hrmp_max_parathread_outbound_channels: 20, hrmp_max_message_num_per_candidate: 20, - ump_max_individual_weight: 909, + ump_max_individual_weight: Weight::from_ref_time(909), pvf_checking_enabled: true, pvf_voting_ttl: 3, minimum_validation_upgrade_delay: 20, }; Configuration::set_validation_upgrade_cooldown( - Origin::root(), + RuntimeOrigin::root(), new_config.validation_upgrade_cooldown, ) .unwrap(); Configuration::set_validation_upgrade_delay( - Origin::root(), + RuntimeOrigin::root(), new_config.validation_upgrade_delay, ) .unwrap(); - Configuration::set_code_retention_period(Origin::root(), new_config.code_retention_period) + Configuration::set_code_retention_period( + RuntimeOrigin::root(), + new_config.code_retention_period, + ) + .unwrap(); + Configuration::set_max_code_size(RuntimeOrigin::root(), new_config.max_code_size).unwrap(); + Configuration::set_max_pov_size(RuntimeOrigin::root(), new_config.max_pov_size).unwrap(); + Configuration::set_max_head_data_size(RuntimeOrigin::root(), new_config.max_head_data_size) .unwrap(); - Configuration::set_max_code_size(Origin::root(), new_config.max_code_size).unwrap(); - Configuration::set_max_pov_size(Origin::root(), new_config.max_pov_size).unwrap(); - Configuration::set_max_head_data_size(Origin::root(), new_config.max_head_data_size) + Configuration::set_parathread_cores(RuntimeOrigin::root(), new_config.parathread_cores) .unwrap(); - Configuration::set_parathread_cores(Origin::root(), new_config.parathread_cores).unwrap(); - Configuration::set_parathread_retries(Origin::root(), new_config.parathread_retries) + Configuration::set_parathread_retries(RuntimeOrigin::root(), new_config.parathread_retries) .unwrap(); Configuration::set_group_rotation_frequency( - Origin::root(), + RuntimeOrigin::root(), new_config.group_rotation_frequency, ) .unwrap(); // This comes out of order to satisfy the validity criteria for the chain and thread // availability periods. Configuration::set_minimum_validation_upgrade_delay( - Origin::root(), + RuntimeOrigin::root(), new_config.minimum_validation_upgrade_delay, ) .unwrap(); Configuration::set_chain_availability_period( - Origin::root(), + RuntimeOrigin::root(), new_config.chain_availability_period, ) .unwrap(); Configuration::set_thread_availability_period( - Origin::root(), + RuntimeOrigin::root(), new_config.thread_availability_period, ) .unwrap(); - Configuration::set_scheduling_lookahead(Origin::root(), new_config.scheduling_lookahead) - .unwrap(); + Configuration::set_scheduling_lookahead( + RuntimeOrigin::root(), + new_config.scheduling_lookahead, + ) + .unwrap(); Configuration::set_max_validators_per_core( - Origin::root(), + RuntimeOrigin::root(), new_config.max_validators_per_core, ) .unwrap(); - Configuration::set_max_validators(Origin::root(), new_config.max_validators).unwrap(); - Configuration::set_dispute_period(Origin::root(), new_config.dispute_period).unwrap(); + Configuration::set_max_validators(RuntimeOrigin::root(), new_config.max_validators) + .unwrap(); + Configuration::set_dispute_period(RuntimeOrigin::root(), new_config.dispute_period) + .unwrap(); Configuration::set_dispute_post_conclusion_acceptance_period( - Origin::root(), + RuntimeOrigin::root(), new_config.dispute_post_conclusion_acceptance_period, ) .unwrap(); Configuration::set_dispute_max_spam_slots( - Origin::root(), + RuntimeOrigin::root(), new_config.dispute_max_spam_slots, ) .unwrap(); Configuration::set_dispute_conclusion_by_time_out_period( - Origin::root(), + RuntimeOrigin::root(), new_config.dispute_conclusion_by_time_out_period, ) .unwrap(); - Configuration::set_no_show_slots(Origin::root(), new_config.no_show_slots).unwrap(); - Configuration::set_n_delay_tranches(Origin::root(), new_config.n_delay_tranches).unwrap(); + Configuration::set_no_show_slots(RuntimeOrigin::root(), new_config.no_show_slots).unwrap(); + Configuration::set_n_delay_tranches(RuntimeOrigin::root(), new_config.n_delay_tranches) + .unwrap(); Configuration::set_zeroth_delay_tranche_width( - Origin::root(), + RuntimeOrigin::root(), new_config.zeroth_delay_tranche_width, ) .unwrap(); - Configuration::set_needed_approvals(Origin::root(), new_config.needed_approvals).unwrap(); + Configuration::set_needed_approvals(RuntimeOrigin::root(), new_config.needed_approvals) + .unwrap(); Configuration::set_relay_vrf_modulo_samples( - Origin::root(), + RuntimeOrigin::root(), new_config.relay_vrf_modulo_samples, ) .unwrap(); Configuration::set_max_upward_queue_count( - Origin::root(), + RuntimeOrigin::root(), new_config.max_upward_queue_count, ) .unwrap(); - Configuration::set_max_upward_queue_size(Origin::root(), new_config.max_upward_queue_size) - .unwrap(); + Configuration::set_max_upward_queue_size( + RuntimeOrigin::root(), + new_config.max_upward_queue_size, + ) + .unwrap(); Configuration::set_max_downward_message_size( - Origin::root(), + RuntimeOrigin::root(), new_config.max_downward_message_size, ) .unwrap(); Configuration::set_ump_service_total_weight( - Origin::root(), + RuntimeOrigin::root(), new_config.ump_service_total_weight, ) .unwrap(); Configuration::set_max_upward_message_size( - Origin::root(), + RuntimeOrigin::root(), new_config.max_upward_message_size, ) .unwrap(); Configuration::set_max_upward_message_num_per_candidate( - Origin::root(), + RuntimeOrigin::root(), new_config.max_upward_message_num_per_candidate, ) .unwrap(); - Configuration::set_hrmp_sender_deposit(Origin::root(), new_config.hrmp_sender_deposit) - .unwrap(); + Configuration::set_hrmp_sender_deposit( + RuntimeOrigin::root(), + new_config.hrmp_sender_deposit, + ) + .unwrap(); Configuration::set_hrmp_recipient_deposit( - Origin::root(), + RuntimeOrigin::root(), new_config.hrmp_recipient_deposit, ) .unwrap(); Configuration::set_hrmp_channel_max_capacity( - Origin::root(), + RuntimeOrigin::root(), new_config.hrmp_channel_max_capacity, ) .unwrap(); Configuration::set_hrmp_channel_max_total_size( - Origin::root(), + RuntimeOrigin::root(), new_config.hrmp_channel_max_total_size, ) .unwrap(); Configuration::set_hrmp_max_parachain_inbound_channels( - Origin::root(), + RuntimeOrigin::root(), new_config.hrmp_max_parachain_inbound_channels, ) .unwrap(); Configuration::set_hrmp_max_parathread_inbound_channels( - Origin::root(), + RuntimeOrigin::root(), new_config.hrmp_max_parathread_inbound_channels, ) .unwrap(); Configuration::set_hrmp_channel_max_message_size( - Origin::root(), + RuntimeOrigin::root(), new_config.hrmp_channel_max_message_size, ) .unwrap(); Configuration::set_hrmp_max_parachain_outbound_channels( - Origin::root(), + RuntimeOrigin::root(), new_config.hrmp_max_parachain_outbound_channels, ) .unwrap(); Configuration::set_hrmp_max_parathread_outbound_channels( - Origin::root(), + RuntimeOrigin::root(), new_config.hrmp_max_parathread_outbound_channels, ) .unwrap(); Configuration::set_hrmp_max_message_num_per_candidate( - Origin::root(), + RuntimeOrigin::root(), new_config.hrmp_max_message_num_per_candidate, ) .unwrap(); Configuration::set_ump_max_individual_weight( - Origin::root(), + RuntimeOrigin::root(), new_config.ump_max_individual_weight, ) .unwrap(); - Configuration::set_pvf_checking_enabled(Origin::root(), new_config.pvf_checking_enabled) + Configuration::set_pvf_checking_enabled( + RuntimeOrigin::root(), + new_config.pvf_checking_enabled, + ) + .unwrap(); + Configuration::set_pvf_voting_ttl(RuntimeOrigin::root(), new_config.pvf_voting_ttl) .unwrap(); - Configuration::set_pvf_voting_ttl(Origin::root(), new_config.pvf_voting_ttl).unwrap(); assert_eq!( ::PendingConfigs::get(), @@ -509,7 +530,7 @@ fn setting_pending_config_members() { #[test] fn non_root_cannot_set_config() { new_test_ext(Default::default()).execute_with(|| { - assert!(Configuration::set_validation_upgrade_delay(Origin::signed(1), 100).is_err()); + assert!(Configuration::set_validation_upgrade_delay(RuntimeOrigin::signed(1), 100).is_err()); }); } diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 9d76b26ec6f9..b9b562954851 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -39,6 +39,7 @@ use sp_std::{cmp::Ordering, prelude::*}; #[allow(unused_imports)] pub(crate) use self::tests::run_to_block; +pub mod slashing; #[cfg(test)] mod tests; @@ -73,35 +74,55 @@ impl RewardValidators for () { } /// Punishment hooks for disputes. -pub trait PunishValidators { - /// Punish a series of validators who were for an invalid parablock. This is expected to be a major - /// punishment. +pub trait SlashingHandler { + /// Punish a series of validators who were for an invalid parablock. This is + /// expected to be a major punishment. fn punish_for_invalid( session: SessionIndex, - validators: impl IntoIterator, + candidate_hash: CandidateHash, + losers: impl IntoIterator, ); - /// Punish a series of validators who were against a valid parablock. This is expected to be a minor - /// punishment. + /// Punish a series of validators who were against a valid parablock. This + /// is expected to be a minor punishment. fn punish_against_valid( session: SessionIndex, - validators: impl IntoIterator, + candidate_hash: CandidateHash, + losers: impl IntoIterator, ); - /// Punish a series of validators who were part of a dispute which never concluded. This is expected - /// to be a minor punishment. - fn punish_inconclusive( - session: SessionIndex, - validators: impl IntoIterator, - ); + /// Called by the initializer to initialize the slashing pallet. + fn initializer_initialize(now: BlockNumber) -> Weight; + + /// Called by the initializer to finalize the slashing pallet. + fn initializer_finalize(); + + /// Called by the initializer to note that a new session has started. + fn initializer_on_new_session(session_index: SessionIndex); } -impl PunishValidators for () { - fn punish_for_invalid(_: SessionIndex, _: impl IntoIterator) {} +impl SlashingHandler for () { + fn punish_for_invalid( + _: SessionIndex, + _: CandidateHash, + _: impl IntoIterator, + ) { + } + + fn punish_against_valid( + _: SessionIndex, + _: CandidateHash, + _: impl IntoIterator, + ) { + } - fn punish_against_valid(_: SessionIndex, _: impl IntoIterator) {} + fn initializer_initialize(_now: BlockNumber) -> Weight { + Weight::zero() + } + + fn initializer_finalize() {} - fn punish_inconclusive(_: SessionIndex, _: impl IntoIterator) {} + fn initializer_on_new_session(_: SessionIndex) {} } /// Binary discriminator to determine if the expensive signature @@ -322,7 +343,7 @@ impl DisputesHandler for () { } fn initializer_initialize(_now: BlockNumber) -> Weight { - 0 + Weight::zero() } fn initializer_finalize() {} @@ -398,7 +419,7 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn force_unfreeze() -> Weight { - 0 + Weight::zero() } } @@ -410,9 +431,9 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + configuration::Config + session_info::Config { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RewardValidators: RewardValidators; - type PunishValidators: PunishValidators; + type SlashingHandler: SlashingHandler; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -797,7 +818,7 @@ impl Pallet { pub(crate) fn initializer_initialize(now: T::BlockNumber) -> Weight { let config = >::config(); - let mut weight = 0; + let mut weight = Weight::zero(); for (session_index, candidate_hash, mut dispute) in >::iter() { weight += T::DbWeight::get().reads_writes(1, 0); @@ -831,14 +852,7 @@ impl Pallet { // it would be unexpected for any change here to occur when the dispute has not concluded // in time, as a dispute guaranteed to have at least one honest participant should // conclude quickly. - let participating = decrement_spam(spam_slots, &dispute); - - // Slight punishment as these validators have failed to make data available to - // others in a timely manner. - T::PunishValidators::punish_inconclusive( - session_index, - participating.iter_ones().map(|i| ValidatorIndex(i as _)), - ); + let _participating = decrement_spam(spam_slots, &dispute); }); weight += T::DbWeight::get().reads_writes(2, 2); @@ -1187,7 +1201,9 @@ impl Pallet { Error::::SingleSidedDispute, ); - let DisputeStatementSet { session, candidate_hash, .. } = set.clone(); + let DisputeStatementSet { ref session, ref candidate_hash, .. } = set; + let session = *session; + let candidate_hash = *candidate_hash; // we can omit spam slot checks, `fn filter_disputes_data` is // always called before calling this `fn`. @@ -1227,10 +1243,14 @@ impl Pallet { // Slash participants on a losing side. { // a valid candidate, according to 2/3. Punish those on the 'against' side. - T::PunishValidators::punish_against_valid(session, summary.slash_against); + T::SlashingHandler::punish_against_valid( + session, + candidate_hash, + summary.slash_against, + ); // an invalid candidate, according to 2/3. Punish those on the 'for' side. - T::PunishValidators::punish_for_invalid(session, summary.slash_for); + T::SlashingHandler::punish_for_invalid(session, candidate_hash, summary.slash_for); } >::insert(&session, &candidate_hash, &summary.state); diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs new file mode 100644 index 000000000000..fd6708de6ba0 --- /dev/null +++ b/runtime/parachains/src/disputes/slashing.rs @@ -0,0 +1,739 @@ +// Copyright 2022 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 . + +//! Dispute slashing pallet. +//! +//! Once a dispute is concluded, we want to slash validators +//! who were on the wrong side of the dispute. The slashing amount +//! depends on whether the candidate was valid (small) or invalid (big). +//! In addition to that, we might want to kick out the validators from the +//! active set. +//! +//! The `offences` pallet from Substrate provides us with a way to do both. +//! Currently, the interface expects us to provide staking information +//! including nominator exposure in order to submit an offence. +//! +//! Normally, we'd able to fetch this information from the runtime as soon as +//! the dispute is concluded. This is also what `im-online` pallet does. +//! However, since a dispute can conclude several sessions after the candidate +//! was backed (see `dispute_period` in `HostConfiguration`), we can't rely on +//! this information be available in the context of the current block. The +//! `babe` and `grandpa` equivocation handlers also have to deal +//! with this problem. +//! +//! Our implementation looks like a hybrid of `im-online` and `grandpa` +//! equivocation handlers. Meaning, we submit an `offence` for the concluded +//! disputes about the current session candidate directly from the runtime. +//! If, however, the dispute is about a past session, we record unapplied +//! slashes on chain, without `FullIdentification` of the offenders. +//! Later on, a block producer can submit an unsigned transaction with +//! `KeyOwnershipProof` of an offender and submit it to the runtime +//! to produce an offence. + +use crate::{disputes, initializer::ValidatorSetCount, session_info::IdentificationTuple}; +use frame_support::{ + dispatch::Pays, + traits::{Defensive, Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification}, + weights::Weight, +}; + +use parity_scale_codec::{Decode, Encode}; +use primitives::v2::{CandidateHash, SessionIndex, ValidatorId, ValidatorIndex}; +use scale_info::TypeInfo; +use sp_runtime::{ + traits::Convert, + transaction_validity::{ + InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity, + TransactionValidityError, ValidTransaction, + }, + DispatchResult, KeyTypeId, Perbill, RuntimeDebug, +}; +use sp_session::{GetSessionNumber, GetValidatorCount}; +use sp_staking::offence::{DisableStrategy, Kind, Offence, OffenceError, ReportOffence}; +use sp_std::{ + collections::btree_map::{BTreeMap, Entry}, + prelude::*, +}; + +const LOG_TARGET: &str = "runtime::parachains::slashing"; + +// These are constants, but we want to make them configurable +// via `HostConfiguration` in the future. +const SLASH_FOR_INVALID: Perbill = Perbill::from_percent(100); +const SLASH_AGAINST_VALID: Perbill = Perbill::from_perthousand(1); +const DEFENSIVE_PROOF: &'static str = "disputes module should bail on old session"; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; + +/// The benchmarking configuration. +pub trait BenchmarkingConfiguration { + const MAX_VALIDATORS: u32; +} + +pub struct BenchConfig; + +impl BenchmarkingConfiguration for BenchConfig { + const MAX_VALIDATORS: u32 = M; +} + +/// Timeslots should uniquely identify offences and are used for the offence +/// deduplication. +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Encode, Decode, TypeInfo, RuntimeDebug)] +pub struct DisputesTimeSlot { + // The order of these matters for `derive(Ord)`. + session_index: SessionIndex, + candidate_hash: CandidateHash, +} + +impl DisputesTimeSlot { + pub fn new(session_index: SessionIndex, candidate_hash: CandidateHash) -> Self { + Self { session_index, candidate_hash } + } +} + +/// An offence that is filed when a series of validators lost a dispute. +#[derive(RuntimeDebug, TypeInfo)] +#[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))] +pub struct SlashingOffence { + /// The size of the validator set in that session. + pub validator_set_count: ValidatorSetCount, + /// Should be unique per dispute. + pub time_slot: DisputesTimeSlot, + /// Staking information about the validators that lost the dispute + /// needed for slashing. + pub offenders: Vec, + /// What fraction of the total exposure that should be slashed for + /// this offence. + pub slash_fraction: Perbill, + /// Whether the candidate was valid or invalid. + pub kind: SlashingOffenceKind, +} + +impl Offence for SlashingOffence +where + Offender: Clone, +{ + const ID: Kind = *b"disputes:slashin"; + + type TimeSlot = DisputesTimeSlot; + + fn offenders(&self) -> Vec { + self.offenders.clone() + } + + fn session_index(&self) -> SessionIndex { + self.time_slot.session_index + } + + fn validator_set_count(&self) -> ValidatorSetCount { + self.validator_set_count + } + + fn time_slot(&self) -> Self::TimeSlot { + self.time_slot.clone() + } + + fn disable_strategy(&self) -> DisableStrategy { + match self.kind { + SlashingOffenceKind::ForInvalid => DisableStrategy::Always, + // in the future we might change it based on number of disputes initiated: + // + SlashingOffenceKind::AgainstValid => DisableStrategy::Never, + } + } + + fn slash_fraction(&self, _offenders: u32) -> Perbill { + self.slash_fraction + } +} + +impl SlashingOffence { + fn new( + session_index: SessionIndex, + candidate_hash: CandidateHash, + validator_set_count: ValidatorSetCount, + offenders: Vec, + kind: SlashingOffenceKind, + ) -> Self { + let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); + let slash_fraction = match kind { + SlashingOffenceKind::ForInvalid => SLASH_FOR_INVALID, + SlashingOffenceKind::AgainstValid => SLASH_AGAINST_VALID, + }; + Self { time_slot, validator_set_count, offenders, slash_fraction, kind } + } +} + +/// This type implements `SlashingHandler`. +pub struct SlashValidatorsForDisputes { + _phantom: sp_std::marker::PhantomData, +} + +impl Default for SlashValidatorsForDisputes { + fn default() -> Self { + Self { _phantom: Default::default() } + } +} + +impl SlashValidatorsForDisputes> +where + T: Config>, +{ + /// If in the current session, returns the identified validators. `None` + /// otherwise. + fn maybe_identify_validators( + session_index: SessionIndex, + validators: impl IntoIterator, + ) -> Option>> { + // We use `ValidatorSet::session_index` and not + // `shared::Pallet::session_index()` because at the first block of a new era, + // the `IdentificationOf` of a validator in the previous session might be + // missing, while `shared` pallet would return the same session index as being + // updated at the end of the block. + let current_session = T::ValidatorSet::session_index(); + if session_index == current_session { + let account_keys = crate::session_info::Pallet::::account_keys(session_index); + let account_ids = account_keys.defensive_unwrap_or_default(); + + let fully_identified = validators + .into_iter() + .flat_map(|i| account_ids.get(i.0 as usize).cloned()) + .filter_map(|id| { + >::IdentificationOf::convert( + id.clone() + ).map(|full_id| (id, full_id)) + }) + .collect::>>(); + return Some(fully_identified) + } + None + } + + fn do_punish( + session_index: SessionIndex, + candidate_hash: CandidateHash, + kind: SlashingOffenceKind, + losers: impl IntoIterator, + ) { + let losers: Vec = losers.into_iter().collect(); + if losers.is_empty() { + // Nothing to do + return + } + let session_info = crate::session_info::Pallet::::session_info(session_index); + let session_info = match session_info.defensive_proof(DEFENSIVE_PROOF) { + Some(info) => info, + None => return, + }; + let maybe = Self::maybe_identify_validators(session_index, losers.iter().cloned()); + if let Some(offenders) = maybe { + let validator_set_count = session_info.discovery_keys.len() as ValidatorSetCount; + let offence = SlashingOffence::new( + session_index, + candidate_hash, + validator_set_count, + offenders, + kind, + ); + // This is the first time we report an offence for this dispute, + // so it is not a duplicate. + let _ = T::HandleReports::report_offence(offence); + return + } + + let keys = losers + .into_iter() + .filter_map(|i| session_info.validators.get(i.0 as usize).cloned().map(|id| (i, id))) + .collect(); + let unapplied = PendingSlashes { keys, kind }; + >::insert(session_index, candidate_hash, unapplied); + } +} + +impl disputes::SlashingHandler for SlashValidatorsForDisputes> +where + T: Config>, +{ + fn punish_for_invalid( + session_index: SessionIndex, + candidate_hash: CandidateHash, + losers: impl IntoIterator, + ) { + let kind = SlashingOffenceKind::ForInvalid; + Self::do_punish(session_index, candidate_hash, kind, losers); + } + + fn punish_against_valid( + session_index: SessionIndex, + candidate_hash: CandidateHash, + losers: impl IntoIterator, + ) { + let kind = SlashingOffenceKind::AgainstValid; + Self::do_punish(session_index, candidate_hash, kind, losers); + } + + fn initializer_initialize(now: T::BlockNumber) -> Weight { + Pallet::::initializer_initialize(now) + } + + fn initializer_finalize() { + Pallet::::initializer_finalize() + } + + fn initializer_on_new_session(session_index: SessionIndex) { + Pallet::::initializer_on_new_session(session_index) + } +} + +#[derive(PartialEq, Eq, Clone, Copy, Encode, Decode, RuntimeDebug, TypeInfo)] +pub enum SlashingOffenceKind { + #[codec(index = 0)] + ForInvalid, + #[codec(index = 1)] + AgainstValid, +} + +/// We store most of the information about a lost dispute on chain. This struct +/// is required to identify and verify it. +#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] +pub struct DisputeProof { + /// Time slot when the dispute occured. + pub time_slot: DisputesTimeSlot, + /// The dispute outcome. + pub kind: SlashingOffenceKind, + /// The index of the validator who lost a dispute. + pub validator_index: ValidatorIndex, + /// The parachain session key of the validator. + pub validator_id: ValidatorId, +} + +/// Slashes that are waiting to be applied once we have validator key +/// identification. +#[derive(Encode, Decode, RuntimeDebug, TypeInfo)] +pub struct PendingSlashes { + /// Indices and keys of the validators who lost a dispute and are pending + /// slashes. + pub keys: BTreeMap, + /// The dispute outcome. + pub kind: SlashingOffenceKind, +} + +/// A trait that defines methods to report an offence (after the slashing report +/// has been validated) and for submitting a transaction to report a slash (from +/// an offchain context). +pub trait HandleReports { + /// The longevity, in blocks, that the offence report is valid for. When + /// using the staking pallet this should be equal to the bonding duration + /// (in blocks, not eras). + type ReportLongevity: Get; + + /// Report an offence. + fn report_offence( + offence: SlashingOffence, + ) -> Result<(), OffenceError>; + + /// Returns true if the offenders at the given time slot has already been + /// reported. + fn is_known_offence( + offenders: &[T::KeyOwnerIdentification], + time_slot: &DisputesTimeSlot, + ) -> bool; + + /// Create and dispatch a slashing report extrinsic. + /// This should be called offchain. + fn submit_unsigned_slashing_report( + dispute_proof: DisputeProof, + key_owner_proof: T::KeyOwnerProof, + ) -> DispatchResult; +} + +impl HandleReports for () { + type ReportLongevity = (); + + fn report_offence( + _offence: SlashingOffence, + ) -> Result<(), OffenceError> { + Ok(()) + } + + fn is_known_offence( + _offenders: &[T::KeyOwnerIdentification], + _time_slot: &DisputesTimeSlot, + ) -> bool { + true + } + + fn submit_unsigned_slashing_report( + _dispute_proof: DisputeProof, + _key_owner_proof: T::KeyOwnerProof, + ) -> DispatchResult { + Ok(()) + } +} + +pub trait WeightInfo { + fn report_dispute_lost(validator_count: ValidatorSetCount) -> Weight; +} + +pub struct TestWeightInfo; +impl WeightInfo for TestWeightInfo { + fn report_dispute_lost(_validator_count: ValidatorSetCount) -> Weight { + Weight::zero() + } +} + +pub use pallet::*; +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config + crate::disputes::Config { + /// The proof of key ownership, used for validating slashing reports. + /// The proof must include the session index and validator count of the + /// session at which the offence occurred. + type KeyOwnerProof: Parameter + GetSessionNumber + GetValidatorCount; + + /// The identification of a key owner, used when reporting slashes. + type KeyOwnerIdentification: Parameter; + + /// A system for proving ownership of keys, i.e. that a given key was + /// part of a validator set, needed for validating slashing reports. + type KeyOwnerProofSystem: KeyOwnerProofSystem< + (KeyTypeId, ValidatorId), + Proof = Self::KeyOwnerProof, + IdentificationTuple = Self::KeyOwnerIdentification, + >; + + /// The slashing report handling subsystem, defines methods to report an + /// offence (after the slashing report has been validated) and for + /// submitting a transaction to report a slash (from an offchain + /// context). NOTE: when enabling slashing report handling (i.e. this + /// type isn't set to `()`) you must use this pallet's + /// `ValidateUnsigned` in the runtime definition. + type HandleReports: HandleReports; + + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; + + /// Benchmarking configuration. + type BenchmarkingConfig: BenchmarkingConfiguration; + } + + #[pallet::pallet] + #[pallet::without_storage_info] + pub struct Pallet(_); + + /// Validators pending dispute slashes. + #[pallet::storage] + pub(super) type UnappliedSlashes = StorageDoubleMap< + _, + Twox64Concat, + SessionIndex, + Blake2_128Concat, + CandidateHash, + PendingSlashes, + >; + + /// `ValidatorSetCount` per session. + #[pallet::storage] + pub(super) type ValidatorSetCounts = + StorageMap<_, Twox64Concat, SessionIndex, ValidatorSetCount>; + + #[pallet::error] + pub enum Error { + /// The key ownership proof is invalid. + InvalidKeyOwnershipProof, + /// The session index is too old or invalid. + InvalidSessionIndex, + /// The candidate hash is invalid. + InvalidCandidateHash, + /// There is no pending slash for the given validator index and time + /// slot. + InvalidValidatorIndex, + /// The validator index does not match the validator id. + ValidatorIndexIdMismatch, + /// The given slashing report is valid but already previously reported. + DuplicateSlashingReport, + } + + #[pallet::call] + impl Pallet { + #[pallet::weight(::WeightInfo::report_dispute_lost( + key_owner_proof.validator_count() + ))] + pub fn report_dispute_lost_unsigned( + origin: OriginFor, + // box to decrease the size of the call + dispute_proof: Box, + key_owner_proof: T::KeyOwnerProof, + ) -> DispatchResultWithPostInfo { + ensure_none(origin)?; + + // check the membership proof to extract the offender's id + let key = (primitives::v2::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); + let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof) + .ok_or(Error::::InvalidKeyOwnershipProof)?; + + let session_index = dispute_proof.time_slot.session_index; + let validator_set_count = crate::session_info::Pallet::::session_info(session_index) + .ok_or(Error::::InvalidSessionIndex)? + .discovery_keys + .len() as ValidatorSetCount; + + // check that there is a pending slash for the given + // validator index and candidate hash + let candidate_hash = dispute_proof.time_slot.candidate_hash; + let try_remove = |v: &mut Option| -> Result<(), DispatchError> { + let pending = v.as_mut().ok_or(Error::::InvalidCandidateHash)?; + if pending.kind != dispute_proof.kind { + return Err(Error::::InvalidCandidateHash.into()) + } + + match pending.keys.entry(dispute_proof.validator_index) { + Entry::Vacant(_) => return Err(Error::::InvalidValidatorIndex.into()), + // check that `validator_index` matches `validator_id` + Entry::Occupied(e) if e.get() != &dispute_proof.validator_id => + return Err(Error::::ValidatorIndexIdMismatch.into()), + Entry::Occupied(e) => { + e.remove(); // the report is correct + }, + } + + // if the last validator is slashed for this dispute, clean up the storage + if pending.keys.is_empty() { + *v = None; + } + + Ok(()) + }; + + >::try_mutate_exists(&session_index, &candidate_hash, try_remove)?; + + let offence = SlashingOffence::new( + session_index, + candidate_hash, + validator_set_count, + vec![offender], + dispute_proof.kind, + ); + + >::report_offence(offence) + .map_err(|_| Error::::DuplicateSlashingReport)?; + + Ok(Pays::No.into()) + } + } + + #[pallet::validate_unsigned] + impl ValidateUnsigned for Pallet { + type Call = Call; + fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { + Self::validate_unsigned(source, call) + } + + fn pre_dispatch(call: &Self::Call) -> Result<(), TransactionValidityError> { + Self::pre_dispatch(call) + } + } +} + +impl Pallet { + /// Called by the initializer to initialize the disputes slashing module. + fn initializer_initialize(_now: T::BlockNumber) -> Weight { + Weight::zero() + } + + /// Called by the initializer to finalize the disputes slashing pallet. + fn initializer_finalize() {} + + /// Called by the initializer to note a new session in the disputes slashing + /// pallet. + fn initializer_on_new_session(session_index: SessionIndex) { + // This should be small, as disputes are limited by spam slots, so no limit is + // fine. + const REMOVE_LIMIT: u32 = u32::MAX; + + let config = >::config(); + if session_index <= config.dispute_period + 1 { + return + } + + let old_session = session_index - config.dispute_period - 1; + let _ = >::clear_prefix(old_session, REMOVE_LIMIT, None); + } +} + +/// Methods for the `ValidateUnsigned` implementation: +/// +/// It restricts calls to `report_dispute_lost_unsigned` to local calls (i.e. +/// extrinsics generated on this node) or that already in a block. This +/// guarantees that only block authors can include unsigned slashing reports. +impl Pallet { + pub fn validate_unsigned(source: TransactionSource, call: &Call) -> TransactionValidity { + if let Call::report_dispute_lost_unsigned { dispute_proof, key_owner_proof } = call { + // discard slashing report not coming from the local node + match source { + TransactionSource::Local | TransactionSource::InBlock => { /* allowed */ }, + _ => { + log::warn!( + target: LOG_TARGET, + "rejecting unsigned transaction because it is not local/in-block." + ); + + return InvalidTransaction::Call.into() + }, + } + + // check report staleness + is_known_offence::(dispute_proof, key_owner_proof)?; + + let longevity = >::ReportLongevity::get(); + + let tag_prefix = match dispute_proof.kind { + SlashingOffenceKind::ForInvalid => "DisputeForInvalid", + SlashingOffenceKind::AgainstValid => "DisputeAgainstValid", + }; + + ValidTransaction::with_tag_prefix(tag_prefix) + // We assign the maximum priority for any report. + .priority(TransactionPriority::max_value()) + // Only one report for the same offender at the same slot. + .and_provides((dispute_proof.time_slot.clone(), dispute_proof.validator_id.clone())) + .longevity(longevity) + // We don't propagate this. This can never be included on a remote node. + .propagate(false) + .build() + } else { + InvalidTransaction::Call.into() + } + } + + pub fn pre_dispatch(call: &Call) -> Result<(), TransactionValidityError> { + if let Call::report_dispute_lost_unsigned { dispute_proof, key_owner_proof } = call { + is_known_offence::(dispute_proof, key_owner_proof) + } else { + Err(InvalidTransaction::Call.into()) + } + } +} + +fn is_known_offence( + dispute_proof: &DisputeProof, + key_owner_proof: &T::KeyOwnerProof, +) -> Result<(), TransactionValidityError> { + // check the membership proof to extract the offender's id + let key = (primitives::v2::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); + + let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone()) + .ok_or(InvalidTransaction::BadProof)?; + + // check if the offence has already been reported, + // and if so then we can discard the report. + let is_known_offence = >::is_known_offence( + &[offender], + &dispute_proof.time_slot, + ); + + if is_known_offence { + Err(InvalidTransaction::Stale.into()) + } else { + Ok(()) + } +} + +/// Actual `HandleReports` implemention. +/// +/// When configured properly, should be instantiated with +/// `T::KeyOwnerIdentification, Offences, ReportLongevity` parameters. +pub struct SlashingReportHandler { + _phantom: sp_std::marker::PhantomData<(I, R, L)>, +} + +impl Default for SlashingReportHandler { + fn default() -> Self { + Self { _phantom: Default::default() } + } +} + +impl HandleReports for SlashingReportHandler +where + T: Config + frame_system::offchain::SendTransactionTypes>, + R: ReportOffence< + T::AccountId, + T::KeyOwnerIdentification, + SlashingOffence, + >, + L: Get, +{ + type ReportLongevity = L; + + fn report_offence( + offence: SlashingOffence, + ) -> Result<(), OffenceError> { + let reporters = Vec::new(); + R::report_offence(reporters, offence) + } + + fn is_known_offence( + offenders: &[T::KeyOwnerIdentification], + time_slot: &DisputesTimeSlot, + ) -> bool { + , + >>::is_known_offence(offenders, time_slot) + } + + fn submit_unsigned_slashing_report( + dispute_proof: DisputeProof, + key_owner_proof: ::KeyOwnerProof, + ) -> DispatchResult { + use frame_system::offchain::SubmitTransaction; + + let session_index = dispute_proof.time_slot.session_index; + let validator_index = dispute_proof.validator_index.0; + let kind = dispute_proof.kind; + + let call = Call::report_dispute_lost_unsigned { + dispute_proof: Box::new(dispute_proof), + key_owner_proof, + }; + + match SubmitTransaction::>::submit_unsigned_transaction(call.into()) { + Ok(()) => log::info!( + target: LOG_TARGET, + "Submitted dispute slashing report, session({}), index({}), kind({:?})", + session_index, + validator_index, + kind, + ), + Err(()) => log::error!( + target: LOG_TARGET, + "Error submitting dispute slashing report, session({}), index({}), kind({:?})", + session_index, + validator_index, + kind, + ), + } + + Ok(()) + } +} diff --git a/runtime/parachains/src/disputes/slashing/benchmarking.rs b/runtime/parachains/src/disputes/slashing/benchmarking.rs new file mode 100644 index 000000000000..2a21c3a0f62b --- /dev/null +++ b/runtime/parachains/src/disputes/slashing/benchmarking.rs @@ -0,0 +1,156 @@ +// Copyright 2021 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 . + +use super::*; + +use crate::{disputes::SlashingHandler, initializer, shared}; +use frame_benchmarking::{benchmarks, whitelist_account}; +use frame_support::traits::{OnFinalize, OnInitialize}; +use frame_system::RawOrigin; +use pallet_staking::testing_utils::create_validators; +use primitives::v2::{Hash, PARACHAIN_KEY_TYPE_ID}; +use sp_runtime::traits::{One, StaticLookup}; +use sp_session::MembershipProof; + +// Candidate hash of the disputed candidate. +const CANDIDATE_HASH: CandidateHash = CandidateHash(Hash::zero()); + +pub trait Config: + pallet_session::Config + + pallet_session::historical::Config + + pallet_staking::Config + + super::Config + + shared::Config + + initializer::Config +{ +} + +fn setup_validator_set(n: u32) -> (SessionIndex, MembershipProof, ValidatorId) +where + T: Config, +{ + pallet_staking::ValidatorCount::::put(n); + + let balance_factor = 1000; + // create validators and set random session keys + for (n, who) in create_validators::(n, balance_factor).unwrap().into_iter().enumerate() { + use rand::{RngCore, SeedableRng}; + + let validator = T::Lookup::lookup(who).unwrap(); + let controller = pallet_staking::Pallet::::bonded(validator).unwrap(); + + let keys = { + const NUM_SESSION_KEYS: usize = 6; + const SESSION_KEY_LEN: usize = 32; + let mut keys = [0u8; NUM_SESSION_KEYS * SESSION_KEY_LEN]; + let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(n as u64); + rng.fill_bytes(&mut keys); + keys + }; + + let keys: T::Keys = Decode::decode(&mut &keys[..]).expect("wrong number of session keys?"); + let proof: Vec = vec![]; + + whitelist_account!(controller); + pallet_session::Pallet::::set_keys(RawOrigin::Signed(controller).into(), keys, proof) + .expect("session::set_keys should work"); + } + + pallet_session::Pallet::::on_initialize(T::BlockNumber::one()); + initializer::Pallet::::on_initialize(T::BlockNumber::one()); + // skip sessions until the new validator set is enacted + while pallet_session::Pallet::::validators().len() < n as usize { + pallet_session::Pallet::::rotate_session(); + } + initializer::Pallet::::on_finalize(T::BlockNumber::one()); + + let session_index = crate::shared::Pallet::::session_index(); + let session_info = crate::session_info::Pallet::::session_info(session_index); + let session_info = session_info.unwrap(); + let validator_id = session_info.validators[0].clone(); + let key = (PARACHAIN_KEY_TYPE_ID, validator_id.clone()); + let key_owner_proof = pallet_session::historical::Pallet::::prove(key).unwrap(); + + // rotate a session to make sure `key_owner_proof` is historical + initializer::Pallet::::on_initialize(T::BlockNumber::one()); + pallet_session::Pallet::::rotate_session(); + initializer::Pallet::::on_finalize(T::BlockNumber::one()); + + let idx = crate::shared::Pallet::::session_index(); + assert!( + idx > session_index, + "session rotation should work for parachain pallets: {} <= {}", + idx, + session_index, + ); + + (session_index, key_owner_proof, validator_id) +} + +fn setup_dispute(session_index: SessionIndex, validator_id: ValidatorId) -> DisputeProof +where + T: Config, +{ + let current_session = T::ValidatorSet::session_index(); + assert_ne!(session_index, current_session); + + let validator_index = ValidatorIndex(0); + let losers = [validator_index].into_iter(); + + T::SlashingHandler::punish_against_valid(session_index, CANDIDATE_HASH, losers); + + let unapplied = >::get(session_index, CANDIDATE_HASH); + assert_eq!(unapplied.unwrap().keys.len(), 1); + + dispute_proof(session_index, validator_id, validator_index) +} + +fn dispute_proof( + session_index: SessionIndex, + validator_id: ValidatorId, + validator_index: ValidatorIndex, +) -> DisputeProof { + let kind = SlashingOffenceKind::AgainstValid; + let time_slot = DisputesTimeSlot::new(session_index, CANDIDATE_HASH); + + DisputeProof { time_slot, kind, validator_index, validator_id } +} + +benchmarks! { + where_clause { + where T: Config, + } + + // in this setup we have a single `AgainstValid` dispute + // submitted for a past session + report_dispute_lost { + let n in 4..<::BenchmarkingConfig as BenchmarkingConfiguration>::MAX_VALIDATORS; + + let origin = RawOrigin::None.into(); + let (session_index, key_owner_proof, validator_id) = setup_validator_set::(n); + let dispute_proof = setup_dispute::(session_index, validator_id); + }: { + let result = Pallet::::report_dispute_lost_unsigned( + origin, + Box::new(dispute_proof), + key_owner_proof, + ); + assert!(result.is_ok()); + } verify { + let unapplied = >::get(session_index, CANDIDATE_HASH); + assert!(unapplied.is_none()); + } +} diff --git a/runtime/parachains/src/disputes/tests.rs b/runtime/parachains/src/disputes/tests.rs index 2897ced22ed0..4d8ac714cb7b 100644 --- a/runtime/parachains/src/disputes/tests.rs +++ b/runtime/parachains/src/disputes/tests.rs @@ -20,8 +20,7 @@ use crate::{ disputes::DisputesHandler, mock::{ new_test_ext, AccountId, AllPalletsWithSystem, Initializer, MockGenesisConfig, System, - Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, PUNISH_VALIDATORS_INCONCLUSIVE, - REWARD_VALIDATORS, + Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, REWARD_VALIDATORS, }, }; use assert_matches::assert_matches; @@ -500,9 +499,9 @@ fn dispute_statement_becoming_onesided_due_to_spamslots_is_accepted() { }); } -// Test that punish_inconclusive is correctly called. +// Test that dispute timeout is handled correctly. #[test] -fn test_initializer_initialize() { +fn test_dispute_timeout() { let dispute_conclusion_by_time_out_period = 3; let start = 10; @@ -602,10 +601,6 @@ fn test_initializer_initialize() { // Run to timeout + 1 in order to executive on_finalize(timeout) run_to_block(start + dispute_conclusion_by_time_out_period + 1, |_| None); assert_eq!(SpamSlots::::get(start - 1), Some(vec![0, 0, 0, 0, 0, 0, 0])); - assert_eq!( - PUNISH_VALIDATORS_INCONCLUSIVE.with(|r| r.borrow()[0].clone()), - (9, vec![ValidatorIndex(0), ValidatorIndex(6)]), - ); }); } diff --git a/runtime/parachains/src/dmp.rs b/runtime/parachains/src/dmp.rs index a2030a2692fa..206c82f190c4 100644 --- a/runtime/parachains/src/dmp.rs +++ b/runtime/parachains/src/dmp.rs @@ -109,7 +109,7 @@ pub mod pallet { impl Pallet { /// Block initialization logic, called by initializer. pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { - 0 + Weight::zero() } /// Block finalization logic, called by initializer. diff --git a/runtime/parachains/src/hrmp.rs b/runtime/parachains/src/hrmp.rs index d18c2b3fc497..53ad6781048f 100644 --- a/runtime/parachains/src/hrmp.rs +++ b/runtime/parachains/src/hrmp.rs @@ -58,6 +58,7 @@ pub trait WeightInfo { fn force_process_hrmp_close(c: u32) -> Weight; fn hrmp_cancel_open_request(c: u32) -> Weight; fn clean_open_channel_requests(c: u32) -> Weight; + fn force_open_hrmp_channel() -> Weight; } /// A weight info that is only suitable for testing. @@ -88,6 +89,9 @@ impl WeightInfo for TestWeightInfo { fn clean_open_channel_requests(_: u32) -> Weight { Weight::MAX } + fn force_open_hrmp_channel() -> Weight { + Weight::MAX + } } /// A description of a request to open an HRMP channel. @@ -239,11 +243,11 @@ pub mod pallet { frame_system::Config + configuration::Config + paras::Config + dmp::Config { /// The outer event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; - type Origin: From - + From<::Origin> - + Into::Origin>>; + type RuntimeOrigin: From + + From<::RuntimeOrigin> + + Into::RuntimeOrigin>>; /// An interface for reserving deposits for opening channels. /// @@ -269,6 +273,9 @@ pub mod pallet { OpenChannelAccepted(ParaId, ParaId), /// HRMP channel closed. `[by_parachain, channel_id]` ChannelClosed(ParaId, HrmpChannelId), + /// An HRMP channel was opened via Root origin. + /// `[sender, recipient, proposed_max_capacity, proposed_max_message_size]` + HrmpChannelForceOpened(ParaId, ParaId, u32, u32), } #[pallet::error] @@ -465,7 +472,7 @@ pub mod pallet { proposed_max_capacity: u32, proposed_max_message_size: u32, ) -> DispatchResult { - let origin = ensure_parachain(::Origin::from(origin))?; + let origin = ensure_parachain(::RuntimeOrigin::from(origin))?; Self::init_open_channel( origin, recipient, @@ -486,7 +493,7 @@ pub mod pallet { /// The channel will be opened only on the next session boundary. #[pallet::weight(::WeightInfo::hrmp_accept_open_channel())] pub fn hrmp_accept_open_channel(origin: OriginFor, sender: ParaId) -> DispatchResult { - let origin = ensure_parachain(::Origin::from(origin))?; + let origin = ensure_parachain(::RuntimeOrigin::from(origin))?; Self::accept_open_channel(origin, sender)?; Self::deposit_event(Event::OpenChannelAccepted(sender, origin)); Ok(()) @@ -501,7 +508,7 @@ pub mod pallet { origin: OriginFor, channel_id: HrmpChannelId, ) -> DispatchResult { - let origin = ensure_parachain(::Origin::from(origin))?; + let origin = ensure_parachain(::RuntimeOrigin::from(origin))?; Self::close_channel(origin, channel_id.clone())?; Self::deposit_event(Event::ChannelClosed(origin, channel_id)); Ok(()) @@ -567,7 +574,7 @@ pub mod pallet { channel_id: HrmpChannelId, open_requests: u32, ) -> DispatchResult { - let origin = ensure_parachain(::Origin::from(origin))?; + let origin = ensure_parachain(::RuntimeOrigin::from(origin))?; ensure!( ::HrmpOpenChannelRequestsList::decode_len().unwrap_or_default() as u32 <= open_requests, @@ -577,6 +584,32 @@ pub mod pallet { Self::deposit_event(Event::OpenChannelCanceled(origin, channel_id)); Ok(()) } + + /// Open a channel from a `sender` to a `recipient` `ParaId` using the Root origin. Although + /// opened by Root, the `max_capacity` and `max_message_size` are still subject to the Relay + /// Chain's configured limits. + /// + /// Expected use is when one of the `ParaId`s involved in the channel is governed by the + /// Relay Chain, e.g. a common good parachain. + #[pallet::weight(::WeightInfo::force_open_hrmp_channel())] + pub fn force_open_hrmp_channel( + origin: OriginFor, + sender: ParaId, + recipient: ParaId, + max_capacity: u32, + max_message_size: u32, + ) -> DispatchResult { + ensure_root(origin)?; + Self::init_open_channel(sender, recipient, max_capacity, max_message_size)?; + Self::accept_open_channel(recipient, sender)?; + Self::deposit_event(Event::HrmpChannelForceOpened( + sender, + recipient, + max_capacity, + max_message_size, + )); + Ok(()) + } } } @@ -609,7 +642,7 @@ fn preopen_hrmp_channel( impl Pallet { /// Block initialization logic, called by initializer. pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { - 0 + Weight::zero() } /// Block finalization logic, called by initializer. @@ -953,7 +986,7 @@ impl Pallet { } pub(crate) fn prune_hrmp(recipient: ParaId, new_hrmp_watermark: T::BlockNumber) -> Weight { - let mut weight = 0; + let mut weight = Weight::zero(); // sift through the incoming messages digest to collect the paras that sent at least one // message to this parachain between the old and new watermarks. @@ -1020,7 +1053,7 @@ impl Pallet { sender: ParaId, out_hrmp_msgs: Vec>, ) -> Weight { - let mut weight = 0; + let mut weight = Weight::zero(); let now = >::block_number(); for out_msg in out_hrmp_msgs { diff --git a/runtime/parachains/src/hrmp/benchmarking.rs b/runtime/parachains/src/hrmp/benchmarking.rs index 3486e990fe57..7ea14b1dc922 100644 --- a/runtime/parachains/src/hrmp/benchmarking.rs +++ b/runtime/parachains/src/hrmp/benchmarking.rs @@ -39,9 +39,9 @@ fn register_parachain_with_balance(id: ParaId, balance: BalanceOf) T::Currency::make_free_balance_be(&id.into_account_truncating(), balance); } -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(event, &system_event); @@ -66,7 +66,7 @@ fn establish_para_connection( until: ParachainSetupStep, ) -> [(ParaId, crate::Origin); 2] where - ::Origin: From, + ::RuntimeOrigin: From, { let config = Configuration::::config(); let deposit: BalanceOf = config.hrmp_sender_deposit.unique_saturated_into(); @@ -138,7 +138,7 @@ static_assertions::const_assert!(HRMP_MAX_INBOUND_CHANNELS_BOUND < PREFIX_0); static_assertions::const_assert!(HRMP_MAX_OUTBOUND_CHANNELS_BOUND < PREFIX_0); frame_benchmarking::benchmarks! { - where_clause { where ::Origin: From } + where_clause { where ::RuntimeOrigin: From } hrmp_init_open_channel { let sender_id: ParaId = 1u32.into(); @@ -296,6 +296,32 @@ frame_benchmarking::benchmarks! { } verify { assert_eq!(HrmpOpenChannelRequestsList::::decode_len().unwrap_or_default() as u32, 0); } + + force_open_hrmp_channel { + let sender_id: ParaId = 1u32.into(); + let recipient_id: ParaId = 2u32.into(); + + // make sure para is registered, and has enough balance. + let sender_deposit: BalanceOf = + Configuration::::config().hrmp_sender_deposit.unique_saturated_into(); + let recipient_deposit: BalanceOf = + Configuration::::config().hrmp_recipient_deposit.unique_saturated_into(); + register_parachain_with_balance::(sender_id, sender_deposit); + register_parachain_with_balance::(recipient_id, recipient_deposit); + + let capacity = Configuration::::config().hrmp_channel_max_capacity; + let message_size = Configuration::::config().hrmp_channel_max_message_size; + + // make sure this channel doesn't exist + let channel_id = HrmpChannelId { sender: sender_id, recipient: recipient_id }; + assert!(HrmpOpenChannelRequests::::get(&channel_id).is_none()); + assert!(HrmpChannels::::get(&channel_id).is_none()); + }: _(frame_system::Origin::::Root, sender_id, recipient_id, capacity, message_size) + verify { + assert_last_event::( + Event::::HrmpChannelForceOpened(sender_id, recipient_id, capacity, message_size).into() + ); + } } frame_benchmarking::impl_benchmark_test_suite!( diff --git a/runtime/parachains/src/hrmp/tests.rs b/runtime/parachains/src/hrmp/tests.rs index 463c5eb39385..9e0d0646d057 100644 --- a/runtime/parachains/src/hrmp/tests.rs +++ b/runtime/parachains/src/hrmp/tests.rs @@ -16,8 +16,8 @@ use super::*; use crate::mock::{ - new_test_ext, Configuration, Event as MockEvent, Hrmp, MockGenesisConfig, Paras, ParasShared, - System, Test, + new_test_ext, Configuration, Hrmp, MockGenesisConfig, Paras, ParasShared, + RuntimeEvent as MockEvent, RuntimeOrigin, System, Test, }; use frame_support::{assert_noop, assert_ok, traits::Currency as _}; use primitives::v2::BlockNumber; @@ -194,6 +194,34 @@ fn open_channel_works() { }); } +#[test] +fn force_open_channel_works() { + let para_a = 1.into(); + let para_b = 3.into(); + + new_test_ext(GenesisConfigBuilder::default().build()).execute_with(|| { + // We need both A & B to be registered and live parachains. + register_parachain(para_a); + register_parachain(para_b); + + run_to_block(5, Some(vec![4, 5])); + Hrmp::force_open_hrmp_channel(RuntimeOrigin::root(), para_a, para_b, 2, 8).unwrap(); + Hrmp::assert_storage_consistency_exhaustive(); + assert!(System::events().iter().any(|record| record.event == + MockEvent::Hrmp(Event::HrmpChannelForceOpened(para_a, para_b, 2, 8)))); + + // Advance to a block 6, but without session change. That means that the channel has + // not been created yet. + run_to_block(6, None); + assert!(!channel_exists(para_a, para_b)); + Hrmp::assert_storage_consistency_exhaustive(); + + // Now let the session change happen and thus open the channel. + run_to_block(8, Some(vec![8])); + assert!(channel_exists(para_a, para_b)); + }); +} + #[test] fn close_channel_works() { let para_a = 5.into(); diff --git a/runtime/parachains/src/inclusion/mod.rs b/runtime/parachains/src/inclusion/mod.rs index c936b54eecfc..f74a8cfd3f8d 100644 --- a/runtime/parachains/src/inclusion/mod.rs +++ b/runtime/parachains/src/inclusion/mod.rs @@ -198,7 +198,7 @@ pub mod pallet { + hrmp::Config + configuration::Config { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; type DisputesHandler: disputes::DisputesHandler; type RewardValidators: RewardValidators; } @@ -303,7 +303,7 @@ const LOG_TARGET: &str = "runtime::inclusion"; impl Pallet { /// Block initialization logic, called by initializer. pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { - 0 + Weight::zero() } /// Block finalization logic, called by initializer. diff --git a/runtime/parachains/src/initializer.rs b/runtime/parachains/src/initializer.rs index 027dd677bbba..eaa4510fafcf 100644 --- a/runtime/parachains/src/initializer.rs +++ b/runtime/parachains/src/initializer.rs @@ -21,7 +21,7 @@ use crate::{ configuration::{self, HostConfiguration}, - disputes::DisputesHandler, + disputes::{self, DisputesHandler as _, SlashingHandler as _}, dmp, hrmp, inclusion, paras, scheduler, session_info, shared, ump, }; use frame_support::{ @@ -59,6 +59,9 @@ pub struct SessionChangeNotification { pub session_index: SessionIndex, } +/// Number of validators (not only parachain) in a session. +pub type ValidatorSetCount = u32; + impl> Default for SessionChangeNotification { fn default() -> Self { Self { @@ -109,6 +112,7 @@ pub mod pallet { + scheduler::Config + inclusion::Config + session_info::Config + + disputes::Config + dmp::Config + ump::Config + hrmp::Config @@ -116,7 +120,7 @@ pub mod pallet { /// A randomness beacon. type Randomness: Randomness; /// An origin which is allowed to force updates to parachains. - type ForceOrigin: EnsureOrigin<::Origin>; + type ForceOrigin: EnsureOrigin<::RuntimeOrigin>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; } @@ -163,6 +167,7 @@ pub mod pallet { inclusion::Pallet::::initializer_initialize(now) + session_info::Pallet::::initializer_initialize(now) + T::DisputesHandler::initializer_initialize(now) + + T::SlashingHandler::initializer_initialize(now) + dmp::Pallet::::initializer_initialize(now) + ump::Pallet::::initializer_initialize(now) + hrmp::Pallet::::initializer_initialize(now); @@ -177,6 +182,7 @@ pub mod pallet { hrmp::Pallet::::initializer_finalize(); ump::Pallet::::initializer_finalize(); dmp::Pallet::::initializer_finalize(); + T::SlashingHandler::initializer_finalize(); T::DisputesHandler::initializer_finalize(); session_info::Pallet::::initializer_finalize(); inclusion::Pallet::::initializer_finalize(); @@ -260,6 +266,7 @@ impl Pallet { inclusion::Pallet::::initializer_on_new_session(¬ification); session_info::Pallet::::initializer_on_new_session(¬ification); T::DisputesHandler::initializer_on_new_session(¬ification); + T::SlashingHandler::initializer_on_new_session(session_index); dmp::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); ump::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); hrmp::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); diff --git a/runtime/parachains/src/lib.rs b/runtime/parachains/src/lib.rs index 2005861a6c4b..3d73a4049ed4 100644 --- a/runtime/parachains/src/lib.rs +++ b/runtime/parachains/src/lib.rs @@ -50,7 +50,8 @@ mod mock; pub use origin::{ensure_parachain, Origin}; pub use paras::ParaLifecycle; -use primitives::v2::Id as ParaId; +use primitives::v2::{HeadData, Id as ParaId, ValidationCode}; +use sp_runtime::DispatchResult; /// Schedule a para to be initialized at the start of the next session with the given genesis data. /// @@ -78,3 +79,20 @@ pub fn schedule_parathread_upgrade(id: ParaId) -> Result<(), ( pub fn schedule_parachain_downgrade(id: ParaId) -> Result<(), ()> { paras::Pallet::::schedule_parachain_downgrade(id).map_err(|_| ()) } + +/// Schedules a validation code upgrade to a parachain with the given id. +/// +/// This simply calls [`crate::paras::Pallet::schedule_code_upgrade_external`]. +pub fn schedule_code_upgrade( + id: ParaId, + new_code: ValidationCode, +) -> DispatchResult { + paras::Pallet::::schedule_code_upgrade_external(id, new_code) +} + +/// Sets the current parachain head with the given id. +/// +/// This simply calls [`crate::paras::Pallet::set_current_head`]. +pub fn set_current_head(id: ParaId, new_head: HeadData) { + paras::Pallet::::set_current_head(id, new_head) +} diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 064b9918ff5f..3e6ed79a77c2 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -31,8 +31,8 @@ use frame_support::{ use frame_support_test::TestRandomness; use parity_scale_codec::Decode; use primitives::v2::{ - AuthorityDiscoveryId, Balance, BlockNumber, Header, Moment, SessionIndex, UpwardMessage, - ValidatorIndex, + AuthorityDiscoveryId, Balance, BlockNumber, CandidateHash, Header, Moment, SessionIndex, + UpwardMessage, ValidatorIndex, }; use sp_core::H256; use sp_io::TestExternalities; @@ -73,16 +73,18 @@ frame_support::construct_runtime!( impl frame_system::offchain::SendTransactionTypes for Test where - Call: From, + RuntimeCall: From, { type Extrinsic = UncheckedExtrinsic; - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; } parameter_types! { pub const BlockHashCount: u32 = 250; pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(4 * 1024 * 1024); + frame_system::limits::BlockWeights::simple_max( + Weight::from_ref_time(4 * 1024 * 1024).set_proof_size(u64::MAX), + ); } pub type AccountId = u64; @@ -92,8 +94,8 @@ impl frame_system::Config for Test { type BlockWeights = BlockWeights; type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = BlockNumber; type Hash = H256; @@ -101,7 +103,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -123,7 +125,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -204,16 +206,16 @@ impl frame_support::traits::EstimateNextSessionRotation for TestNextSession } fn estimate_current_session_progress(_now: u32) -> (Option, Weight) { - (None, 0) + (None, Weight::zero()) } fn estimate_next_session_rotation(_now: u32) -> (Option, Weight) { - (None, 0) + (None, Weight::zero()) } } impl crate::paras::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = crate::paras::TestWeightInfo; type UnsignedPriority = ParasUnsignedPriority; type NextSessionRotation = TestNextSessionRotation; @@ -226,7 +228,7 @@ parameter_types! { } impl crate::ump::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type UmpSink = TestUmpSink; type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = frame_system::EnsureRoot; @@ -234,16 +236,16 @@ impl crate::ump::Config for Test { } impl crate::hrmp::Config for Test { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type Currency = pallet_balances::Pallet; type WeightInfo = crate::hrmp::TestWeightInfo; } impl crate::disputes::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type RewardValidators = Self; - type PunishValidators = Self; + type SlashingHandler = Self; type WeightInfo = crate::disputes::TestWeightInfo; } @@ -251,7 +253,6 @@ thread_local! { pub static REWARD_VALIDATORS: RefCell)>> = RefCell::new(Vec::new()); pub static PUNISH_VALIDATORS_FOR: RefCell)>> = RefCell::new(Vec::new()); pub static PUNISH_VALIDATORS_AGAINST: RefCell)>> = RefCell::new(Vec::new()); - pub static PUNISH_VALIDATORS_INCONCLUSIVE: RefCell)>> = RefCell::new(Vec::new()); } impl crate::disputes::RewardValidators for Test { @@ -263,36 +264,37 @@ impl crate::disputes::RewardValidators for Test { } } -impl crate::disputes::PunishValidators for Test { +impl crate::disputes::SlashingHandler for Test { fn punish_for_invalid( session: SessionIndex, - validators: impl IntoIterator, + _: CandidateHash, + losers: impl IntoIterator, ) { - PUNISH_VALIDATORS_FOR - .with(|r| r.borrow_mut().push((session, validators.into_iter().collect()))) + PUNISH_VALIDATORS_FOR.with(|r| r.borrow_mut().push((session, losers.into_iter().collect()))) } fn punish_against_valid( session: SessionIndex, - validators: impl IntoIterator, + _: CandidateHash, + losers: impl IntoIterator, ) { PUNISH_VALIDATORS_AGAINST - .with(|r| r.borrow_mut().push((session, validators.into_iter().collect()))) + .with(|r| r.borrow_mut().push((session, losers.into_iter().collect()))) } - fn punish_inconclusive( - session: SessionIndex, - validators: impl IntoIterator, - ) { - PUNISH_VALIDATORS_INCONCLUSIVE - .with(|r| r.borrow_mut().push((session, validators.into_iter().collect()))) + fn initializer_initialize(_now: BlockNumber) -> Weight { + Weight::zero() } + + fn initializer_finalize() {} + + fn initializer_on_new_session(_: SessionIndex) {} } impl crate::scheduler::Config for Test {} impl crate::inclusion::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DisputesHandler = Disputes; type RewardValidators = TestRewardValidators; } @@ -375,7 +377,7 @@ std::thread_local! { static PROCESSED: RefCell> = RefCell::new(vec![]); } -/// Return which messages have been processed by `pocess_upward_message` and clear the buffer. +/// Return which messages have been processed by `process_upward_message` and clear the buffer. pub fn take_processed() -> Vec<(ParaId, UpwardMessage)> { PROCESSED.with(|opt_hook| std::mem::take(&mut *opt_hook.borrow_mut())) } @@ -392,10 +394,10 @@ impl UmpSink for TestUmpSink { max_weight: Weight, ) -> Result { let weight = match u32::decode(&mut &actual_msg[..]) { - Ok(w) => w as Weight, - Err(_) => return Ok(0), // same as the real `UmpSink` + Ok(w) => Weight::from_ref_time(w as u64), + Err(_) => return Ok(Weight::zero()), // same as the real `UmpSink` }; - if weight > max_weight { + if weight.any_gt(max_weight) { let id = sp_io::hashing::blake2_256(actual_msg); return Err((id, weight)) } @@ -455,9 +457,9 @@ pub struct MockGenesisConfig { pub paras: crate::paras::GenesisConfig, } -pub fn assert_last_event(generic_event: Event) { +pub fn assert_last_event(generic_event: RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(event, &system_event); diff --git a/runtime/parachains/src/paras/benchmarking.rs b/runtime/parachains/src/paras/benchmarking.rs index 9d31453638a7..9970937f4558 100644 --- a/runtime/parachains/src/paras/benchmarking.rs +++ b/runtime/parachains/src/paras/benchmarking.rs @@ -31,9 +31,9 @@ use self::pvf_check::{VoteCause, VoteOutcome}; // shouldn't exceed this number. const SAMPLE_SIZE: u32 = 1024; -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(event, &system_event); diff --git a/runtime/parachains/src/paras/mod.rs b/runtime/parachains/src/paras/mod.rs index c5b932ad7a53..5ecaf6311d00 100644 --- a/runtime/parachains/src/paras/mod.rs +++ b/runtime/parachains/src/paras/mod.rs @@ -118,7 +118,7 @@ use primitives::v2::{ use scale_info::TypeInfo; use sp_core::RuntimeDebug; use sp_runtime::{ - traits::{AppVerify, One}, + traits::{AppVerify, One, Saturating}, DispatchResult, SaturatedConversion, }; use sp_std::{cmp, mem, prelude::*}; @@ -449,7 +449,7 @@ impl WeightInfo for TestWeightInfo { } fn include_pvf_check_statement() -> Weight { // This special value is to distinguish from the finalizing variants above in tests. - Weight::MAX - 1 + Weight::MAX - Weight::from_ref_time(1) } } @@ -473,7 +473,7 @@ pub mod pallet { + shared::Config + frame_system::offchain::SendTransactionTypes> { - type Event: From + IsType<::Event>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; #[pallet::constant] type UnsignedPriority: Get; @@ -535,6 +535,8 @@ pub mod pallet { /// The PVF pre-checking statement cannot be included since the PVF pre-checking mechanism /// is disabled. PvfCheckDisabled, + /// Parachain cannot currently schedule a code upgrade. + CannotUpgradeCode, } /// All currently active PVF pre-checking votes. @@ -752,8 +754,7 @@ pub mod pallet { new_head: HeadData, ) -> DispatchResult { ensure_root(origin)?; - ::Heads::insert(¶, new_head); - Self::deposit_event(Event::CurrentHeadUpdated(para)); + Self::set_current_head(para, new_head); Ok(()) } @@ -878,16 +879,11 @@ pub mod pallet { /// Includes a statement for a PVF pre-checking vote. Potentially, finalizes the vote and /// enacts the results if that was the last vote before achieving the supermajority. #[pallet::weight( - sp_std::cmp::max( - sp_std::cmp::max( - ::WeightInfo::include_pvf_check_statement_finalize_upgrade_accept(), - ::WeightInfo::include_pvf_check_statement_finalize_upgrade_reject(), - ), - sp_std::cmp::max( - ::WeightInfo::include_pvf_check_statement_finalize_onboarding_accept(), - ::WeightInfo::include_pvf_check_statement_finalize_onboarding_reject(), + ::WeightInfo::include_pvf_check_statement_finalize_upgrade_accept() + .max(::WeightInfo::include_pvf_check_statement_finalize_upgrade_reject()) + .max(::WeightInfo::include_pvf_check_statement_finalize_onboarding_accept() + .max(::WeightInfo::include_pvf_check_statement_finalize_onboarding_reject()) ) - ) )] pub fn include_pvf_check_statement( origin: OriginFor, @@ -1055,6 +1051,31 @@ const INVALID_TX_DOUBLE_VOTE: u8 = 3; const INVALID_TX_PVF_CHECK_DISABLED: u8 = 4; impl Pallet { + /// This is a call to schedule code upgrades for parachains which is safe to be called + /// outside of this module. That means this function does all checks necessary to ensure + /// that some external code is allowed to trigger a code upgrade. We do not do auth checks, + /// that should be handled by whomever calls this function. + pub(crate) fn schedule_code_upgrade_external( + id: ParaId, + new_code: ValidationCode, + ) -> DispatchResult { + // Check that we can schedule an upgrade at all. + ensure!(Self::can_upgrade_validation_code(id), Error::::CannotUpgradeCode); + let config = configuration::Pallet::::config(); + let current_block = frame_system::Pallet::::block_number(); + // Schedule the upgrade with a delay just like if a parachain triggered the upgrade. + let upgrade_block = current_block.saturating_add(config.validation_upgrade_delay); + Self::schedule_code_upgrade(id, new_code, upgrade_block, &config); + Self::deposit_event(Event::CodeUpgradeScheduled(id)); + Ok(()) + } + + /// Set the current head of a parachain. + pub(crate) fn set_current_head(para: ParaId, new_head: HeadData) { + ::Heads::insert(¶, new_head); + Self::deposit_event(Event::CurrentHeadUpdated(para)); + } + /// Called by the initializer to initialize the paras pallet. pub(crate) fn initializer_initialize(now: T::BlockNumber) -> Weight { let weight = Self::prune_old_code(now); @@ -1372,7 +1393,7 @@ impl Pallet { sessions_observed: SessionIndex, cfg: &configuration::HostConfiguration, ) -> Weight { - let mut weight = 0; + let mut weight = Weight::zero(); for cause in causes { weight += T::DbWeight::get().reads_writes(3, 2); Self::deposit_event(Event::PvfCheckAccepted(*code_hash, cause.para_id())); @@ -1417,7 +1438,7 @@ impl Pallet { relay_parent_number: T::BlockNumber, cfg: &configuration::HostConfiguration, ) -> Weight { - let mut weight = 0; + let mut weight = Weight::zero(); // Compute the relay-chain block number starting at which the code upgrade is ready to be // applied. @@ -1457,7 +1478,7 @@ impl Pallet { code_hash: &ValidationCodeHash, causes: Vec>, ) -> Weight { - let mut weight = 0; + let mut weight = Weight::zero(); for cause in causes { // Whenever PVF pre-checking is started or a new cause is added to it, the RC is bumped. @@ -1575,15 +1596,21 @@ impl Pallet { /// /// No-op if para is not registered at all. pub(crate) fn schedule_para_cleanup(id: ParaId) -> DispatchResult { - // Disallow offboarding in case there is an upcoming upgrade. + // Disallow offboarding in case there is a PVF pre-checking in progress. // // This is not a fundamential limitation but rather simplification: it allows us to get // away without introducing additional logic for pruning and, more importantly, enacting // ongoing PVF pre-checking votes. It also removes some nasty edge cases. // + // However, an upcoming upgrade on its own imposes no restrictions. An upgrade is enacted + // with a new para head, so if a para never progresses we still should be able to offboard it. + // // This implicitly assumes that the given para exists, i.e. it's lifecycle != None. - if FutureCodeHash::::contains_key(&id) { - return Err(Error::::CannotOffboard.into()) + if let Some(future_code_hash) = FutureCodeHash::::get(&id) { + let active_prechecking = PvfActiveVoteList::::get(); + if active_prechecking.contains(&future_code_hash) { + return Err(Error::::CannotOffboard.into()) + } } let lifecycle = ParaLifecycles::::get(&id); @@ -1746,7 +1773,7 @@ impl Pallet { code: ValidationCode, cfg: &configuration::HostConfiguration, ) -> Weight { - let mut weight = 0; + let mut weight = Weight::zero(); weight += T::DbWeight::get().reads_writes(3, 2); Self::deposit_event(Event::PvfCheckStarted(code_hash, cause.para_id())); @@ -1845,7 +1872,7 @@ impl Pallet { Self::note_past_code(id, expected_at, now, prior_code_hash) } else { log::error!(target: LOG_TARGET, "Missing prior code hash for para {:?}", &id); - 0 as Weight + Weight::zero() }; // add 1 to writes due to heads update. diff --git a/runtime/parachains/src/paras/tests.rs b/runtime/parachains/src/paras/tests.rs index 960132d5f804..766fa00d01b3 100644 --- a/runtime/parachains/src/paras/tests.rs +++ b/runtime/parachains/src/paras/tests.rs @@ -26,7 +26,8 @@ use test_helpers::{dummy_head_data, dummy_validation_code}; use crate::{ configuration::HostConfiguration, mock::{ - new_test_ext, Configuration, MockGenesisConfig, Origin, Paras, ParasShared, System, Test, + new_test_ext, Configuration, MockGenesisConfig, Paras, ParasShared, RuntimeOrigin, System, + Test, }, }; @@ -112,8 +113,12 @@ fn check_code_is_not_stored(validation_code: &ValidationCode) { /// An utility for checking that certain events were deposited. struct EventValidator { - events: - Vec::Event, primitives::v2::Hash>>, + events: Vec< + frame_system::EventRecord< + ::RuntimeEvent, + primitives::v2::Hash, + >, + >, } impl EventValidator { @@ -767,9 +772,6 @@ fn full_parachain_cleanup_storage() { expected_at }; - // Cannot offboard while an upgrade is pending. - assert_err!(Paras::schedule_para_cleanup(para_id), Error::::CannotOffboard); - // Enact the upgrade. // // For that run to block #7 and submit a new head. @@ -815,6 +817,65 @@ fn full_parachain_cleanup_storage() { }); } +#[test] +fn cannot_offboard_ongoing_pvf_check() { + let para_id = ParaId::from(0); + + let existing_code: ValidationCode = vec![1, 2, 3].into(); + let new_code: ValidationCode = vec![3, 2, 1].into(); + + let paras = vec![( + para_id, + ParaGenesisArgs { + parachain: true, + genesis_head: Default::default(), + validation_code: existing_code, + }, + )]; + + let genesis_config = MockGenesisConfig { + paras: GenesisConfig { paras, ..Default::default() }, + configuration: crate::configuration::GenesisConfig { + config: HostConfiguration { pvf_checking_enabled: true, ..Default::default() }, + ..Default::default() + }, + ..Default::default() + }; + + new_test_ext(genesis_config).execute_with(|| { + run_to_block(2, Some(vec![1])); + + // Relay parent of the block that schedules the upgrade. + const RELAY_PARENT: BlockNumber = 1; + // Expected current session index. + const EXPECTED_SESSION: SessionIndex = 1; + + Paras::schedule_code_upgrade( + para_id, + new_code.clone(), + RELAY_PARENT, + &Configuration::config(), + ); + assert!(!Paras::pvfs_require_precheck().is_empty()); + + // Cannot offboard when there's an ongoing pvf-check voting. + assert_err!(Paras::schedule_para_cleanup(para_id), Error::::CannotOffboard); + + // Include votes for super-majority. + IntoIterator::into_iter([0, 1, 2, 3]) + .map(|i| PvfCheckStatement { + accept: true, + subject: new_code.hash(), + session_index: EXPECTED_SESSION, + validator_index: i.into(), + }) + .for_each(sign_and_include_pvf_check_statement); + + // Voting concluded, can offboard even though an upgrade is in progress. + assert_ok!(Paras::schedule_para_cleanup(para_id)); + }); +} + #[test] fn para_incoming_at_session() { let code_a = ValidationCode(vec![2]); @@ -1445,7 +1506,10 @@ fn add_trusted_validation_code_inserts_with_no_users() { // with the reference count equal to 0. let validation_code = ValidationCode(vec![1, 2, 3]); new_test_ext(Default::default()).execute_with(|| { - assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); + assert_ok!(Paras::add_trusted_validation_code( + RuntimeOrigin::root(), + validation_code.clone() + )); assert_eq!(::CodeByHashRefs::get(&validation_code.hash()), 0,); }); } @@ -1456,9 +1520,15 @@ fn add_trusted_validation_code_idempotent() { // parameters is a no-op. let validation_code = ValidationCode(vec![1, 2, 3]); new_test_ext(Default::default()).execute_with(|| { - assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); + assert_ok!(Paras::add_trusted_validation_code( + RuntimeOrigin::root(), + validation_code.clone() + )); assert_storage_noop!({ - assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); + assert_ok!(Paras::add_trusted_validation_code( + RuntimeOrigin::root(), + validation_code.clone() + )); }); }); } @@ -1469,8 +1539,14 @@ fn poke_unused_validation_code_removes_code_cleanly() { // in the storage but has no users will remove it cleanly from the storage. let validation_code = ValidationCode(vec![1, 2, 3]); new_test_ext(Default::default()).execute_with(|| { - assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); - assert_ok!(Paras::poke_unused_validation_code(Origin::root(), validation_code.hash())); + assert_ok!(Paras::add_trusted_validation_code( + RuntimeOrigin::root(), + validation_code.clone() + )); + assert_ok!(Paras::poke_unused_validation_code( + RuntimeOrigin::root(), + validation_code.hash() + )); assert_eq!(::CodeByHashRefs::get(&validation_code.hash()), 0); assert!(!::CodeByHash::contains_key(&validation_code.hash())); @@ -1483,7 +1559,10 @@ fn poke_unused_validation_code_doesnt_remove_code_with_users() { let validation_code = ValidationCode(vec![1, 2, 3]); new_test_ext(Default::default()).execute_with(|| { // First we add the code to the storage. - assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); + assert_ok!(Paras::add_trusted_validation_code( + RuntimeOrigin::root(), + validation_code.clone() + )); // Then we add a user to the code, say by upgrading. run_to_block(2, None); @@ -1492,7 +1571,10 @@ fn poke_unused_validation_code_doesnt_remove_code_with_users() { // Finally we poke the code, which should not remove it from the storage. assert_storage_noop!({ - assert_ok!(Paras::poke_unused_validation_code(Origin::root(), validation_code.hash())); + assert_ok!(Paras::poke_unused_validation_code( + RuntimeOrigin::root(), + validation_code.hash() + )); }); check_code_is_stored(&validation_code); }); @@ -1507,7 +1589,7 @@ fn increase_code_ref_doesnt_have_allergy_on_add_trusted_validation_code() { let code = ValidationCode(vec![1, 2, 3]); new_test_ext(Default::default()).execute_with(|| { - assert_ok!(Paras::add_trusted_validation_code(Origin::root(), code.clone())); + assert_ok!(Paras::add_trusted_validation_code(RuntimeOrigin::root(), code.clone())); Paras::increase_code_ref(&code.hash(), &code); Paras::increase_code_ref(&code.hash(), &code); assert!(::CodeByHash::contains_key(code.hash())); @@ -1515,7 +1597,7 @@ fn increase_code_ref_doesnt_have_allergy_on_add_trusted_validation_code() { }); new_test_ext(Default::default()).execute_with(|| { - assert_ok!(Paras::add_trusted_validation_code(Origin::root(), code.clone())); + assert_ok!(Paras::add_trusted_validation_code(RuntimeOrigin::root(), code.clone())); Paras::decrease_code_ref(&code.hash()); assert!(::CodeByHash::contains_key(code.hash())); assert_eq!(::CodeByHashRefs::get(code.hash()), 0); @@ -1543,7 +1625,10 @@ fn add_trusted_validation_code_insta_approval() { ..Default::default() }; new_test_ext(genesis_config).execute_with(|| { - assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); + assert_ok!(Paras::add_trusted_validation_code( + RuntimeOrigin::root(), + validation_code.clone() + )); // Then some parachain upgrades it's code with the relay-parent 1. run_to_block(2, None); @@ -1598,7 +1683,10 @@ fn add_trusted_validation_code_enacts_existing_pvf_vote() { assert!(::PvfActiveVoteMap::contains_key(&validation_code.hash())); // Then we add a trusted validation code. That should conclude the vote. - assert_ok!(Paras::add_trusted_validation_code(Origin::root(), validation_code.clone())); + assert_ok!(Paras::add_trusted_validation_code( + RuntimeOrigin::root(), + validation_code.clone() + )); assert!(::FutureCodeUpgrades::get(¶_id).is_some()); assert!(!::PvfActiveVoteMap::contains_key(&validation_code.hash())); }); diff --git a/runtime/parachains/src/paras_inherent/mod.rs b/runtime/parachains/src/paras_inherent/mod.rs index e6a4f6e7a6aa..188a8f677979 100644 --- a/runtime/parachains/src/paras_inherent/mod.rs +++ b/runtime/parachains/src/paras_inherent/mod.rs @@ -339,7 +339,8 @@ impl Pallet { let max_block_weight = ::BlockWeights::get().max_block; - METRICS.on_before_filter(candidates_weight + bitfields_weight + disputes_weight); + METRICS + .on_before_filter((candidates_weight + bitfields_weight + disputes_weight).ref_time()); T::DisputesHandler::assure_deduplicated_and_sorted(&mut disputes) .map_err(|_e| Error::::DisputeStatementsUnsortedOrDuplicates)?; @@ -372,14 +373,14 @@ impl Pallet { // the block. It's still reasonable to protect against a massive amount of disputes. if candidates_weight .saturating_add(bitfields_weight) - .saturating_add(disputes_weight) > - max_block_weight + .saturating_add(disputes_weight) + .any_gt(max_block_weight) { log::warn!("Overweight para inherent data reached the runtime {:?}", parent_hash); backed_candidates.clear(); - candidates_weight = 0; + candidates_weight = Weight::zero(); signed_bitfields.clear(); - bitfields_weight = 0; + bitfields_weight = Weight::zero(); } let entropy = compute_entropy::(parent_hash); @@ -537,7 +538,7 @@ impl Pallet { // this is max config.ump_service_total_weight let _ump_weight = >::process_pending_upward_messages(); - METRICS.on_after_filter(total_consumed_weight); + METRICS.on_after_filter(total_consumed_weight.ref_time()); Ok(Some(total_consumed_weight).into()) } @@ -752,7 +753,7 @@ impl Pallet { &mut rng, ); - if actual_weight > max_block_weight { + if actual_weight.any_gt(max_block_weight) { log::warn!(target: LOG_TARGET, "Post weight limiting weight is still too large."); } @@ -803,7 +804,7 @@ fn random_sel Weight>( weight_limit: Weight, ) -> (Weight, Vec) { if selectables.is_empty() { - return (0 as Weight, Vec::new()) + return (Weight::zero(), Vec::new()) } // all indices that are not part of the preferred set let mut indices = (0..selectables.len()) @@ -812,14 +813,14 @@ fn random_sel Weight>( .collect::>(); let mut picked_indices = Vec::with_capacity(selectables.len().saturating_sub(1)); - let mut weight_acc = 0 as Weight; + let mut weight_acc = Weight::zero(); preferred_indices.shuffle(rng); for preferred_idx in preferred_indices { // preferred indices originate from outside if let Some(item) = selectables.get(preferred_idx) { let updated = weight_acc.saturating_add(weight_fn(item)); - if updated > weight_limit { + if updated.any_gt(weight_limit) { continue } weight_acc = updated; @@ -832,7 +833,7 @@ fn random_sel Weight>( let item = &selectables[idx]; let updated = weight_acc.saturating_add(weight_fn(item)); - if updated > weight_limit { + if updated.any_gt(weight_limit) { continue } weight_acc = updated; @@ -876,7 +877,7 @@ fn apply_weight_limit( let total = total_bitfields_weight.saturating_add(total_candidates_weight); // candidates + bitfields fit into the block - if max_consumable_weight >= total { + if max_consumable_weight.all_gte(total) { return total } @@ -893,7 +894,7 @@ fn apply_weight_limit( // There is weight remaining to be consumed by a subset of candidates // which are going to be picked now. if let Some(max_consumable_by_candidates) = - max_consumable_weight.checked_sub(total_bitfields_weight) + max_consumable_weight.checked_sub(&total_bitfields_weight) { let (acc_candidate_weight, indices) = random_sel::::Hash>, _>( @@ -1242,7 +1243,7 @@ fn limit_and_sanitize_disputes< // The total weight if all disputes would be included let disputes_weight = multi_dispute_statement_sets_weight::(&disputes); - if disputes_weight > max_consumable_weight { + if disputes_weight.any_gt(max_consumable_weight) { let mut checked_acc = Vec::::with_capacity(disputes.len()); // Since the disputes array is sorted, we may use binary search to find the beginning of @@ -1265,7 +1266,7 @@ fn limit_and_sanitize_disputes< let remote_disputes = disputes.split_off(idx); // Accumualated weight of all disputes picked, that passed the checks. - let mut weight_acc = 0 as Weight; + let mut weight_acc = Weight::zero(); // Select disputes in-order until the remaining weight is attained disputes.iter().for_each(|dss| { @@ -1273,7 +1274,7 @@ fn limit_and_sanitize_disputes< dss.statements.len() as u32, ); let updated = weight_acc.saturating_add(dispute_weight); - if max_consumable_weight >= updated { + if max_consumable_weight.all_gte(updated) { // only apply the weight if the validity check passes if let Some(checked) = dispute_statement_set_valid(dss.clone()) { checked_acc.push(checked); diff --git a/runtime/parachains/src/paras_inherent/tests.rs b/runtime/parachains/src/paras_inherent/tests.rs index d1e02837e3c1..86d2f1c10537 100644 --- a/runtime/parachains/src/paras_inherent/tests.rs +++ b/runtime/parachains/src/paras_inherent/tests.rs @@ -607,11 +607,9 @@ mod enter { let limit_inherent_data = Pallet::::create_inherent_inner(&inherent_data.clone()).unwrap(); assert_ne!(limit_inherent_data, expected_para_inherent_data); - assert!( - inherent_data_weight(&limit_inherent_data) <= - inherent_data_weight(&expected_para_inherent_data) - ); - assert!(inherent_data_weight(&limit_inherent_data) <= max_block_weight()); + assert!(inherent_data_weight(&limit_inherent_data) + .all_lte(inherent_data_weight(&expected_para_inherent_data))); + assert!(inherent_data_weight(&limit_inherent_data).all_lte(max_block_weight())); // Three disputes is over weight (see previous test), so we expect to only see 2 disputes assert_eq!(limit_inherent_data.disputes.len(), 2); @@ -760,7 +758,7 @@ mod enter { }); let expected_para_inherent_data = scenario.data.clone(); - assert!(max_block_weight() < inherent_data_weight(&expected_para_inherent_data)); + assert!(max_block_weight().any_lt(inherent_data_weight(&expected_para_inherent_data))); // Check the para inherent data is as expected: // * 1 bitfield per validator (5 validators per core, 2 backed candidates, 3 disputes => 5*5 = 25) @@ -779,7 +777,7 @@ mod enter { // Expect that inherent data is filtered to include only 1 backed candidate and 2 disputes assert!(limit_inherent_data != expected_para_inherent_data); assert!( - max_block_weight() >= inherent_data_weight(&limit_inherent_data), + max_block_weight().all_gte(inherent_data_weight(&limit_inherent_data)), "Post limiting exceeded block weight: max={} vs. inherent={}", max_block_weight(), inherent_data_weight(&limit_inherent_data) diff --git a/runtime/parachains/src/paras_inherent/weights.rs b/runtime/parachains/src/paras_inherent/weights.rs index d177151548df..c1680659dc54 100644 --- a/runtime/parachains/src/paras_inherent/weights.rs +++ b/runtime/parachains/src/paras_inherent/weights.rs @@ -37,18 +37,18 @@ pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn enter_variable_disputes(v: u32) -> Weight { // MAX Block Weight should fit 4 disputes - 80_000 * v as Weight + 80_000 + Weight::from_ref_time(80_000 * v as u64 + 80_000) } fn enter_bitfields() -> Weight { // MAX Block Weight should fit 4 backed candidates - 40_000 as Weight + Weight::from_ref_time(40_000u64) } fn enter_backed_candidates_variable(v: u32) -> Weight { // MAX Block Weight should fit 4 backed candidates - 40_000 * v as Weight + 40_000 + Weight::from_ref_time(40_000 * v as u64 + 40_000) } fn enter_backed_candidate_code_upgrade() -> Weight { - 0 + Weight::zero() } } // To simplify benchmarks running as tests, we set all the weights to 0. `enter` will exit early @@ -57,16 +57,16 @@ impl WeightInfo for TestWeightInfo { #[cfg(feature = "runtime-benchmarks")] impl WeightInfo for TestWeightInfo { fn enter_variable_disputes(_v: u32) -> Weight { - 0 + Weight::zero() } fn enter_bitfields() -> Weight { - 0 + Weight::zero() } fn enter_backed_candidates_variable(_v: u32) -> Weight { - 0 + Weight::zero() } fn enter_backed_candidate_code_upgrade() -> Weight { - 0 + Weight::zero() } } @@ -99,12 +99,12 @@ pub fn multi_dispute_statement_sets_weight< .as_ref() .iter() .map(|d| dispute_statement_set_weight::(d)) - .fold(0, |acc_weight, weight| acc_weight.saturating_add(weight)) + .fold(Weight::zero(), |acc_weight, weight| acc_weight.saturating_add(weight)) } pub fn signed_bitfields_weight(bitfields_len: usize) -> Weight { <::WeightInfo as WeightInfo>::enter_bitfields() - .saturating_mul(bitfields_len as Weight) + .saturating_mul(bitfields_len as u64) } pub fn backed_candidate_weight( @@ -125,5 +125,5 @@ pub fn backed_candidates_weight( candidates .iter() .map(|c| backed_candidate_weight::(c)) - .fold(0, |acc, x| acc.saturating_add(x)) + .fold(Weight::zero(), |acc, x| acc.saturating_add(x)) } diff --git a/runtime/parachains/src/reward_points.rs b/runtime/parachains/src/reward_points.rs index a1d4dceba5c5..1d1d8748f1c2 100644 --- a/runtime/parachains/src/reward_points.rs +++ b/runtime/parachains/src/reward_points.rs @@ -22,42 +22,71 @@ //! for the time being, although we will build schemes to do so in the future. use crate::{session_info, shared}; -use frame_support::traits::ValidatorSet; -use primitives::v2::ValidatorIndex; +use frame_support::traits::{Defensive, ValidatorSet}; +use primitives::v2::{SessionIndex, ValidatorIndex}; +use sp_std::collections::btree_set::BTreeSet; /// The amount of era points given by backing a candidate that is included. pub const BACKING_POINTS: u32 = 20; +/// The amount of era points given by dispute voting on a candidate. +pub const DISPUTE_STATEMENT_POINTS: u32 = 20; /// Rewards validators for participating in parachains with era points in pallet-staking. pub struct RewardValidatorsWithEraPoints(sp_std::marker::PhantomData); -impl crate::inclusion::RewardValidators for RewardValidatorsWithEraPoints +impl RewardValidatorsWithEraPoints where - C: pallet_staking::Config + shared::Config + session_info::Config, + C: pallet_staking::Config + session_info::Config, C::ValidatorSet: ValidatorSet, { - fn reward_backing(indices: impl IntoIterator) { - // Fetch the validators from the _session_ because sessions are offset from eras - // and we are rewarding for behavior in current session. - let session_index = shared::Pallet::::session_index(); + /// Reward validators in session with points, but only if they are in the active set. + fn reward_only_active( + session_index: SessionIndex, + indices: impl IntoIterator, + points: u32, + ) { let validators = session_info::Pallet::::account_keys(&session_index); - let validators = match validators { + let validators = match validators + .defensive_proof("account_keys are present for dispute_period sessions") + { Some(validators) => validators, - None => { - // Account keys are missing for the current session. - // This might happen only for the first session after - // `AccountKeys` were introduced via runtime upgrade. - return - }, + None => return, }; + // limit rewards to the active validator set + let active_set: BTreeSet<_> = C::ValidatorSet::validators().into_iter().collect(); let rewards = indices .into_iter() .filter_map(|i| validators.get(i.0 as usize).cloned()) - .map(|v| (v, BACKING_POINTS)); + .filter(|v| active_set.contains(v)) + .map(|v| (v, points)); >::reward_by_ids(rewards); } +} + +impl crate::inclusion::RewardValidators for RewardValidatorsWithEraPoints +where + C: pallet_staking::Config + shared::Config + session_info::Config, + C::ValidatorSet: ValidatorSet, +{ + fn reward_backing(indices: impl IntoIterator) { + let session_index = shared::Pallet::::session_index(); + Self::reward_only_active(session_index, indices, BACKING_POINTS); + } fn reward_bitfields(_validators: impl IntoIterator) {} } + +impl crate::disputes::RewardValidators for RewardValidatorsWithEraPoints +where + C: pallet_staking::Config + session_info::Config, + C::ValidatorSet: ValidatorSet, +{ + fn reward_dispute_statement( + session: SessionIndex, + validators: impl IntoIterator, + ) { + Self::reward_only_active(session, validators, DISPUTE_STATEMENT_POINTS); + } +} diff --git a/runtime/parachains/src/runtime_api_impl/mod.rs b/runtime/parachains/src/runtime_api_impl/mod.rs index 603b6c4cb385..da1cd6d09337 100644 --- a/runtime/parachains/src/runtime_api_impl/mod.rs +++ b/runtime/parachains/src/runtime_api_impl/mod.rs @@ -17,9 +17,14 @@ //! Runtime API implementations for Parachains. //! //! These are exposed as different modules using different sets of primitives. -//! At the moment there is only a v2 module and it is not completely clear how migration -//! to a v2 would be done. - +//! At the moment there is a `v2` module for the current stable API and +//! `vstaging` module for all staging methods. +//! When new version of the stable API is released it will be based on `v2` and +//! will contain methods from `vstaging`. +//! The promotion consists of the following steps: +//! 1. Bump the version of the stable module (e.g. `v2` becomes `v3`) +//! 2. Move methods from `vstaging` to `v3`. The new stable version should include +//! all methods from `vstaging` tagged with the new version number (e.g. all +//! `v3` methods). pub mod v2; -#[cfg(feature = "vstaging")] pub mod vstaging; diff --git a/runtime/parachains/src/runtime_api_impl/v2.rs b/runtime/parachains/src/runtime_api_impl/v2.rs index 20ee41636d81..77ea96742b54 100644 --- a/runtime/parachains/src/runtime_api_impl/v2.rs +++ b/runtime/parachains/src/runtime_api_impl/v2.rs @@ -323,7 +323,7 @@ pub fn candidate_pending_availability( pub fn candidate_events(extract_event: F) -> Vec> where T: initializer::Config, - F: Fn(::Event) -> Option>, + F: Fn(::RuntimeEvent) -> Option>, { use inclusion::Event as RawEvent; diff --git a/runtime/parachains/src/runtime_api_impl/vstaging.rs b/runtime/parachains/src/runtime_api_impl/vstaging.rs index 8715cdc53121..7ae235c8133a 100644 --- a/runtime/parachains/src/runtime_api_impl/vstaging.rs +++ b/runtime/parachains/src/runtime_api_impl/vstaging.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -// Put implementations of functions from staging API here. +//! Put implementations of functions from staging APIs here. use crate::disputes; use primitives::v2::{CandidateHash, DisputeState, SessionIndex}; diff --git a/runtime/parachains/src/scheduler.rs b/runtime/parachains/src/scheduler.rs index 7cb7497571da..0185817b2aa1 100644 --- a/runtime/parachains/src/scheduler.rs +++ b/runtime/parachains/src/scheduler.rs @@ -226,7 +226,7 @@ pub mod pallet { impl Pallet { /// Called by the initializer to initialize the scheduler pallet. pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { - 0 + Weight::zero() } /// Called by the initializer to finalize the scheduler pallet. diff --git a/runtime/parachains/src/session_info.rs b/runtime/parachains/src/session_info.rs index 5f19d995f844..c903638423c2 100644 --- a/runtime/parachains/src/session_info.rs +++ b/runtime/parachains/src/session_info.rs @@ -188,7 +188,7 @@ impl Pallet { /// Called by the initializer to initialize the session info pallet. pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { - 0 + Weight::zero() } /// Called by the initializer to finalize the session info pallet. diff --git a/runtime/parachains/src/session_info/tests.rs b/runtime/parachains/src/session_info/tests.rs index 4128463578e6..168bd3d1cc27 100644 --- a/runtime/parachains/src/session_info/tests.rs +++ b/runtime/parachains/src/session_info/tests.rs @@ -19,8 +19,8 @@ use crate::{ configuration::HostConfiguration, initializer::SessionChangeNotification, mock::{ - new_test_ext, Configuration, MockGenesisConfig, Origin, ParasShared, SessionInfo, System, - Test, + new_test_ext, Configuration, MockGenesisConfig, ParasShared, RuntimeOrigin, SessionInfo, + System, Test, }, util::take_active_subset, }; @@ -109,7 +109,7 @@ fn session_pruning_is_based_on_dispute_period() { // changing `dispute_period` works let dispute_period = 5; - Configuration::set_dispute_period(Origin::root(), dispute_period).unwrap(); + Configuration::set_dispute_period(RuntimeOrigin::root(), dispute_period).unwrap(); // Dispute period does not automatically change let config = Configuration::config(); @@ -124,7 +124,7 @@ fn session_pruning_is_based_on_dispute_period() { // Increase dispute period even more let new_dispute_period = 16; - Configuration::set_dispute_period(Origin::root(), new_dispute_period).unwrap(); + Configuration::set_dispute_period(RuntimeOrigin::root(), new_dispute_period).unwrap(); run_to_block(210, session_changes); assert_eq!(EarliestStoredSession::::get(), 21 - dispute_period); @@ -154,7 +154,7 @@ fn session_info_is_based_on_config() { assert_eq!(session.needed_approvals, 3); // change some param - Configuration::set_needed_approvals(Origin::root(), 42).unwrap(); + Configuration::set_needed_approvals(RuntimeOrigin::root(), 42).unwrap(); // 2 sessions later run_to_block(3, new_session_every_block); let session = Sessions::::get(&3).unwrap(); diff --git a/runtime/parachains/src/shared.rs b/runtime/parachains/src/shared.rs index 3769ff4525c1..5f5d44509ed2 100644 --- a/runtime/parachains/src/shared.rs +++ b/runtime/parachains/src/shared.rs @@ -75,7 +75,7 @@ pub mod pallet { impl Pallet { /// Called by the initializer to initialize the configuration pallet. pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { - 0 + Weight::zero() } /// Called by the initializer to finalize the configuration pallet. diff --git a/runtime/parachains/src/ump.rs b/runtime/parachains/src/ump.rs index 47453c89c3ab..63e6e2c4692b 100644 --- a/runtime/parachains/src/ump.rs +++ b/runtime/parachains/src/ump.rs @@ -73,7 +73,7 @@ impl UmpSink for () { _: &[u8], _: Weight, ) -> Result { - Ok(0) + Ok(Weight::zero()) } } @@ -93,7 +93,9 @@ fn upward_message_id(data: &[u8]) -> MessageId { sp_io::hashing::blake2_256(data) } -impl, C: Config> UmpSink for XcmSink { +impl, C: Config> UmpSink + for XcmSink +{ fn process_upward_message( origin: ParaId, mut data: &[u8], @@ -106,13 +108,13 @@ impl, C: Config> UmpSink for XcmSi }; let id = upward_message_id(&data[..]); - let maybe_msg_and_weight = VersionedXcm::::decode_all_with_depth_limit( + let maybe_msg_and_weight = VersionedXcm::::decode_all_with_depth_limit( xcm::MAX_XCM_DECODE_DEPTH, &mut data, ) .map(|xcm| { ( - Xcm::::try_from(xcm), + Xcm::::try_from(xcm), // NOTE: We are overestimating slightly here. // The benchmark is timing this whole function with different message sizes and a NOOP extrinsic to // measure the size-dependent weight. But as we use the weight funtion **in** the benchmarked funtion we @@ -123,7 +125,7 @@ impl, C: Config> UmpSink for XcmSi match maybe_msg_and_weight { Err(_) => { Pallet::::deposit_event(Event::InvalidFormat(id)); - Ok(0) + Ok(Weight::zero()) }, Ok((Err(()), weight_used)) => { Pallet::::deposit_event(Event::UnsupportedVersion(id)); @@ -131,11 +133,13 @@ impl, C: Config> UmpSink for XcmSi }, Ok((Ok(xcm_message), weight_used)) => { let xcm_junction = Junction::Parachain(origin.into()); - let outcome = XcmExecutor::execute_xcm(xcm_junction, xcm_message, id, max_weight); + let outcome = + XcmExecutor::execute_xcm(xcm_junction, xcm_message, id, max_weight.ref_time()); match outcome { - Outcome::Error(XcmError::WeightLimitReached(required)) => Err((id, required)), + Outcome::Error(XcmError::WeightLimitReached(required)) => + Err((id, Weight::from_ref_time(required))), outcome => { - let outcome_weight = outcome.weight_used(); + let outcome_weight = Weight::from_ref_time(outcome.weight_used()); Pallet::::deposit_event(Event::ExecutedUpward(id, outcome)); Ok(weight_used.saturating_add(outcome_weight)) }, @@ -216,7 +220,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + configuration::Config { /// The aggregate event. - type Event: From + IsType<::Event>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; /// A place where all received upward messages are funneled. type UmpSink: UmpSink; @@ -227,10 +231,10 @@ pub mod pallet { /// stalls the queue in doing so. More than 100 will provide additional weight for the first message only. /// /// Generally you'll want this to be a bit more - 150 or 200 would be good values. - type FirstMessageFactorPercent: Get; + type FirstMessageFactorPercent: Get; /// Origin which is allowed to execute overweight messages. - type ExecuteOverweightOrigin: EnsureOrigin; + type ExecuteOverweightOrigin: EnsureOrigin; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -368,7 +372,7 @@ pub mod pallet { impl Pallet { /// Block initialization logic, called by initializer. pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { - 0 + Weight::zero() } /// Block finalization logic, called by initializer. @@ -385,7 +389,7 @@ impl Pallet { /// Iterate over all paras that were noted for offboarding and remove all the data /// associated with them. fn perform_outgoing_para_cleanup(outgoing: &[ParaId]) -> Weight { - let mut weight: Weight = 0; + let mut weight: Weight = Weight::zero(); for outgoing_para in outgoing { weight = weight.saturating_add(Self::clean_ump_after_outgoing(outgoing_para)); } @@ -467,7 +471,7 @@ impl Pallet { para: ParaId, upward_messages: Vec, ) -> Weight { - let mut weight = 0; + let mut weight = Weight::zero(); if !upward_messages.is_empty() { let (extra_count, extra_size) = upward_messages @@ -503,24 +507,27 @@ impl Pallet { /// Devote some time into dispatching pending upward messages. pub(crate) fn process_pending_upward_messages() -> Weight { - let mut weight_used = 0; + let mut weight_used = Weight::zero(); let config = >::config(); let mut cursor = NeedsDispatchCursor::new::(); let mut queue_cache = QueueCache::new(); while let Some(dispatchee) = cursor.peek() { - if weight_used >= config.ump_service_total_weight { + if weight_used.any_gte(config.ump_service_total_weight) { // Then check whether we've reached or overshoot the // preferred weight for the dispatching stage. // // if so - bail. break } - let max_weight = if weight_used == 0 { + let max_weight = if weight_used == Weight::zero() { // we increase the amount of weight that we're allowed to use on the first message to try to prevent // the possibility of blockage of the queue. - config.ump_service_total_weight * T::FirstMessageFactorPercent::get() / 100 + config + .ump_service_total_weight + .saturating_mul(T::FirstMessageFactorPercent::get()) / + 100 } else { config.ump_service_total_weight - weight_used }; @@ -535,7 +542,7 @@ impl Pallet { let _ = queue_cache.consume_front::(dispatchee); }, Err((id, required)) => { - if required > config.ump_max_individual_weight { + if required.any_gt(config.ump_max_individual_weight) { // overweight - add to overweight queue and continue with message // execution consuming the message. let upward_message = queue_cache.consume_front::(dispatchee).expect( diff --git a/runtime/parachains/src/ump/benchmarking.rs b/runtime/parachains/src/ump/benchmarking.rs index 0d38e77b7b71..206829599f9b 100644 --- a/runtime/parachains/src/ump/benchmarking.rs +++ b/runtime/parachains/src/ump/benchmarking.rs @@ -18,9 +18,9 @@ use super::{Pallet as Ump, *}; use frame_system::RawOrigin; use xcm::prelude::*; -fn assert_last_event_type(generic_event: ::Event) { +fn assert_last_event_type(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(sp_std::mem::discriminant(event), sp_std::mem::discriminant(&system_event)); @@ -43,7 +43,7 @@ fn create_message_min_size(size: u32) -> Vec { // Create a message with an empty remark call to determine the encoding overhead let msg_size_empty_transact = VersionedXcm::::from(Xcm::(vec![Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: Weight::MAX, + require_weight_at_most: Weight::MAX.ref_time(), call: frame_system::Call::::remark_with_event { remark: vec![] }.encode().into(), }])) .encode() @@ -55,7 +55,7 @@ fn create_message_min_size(size: u32) -> Vec { remark.resize(size, 0u8); let msg = VersionedXcm::::from(Xcm::(vec![Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: Weight::MAX, + require_weight_at_most: Weight::MAX.ref_time(), call: frame_system::Call::::remark_with_event { remark }.encode().into(), }])) .encode(); @@ -70,7 +70,7 @@ fn create_message_overweight() -> Vec { let call = frame_system::Call::::set_code { code: vec![] }; VersionedXcm::::from(Xcm::(vec![Transact { origin_kind: OriginKind::Superuser, - require_weight_at_most: max_block_weight, + require_weight_at_most: max_block_weight.ref_time(), call: call.encode().into(), }])) .encode() @@ -107,7 +107,7 @@ frame_benchmarking::benchmarks! { service_overweight { let host_conf = configuration::ActiveConfig::::get(); - let weight = host_conf.ump_max_individual_weight + host_conf.ump_max_individual_weight + 1000000; + let weight = host_conf.ump_max_individual_weight + host_conf.ump_max_individual_weight + Weight::from_ref_time(1000000); let para = ParaId::from(1978); // The message's weight does not really matter here, as we add service_overweight's // max_weight parameter to the extrinsic's weight in the weight calculation. @@ -117,18 +117,18 @@ frame_benchmarking::benchmarks! { let msg = create_message_overweight::(); // This just makes sure that 0 is not a valid index and we can use it later on. - let _ = Ump::::service_overweight(RawOrigin::Root.into(), 0, 1000); + let _ = Ump::::service_overweight(RawOrigin::Root.into(), 0, Weight::from_ref_time(1000).set_proof_size(u64::MAX)); // Start with the block number 1. This is needed because should an event be // emitted during the genesis block they will be implicitly wiped. frame_system::Pallet::::set_block_number(1u32.into()); queue_upward_msg::(&host_conf, para, msg.clone()); Ump::::process_pending_upward_messages(); assert_last_event_type::( - Event::OverweightEnqueued(para, upward_message_id(&msg), 0, 0).into() + Event::OverweightEnqueued(para, upward_message_id(&msg), 0, Weight::zero()).into() ); }: _(RawOrigin::Root, 0, Weight::MAX) verify { - assert_last_event_type::(Event::OverweightServiced(0, 0).into()); + assert_last_event_type::(Event::OverweightServiced(0, Weight::zero()).into()); } } diff --git a/runtime/parachains/src/ump/tests.rs b/runtime/parachains/src/ump/tests.rs index b4e758b4b88c..23c5159eab0f 100644 --- a/runtime/parachains/src/ump/tests.rs +++ b/runtime/parachains/src/ump/tests.rs @@ -16,8 +16,8 @@ use super::*; use crate::mock::{ - assert_last_event, new_test_ext, take_processed, Configuration, MockGenesisConfig, Origin, - System, Test, Ump, + assert_last_event, new_test_ext, take_processed, Configuration, MockGenesisConfig, + RuntimeOrigin, System, Test, Ump, }; use frame_support::{assert_noop, assert_ok, weights::Weight}; use std::collections::HashSet; @@ -38,8 +38,8 @@ impl Default for GenesisConfigBuilder { max_upward_message_num_per_candidate: 2, max_upward_queue_count: 4, max_upward_queue_size: 64, - ump_service_total_weight: 1000, - ump_max_individual_weight: 100, + ump_service_total_weight: Weight::from_ref_time(1000).set_proof_size(1000), + ump_max_individual_weight: Weight::from_ref_time(100).set_proof_size(100), } } } @@ -155,7 +155,11 @@ fn dispatch_resume_after_exceeding_dispatch_stage_weight() { let q_msg = (500u32, "q_msg").encode(); new_test_ext( - GenesisConfigBuilder { ump_service_total_weight: 500, ..Default::default() }.build(), + GenesisConfigBuilder { + ump_service_total_weight: Weight::from_ref_time(500).set_proof_size(500), + ..Default::default() + } + .build(), ) .execute_with(|| { queue_upward_msg(q, q_msg.clone()); @@ -199,8 +203,8 @@ fn dispatch_keeps_message_after_weight_exhausted() { new_test_ext( GenesisConfigBuilder { - ump_service_total_weight: 500, - ump_max_individual_weight: 300, + ump_service_total_weight: Weight::from_ref_time(500).set_proof_size(500), + ump_max_individual_weight: Weight::from_ref_time(300).set_proof_size(300), ..Default::default() } .build(), @@ -238,7 +242,11 @@ fn dispatch_correctly_handle_remove_of_latest() { let b_msg_1 = (300u32, "b_msg_1").encode(); new_test_ext( - GenesisConfigBuilder { ump_service_total_weight: 900, ..Default::default() }.build(), + GenesisConfigBuilder { + ump_service_total_weight: Weight::from_ref_time(900).set_proof_size(900), + ..Default::default() + } + .build(), ) .execute_with(|| { // We want to test here an edge case, where we remove the queue with the highest @@ -288,7 +296,7 @@ fn service_overweight_unknown() { // the next test. new_test_ext(GenesisConfigBuilder::default().build()).execute_with(|| { assert_noop!( - Ump::service_overweight(Origin::root(), 0, 1000), + Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(1000)), Error::::UnknownMessageIndex ); }); @@ -304,8 +312,8 @@ fn overweight_queue_works() { new_test_ext( GenesisConfigBuilder { - ump_service_total_weight: 900, - ump_max_individual_weight: 300, + ump_service_total_weight: Weight::from_ref_time(900).set_proof_size(900), + ump_max_individual_weight: Weight::from_ref_time(300).set_proof_size(300), ..Default::default() } .build(), @@ -326,24 +334,30 @@ fn overweight_queue_works() { queue_upward_msg(para_a, a_msg_3.clone()); Ump::process_pending_upward_messages(); assert_last_event( - Event::OverweightEnqueued(para_a, upward_message_id(&a_msg_3[..]), 0, 500).into(), + Event::OverweightEnqueued( + para_a, + upward_message_id(&a_msg_3[..]), + 0, + Weight::from_ref_time(500), + ) + .into(), ); // Now verify that if we wanted to service this overweight message with less than enough // weight it will fail. assert_noop!( - Ump::service_overweight(Origin::root(), 0, 499), + Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(499)), Error::::WeightOverLimit ); // ... and if we try to service it with just enough weight it will succeed as well. - assert_ok!(Ump::service_overweight(Origin::root(), 0, 500)); - assert_last_event(Event::OverweightServiced(0, 500).into()); + assert_ok!(Ump::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(500))); + assert_last_event(Event::OverweightServiced(0, Weight::from_ref_time(500)).into()); // ... and if we try to service a message with index that doesn't exist it will error // out. assert_noop!( - Ump::service_overweight(Origin::root(), 1, 1000), + Ump::service_overweight(RuntimeOrigin::root(), 1, Weight::from_ref_time(1000)), Error::::UnknownMessageIndex ); }); diff --git a/runtime/polkadot/Cargo.toml b/runtime/polkadot/Cargo.toml index b57b6cfda572..c52aeb2a1ec0 100644 --- a/runtime/polkadot/Cargo.toml +++ b/runtime/polkadot/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-runtime" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" build = "build.rs" @@ -16,71 +16,73 @@ serde_derive = { version = "1.0.117", optional = true } static_assertions = "1.1.0" smallvec = "1.8.0" -authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-npos-elections = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-npos-elections = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } -pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-bags-list = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-child-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-im-online = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-indices = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-membership = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-nomination-pools = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-offences = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-system = {git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-bags-list = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-child-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-fast-unstake = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-im-online = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-indices = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-membership = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-nomination-pools = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-offences = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-system = {git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } polkadot-runtime-constants = { package = "polkadot-runtime-constants", path = "./constants", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-tips = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-election-provider-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-tips = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-election-provider-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false } -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-election-provider-support-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-election-provider-support-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } hex-literal = { version = "0.3.4", optional = true } runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false } @@ -94,17 +96,16 @@ xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default [dev-dependencies] hex-literal = "0.3.4" tiny-keccak = { version = "2.0.2", features = ["keccak"] } -keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -trie-db = "0.23.1" +keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } serde_json = "1.0.81" separator = "0.4.1" -remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } tokio = { version = "1.19.2", features = ["macros"] } -sp-tracing = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-tracing = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] default = ["std"] @@ -139,6 +140,7 @@ std = [ "pallet-elections-phragmen/std", "pallet-election-provider-multi-phase/std", "pallet-democracy/std", + "pallet-fast-unstake/std", "pallet-grandpa/std", "pallet-identity/std", "pallet-im-online/std", @@ -146,6 +148,7 @@ std = [ "pallet-membership/std", "pallet-multisig/std", "pallet-nomination-pools/std", + "pallet-nomination-pools-runtime-api/std", "pallet-offences/std", "pallet-preimage/std", "pallet-proxy/std", @@ -193,6 +196,7 @@ runtime-benchmarks = [ "pallet-elections-phragmen/runtime-benchmarks", "pallet-election-provider-multi-phase/runtime-benchmarks", "pallet-election-provider-support-benchmarking/runtime-benchmarks", + "pallet-fast-unstake/runtime-benchmarks", "pallet-grandpa/runtime-benchmarks", "pallet-identity/runtime-benchmarks", "pallet-im-online/runtime-benchmarks", @@ -200,7 +204,7 @@ runtime-benchmarks = [ "pallet-membership/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", "pallet-nomination-pools/runtime-benchmarks", - "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-benchmarking/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", @@ -213,9 +217,9 @@ runtime-benchmarks = [ "pallet-utility/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", - "pallet-offences-benchmarking", - "pallet-session-benchmarking", - "frame-system-benchmarking", + "pallet-offences-benchmarking/runtime-benchmarks", + "pallet-session-benchmarking/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", "hex-literal", "xcm-builder/runtime-benchmarks", "frame-election-provider-support/runtime-benchmarks", @@ -225,6 +229,7 @@ try-runtime = [ "frame-executive/try-runtime", "frame-try-runtime", "frame-system/try-runtime", + "runtime-common/try-runtime", "pallet-authority-discovery/try-runtime", "pallet-authorship/try-runtime", "pallet-balances/try-runtime", @@ -235,6 +240,7 @@ try-runtime = [ "pallet-collective/try-runtime", "pallet-elections-phragmen/try-runtime", "pallet-election-provider-multi-phase/try-runtime", + "pallet-fast-unstake/try-runtime", "pallet-democracy/try-runtime", "pallet-grandpa/try-runtime", "pallet-identity/try-runtime", @@ -242,6 +248,7 @@ try-runtime = [ "pallet-indices/try-runtime", "pallet-membership/try-runtime", "pallet-multisig/try-runtime", + "pallet-nomination-pools/try-runtime", "pallet-offences/try-runtime", "pallet-preimage/try-runtime", "pallet-proxy/try-runtime", @@ -254,7 +261,7 @@ try-runtime = [ "pallet-babe/try-runtime", "pallet-vesting/try-runtime", "pallet-utility/try-runtime", - "runtime-common/try-runtime", + "pallet-xcm/try-runtime", ] # When enabled, the runtime API will not be build. # diff --git a/runtime/polkadot/constants/Cargo.toml b/runtime/polkadot/constants/Cargo.toml index 26af94a7b160..717be2c5dfa7 100644 --- a/runtime/polkadot/constants/Cargo.toml +++ b/runtime/polkadot/constants/Cargo.toml @@ -1,19 +1,23 @@ [package] name = "polkadot-runtime-constants" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] smallvec = "1.8.0" -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } primitives = { package = "polkadot-primitives", path = "../../../primitives", default-features = false } runtime-common = { package = "polkadot-runtime-common", path = "../../common", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } [features] default = ["std"] std = [ - "sp-runtime/std" + "sp-core/std", + "sp-runtime/std", + "sp-weights/std" ] diff --git a/runtime/polkadot/constants/src/lib.rs b/runtime/polkadot/constants/src/lib.rs index dfd50b7f0bb6..be37482968a8 100644 --- a/runtime/polkadot/constants/src/lib.rs +++ b/runtime/polkadot/constants/src/lib.rs @@ -52,6 +52,9 @@ pub mod time { pub const WEEKS: BlockNumber = DAYS * 7; // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. + // The choice of is done in accordance to the slot duration and expected target + // block time, for safely resisting network delays of maximum two seconds. + // pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); } @@ -84,7 +87,7 @@ pub mod fee { fn polynomial() -> WeightToFeeCoefficients { // in Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: let p = super::currency::CENTS; - let q = 10 * Balance::from(ExtrinsicBaseWeight::get()); + let q = 10 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); smallvec![WeightToFeeCoefficient { degree: 1, negative: false, diff --git a/runtime/polkadot/constants/src/weights/block_weights.rs b/runtime/polkadot/constants/src/weights/block_weights.rs index 8d13fcdc54d0..ffe23486689f 100644 --- a/runtime/polkadot/constants/src/weights/block_weights.rs +++ b/runtime/polkadot/constants/src/weights/block_weights.rs @@ -1,28 +1,26 @@ -// This file is part of Substrate. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// 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. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// 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 . //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19 (Y/M/D) -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25 (Y/M/D) +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Development` //! WARMUPS: `10`, REPEAT: `100` //! WEIGHT-PATH: `runtime/polkadot/constants/src/weights/` -//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1`, WEIGHT-ADD: `0` +//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` // Executed Command: // ./target/production/polkadot @@ -34,32 +32,31 @@ // --weight-path=runtime/polkadot/constants/src/weights/ // --warmup=10 // --repeat=100 +// --header=./file_header.txt -use frame_support::{ - parameter_types, - weights::{constants::WEIGHT_PER_NANOS, Weight}, -}; +use sp_core::parameter_types; +use sp_weights::{constants::WEIGHT_PER_NANOS, Weight}; parameter_types! { /// Time to execute an empty block. - /// Calculated by multiplying the *Average* with `1` and adding `0`. + /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 5_736_651, 6_591_625 - /// Average: 5_849_907 - /// Median: 5_847_129 - /// Std-Dev: 109200.59 + /// Min, Max: 5_724_661, 5_957_728 + /// Average: 5_773_973 + /// Median: 5_766_638 + /// Std-Dev: 41694.64 /// /// Percentiles nanoseconds: - /// 99th: 6_131_246 - /// 95th: 5_988_921 - /// 75th: 5_885_724 - pub const BlockExecutionWeight: Weight = 5_849_907 * WEIGHT_PER_NANOS; + /// 99th: 5_903_185 + /// 95th: 5_846_214 + /// 75th: 5_789_579 + pub const BlockExecutionWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(5_773_973); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; + use sp_weights::constants; /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, @@ -69,8 +66,14 @@ mod test_weights { let w = super::BlockExecutionWeight::get(); // At least 100 µs. - assert!(w >= 100 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs."); + assert!( + w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(), + "Weight should be at least 100 µs." + ); // At most 50 ms. - assert!(w <= 50 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); + assert!( + w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(), + "Weight should be at most 50 ms." + ); } } diff --git a/runtime/polkadot/constants/src/weights/extrinsic_weights.rs b/runtime/polkadot/constants/src/weights/extrinsic_weights.rs index 6bf5ba0c9831..0e0481048e38 100644 --- a/runtime/polkadot/constants/src/weights/extrinsic_weights.rs +++ b/runtime/polkadot/constants/src/weights/extrinsic_weights.rs @@ -1,27 +1,26 @@ -// This file is part of Substrate. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// 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. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// 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 . //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-04-20 (Y/M/D) +//! DATE: 2022-10-25 (Y/M/D) +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Development` //! WARMUPS: `10`, REPEAT: `100` //! WEIGHT-PATH: `runtime/polkadot/constants/src/weights/` -//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1`, WEIGHT-ADD: `0` +//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` // Executed Command: // ./target/production/polkadot @@ -33,32 +32,31 @@ // --weight-path=runtime/polkadot/constants/src/weights/ // --warmup=10 // --repeat=100 +// --header=./file_header.txt -use frame_support::{ - parameter_types, - weights::{constants::WEIGHT_PER_NANOS, Weight}, -}; +use sp_core::parameter_types; +use sp_weights::{constants::WEIGHT_PER_NANOS, Weight}; parameter_types! { /// Time to execute a NO-OP extrinsic, for example `System::remark`. - /// Calculated by multiplying the *Average* with `1` and adding `0`. + /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// - /// Stats [NS]: - /// Min, Max: 84_940, 86_590 - /// Average: 85_212 - /// Median: 85_156 - /// Std-Dev: 243.25 + /// Stats nanoseconds: + /// Min, Max: 93_411, 94_850 + /// Average: 93_780 + /// Median: 93_708 + /// Std-Dev: 265.55 /// - /// Percentiles [NS]: - /// 99th: 86_269 - /// 95th: 85_510 - /// 75th: 85_216 - pub const ExtrinsicBaseWeight: Weight = 85_212 * WEIGHT_PER_NANOS; + /// Percentiles nanoseconds: + /// 99th: 94_619 + /// 95th: 94_334 + /// 75th: 93_854 + pub const ExtrinsicBaseWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(93_780); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; + use sp_weights::constants; /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, @@ -68,8 +66,14 @@ mod test_weights { let w = super::ExtrinsicBaseWeight::get(); // At least 10 µs. - assert!(w >= 10 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); + assert!( + w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(), + "Weight should be at least 10 µs." + ); // At most 1 ms. - assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); + assert!( + w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), + "Weight should be at most 1 ms." + ); } } diff --git a/runtime/polkadot/constants/src/weights/paritydb_weights.rs b/runtime/polkadot/constants/src/weights/paritydb_weights.rs index ae4ac96f392b..9695b7bc7800 100644 --- a/runtime/polkadot/constants/src/weights/paritydb_weights.rs +++ b/runtime/polkadot/constants/src/weights/paritydb_weights.rs @@ -57,7 +57,7 @@ pub mod constants { /// 99th: 14_451 /// 95th: 12_588 /// 75th: 11_200 - read: 11_826 * constants::WEIGHT_PER_NANOS, + read: 11_826 * constants::WEIGHT_PER_NANOS.ref_time(), /// Time to write one storage item. /// Calculated by multiplying the *Average* of all values with `1.1` and adding `0`. @@ -72,7 +72,7 @@ pub mod constants { /// 99th: 69_379 /// 95th: 47_168 /// 75th: 35_252 - write: 38_052 * constants::WEIGHT_PER_NANOS, + write: 38_052 * constants::WEIGHT_PER_NANOS.ref_time(), }; } @@ -88,20 +88,20 @@ pub mod constants { fn bound() { // At least 1 µs. assert!( - W::get().reads(1) >= constants::WEIGHT_PER_MICROS, + W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Read weight should be at least 1 µs." ); assert!( - W::get().writes(1) >= constants::WEIGHT_PER_MICROS, + W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Write weight should be at least 1 µs." ); // At most 1 ms. assert!( - W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, + W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Read weight should be at most 1 ms." ); assert!( - W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, + W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Write weight should be at most 1 ms." ); } diff --git a/runtime/polkadot/constants/src/weights/rocksdb_weights.rs b/runtime/polkadot/constants/src/weights/rocksdb_weights.rs index 2270f3a56689..1ed70431b9e3 100644 --- a/runtime/polkadot/constants/src/weights/rocksdb_weights.rs +++ b/runtime/polkadot/constants/src/weights/rocksdb_weights.rs @@ -56,7 +56,7 @@ pub mod constants { /// 99th: 32_074 /// 95th: 26_658 /// 75th: 19_363 - read: 20_499 * constants::WEIGHT_PER_NANOS, + read: 20_499 * constants::WEIGHT_PER_NANOS.ref_time(), /// Time to write one storage item. /// Calculated by multiplying the *Average* of all values with `1.1` and adding `0`. @@ -71,7 +71,7 @@ pub mod constants { /// 99th: 111_151 /// 95th: 92_666 /// 75th: 80_297 - write: 83_471 * constants::WEIGHT_PER_NANOS, + write: 83_471 * constants::WEIGHT_PER_NANOS.ref_time(), }; } @@ -87,20 +87,20 @@ pub mod constants { fn bound() { // At least 1 µs. assert!( - W::get().reads(1) >= constants::WEIGHT_PER_MICROS, + W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Read weight should be at least 1 µs." ); assert!( - W::get().writes(1) >= constants::WEIGHT_PER_MICROS, + W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Write weight should be at least 1 µs." ); // At most 1 ms. assert!( - W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, + W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Read weight should be at most 1 ms." ); assert!( - W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, + W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Write weight should be at most 1 ms." ); } diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index ba228396f0a7..02f9fd09d482 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -41,8 +41,8 @@ use frame_election_provider_support::{generate_solution_type, onchain, Sequentia use frame_support::{ construct_runtime, parameter_types, traits::{ - Contains, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, - PrivilegeCmp, + ConstU32, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, + PrivilegeCmp, WithdrawReasons, }, weights::ConstantMultiplier, PalletId, RuntimeDebug, @@ -54,11 +54,10 @@ use pallet_session::historical as session_historical; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::v2::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId, - InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, - PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, - ValidationCodeHash, ValidatorId, ValidatorIndex, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, + CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, + Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, + SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, }; use sp_core::OpaqueMetadata; use sp_mmr_primitives as mmr; @@ -85,7 +84,9 @@ pub use pallet_balances::Call as BalancesCall; pub use pallet_election_provider_multi_phase::Call as EPMCall; #[cfg(feature = "std")] pub use pallet_staking::StakerStatus; +use pallet_staking::UseValidatorsMap; pub use pallet_timestamp::Call as TimestampCall; +use sp_runtime::traits::Get; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -112,13 +113,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("polkadot"), impl_name: create_runtime_str!("parity-polkadot"), authoring_version: 0, - spec_version: 9280, + spec_version: 9310, impl_version: 0, #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS, #[cfg(feature = "disable-runtime-api")] apis: sp_version::create_apis_vec![[]], - transaction_version: 13, + transaction_version: 16, state_version: 0, }; @@ -135,62 +136,6 @@ pub fn native_version() -> NativeVersion { NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } } -pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(call: &Call) -> bool { - match call { - // These modules are all allowed to be called by transactions: - Call::Democracy(_) | - Call::Council(_) | - Call::TechnicalCommittee(_) | - Call::TechnicalMembership(_) | - Call::Treasury(_) | - Call::PhragmenElection(_) | - Call::System(_) | - Call::Scheduler(_) | - Call::Preimage(_) | - Call::Indices(_) | - Call::Babe(_) | - Call::Timestamp(_) | - Call::Balances(_) | - Call::Authorship(_) | - Call::Staking(_) | - Call::Session(_) | - Call::Grandpa(_) | - Call::ImOnline(_) | - Call::Utility(_) | - Call::Claims(_) | - Call::Vesting(_) | - Call::Identity(_) | - Call::Proxy(_) | - Call::Multisig(_) | - Call::Bounties(_) | - Call::ChildBounties(_) | - Call::Tips(_) | - Call::ElectionProviderMultiPhase(_) | - Call::Configuration(_) | - Call::ParasShared(_) | - Call::ParaInclusion(_) | - Call::Paras(_) | - Call::Initializer(_) | - Call::ParaInherent(_) | - Call::ParasDisputes(_) | - Call::Dmp(_) | - Call::Ump(_) | - Call::Hrmp(_) | - Call::Slots(_) | - Call::Registrar(_) | - Call::Auctions(_) | - Call::Crowdloan(_) | - Call::VoterList(_) | - Call::XcmPallet(_) | - Call::NominationPools(_) => true, - // All pallets are allowed, but exhaustive match is defensive - // in the case of adding new pallets. - } - } -} - type MoreThanHalfCouncil = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, @@ -202,11 +147,11 @@ parameter_types! { } impl frame_system::Config for Runtime { - type BaseCallFilter = BaseFilter; + type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = BlockWeights; type BlockLength = BlockLength; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = Nonce; type BlockNumber = BlockNumber; type Hash = Hash; @@ -214,7 +159,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = AccountIdLookup; type Header = generic::Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = RocksDbWeight; type Version = Version; @@ -264,17 +209,16 @@ impl PrivilegeCmp for OriginPrivilegeCmp { } impl pallet_scheduler::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type PalletsOrigin = OriginCaller; - type Call = Call; + type RuntimeCall = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = ScheduleOrigin; type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = weights::pallet_scheduler::WeightInfo; type OriginPrivilegeCmp = OriginPrivilegeCmp; - type PreimageProvider = Preimage; - type NoPreimagePostponement = NoPreimagePostponement; + type Preimages = Preimage; } parameter_types! { @@ -284,11 +228,10 @@ parameter_types! { } impl pallet_preimage::Config for Runtime { - type WeightInfo = pallet_preimage::weights::SubstrateWeight; - type Event = Event; + type WeightInfo = weights::pallet_preimage::WeightInfo; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; - type MaxSize = PreimageMaxSize; type BaseDeposit = PreimageBaseDeposit; type ByteDeposit = PreimageByteDeposit; } @@ -341,7 +284,7 @@ impl pallet_indices::Config for Runtime { type AccountIndex = AccountIndex; type Currency = Balances; type Deposit = IndexDeposit; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::pallet_indices::WeightInfo; } @@ -354,7 +297,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type Balance = Balance; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type MaxLocks = MaxLocks; @@ -371,7 +314,7 @@ parameter_types! { } impl pallet_transaction_payment::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter>; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = WeightToFee; @@ -413,7 +356,7 @@ impl_opaque_keys! { } impl pallet_session::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = pallet_staking::StashOf; type ShouldEndSession = Babe; @@ -505,7 +448,7 @@ impl pallet_election_provider_multi_phase::MinerConfig for Runtime { } impl pallet_election_provider_multi_phase::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type EstimateCallFee = TransactionPayment; type SignedPhase = SignedPhase; @@ -526,6 +469,9 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type OffchainRepeat = OffchainRepeat; type MinerTxPriority = NposSolutionPriority; type DataProvider = Staking; + #[cfg(feature = "fast-runtime")] + type Fallback = onchain::UnboundedExecution; + #[cfg(not(feature = "fast-runtime"))] type Fallback = pallet_election_provider_multi_phase::NoFallback; type GovernanceFallback = onchain::UnboundedExecution; type Solver = SequentialPhragmen< @@ -547,8 +493,9 @@ parameter_types! { pub const BagThresholds: &'static [u64] = &bag_thresholds::THRESHOLDS; } -impl pallet_bags_list::Config for Runtime { - type Event = Event; +type VoterBagsListInstance = pallet_bags_list::Instance1; +impl pallet_bags_list::Config for Runtime { + type RuntimeEvent = RuntimeEvent; type ScoreProvider = Staking; type WeightInfo = weights::pallet_bags_list::WeightInfo; type BagThresholds = BagThresholds; @@ -573,7 +520,7 @@ pallet_staking_reward_curve::build! { parameter_types! { // Six sessions in an era (24 hours). - pub const SessionsPerEra: SessionIndex = 6; + pub const SessionsPerEra: SessionIndex = prod_or_fast!(6, 1); // 28 eras for unbonding (28 days). pub const BondingDuration: sp_staking::EraIndex = 28; pub const SlashDeferDuration: sp_staking::EraIndex = 27; @@ -596,7 +543,7 @@ impl pallet_staking::Config for Runtime { type UnixTime = Timestamp; type CurrencyToVote = CurrencyToVote; type RewardRemainder = Treasury; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Slash = Treasury; type Reward = (); type SessionsPerEra = SessionsPerEra; @@ -612,12 +559,25 @@ impl pallet_staking::Config for Runtime { type ElectionProvider = ElectionProviderMultiPhase; type GenesisElectionProvider = onchain::UnboundedExecution; type VoterList = VoterList; + type TargetList = UseValidatorsMap; type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; + type HistoryDepth = frame_support::traits::ConstU32<84>; type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; type OnStakerSlash = NominationPools; type WeightInfo = weights::pallet_staking::WeightInfo; } +impl pallet_fast_unstake::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type DepositCurrency = Balances; + type Deposit = frame_support::traits::ConstU128<{ UNITS }>; + type ControlOrigin = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, + >; + type WeightInfo = weights::pallet_fast_unstake::WeightInfo; +} + parameter_types! { // Minimum 4 CENTS/byte pub const BasicDeposit: Balance = deposit(1, 258); @@ -629,7 +589,7 @@ parameter_types! { } impl pallet_identity::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BasicDeposit = BasicDeposit; type FieldDeposit = FieldDeposit; @@ -656,8 +616,7 @@ parameter_types! { } impl pallet_democracy::Config for Runtime { - type Proposal = Call; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type EnactmentPeriod = EnactmentPeriod; type VoteLockingPeriod = EnactmentPeriod; @@ -708,14 +667,15 @@ impl pallet_democracy::Config for Runtime { // only do it once and it lasts only for the cooloff period. type VetoOrigin = pallet_collective::EnsureMember; type CooloffPeriod = CooloffPeriod; - type PreimageByteDeposit = PreimageByteDeposit; - type OperationalPreimageOrigin = pallet_collective::EnsureMember; type Slash = Treasury; type Scheduler = Scheduler; type PalletsOrigin = OriginCaller; type MaxVotes = MaxVotes; type WeightInfo = weights::pallet_democracy::WeightInfo; type MaxProposals = MaxProposals; + type Preimages = Preimage; + type MaxDeposits = ConstU32<100>; + type MaxBlacklisted = ConstU32<100>; } parameter_types! { @@ -726,9 +686,9 @@ parameter_types! { pub type CouncilCollective = pallet_collective::Instance1; impl pallet_collective::Config for Runtime { - type Origin = Origin; - type Proposal = Call; - type Event = Event; + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; type MotionDuration = CouncilMotionDuration; type MaxProposals = CouncilMaxProposals; type MaxMembers = CouncilMaxMembers; @@ -755,7 +715,7 @@ parameter_types! { const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); impl pallet_elections_phragmen::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type PalletId = PhragmenElectionPalletId; type Currency = Balances; type ChangeMembers = Council; @@ -782,9 +742,9 @@ parameter_types! { pub type TechnicalCollective = pallet_collective::Instance2; impl pallet_collective::Config for Runtime { - type Origin = Origin; - type Proposal = Call; - type Event = Event; + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; type MotionDuration = TechnicalMotionDuration; type MaxProposals = TechnicalMaxProposals; type MaxMembers = TechnicalMaxMembers; @@ -793,7 +753,7 @@ impl pallet_collective::Config for Runtime { } impl pallet_membership::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type AddOrigin = MoreThanHalfCouncil; type RemoveOrigin = MoreThanHalfCouncil; type SwapOrigin = MoreThanHalfCouncil; @@ -834,7 +794,7 @@ impl pallet_treasury::Config for Runtime { type Currency = Balances; type ApproveOrigin = ApproveOrigin; type RejectOrigin = MoreThanHalfCouncil; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type OnSlash = Treasury; type ProposalBond = ProposalBond; type ProposalBondMinimum = ProposalBondMinimum; @@ -860,7 +820,7 @@ parameter_types! { } impl pallet_bounties::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BountyDepositBase = BountyDepositBase; type BountyDepositPayoutDelay = BountyDepositPayoutDelay; type BountyUpdatePeriod = BountyUpdatePeriod; @@ -880,14 +840,14 @@ parameter_types! { } impl pallet_child_bounties::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type MaxActiveChildBountyCount = MaxActiveChildBountyCount; type ChildBountyValueMinimum = ChildBountyValueMinimum; type WeightInfo = weights::pallet_child_bounties::WeightInfo; } impl pallet_tips::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DataDepositPerByte = DataDepositPerByte; type MaximumReasonLength = MaximumReasonLength; type Tippers = PhragmenElection; @@ -898,7 +858,7 @@ impl pallet_tips::Config for Runtime { } impl pallet_offences::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } @@ -915,7 +875,7 @@ parameter_types! { impl pallet_im_online::Config for Runtime { type AuthorityId = ImOnlineId; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorSet = Historical; type NextSessionRotation = Babe; type ReportUnresponsiveness = Offences; @@ -927,8 +887,7 @@ impl pallet_im_online::Config for Runtime { } impl pallet_grandpa::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; type KeyOwnerProof = >::Proof; @@ -954,14 +913,14 @@ impl pallet_grandpa::Config for Runtime { /// format of the chain. impl frame_system::offchain::CreateSignedTransaction for Runtime where - Call: From, + RuntimeCall: From, { fn create_transaction>( - call: Call, + call: RuntimeCall, public: ::Signer, account: AccountId, nonce: ::Index, - ) -> Option<(Call, ::SignaturePayload)> { + ) -> Option<(RuntimeCall, ::SignaturePayload)> { use sp_runtime::traits::StaticLookup; // take the biggest period possible. let period = @@ -1006,10 +965,10 @@ impl frame_system::offchain::SigningTypes for Runtime { impl frame_system::offchain::SendTransactionTypes for Runtime where - Call: From, + RuntimeCall: From, { type Extrinsic = UncheckedExtrinsic; - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; } parameter_types! { @@ -1022,7 +981,7 @@ parameter_types! { } impl claims::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type VestingSchedule = Vesting; type Prefix = Prefix; /// At least 3/4 of the council must agree to a claim move before it can happen. @@ -1033,20 +992,23 @@ impl claims::Config for Runtime { parameter_types! { pub const MinVestedTransfer: Balance = 1 * DOLLARS; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } impl pallet_vesting::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BlockNumberToBalance = ConvertInto; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = weights::pallet_vesting::WeightInfo; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; const MAX_VESTING_SCHEDULES: u32 = 28; } impl pallet_utility::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = weights::pallet_utility::WeightInfo; } @@ -1060,8 +1022,8 @@ parameter_types! { } impl pallet_multisig::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; @@ -1141,75 +1103,87 @@ impl Default for ProxyType { Self::Any } } -impl InstanceFilter for ProxyType { - fn filter(&self, c: &Call) -> bool { +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { match self { ProxyType::Any => true, ProxyType::NonTransfer => matches!( c, - Call::System(..) | - Call::Scheduler(..) | - Call::Babe(..) | - Call::Timestamp(..) | - Call::Indices(pallet_indices::Call::claim{..}) | - Call::Indices(pallet_indices::Call::free{..}) | - Call::Indices(pallet_indices::Call::freeze{..}) | + RuntimeCall::System(..) | + RuntimeCall::Scheduler(..) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(pallet_indices::Call::claim{..}) | + RuntimeCall::Indices(pallet_indices::Call::free{..}) | + RuntimeCall::Indices(pallet_indices::Call::freeze{..}) | // Specifically omitting Indices `transfer`, `force_transfer` // Specifically omitting the entire Balances pallet - Call::Authorship(..) | - Call::Staking(..) | - Call::Session(..) | - Call::Grandpa(..) | - Call::ImOnline(..) | - Call::Democracy(..) | - Call::Council(..) | - Call::TechnicalCommittee(..) | - Call::PhragmenElection(..) | - Call::TechnicalMembership(..) | - Call::Treasury(..) | - Call::Bounties(..) | - Call::ChildBounties(..) | - Call::Tips(..) | - Call::Claims(..) | - Call::Vesting(pallet_vesting::Call::vest{..}) | - Call::Vesting(pallet_vesting::Call::vest_other{..}) | + RuntimeCall::Authorship(..) | + RuntimeCall::Staking(..) | + RuntimeCall::Session(..) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy(..) | + RuntimeCall::Council(..) | + RuntimeCall::TechnicalCommittee(..) | + RuntimeCall::PhragmenElection(..) | + RuntimeCall::TechnicalMembership(..) | + RuntimeCall::Treasury(..) | + RuntimeCall::Bounties(..) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::Tips(..) | + RuntimeCall::Claims(..) | + RuntimeCall::Vesting(pallet_vesting::Call::vest{..}) | + RuntimeCall::Vesting(pallet_vesting::Call::vest_other{..}) | // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` - Call::Utility(..) | - Call::Identity(..) | - Call::Proxy(..) | - Call::Multisig(..) | - Call::Registrar(paras_registrar::Call::register {..}) | - Call::Registrar(paras_registrar::Call::deregister {..}) | + RuntimeCall::Utility(..) | + RuntimeCall::Identity(..) | + RuntimeCall::Proxy(..) | + RuntimeCall::Multisig(..) | + RuntimeCall::Registrar(paras_registrar::Call::register {..}) | + RuntimeCall::Registrar(paras_registrar::Call::deregister {..}) | // Specifically omitting Registrar `swap` - Call::Registrar(paras_registrar::Call::reserve {..}) | - Call::Crowdloan(..) | - Call::Slots(..) | - Call::Auctions(..) | // Specifically omitting the entire XCM Pallet - Call::VoterList(..) | - Call::NominationPools(..) - ), - ProxyType::Governance => matches!( - c, - Call::Democracy(..) | - Call::Council(..) | Call::TechnicalCommittee(..) | - Call::PhragmenElection(..) | - Call::Treasury(..) | Call::Bounties(..) | - Call::Tips(..) | Call::Utility(..) | - Call::ChildBounties(..) + RuntimeCall::Registrar(paras_registrar::Call::reserve {..}) | + RuntimeCall::Crowdloan(..) | + RuntimeCall::Slots(..) | + RuntimeCall::Auctions(..) | // Specifically omitting the entire XCM Pallet + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools(..) | + RuntimeCall::FastUnstake(..) ), + ProxyType::Governance => + matches!( + c, + RuntimeCall::Democracy(..) | + RuntimeCall::Council(..) | RuntimeCall::TechnicalCommittee(..) | + RuntimeCall::PhragmenElection(..) | + RuntimeCall::Treasury(..) | + RuntimeCall::Bounties(..) | + RuntimeCall::Tips(..) | RuntimeCall::Utility(..) | + RuntimeCall::ChildBounties(..) + ), ProxyType::Staking => { - matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)) + matches!( + c, + RuntimeCall::Staking(..) | + RuntimeCall::Session(..) | RuntimeCall::Utility(..) | + RuntimeCall::FastUnstake(..) + ) }, ProxyType::IdentityJudgement => matches!( c, - Call::Identity(pallet_identity::Call::provide_judgement { .. }) | Call::Utility(..) + RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) | + RuntimeCall::Utility(..) ), ProxyType::CancelProxy => { - matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })) + matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })) }, ProxyType::Auction => matches!( c, - Call::Auctions(..) | Call::Crowdloan(..) | Call::Registrar(..) | Call::Slots(..) + RuntimeCall::Auctions(..) | + RuntimeCall::Crowdloan(..) | + RuntimeCall::Registrar(..) | + RuntimeCall::Slots(..) ), } } @@ -1225,8 +1199,8 @@ impl InstanceFilter for ProxyType { } impl pallet_proxy::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; @@ -1252,7 +1226,7 @@ impl parachains_session_info::Config for Runtime { } impl parachains_inclusion::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DisputesHandler = ParasDisputes; type RewardValidators = parachains_reward_points::RewardValidatorsWithEraPoints; } @@ -1262,7 +1236,7 @@ parameter_types! { } impl parachains_paras::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::runtime_parachains_paras::WeightInfo; type UnsignedPriority = ParasUnsignedPriority; type NextSessionRotation = Babe; @@ -1273,7 +1247,7 @@ parameter_types! { } impl parachains_ump::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type UmpSink = crate::parachains_ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; @@ -1284,8 +1258,8 @@ impl parachains_ump::Config for Runtime { impl parachains_dmp::Config for Runtime {} impl parachains_hrmp::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo; } @@ -1303,9 +1277,9 @@ impl parachains_initializer::Config for Runtime { } impl parachains_disputes::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type RewardValidators = (); - type PunishValidators = (); + type SlashingHandler = (); type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } @@ -1317,8 +1291,8 @@ parameter_types! { } impl paras_registrar::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type OnSwap = (Crowdloan, Slots); type ParaDeposit = ParaDeposit; @@ -1338,7 +1312,7 @@ parameter_types! { } impl slots::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type Registrar = Registrar; type LeasePeriod = LeasePeriod; @@ -1360,7 +1334,7 @@ parameter_types! { } impl crowdloan::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type PalletId = CrowdloanId; type SubmissionDeposit = SubmissionDeposit; type MinContribution = MinContribution; @@ -1385,7 +1359,7 @@ type AuctionInitiate = EitherOfDiverse< >; impl auctions::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Leaser = Slots; type Registrar = Registrar; type EndingPeriod = EndingPeriod; @@ -1402,7 +1376,7 @@ parameter_types! { } impl pallet_nomination_pools::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type CurrencyBalance = Balance; type RewardCounter = FixedU128; @@ -1509,11 +1483,14 @@ construct_runtime! { ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event, ValidateUnsigned} = 36, // Provides a semi-sorted list of nominators for staking. - VoterList: pallet_bags_list::{Pallet, Call, Storage, Event} = 37, + VoterList: pallet_bags_list::::{Pallet, Call, Storage, Event} = 37, - // nomination pools: extension to staking. + // Nomination pools: extension to staking. NominationPools: pallet_nomination_pools::{Pallet, Call, Storage, Event, Config} = 39, + // Fast unstake pallet: extension to staking. + FastUnstake: pallet_fast_unstake = 40, + // Parachains pallets. Start indices at 50 to leave room. ParachainsOrigin: parachains_origin::{Pallet, Origin} = 50, Configuration: parachains_configuration::{Pallet, Call, Storage, Config} = 51, @@ -1521,7 +1498,7 @@ construct_runtime! { ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event} = 53, ParaInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 54, ParaScheduler: parachains_scheduler::{Pallet, Storage} = 55, - Paras: parachains_paras::{Pallet, Call, Storage, Event, Config} = 56, + Paras: parachains_paras::{Pallet, Call, Storage, Event, Config, ValidateUnsigned} = 56, Initializer: parachains_initializer::{Pallet, Call, Storage} = 57, Dmp: parachains_dmp::{Pallet, Call, Storage} = 58, Ump: parachains_ump::{Pallet, Call, Storage, Event} = 59, @@ -1562,8 +1539,17 @@ pub type SignedExtra = ( pallet_transaction_payment::ChargeTransactionPayment, claims::PrevalidateAttests, ); + +pub struct StakingMigrationV11OldPallet; +impl Get<&'static str> for StakingMigrationV11OldPallet { + fn get() -> &'static str { + "VoterList" + } +} + /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = + generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -1571,10 +1557,19 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - InitiateNominationPools, + ( + // "Bound uses of call" + pallet_preimage::migration::v1::Migration, + pallet_scheduler::migration::v3::MigrateToV4, + pallet_democracy::migrations::v1::Migration, + pallet_multisig::migrations::v1::MigrateToV1, + // "Properly migrate weights to v2" + parachains_configuration::migration::v3::MigrateToV3, + ), >; + /// The payload being signed in transactions. -pub type SignedPayload = generic::SignedPayload; +pub type SignedPayload = generic::SignedPayload; #[cfg(feature = "runtime-benchmarks")] #[macro_use] @@ -1593,6 +1588,7 @@ mod benches { [runtime_common::paras_registrar, Registrar] [runtime_parachains::configuration, Configuration] [runtime_parachains::disputes, ParasDisputes] + [runtime_parachains::hrmp, Hrmp] [runtime_parachains::initializer, Initializer] [runtime_parachains::paras, Paras] [runtime_parachains::paras_inherent, ParaInherent] @@ -1609,6 +1605,7 @@ mod benches { [pallet_elections_phragmen, PhragmenElection] [pallet_election_provider_multi_phase, ElectionProviderMultiPhase] [frame_election_provider_support, ElectionProviderBench::] + [pallet_fast_unstake, FastUnstake] [pallet_identity, Identity] [pallet_im_online, ImOnline] [pallet_indices, Indices] @@ -1673,6 +1670,16 @@ sp_api::impl_runtime_apis! { } } + impl pallet_nomination_pools_runtime_api::NominationPoolsApi< + Block, + AccountId, + Balance, + > for Runtime { + fn pending_rewards(member: AccountId) -> Balance { + NominationPools::pending_rewards(member).unwrap_or_default() + } + } + impl tx_pool_api::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction( source: TransactionSource, @@ -1740,7 +1747,7 @@ sp_api::impl_runtime_apis! { fn candidate_events() -> Vec> { parachains_runtime_api_impl::candidate_events::(|ev| { match ev { - Event::ParaInclusion(ev) => { + RuntimeEvent::ParaInclusion(ev) => { Some(ev) } _ => None, @@ -1786,10 +1793,6 @@ sp_api::impl_runtime_apis! { { parachains_runtime_api_impl::validation_code_hash::(para_id, assumption) } - - fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { - unimplemented!() - } } impl beefy_primitives::BeefyApi for Runtime { @@ -1799,8 +1802,8 @@ sp_api::impl_runtime_apis! { } } - impl mmr::MmrApi for Runtime { - fn generate_proof(_leaf_index: u64) + impl mmr::MmrApi for Runtime { + fn generate_proof(_block_number: BlockNumber) -> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof), mmr::Error> { Err(mmr::Error::PalletNotIncluded) @@ -1824,12 +1827,19 @@ sp_api::impl_runtime_apis! { Err(mmr::Error::PalletNotIncluded) } - fn generate_batch_proof(_leaf_indices: Vec) + fn generate_batch_proof(_block_numbers: Vec) -> Result<(Vec, mmr::BatchProof), mmr::Error> { Err(mmr::Error::PalletNotIncluded) } + fn generate_historical_batch_proof( + _block_numbers: Vec, + _best_known_block_number: BlockNumber, + ) -> Result<(Vec, mmr::BatchProof), mmr::Error> { + Err(mmr::Error::PalletNotIncluded) + } + fn verify_batch_proof(_leaves: Vec, _proof: mmr::BatchProof) -> Result<(), mmr::Error> { @@ -1882,19 +1892,15 @@ sp_api::impl_runtime_apis! { } impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeGenesisConfiguration { - // The choice of `c` parameter (where `1 - c` represents the - // probability of a slot being empty), is done in accordance to the - // slot duration and expected target block time, for safely - // resisting network delays of maximum two seconds. - // - babe_primitives::BabeGenesisConfiguration { + fn configuration() -> babe_primitives::BabeConfiguration { + let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG); + babe_primitives::BabeConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDuration::get(), - c: BABE_GENESIS_EPOCH_CONFIG.c, - genesis_authorities: Babe::authorities().to_vec(), + c: epoch_config.c, + authorities: Babe::authorities().to_vec(), randomness: Babe::randomness(), - allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots, + allowed_slots: epoch_config.allowed_slots, } } @@ -1970,13 +1976,13 @@ sp_api::impl_runtime_apis! { } } - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi for Runtime { - fn query_call_info(call: Call, len: u32) -> RuntimeDispatchInfo { + fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo { TransactionPayment::query_call_info(call, len) } - fn query_call_fee_details(call: Call, len: u32) -> FeeDetails { + fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails { TransactionPayment::query_call_fee_details(call, len) } } @@ -1989,8 +1995,15 @@ sp_api::impl_runtime_apis! { (weight, BlockWeights::get().max_block) } - fn execute_block_no_check(block: Block) -> Weight { - Executive::execute_block_no_check(block) + fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight { + log::info!( + target: "runtime::polkadot", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}", + block.header.number, + block.header.hash(), + state_root_check, + select, + ); + Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed") } } @@ -2068,7 +2081,7 @@ sp_api::impl_runtime_apis! { #[cfg(test)] mod test_fees { use super::*; - use frame_support::weights::{GetDispatchInfo, WeightToFee as WeightToFeeT}; + use frame_support::{dispatch::GetDispatchInfo, weights::WeightToFee as WeightToFeeT}; use keyring::Sr25519Keyring::{Alice, Charlie}; use pallet_transaction_payment::Multiplier; use runtime_common::MinimumMultiplier; @@ -2081,8 +2094,9 @@ mod test_fees { let payout_weight = ::WeightInfo::payout_stakers_alive_staked( MaxNominatorRewardedPerValidator::get(), - ) as f64; - let block_weight = BlockWeights::get().max_block as f64; + ) + .ref_time() as f64; + let block_weight = BlockWeights::get().max_block.ref_time() as f64; println!( "a full payout takes {:.2} of the block weight [{} / {}]", @@ -2121,8 +2135,8 @@ mod test_fees { }; let info = call.get_dispatch_info(); println!("call = {:?} / info = {:?}", call, info); - // convert to outer call. - let call = Call::Balances(call); + // convert to runtime call. + let call = RuntimeCall::Balances(call); let extra: SignedExtra = ( frame_system::CheckNonZeroSender::::new(), frame_system::CheckSpecVersion::::new(), @@ -2186,7 +2200,7 @@ mod test_fees { ) }; - while weight_with(voters) <= BlockWeights::get().max_block { + while weight_with(voters).all_lte(BlockWeights::get().max_block) { voters += 1; } @@ -2220,7 +2234,9 @@ mod test_fees { }; let mut active = target_voters; - while weight_with(active) <= OffchainSolutionWeightLimit::get() || active == target_voters { + while weight_with(active).all_lte(OffchainSolutionWeightLimit::get()) || + active == target_voters + { active += 1; } @@ -2244,9 +2260,9 @@ mod test { #[test] fn call_size() { assert!( - core::mem::size_of::() <= 230, - "size of Call is more than 230 bytes: some calls have too big arguments, use Box to \ - reduce the size of Call. + core::mem::size_of::() <= 230, + "size of RuntimeCall is more than 230 bytes: some calls have too big arguments, use Box to \ + reduce the size of RuntimeCall. If the limit is too strong, maybe consider increase the limit", ); } @@ -2281,7 +2297,7 @@ mod multiplier_tests { BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap(); // if the min is too small, then this will not change, and we are doomed forever. // the weight is 1/100th bigger than target. - run_with_system_weight(target * 101 / 100, || { + run_with_system_weight(target.saturating_mul(101) / 100, || { let next = SlowAdjustingFeeUpdate::::convert(minimum_multiplier); assert!(next > minimum_multiplier, "{:?} !>= {:?}", next, minimum_multiplier); }) @@ -2299,14 +2315,14 @@ mod multiplier_tests { let call = frame_system::Call::::fill_block { ratio: Perbill::from_rational( - block_weight, - BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap(), + block_weight.ref_time(), + BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap().ref_time(), ), }; println!("calling {:?}", call); let info = call.get_dispatch_info(); // convert to outer call. - let call = Call::System(call); + let call = RuntimeCall::System(call); let len = call.using_encoded(|e| e.len()) as u32; let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::default() diff --git a/runtime/polkadot/src/weights/frame_benchmarking_baseline.rs b/runtime/polkadot/src/weights/frame_benchmarking_baseline.rs index e4171f58bca0..92a81015d98b 100644 --- a/runtime/polkadot/src/weights/frame_benchmarking_baseline.rs +++ b/runtime/polkadot/src/weights/frame_benchmarking_baseline.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `frame_benchmarking::baseline` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -46,46 +46,52 @@ pub struct WeightInfo(PhantomData); impl frame_benchmarking::baseline::WeightInfo for WeightInfo { /// The range of component `i` is `[0, 1000000]`. fn addition(_i: u32, ) -> Weight { - (122_000 as Weight) + // Minimum execution time: 90 nanoseconds. + Weight::from_ref_time(115_922 as u64) } /// The range of component `i` is `[0, 1000000]`. fn subtraction(_i: u32, ) -> Weight { - (118_000 as Weight) + // Minimum execution time: 95 nanoseconds. + Weight::from_ref_time(122_150 as u64) } /// The range of component `i` is `[0, 1000000]`. fn multiplication(_i: u32, ) -> Weight { - (112_000 as Weight) + // Minimum execution time: 100 nanoseconds. + Weight::from_ref_time(122_417 as u64) } /// The range of component `i` is `[0, 1000000]`. fn division(_i: u32, ) -> Weight { - (115_000 as Weight) + // Minimum execution time: 94 nanoseconds. + Weight::from_ref_time(113_684 as u64) } /// The range of component `i` is `[0, 100]`. - fn hashing(i: u32, ) -> Weight { - (19_362_503_000 as Weight) - // Standard Error: 194_000 - .saturating_add((389_000 as Weight).saturating_mul(i as Weight)) + fn hashing(_i: u32, ) -> Weight { + // Minimum execution time: 18_993_431 nanoseconds. + Weight::from_ref_time(19_437_135_598 as u64) } - /// The range of component `i` is `[1, 100]`. + /// The range of component `i` is `[0, 100]`. fn sr25519_verification(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 39_000 - .saturating_add((47_745_000 as Weight).saturating_mul(i as Weight)) + // Minimum execution time: 109 nanoseconds. + Weight::from_ref_time(442_381 as u64) + // Standard Error: 16_514 + .saturating_add(Weight::from_ref_time(47_391_423 as u64).saturating_mul(i as u64)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `i` is `[0, 1000]`. fn storage_read(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 3_000 - .saturating_add((2_129_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 112 nanoseconds. + Weight::from_ref_time(117_000 as u64) + // Standard Error: 3_518 + .saturating_add(Weight::from_ref_time(1_822_376 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `i` is `[0, 1000]`. fn storage_write(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((330_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 97 nanoseconds. + Weight::from_ref_time(106_000 as u64) + // Standard Error: 803 + .saturating_add(Weight::from_ref_time(317_931 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } } diff --git a/runtime/polkadot/src/weights/frame_election_provider_support.rs b/runtime/polkadot/src/weights/frame_election_provider_support.rs index 81863c04d03c..95149f13a83a 100644 --- a/runtime/polkadot/src/weights/frame_election_provider_support.rs +++ b/runtime/polkadot/src/weights/frame_election_provider_support.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `frame_election_provider_support` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/frame_election_provider_support.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -48,20 +48,22 @@ impl frame_election_provider_support::WeightInfo for We /// The range of component `t` is `[500, 1000]`. /// The range of component `d` is `[5, 16]`. fn phragmen(v: u32, _t: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 94_000 - .saturating_add((22_018_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 8_192_000 - .saturating_add((3_552_773_000 as Weight).saturating_mul(d as Weight)) + // Minimum execution time: 5_430_677 nanoseconds. + Weight::from_ref_time(5_464_877_000 as u64) + // Standard Error: 136_164 + .saturating_add(Weight::from_ref_time(5_537_233 as u64).saturating_mul(v as u64)) + // Standard Error: 13_920_972 + .saturating_add(Weight::from_ref_time(1_533_450_990 as u64).saturating_mul(d as u64)) } /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. /// The range of component `d` is `[5, 16]`. fn phragmms(v: u32, _t: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 74_000 - .saturating_add((14_903_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 6_457_000 - .saturating_add((2_556_711_000 as Weight).saturating_mul(d as Weight)) + // Minimum execution time: 4_281_157 nanoseconds. + Weight::from_ref_time(4_309_020_000 as u64) + // Standard Error: 145_954 + .saturating_add(Weight::from_ref_time(5_463_106 as u64).saturating_mul(v as u64)) + // Standard Error: 14_921_849 + .saturating_add(Weight::from_ref_time(1_772_340_546 as u64).saturating_mul(d as u64)) } } diff --git a/runtime/polkadot/src/weights/frame_system.rs b/runtime/polkadot/src/weights/frame_system.rs index 4f1e08c1479f..1ad8c7e3ea02 100644 --- a/runtime/polkadot/src/weights/frame_system.rs +++ b/runtime/polkadot/src/weights/frame_system.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `frame_system` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/frame_system.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,45 +46,51 @@ pub struct WeightInfo(PhantomData); impl frame_system::WeightInfo for WeightInfo { /// The range of component `b` is `[0, 3932160]`. fn remark(b: u32, ) -> Weight { - (0 as Weight) + // Minimum execution time: 2_963 nanoseconds. + Weight::from_ref_time(3_019_000 as u64) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(409 as u64).saturating_mul(b as u64)) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { - (0 as Weight) + // Minimum execution time: 11_944 nanoseconds. + Weight::from_ref_time(12_024_000 as u64) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(1_718 as u64).saturating_mul(b as u64)) } // Storage: System Digest (r:1 w:1) // Storage: unknown [0x3a686561707061676573] (r:0 w:1) fn set_heap_pages() -> Weight { - (4_732_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 7_391 nanoseconds. + Weight::from_ref_time(7_747_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[1, 1000]`. + /// The range of component `i` is `[0, 1000]`. fn set_storage(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((546_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 3_096 nanoseconds. + Weight::from_ref_time(3_168_000 as u64) + // Standard Error: 2_366 + .saturating_add(Weight::from_ref_time(607_856 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[1, 1000]`. + /// The range of component `i` is `[0, 1000]`. fn kill_storage(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((444_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 3_088 nanoseconds. + Weight::from_ref_time(3_190_000 as u64) + // Standard Error: 893 + .saturating_add(Weight::from_ref_time(434_445 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `p` is `[1, 1000]`. + /// The range of component `p` is `[0, 1000]`. fn kill_prefix(p: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((961_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + // Minimum execution time: 4_592 nanoseconds. + Weight::from_ref_time(4_633_000 as u64) + // Standard Error: 1_146 + .saturating_add(Weight::from_ref_time(928_996 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } } diff --git a/runtime/polkadot/src/weights/mod.rs b/runtime/polkadot/src/weights/mod.rs index 9435ef0c2e0e..cef1ce83bd11 100644 --- a/runtime/polkadot/src/weights/mod.rs +++ b/runtime/polkadot/src/weights/mod.rs @@ -26,6 +26,7 @@ pub mod pallet_collective_technical_committee; pub mod pallet_democracy; pub mod pallet_election_provider_multi_phase; pub mod pallet_elections_phragmen; +pub mod pallet_fast_unstake; pub mod pallet_identity; pub mod pallet_im_online; pub mod pallet_indices; diff --git a/runtime/polkadot/src/weights/pallet_bags_list.rs b/runtime/polkadot/src/weights/pallet_bags_list.rs index 6e55c53f6c39..e02009f6b6e4 100644 --- a/runtime/polkadot/src/weights/pallet_bags_list.rs +++ b/runtime/polkadot/src/weights/pallet_bags_list.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_bags_list` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_bags_list.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -49,18 +49,20 @@ impl pallet_bags_list::WeightInfo for WeightInfo { // Storage: VoterList ListNodes (r:4 w:4) // Storage: VoterList ListBags (r:1 w:1) fn rebag_non_terminal() -> Weight { - (51_184_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 59_212 nanoseconds. + Weight::from_ref_time(59_911_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn rebag_terminal() -> Weight { - (48_605_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 59_706 nanoseconds. + Weight::from_ref_time(60_434_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: VoterList ListNodes (r:4 w:4) // Storage: Staking Bonded (r:2 w:0) @@ -68,8 +70,9 @@ impl pallet_bags_list::WeightInfo for WeightInfo { // Storage: VoterList CounterForListNodes (r:1 w:1) // Storage: VoterList ListBags (r:1 w:1) fn put_in_front_of() -> Weight { - (52_660_000 as Weight) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 59_346 nanoseconds. + Weight::from_ref_time(60_037_000 as u64) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_balances.rs b/runtime/polkadot/src/weights/pallet_balances.rs index fc35c08e309a..aa55f9b76dd0 100644 --- a/runtime/polkadot/src/weights/pallet_balances.rs +++ b/runtime/polkadot/src/weights/pallet_balances.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_balances.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,44 +46,51 @@ pub struct WeightInfo(PhantomData); impl pallet_balances::WeightInfo for WeightInfo { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (38_099_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 38_197 nanoseconds. + Weight::from_ref_time(39_286_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (28_954_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 28_875 nanoseconds. + Weight::from_ref_time(29_367_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (19_163_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 21_697 nanoseconds. + Weight::from_ref_time(22_248_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (22_204_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_515 nanoseconds. + Weight::from_ref_time(25_094_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (38_450_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 38_293 nanoseconds. + Weight::from_ref_time(38_972_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (33_958_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 33_997 nanoseconds. + Weight::from_ref_time(34_619_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn force_unreserve() -> Weight { - (17_120_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 18_917 nanoseconds. + Weight::from_ref_time(19_358_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_bounties.rs b/runtime/polkadot/src/weights/pallet_bounties.rs index c2009e91cc70..b1f502e179bc 100644 --- a/runtime/polkadot/src/weights/pallet_bounties.rs +++ b/runtime/polkadot/src/weights/pallet_bounties.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_bounties` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_bounties.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,90 +50,101 @@ impl pallet_bounties::WeightInfo for WeightInfo { // Storage: Bounties Bounties (r:0 w:1) /// The range of component `d` is `[0, 16384]`. fn propose_bounty(d: u32, ) -> Weight { - (26_205_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 27_752 nanoseconds. + Weight::from_ref_time(29_022_492 as u64) + // Standard Error: 9 + .saturating_add(Weight::from_ref_time(799 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: Bounties BountyApprovals (r:1 w:1) fn approve_bounty() -> Weight { - (9_686_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 11_725 nanoseconds. + Weight::from_ref_time(11_880_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Bounties Bounties (r:1 w:1) fn propose_curator() -> Weight { - (8_118_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 10_693 nanoseconds. + Weight::from_ref_time(11_112_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn unassign_curator() -> Weight { - (35_374_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 38_901 nanoseconds. + Weight::from_ref_time(39_518_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn accept_curator() -> Weight { - (22_927_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 27_039 nanoseconds. + Weight::from_ref_time(27_547_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) fn award_bounty() -> Weight { - (19_186_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 23_046 nanoseconds. + Weight::from_ref_time(23_499_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: System Account (r:3 w:3) // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) // Storage: Bounties BountyDescriptions (r:0 w:1) fn claim_bounty() -> Weight { - (63_444_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 66_013 nanoseconds. + Weight::from_ref_time(67_696_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: Bounties BountyDescriptions (r:0 w:1) fn close_bounty_proposed() -> Weight { - (38_612_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 41_852 nanoseconds. + Weight::from_ref_time(42_274_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Bounties Bounties (r:1 w:1) // Storage: ChildBounties ParentChildBounties (r:1 w:0) // Storage: System Account (r:2 w:2) // Storage: Bounties BountyDescriptions (r:0 w:1) fn close_bounty_active() -> Weight { - (46_153_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 51_433 nanoseconds. + Weight::from_ref_time(52_097_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Bounties Bounties (r:1 w:1) fn extend_bounty_expiry() -> Weight { - (16_573_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 20_562 nanoseconds. + Weight::from_ref_time(20_973_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Bounties BountyApprovals (r:1 w:1) - // Storage: Bounties Bounties (r:1 w:1) - // Storage: System Account (r:2 w:2) - /// The range of component `b` is `[1, 100]`. + // Storage: Bounties Bounties (r:2 w:2) + // Storage: System Account (r:4 w:4) + /// The range of component `b` is `[0, 100]`. fn spend_funds(b: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 28_000 - .saturating_add((29_706_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(b as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight))) + // Minimum execution time: 6_980 nanoseconds. + Weight::from_ref_time(9_837_399 as u64) + // Standard Error: 20_050 + .saturating_add(Weight::from_ref_time(24_678_056 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(b as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(b as u64))) } } diff --git a/runtime/polkadot/src/weights/pallet_child_bounties.rs b/runtime/polkadot/src/weights/pallet_child_bounties.rs index 997836cbf0c4..3a5ec2f9b11f 100644 --- a/runtime/polkadot/src/weights/pallet_child_bounties.rs +++ b/runtime/polkadot/src/weights/pallet_child_bounties.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_child_bounties` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_child_bounties.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -52,51 +52,57 @@ impl pallet_child_bounties::WeightInfo for WeightInfo Weight { - (47_819_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 49_044 nanoseconds. + Weight::from_ref_time(50_308_289 as u64) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(783 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) fn propose_curator() -> Weight { - (14_018_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 17_933 nanoseconds. + Weight::from_ref_time(18_741_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: System Account (r:1 w:1) fn accept_curator() -> Weight { - (25_943_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 31_905 nanoseconds. + Weight::from_ref_time(32_602_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: Bounties Bounties (r:1 w:0) // Storage: System Account (r:1 w:1) fn unassign_curator() -> Weight { - (38_240_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 43_592 nanoseconds. + Weight::from_ref_time(44_161_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) fn award_child_bounty() -> Weight { - (20_823_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_698 nanoseconds. + Weight::from_ref_time(27_014_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ChildBounties ChildBounties (r:1 w:1) // Storage: System Account (r:3 w:3) // Storage: ChildBounties ParentChildBounties (r:1 w:1) // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) fn claim_child_bounty() -> Weight { - (63_323_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 65_588 nanoseconds. + Weight::from_ref_time(66_068_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) @@ -105,9 +111,10 @@ impl pallet_child_bounties::WeightInfo for WeightInfo Weight { - (45_174_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 48_802 nanoseconds. + Weight::from_ref_time(49_236_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Bounties Bounties (r:1 w:0) // Storage: ChildBounties ChildBounties (r:1 w:1) @@ -116,8 +123,9 @@ impl pallet_child_bounties::WeightInfo for WeightInfo Weight { - (54_312_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 58_165 nanoseconds. + Weight::from_ref_time(58_828_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_collective_council.rs b/runtime/polkadot/src/weights/pallet_collective_council.rs index 6d7eabaef2b2..0251f55cb6ca 100644 --- a/runtime/polkadot/src/weights/pallet_collective_council.rs +++ b/runtime/polkadot/src/weights/pallet_collective_council.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2021 Parity Technologies (UK) Ltd. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. // This file is part of Polkadot. // Polkadot is free software: you can redistribute it and/or modify @@ -16,12 +16,14 @@ //! Autogenerated weights for `pallet_collective` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-08-27, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 128 +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: -// target/release/polkadot +// ./target/production/polkadot // benchmark +// pallet // --chain=polkadot-dev // --steps=50 // --repeat=20 @@ -29,11 +31,9 @@ // --extrinsic=* // --execution=wasm // --wasm-execution=compiled -// --heap-pages=4096 // --header=./file_header.txt // --output=./runtime/polkadot/src/weights/ - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -44,133 +44,185 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_collective`. pub struct WeightInfo(PhantomData); impl pallet_collective::WeightInfo for WeightInfo { - // Storage: Instance1Collective Members (r:1 w:1) - // Storage: Instance1Collective Proposals (r:1 w:0) - // Storage: Instance1Collective Voting (r:100 w:100) - // Storage: Instance1Collective Prime (r:0 w:1) - fn set_members(m: u32, n: u32, p: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 6_000 - .saturating_add((14_248_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 6_000 - .saturating_add((320_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 6_000 - .saturating_add((19_166_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + // Storage: Council Members (r:1 w:1) + // Storage: Council Proposals (r:1 w:0) + // Storage: Council Prime (r:0 w:1) + // Storage: Council Voting (r:100 w:100) + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { + // Minimum execution time: 16_559 nanoseconds. + Weight::from_ref_time(16_803_000 as u64) + // Standard Error: 46_979 + .saturating_add(Weight::from_ref_time(5_411_495 as u64).saturating_mul(m as u64)) + // Standard Error: 46_979 + .saturating_add(Weight::from_ref_time(7_379_659 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } - // Storage: Instance1Collective Members (r:1 w:0) + // Storage: Council Members (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { - (21_101_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((83_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + // Minimum execution time: 18_843 nanoseconds. + Weight::from_ref_time(18_477_543 as u64) + // Standard Error: 34 + .saturating_add(Weight::from_ref_time(1_767 as u64).saturating_mul(b as u64)) + // Standard Error: 360 + .saturating_add(Weight::from_ref_time(12_265 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective ProposalOf (r:1 w:0) + // Storage: Council Members (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { - (25_378_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((163_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) + // Minimum execution time: 20_542 nanoseconds. + Weight::from_ref_time(19_952_992 as u64) + // Standard Error: 24 + .saturating_add(Weight::from_ref_time(1_708 as u64).saturating_mul(b as u64)) + // Standard Error: 253 + .saturating_add(Weight::from_ref_time(23_664 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) } - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective ProposalOf (r:1 w:1) - // Storage: Instance1Collective Proposals (r:1 w:1) - // Storage: Instance1Collective ProposalCount (r:1 w:1) - // Storage: Instance1Collective Voting (r:0 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:1) + // Storage: Council Proposals (r:1 w:1) + // Storage: Council ProposalCount (r:1 w:1) + // Storage: Council Voting (r:0 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (40_063_000 as Weight) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((88_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((373_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 26_525 nanoseconds. + Weight::from_ref_time(26_095_210 as u64) + // Standard Error: 65 + .saturating_add(Weight::from_ref_time(3_546 as u64).saturating_mul(b as u64)) + // Standard Error: 679 + .saturating_add(Weight::from_ref_time(21_644 as u64).saturating_mul(m as u64)) + // Standard Error: 670 + .saturating_add(Weight::from_ref_time(108_657 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council Voting (r:1 w:1) + /// The range of component `m` is `[5, 100]`. + /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { - (31_307_000 as Weight) - // Standard Error: 0 - .saturating_add((196_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_960 nanoseconds. + Weight::from_ref_time(27_053_792 as u64) + // Standard Error: 417 + .saturating_add(Weight::from_ref_time(36_479 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: Instance1Collective Voting (r:1 w:1) - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective Proposals (r:1 w:1) - // Storage: Instance1Collective ProposalOf (r:0 w:1) + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council Proposals (r:1 w:1) + // Storage: Council ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (39_515_000 as Weight) - // Standard Error: 0 - .saturating_add((165_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((343_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 28_862 nanoseconds. + Weight::from_ref_time(31_105_191 as u64) + // Standard Error: 505 + .saturating_add(Weight::from_ref_time(22_024 as u64).saturating_mul(m as u64)) + // Standard Error: 493 + .saturating_add(Weight::from_ref_time(82_056 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance1Collective Voting (r:1 w:1) - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective ProposalOf (r:1 w:1) - // Storage: Instance1Collective Proposals (r:1 w:1) + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:1) + // Storage: Council Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (54_757_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((163_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((340_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 38_616 nanoseconds. + Weight::from_ref_time(38_991_996 as u64) + // Standard Error: 57 + .saturating_add(Weight::from_ref_time(1_897 as u64).saturating_mul(b as u64)) + // Standard Error: 613 + .saturating_add(Weight::from_ref_time(25_955 as u64).saturating_mul(m as u64)) + // Standard Error: 597 + .saturating_add(Weight::from_ref_time(98_694 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance1Collective Voting (r:1 w:1) - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective Prime (r:1 w:0) - // Storage: Instance1Collective Proposals (r:1 w:1) - // Storage: Instance1Collective ProposalOf (r:0 w:1) + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council Prime (r:1 w:0) + // Storage: Council Proposals (r:1 w:1) + // Storage: Council ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { - (43_851_000 as Weight) - // Standard Error: 0 - .saturating_add((167_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((344_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 32_082 nanoseconds. + Weight::from_ref_time(33_158_636 as u64) + // Standard Error: 466 + .saturating_add(Weight::from_ref_time(25_605 as u64).saturating_mul(m as u64)) + // Standard Error: 454 + .saturating_add(Weight::from_ref_time(82_085 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance1Collective Voting (r:1 w:1) - // Storage: Instance1Collective Members (r:1 w:0) - // Storage: Instance1Collective Prime (r:1 w:0) - // Storage: Instance1Collective ProposalOf (r:1 w:1) - // Storage: Instance1Collective Proposals (r:1 w:1) + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council Prime (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:1) + // Storage: Council Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (57_946_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((168_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((344_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 40_968 nanoseconds. + Weight::from_ref_time(41_242_466 as u64) + // Standard Error: 60 + .saturating_add(Weight::from_ref_time(1_955 as u64).saturating_mul(b as u64)) + // Standard Error: 640 + .saturating_add(Weight::from_ref_time(24_889 as u64).saturating_mul(m as u64)) + // Standard Error: 624 + .saturating_add(Weight::from_ref_time(99_929 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance1Collective Proposals (r:1 w:1) - // Storage: Instance1Collective Voting (r:0 w:1) - // Storage: Instance1Collective ProposalOf (r:0 w:1) + // Storage: Council Proposals (r:1 w:1) + // Storage: Council Voting (r:0 w:1) + // Storage: Council ProposalOf (r:0 w:1) + /// The range of component `p` is `[1, 100]`. + /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { - (24_228_000 as Weight) - // Standard Error: 0 - .saturating_add((348_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 17_891 nanoseconds. + Weight::from_ref_time(21_059_063 as u64) + // Standard Error: 662 + .saturating_add(Weight::from_ref_time(92_982 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_collective_technical_committee.rs b/runtime/polkadot/src/weights/pallet_collective_technical_committee.rs index a272fc708f00..35adf5db0fa6 100644 --- a/runtime/polkadot/src/weights/pallet_collective_technical_committee.rs +++ b/runtime/polkadot/src/weights/pallet_collective_technical_committee.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2021 Parity Technologies (UK) Ltd. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. // This file is part of Polkadot. // Polkadot is free software: you can redistribute it and/or modify @@ -16,12 +16,14 @@ //! Autogenerated weights for `pallet_collective` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-08-27, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 128 +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: -// target/release/polkadot +// ./target/production/polkadot // benchmark +// pallet // --chain=polkadot-dev // --steps=50 // --repeat=20 @@ -29,11 +31,9 @@ // --extrinsic=* // --execution=wasm // --wasm-execution=compiled -// --heap-pages=4096 // --header=./file_header.txt // --output=./runtime/polkadot/src/weights/ - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -44,133 +44,185 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_collective`. pub struct WeightInfo(PhantomData); impl pallet_collective::WeightInfo for WeightInfo { - // Storage: Instance2Collective Members (r:1 w:1) - // Storage: Instance2Collective Proposals (r:1 w:0) - // Storage: Instance2Collective Voting (r:100 w:100) - // Storage: Instance2Collective Prime (r:0 w:1) - fn set_members(m: u32, n: u32, p: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 6_000 - .saturating_add((14_085_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 6_000 - .saturating_add((40_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 6_000 - .saturating_add((19_086_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + // Storage: TechnicalCommittee Members (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:0) + // Storage: TechnicalCommittee Prime (r:0 w:1) + // Storage: TechnicalCommittee Voting (r:100 w:100) + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { + // Minimum execution time: 16_672 nanoseconds. + Weight::from_ref_time(16_894_000 as u64) + // Standard Error: 46_829 + .saturating_add(Weight::from_ref_time(5_355_665 as u64).saturating_mul(m as u64)) + // Standard Error: 46_829 + .saturating_add(Weight::from_ref_time(7_426_019 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } - // Storage: Instance2Collective Members (r:1 w:0) + // Storage: TechnicalCommittee Members (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { - (21_082_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((79_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + // Minimum execution time: 19_220 nanoseconds. + Weight::from_ref_time(18_726_422 as u64) + // Standard Error: 35 + .saturating_add(Weight::from_ref_time(1_756 as u64).saturating_mul(b as u64)) + // Standard Error: 368 + .saturating_add(Weight::from_ref_time(12_959 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective ProposalOf (r:1 w:0) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { - (25_580_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((157_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) + // Minimum execution time: 20_968 nanoseconds. + Weight::from_ref_time(20_449_941 as u64) + // Standard Error: 23 + .saturating_add(Weight::from_ref_time(1_776 as u64).saturating_mul(b as u64)) + // Standard Error: 242 + .saturating_add(Weight::from_ref_time(22_714 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) } - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective ProposalOf (r:1 w:1) - // Storage: Instance2Collective Proposals (r:1 w:1) - // Storage: Instance2Collective ProposalCount (r:1 w:1) - // Storage: Instance2Collective Voting (r:0 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee ProposalCount (r:1 w:1) + // Storage: TechnicalCommittee Voting (r:0 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (40_015_000 as Weight) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((85_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((371_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 27_344 nanoseconds. + Weight::from_ref_time(27_254_179 as u64) + // Standard Error: 61 + .saturating_add(Weight::from_ref_time(3_575 as u64).saturating_mul(b as u64)) + // Standard Error: 637 + .saturating_add(Weight::from_ref_time(18_357 as u64).saturating_mul(m as u64)) + // Standard Error: 629 + .saturating_add(Weight::from_ref_time(114_724 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Voting (r:1 w:1) + /// The range of component `m` is `[5, 100]`. + /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { - (31_124_000 as Weight) - // Standard Error: 0 - .saturating_add((195_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 27_321 nanoseconds. + Weight::from_ref_time(28_666_629 as u64) + // Standard Error: 486 + .saturating_add(Weight::from_ref_time(39_409 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: Instance2Collective Voting (r:1 w:1) - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective Proposals (r:1 w:1) - // Storage: Instance2Collective ProposalOf (r:0 w:1) + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (39_289_000 as Weight) - // Standard Error: 0 - .saturating_add((167_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((342_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 30_522 nanoseconds. + Weight::from_ref_time(31_888_685 as u64) + // Standard Error: 445 + .saturating_add(Weight::from_ref_time(21_903 as u64).saturating_mul(m as u64)) + // Standard Error: 434 + .saturating_add(Weight::from_ref_time(81_600 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance2Collective Voting (r:1 w:1) - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective ProposalOf (r:1 w:1) - // Storage: Instance2Collective Proposals (r:1 w:1) + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (54_722_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((163_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((339_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 39_694 nanoseconds. + Weight::from_ref_time(39_895_326 as u64) + // Standard Error: 53 + .saturating_add(Weight::from_ref_time(1_748 as u64).saturating_mul(b as u64)) + // Standard Error: 562 + .saturating_add(Weight::from_ref_time(23_990 as u64).saturating_mul(m as u64)) + // Standard Error: 548 + .saturating_add(Weight::from_ref_time(98_021 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance2Collective Voting (r:1 w:1) - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective Prime (r:1 w:0) - // Storage: Instance2Collective Proposals (r:1 w:1) - // Storage: Instance2Collective ProposalOf (r:0 w:1) + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Prime (r:1 w:0) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { - (43_840_000 as Weight) - // Standard Error: 0 - .saturating_add((168_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((340_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 32_817 nanoseconds. + Weight::from_ref_time(33_690_970 as u64) + // Standard Error: 459 + .saturating_add(Weight::from_ref_time(26_971 as u64).saturating_mul(m as u64)) + // Standard Error: 447 + .saturating_add(Weight::from_ref_time(82_860 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance2Collective Voting (r:1 w:1) - // Storage: Instance2Collective Members (r:1 w:0) - // Storage: Instance2Collective Prime (r:1 w:0) - // Storage: Instance2Collective ProposalOf (r:1 w:1) - // Storage: Instance2Collective Proposals (r:1 w:1) + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Prime (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (58_145_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((168_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((341_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 41_611 nanoseconds. + Weight::from_ref_time(42_243_655 as u64) + // Standard Error: 54 + .saturating_add(Weight::from_ref_time(1_702 as u64).saturating_mul(b as u64)) + // Standard Error: 580 + .saturating_add(Weight::from_ref_time(23_529 as u64).saturating_mul(m as u64)) + // Standard Error: 565 + .saturating_add(Weight::from_ref_time(98_033 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Instance2Collective Proposals (r:1 w:1) - // Storage: Instance2Collective Voting (r:0 w:1) - // Storage: Instance2Collective ProposalOf (r:0 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee Voting (r:0 w:1) + // Storage: TechnicalCommittee ProposalOf (r:0 w:1) + /// The range of component `p` is `[1, 100]`. + /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { - (24_137_000 as Weight) - // Standard Error: 0 - .saturating_add((348_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 18_237 nanoseconds. + Weight::from_ref_time(21_495_420 as u64) + // Standard Error: 708 + .saturating_add(Weight::from_ref_time(96_658 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_democracy.rs b/runtime/polkadot/src/weights/pallet_democracy.rs index 2eaa8f7ccc4e..425a4b7cd961 100644 --- a/runtime/polkadot/src/weights/pallet_democracy.rs +++ b/runtime/polkadot/src/weights/pallet_democracy.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_democracy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_democracy.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -49,251 +49,214 @@ impl pallet_democracy::WeightInfo for WeightInfo { // Storage: Democracy Blacklist (r:1 w:0) // Storage: Democracy DepositOf (r:0 w:1) fn propose() -> Weight { - (37_411_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 42_035 nanoseconds. + Weight::from_ref_time(42_673_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy DepositOf (r:1 w:1) - /// The range of component `s` is `[0, 100]`. - fn second(s: u32, ) -> Weight { - (27_380_000 as Weight) - // Standard Error: 0 - .saturating_add((67_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn second() -> Weight { + // Minimum execution time: 37_908 nanoseconds. + Weight::from_ref_time(39_524_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - /// The range of component `r` is `[1, 99]`. - fn vote_new(r: u32, ) -> Weight { - (35_299_000 as Weight) - // Standard Error: 1_000 - .saturating_add((117_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn vote_new() -> Weight { + // Minimum execution time: 48_027 nanoseconds. + Weight::from_ref_time(48_672_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - /// The range of component `r` is `[1, 99]`. - fn vote_existing(r: u32, ) -> Weight { - (35_585_000 as Weight) - // Standard Error: 1_000 - .saturating_add((110_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn vote_existing() -> Weight { + // Minimum execution time: 48_623 nanoseconds. + Weight::from_ref_time(49_248_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy Cancellations (r:1 w:1) fn emergency_cancel() -> Weight { - (17_502_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 19_752 nanoseconds. + Weight::from_ref_time(20_235_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Democracy PublicProps (r:1 w:1) + // Storage: Democracy DepositOf (r:1 w:1) + // Storage: System Account (r:1 w:1) // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy Blacklist (r:0 w:1) - // Storage: Democracy DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) - /// The range of component `p` is `[1, 100]`. - fn blacklist(p: u32, ) -> Weight { - (51_416_000 as Weight) - // Standard Error: 6_000 - .saturating_add((181_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + fn blacklist() -> Weight { + // Minimum execution time: 75_593 nanoseconds. + Weight::from_ref_time(76_707_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:0) - /// The range of component `v` is `[1, 100]`. - fn external_propose(v: u32, ) -> Weight { - (9_901_000 as Weight) - // Standard Error: 0 - .saturating_add((10_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn external_propose() -> Weight { + // Minimum execution time: 15_433 nanoseconds. + Weight::from_ref_time(15_751_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_majority() -> Weight { - (3_582_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_187 nanoseconds. + Weight::from_ref_time(4_344_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:0 w:1) fn external_propose_default() -> Weight { - (3_595_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_424 nanoseconds. + Weight::from_ref_time(4_522_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:1) // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn fast_track() -> Weight { - (17_658_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 18_919 nanoseconds. + Weight::from_ref_time(19_574_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy NextExternal (r:1 w:1) // Storage: Democracy Blacklist (r:1 w:1) - /// The range of component `v` is `[0, 100]`. - fn veto_external(v: u32, ) -> Weight { - (18_457_000 as Weight) - // Standard Error: 0 - .saturating_add((45_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn veto_external() -> Weight { + // Minimum execution time: 24_749 nanoseconds. + Weight::from_ref_time(25_443_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Democracy PublicProps (r:1 w:1) // Storage: Democracy DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) - /// The range of component `p` is `[1, 100]`. - fn cancel_proposal(p: u32, ) -> Weight { - (42_442_000 as Weight) - // Standard Error: 1_000 - .saturating_add((150_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn cancel_proposal() -> Weight { + // Minimum execution time: 63_025 nanoseconds. + Weight::from_ref_time(64_438_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:0 w:1) fn cancel_referendum() -> Weight { - (12_097_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - /// The range of component `r` is `[1, 99]`. - fn cancel_queued(r: u32, ) -> Weight { - (22_952_000 as Weight) - // Standard Error: 4_000 - .saturating_add((1_756_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 12_754 nanoseconds. + Weight::from_ref_time(13_249_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:1 w:0) - /// The range of component `r` is `[1, 99]`. + // Storage: Democracy ReferendumInfoOf (r:2 w:0) + /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { - (1_874_000 as Weight) - // Standard Error: 4_000 - .saturating_add((2_927_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 6_036 nanoseconds. + Weight::from_ref_time(9_221_096 as u64) + // Standard Error: 3_753 + .saturating_add(Weight::from_ref_time(2_068_013 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy LowestUnbaked (r:1 w:1) // Storage: Democracy ReferendumCount (r:1 w:0) // Storage: Democracy LastTabledWasExternal (r:1 w:0) // Storage: Democracy NextExternal (r:1 w:0) // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:1 w:0) - /// The range of component `r` is `[1, 99]`. + // Storage: Democracy ReferendumInfoOf (r:2 w:0) + /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - (4_956_000 as Weight) - // Standard Error: 19_000 - .saturating_add((3_013_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_435 nanoseconds. + Weight::from_ref_time(11_539_062 as u64) + // Standard Error: 3_966 + .saturating_add(Weight::from_ref_time(2_069_630 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:3 w:3) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + // Storage: Democracy ReferendumInfoOf (r:2 w:2) + /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { - (35_923_000 as Weight) - // Standard Error: 5_000 - .saturating_add((3_904_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight))) + // Minimum execution time: 39_949 nanoseconds. + Weight::from_ref_time(46_035_539 as u64) + // Standard Error: 5_044 + .saturating_add(Weight::from_ref_time(2_971_650 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) } // Storage: Democracy VotingOf (r:2 w:2) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + // Storage: Democracy ReferendumInfoOf (r:2 w:2) + /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { - (20_735_000 as Weight) - // Standard Error: 5_000 - .saturating_add((3_853_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight))) + // Minimum execution time: 23_826 nanoseconds. + Weight::from_ref_time(27_032_402 as u64) + // Standard Error: 4_525 + .saturating_add(Weight::from_ref_time(2_958_429 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) } // Storage: Democracy PublicProps (r:0 w:1) fn clear_public_proposals() -> Weight { - (3_842_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Democracy Preimages (r:1 w:1) - /// The range of component `b` is `[0, 16384]`. - fn note_preimage(b: u32, ) -> Weight { - (25_748_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Democracy Preimages (r:1 w:1) - /// The range of component `b` is `[0, 16384]`. - fn note_imminent_preimage(b: u32, ) -> Weight { - (17_855_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Democracy Preimages (r:1 w:1) - // Storage: System Account (r:1 w:0) - /// The range of component `b` is `[0, 16384]`. - fn reap_preimage(b: u32, ) -> Weight { - (24_856_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_775 nanoseconds. + Weight::from_ref_time(5_033_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { - (22_749_000 as Weight) - // Standard Error: 0 - .saturating_add((33_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 23_245 nanoseconds. + Weight::from_ref_time(30_061_940 as u64) + // Standard Error: 1_523 + .saturating_add(Weight::from_ref_time(34_810 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy VotingOf (r:1 w:1) // Storage: Balances Locks (r:1 w:1) // Storage: System Account (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { - (21_921_000 as Weight) - // Standard Error: 0 - .saturating_add((102_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 28_063 nanoseconds. + Weight::from_ref_time(30_002_043 as u64) + // Standard Error: 636 + .saturating_add(Weight::from_ref_time(67_182 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { - (13_586_000 as Weight) - // Standard Error: 0 - .saturating_add((98_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 15_306 nanoseconds. + Weight::from_ref_time(17_690_130 as u64) + // Standard Error: 836 + .saturating_add(Weight::from_ref_time(68_122 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Democracy ReferendumInfoOf (r:1 w:1) // Storage: Democracy VotingOf (r:1 w:1) - /// The range of component `r` is `[1, 99]`. + /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { - (13_599_000 as Weight) - // Standard Error: 0 - .saturating_add((96_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 15_392 nanoseconds. + Weight::from_ref_time(17_610_812 as u64) + // Standard Error: 819 + .saturating_add(Weight::from_ref_time(69_086 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_election_provider_multi_phase.rs b/runtime/polkadot/src/weights/pallet_election_provider_multi_phase.rs index 0c2336196b10..9d2afa4d2755 100644 --- a/runtime/polkadot/src/weights/pallet_election_provider_multi_phase.rs +++ b/runtime/polkadot/src/weights/pallet_election_provider_multi_phase.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_election_provider_multi_phase` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_election_provider_multi_phase.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -53,48 +53,52 @@ impl pallet_election_provider_multi_phase::WeightInfo f // Storage: Staking ForceEra (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) fn on_initialize_nothing() -> Weight { - (13_304_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) + // Minimum execution time: 15_173 nanoseconds. + Weight::from_ref_time(15_566_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn on_initialize_open_signed() -> Weight { - (12_920_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 13_691 nanoseconds. + Weight::from_ref_time(14_176_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn on_initialize_open_unsigned() -> Weight { - (12_482_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 13_539 nanoseconds. + Weight::from_ref_time(14_023_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) // Storage: ElectionProviderMultiPhase QueuedSolution (r:0 w:1) fn finalize_signed_phase_accept_solution() -> Weight { - (25_726_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 27_536 nanoseconds. + Weight::from_ref_time(28_008_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: System Account (r:1 w:1) fn finalize_signed_phase_reject_solution() -> Weight { - (19_640_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 21_053 nanoseconds. + Weight::from_ref_time(21_495_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:0 w:1) // Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) // Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. - fn create_snapshot_internal(v: u32, t: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 2_000 - .saturating_add((406_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 5_000 - .saturating_add((62_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn create_snapshot_internal(v: u32, _t: u32, ) -> Weight { + // Minimum execution time: 422_358 nanoseconds. + Weight::from_ref_time(435_895_000 as u64) + // Standard Error: 2_376 + .saturating_add(Weight::from_ref_time(268_064 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) @@ -109,13 +113,14 @@ impl pallet_election_provider_multi_phase::WeightInfo f /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. fn elect_queued(a: u32, d: u32, ) -> Weight { - (113_324_000 as Weight) - // Standard Error: 7_000 - .saturating_add((342_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 11_000 - .saturating_add((54_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(9 as Weight)) + // Minimum execution time: 282_891 nanoseconds. + Weight::from_ref_time(64_783_615 as u64) + // Standard Error: 6_219 + .saturating_add(Weight::from_ref_time(362_403 as u64).saturating_mul(a as u64)) + // Standard Error: 9_322 + .saturating_add(Weight::from_ref_time(129_048 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) @@ -124,9 +129,10 @@ impl pallet_election_provider_multi_phase::WeightInfo f // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) // Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:0 w:1) fn submit() -> Weight { - (45_851_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 48_593 nanoseconds. + Weight::from_ref_time(49_233_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: ElectionProviderMultiPhase Round (r:1 w:0) @@ -139,18 +145,15 @@ impl pallet_election_provider_multi_phase::WeightInfo f /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. - fn submit_unsigned(v: u32, t: u32, a: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 5_000 - .saturating_add((850_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 11_000 - .saturating_add((11_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 19_000 - .saturating_add((7_957_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 28_000 - .saturating_add((1_659_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn submit_unsigned(v: u32, _t: u32, a: u32, _d: u32, ) -> Weight { + // Minimum execution time: 4_793_536 nanoseconds. + Weight::from_ref_time(4_829_131_000 as u64) + // Standard Error: 14_655 + .saturating_add(Weight::from_ref_time(98_228 as u64).saturating_mul(v as u64)) + // Standard Error: 43_429 + .saturating_add(Weight::from_ref_time(4_641_460 as u64).saturating_mul(a as u64)) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) @@ -160,16 +163,13 @@ impl pallet_election_provider_multi_phase::WeightInfo f /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. - fn feasibility_check(v: u32, t: u32, a: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 4_000 - .saturating_add((856_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 9_000 - .saturating_add((63_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 16_000 - .saturating_add((5_762_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 24_000 - .saturating_add((1_360_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) + fn feasibility_check(v: u32, _t: u32, a: u32, _d: u32, ) -> Weight { + // Minimum execution time: 3_977_796 nanoseconds. + Weight::from_ref_time(3_993_895_000 as u64) + // Standard Error: 12_592 + .saturating_add(Weight::from_ref_time(207_036 as u64).saturating_mul(v as u64)) + // Standard Error: 37_315 + .saturating_add(Weight::from_ref_time(3_356_343 as u64).saturating_mul(a as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_elections_phragmen.rs b/runtime/polkadot/src/weights/pallet_elections_phragmen.rs index c7cee9e38008..99eb364f1f98 100644 --- a/runtime/polkadot/src/weights/pallet_elections_phragmen.rs +++ b/runtime/polkadot/src/weights/pallet_elections_phragmen.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_elections_phragmen` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_elections_phragmen.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -51,11 +51,12 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[1, 16]`. fn vote_equal(v: u32, ) -> Weight { - (24_201_000 as Weight) - // Standard Error: 3_000 - .saturating_add((157_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 30_071 nanoseconds. + Weight::from_ref_time(31_578_033 as u64) + // Standard Error: 3_999 + .saturating_add(Weight::from_ref_time(189_446 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Candidates (r:1 w:0) // Storage: PhragmenElection Members (r:1 w:0) @@ -64,11 +65,12 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[2, 16]`. fn vote_more(v: u32, ) -> Weight { - (36_619_000 as Weight) - // Standard Error: 3_000 - .saturating_add((161_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 40_205 nanoseconds. + Weight::from_ref_time(41_743_927 as u64) + // Standard Error: 5_811 + .saturating_add(Weight::from_ref_time(147_480 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Candidates (r:1 w:0) // Storage: PhragmenElection Members (r:1 w:0) @@ -77,38 +79,42 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Balances Locks (r:1 w:1) /// The range of component `v` is `[2, 16]`. fn vote_less(v: u32, ) -> Weight { - (36_953_000 as Weight) - // Standard Error: 3_000 - .saturating_add((121_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 39_612 nanoseconds. + Weight::from_ref_time(41_027_731 as u64) + // Standard Error: 5_632 + .saturating_add(Weight::from_ref_time(201_456 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Voting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) fn remove_voter() -> Weight { - (32_792_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 39_544 nanoseconds. + Weight::from_ref_time(42_718_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Candidates (r:1 w:1) // Storage: PhragmenElection Members (r:1 w:0) // Storage: PhragmenElection RunnersUp (r:1 w:0) /// The range of component `c` is `[1, 1000]`. fn submit_candidacy(c: u32, ) -> Weight { - (26_285_000 as Weight) - // Standard Error: 0 - .saturating_add((98_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 35_706 nanoseconds. + Weight::from_ref_time(27_153_321 as u64) + // Standard Error: 992 + .saturating_add(Weight::from_ref_time(91_044 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: PhragmenElection Candidates (r:1 w:1) /// The range of component `c` is `[1, 1000]`. fn renounce_candidacy_candidate(c: u32, ) -> Weight { - (23_041_000 as Weight) - // Standard Error: 0 - .saturating_add((64_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 30_444 nanoseconds. + Weight::from_ref_time(22_835_523 as u64) + // Standard Error: 1_029 + .saturating_add(Weight::from_ref_time(71_777 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: PhragmenElection Members (r:1 w:1) // Storage: PhragmenElection RunnersUp (r:1 w:1) @@ -116,19 +122,22 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Council Proposals (r:1 w:0) // Storage: Council Members (r:0 w:1) fn renounce_candidacy_members() -> Weight { - (41_166_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 43_311 nanoseconds. + Weight::from_ref_time(43_994_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: PhragmenElection RunnersUp (r:1 w:1) fn renounce_candidacy_runners_up() -> Weight { - (30_928_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 33_291 nanoseconds. + Weight::from_ref_time(34_436_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Benchmark Override (r:0 w:0) fn remove_member_without_replacement() -> Weight { - (2_000_000_000_000 as Weight) + // Minimum execution time: 2_000_000_000 nanoseconds. + Weight::from_ref_time(2_000_000_000_000 as u64) } // Storage: PhragmenElection Members (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -137,9 +146,10 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Council Proposals (r:1 w:0) // Storage: Council Members (r:0 w:1) fn remove_member_with_replacement() -> Weight { - (57_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 56_677 nanoseconds. + Weight::from_ref_time(58_359_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: PhragmenElection Voting (r:5001 w:5000) // Storage: PhragmenElection Members (r:1 w:0) @@ -148,14 +158,15 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn // Storage: Balances Locks (r:5000 w:5000) // Storage: System Account (r:5000 w:5000) /// The range of component `v` is `[5000, 10000]`. - /// The range of component `d` is `[1, 5000]`. + /// The range of component `d` is `[0, 5000]`. fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 74_000 - .saturating_add((61_573_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + // Minimum execution time: 270_248_956 nanoseconds. + Weight::from_ref_time(271_306_495_000 as u64) + // Standard Error: 233_605 + .saturating_add(Weight::from_ref_time(34_076_228 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(v as u64))) } // Storage: PhragmenElection Candidates (r:1 w:1) // Storage: PhragmenElection Members (r:1 w:1) @@ -170,14 +181,16 @@ impl pallet_elections_phragmen::WeightInfo for WeightIn /// The range of component `v` is `[1, 10000]`. /// The range of component `e` is `[10000, 160000]`. fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_489_000 - .saturating_add((138_137_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 99_000 - .saturating_add((7_943_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(269 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 27_528_355 nanoseconds. + Weight::from_ref_time(27_615_108_000 as u64) + // Standard Error: 467_319 + .saturating_add(Weight::from_ref_time(41_041_560 as u64).saturating_mul(v as u64)) + // Standard Error: 29_989 + .saturating_add(Weight::from_ref_time(2_059_675 as u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(269 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) } } diff --git a/runtime/polkadot/src/weights/pallet_fast_unstake.rs b/runtime/polkadot/src/weights/pallet_fast_unstake.rs new file mode 100644 index 000000000000..3ba0765d4a87 --- /dev/null +++ b/runtime/polkadot/src/weights/pallet_fast_unstake.rs @@ -0,0 +1,120 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_fast_unstake` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=polkadot-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_fast_unstake +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/polkadot/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_fast_unstake`. +pub struct WeightInfo(PhantomData); +impl pallet_fast_unstake::WeightInfo for WeightInfo { + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + // Storage: FastUnstake Head (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking Payee (r:0 w:1) + fn on_idle_unstake() -> Weight { + // Minimum execution time: 71_042 nanoseconds. + Weight::from_ref_time(71_868_000 as u64) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + // Storage: FastUnstake Head (r:1 w:1) + // Storage: FastUnstake Queue (r:2 w:1) + // Storage: FastUnstake CounterForQueue (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking ErasStakers (r:56 w:0) + /// The range of component `x` is `[28, 3584]`. + fn on_idle_check(x: u32, ) -> Weight { + // Minimum execution time: 508_029 nanoseconds. + Weight::from_ref_time(509_743_000 as u64) + // Standard Error: 12_195 + .saturating_add(Weight::from_ref_time(14_175_618 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(22 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: FastUnstake Queue (r:1 w:1) + // Storage: FastUnstake Head (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking CounterForNominators (r:1 w:1) + // Storage: VoterList ListNodes (r:2 w:2) + // Storage: VoterList ListBags (r:1 w:1) + // Storage: VoterList CounterForListNodes (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: FastUnstake CounterForQueue (r:1 w:1) + fn register_fast_unstake() -> Weight { + // Minimum execution time: 95_147 nanoseconds. + Weight::from_ref_time(96_423_000 as u64) + .saturating_add(T::DbWeight::get().reads(14 as u64)) + .saturating_add(T::DbWeight::get().writes(10 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: FastUnstake Queue (r:1 w:1) + // Storage: FastUnstake Head (r:1 w:0) + // Storage: FastUnstake CounterForQueue (r:1 w:1) + fn deregister() -> Weight { + // Minimum execution time: 40_560 nanoseconds. + Weight::from_ref_time(41_100_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1) + fn control() -> Weight { + // Minimum execution time: 3_685 nanoseconds. + Weight::from_ref_time(3_903_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } +} diff --git a/runtime/polkadot/src/weights/pallet_identity.rs b/runtime/polkadot/src/weights/pallet_identity.rs index 87ea8d55ca82..16a08ff316ac 100644 --- a/runtime/polkadot/src/weights/pallet_identity.rs +++ b/runtime/polkadot/src/weights/pallet_identity.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_identity` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_identity.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,189 +47,207 @@ impl pallet_identity::WeightInfo for WeightInfo { // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn add_registrar(r: u32, ) -> Weight { - (15_723_000 as Weight) - // Standard Error: 3_000 - .saturating_add((163_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 15_843 nanoseconds. + Weight::from_ref_time(18_367_858 as u64) + // Standard Error: 6_600 + .saturating_add(Weight::from_ref_time(96_189 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn set_identity(r: u32, x: u32, ) -> Weight { - (28_673_000 as Weight) - // Standard Error: 6_000 - .saturating_add((188_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 1_000 - .saturating_add((335_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 33_756 nanoseconds. + Weight::from_ref_time(33_692_837 as u64) + // Standard Error: 3_623 + .saturating_add(Weight::from_ref_time(80_533 as u64).saturating_mul(r as u64)) + // Standard Error: 707 + .saturating_add(Weight::from_ref_time(299_420 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity SuperOf (r:1 w:1) - /// The range of component `s` is `[1, 100]`. + // Storage: Identity SuperOf (r:2 w:2) + /// The range of component `s` is `[0, 100]`. fn set_subs_new(s: u32, ) -> Weight { - (25_786_000 as Weight) - // Standard Error: 4_000 - .saturating_add((2_924_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 9_638 nanoseconds. + Weight::from_ref_time(26_873_592 as u64) + // Standard Error: 4_582 + .saturating_add(Weight::from_ref_time(2_089_827 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity SuperOf (r:0 w:1) - /// The range of component `p` is `[1, 100]`. + // Storage: Identity SuperOf (r:0 w:2) + /// The range of component `p` is `[0, 100]`. fn set_subs_old(p: u32, ) -> Weight { - (25_940_000 as Weight) - // Standard Error: 1_000 - .saturating_add((917_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + // Minimum execution time: 9_876 nanoseconds. + Weight::from_ref_time(27_132_981 as u64) + // Standard Error: 4_104 + .saturating_add(Weight::from_ref_time(907_310 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity SuperOf (r:0 w:100) /// The range of component `r` is `[1, 20]`. - /// The range of component `s` is `[1, 100]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `s` is `[0, 100]`. + /// The range of component `x` is `[0, 100]`. fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { - (30_589_000 as Weight) - // Standard Error: 9_000 - .saturating_add((106_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 1_000 - .saturating_add((929_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 1_000 - .saturating_add((168_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 48_877 nanoseconds. + Weight::from_ref_time(34_036_193 as u64) + // Standard Error: 4_926 + .saturating_add(Weight::from_ref_time(129_984 as u64).saturating_mul(r as u64)) + // Standard Error: 962 + .saturating_add(Weight::from_ref_time(878_298 as u64).saturating_mul(s as u64)) + // Standard Error: 962 + .saturating_add(Weight::from_ref_time(161_294 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn request_judgement(r: u32, x: u32, ) -> Weight { - (30_524_000 as Weight) - // Standard Error: 3_000 - .saturating_add((160_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 0 - .saturating_add((339_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 36_360 nanoseconds. + Weight::from_ref_time(35_038_187 as u64) + // Standard Error: 4_080 + .saturating_add(Weight::from_ref_time(121_407 as u64).saturating_mul(r as u64)) + // Standard Error: 796 + .saturating_add(Weight::from_ref_time(317_545 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn cancel_request(r: u32, x: u32, ) -> Weight { - (28_075_000 as Weight) - // Standard Error: 3_000 - .saturating_add((114_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 0 - .saturating_add((330_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 33_392 nanoseconds. + Weight::from_ref_time(31_829_430 as u64) + // Standard Error: 5_041 + .saturating_add(Weight::from_ref_time(100_136 as u64).saturating_mul(r as u64)) + // Standard Error: 983 + .saturating_add(Weight::from_ref_time(316_813 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_fee(r: u32, ) -> Weight { - (6_835_000 as Weight) - // Standard Error: 1_000 - .saturating_add((133_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_200 nanoseconds. + Weight::from_ref_time(9_149_038 as u64) + // Standard Error: 2_439 + .saturating_add(Weight::from_ref_time(122_207 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_account_id(r: u32, ) -> Weight { - (6_829_000 as Weight) - // Standard Error: 1_000 - .saturating_add((119_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_237 nanoseconds. + Weight::from_ref_time(9_267_742 as u64) + // Standard Error: 2_410 + .saturating_add(Weight::from_ref_time(122_610 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_fields(r: u32, ) -> Weight { - (7_029_000 as Weight) - // Standard Error: 1_000 - .saturating_add((118_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_120 nanoseconds. + Weight::from_ref_time(9_089_436 as u64) + // Standard Error: 2_330 + .saturating_add(Weight::from_ref_time(121_665 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 19]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn provide_judgement(r: u32, x: u32, ) -> Weight { - (21_589_000 as Weight) - // Standard Error: 2_000 - .saturating_add((112_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 0 - .saturating_add((339_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 27_286 nanoseconds. + Weight::from_ref_time(26_160_470 as u64) + // Standard Error: 4_870 + .saturating_add(Weight::from_ref_time(110_855 as u64).saturating_mul(r as u64)) + // Standard Error: 901 + .saturating_add(Weight::from_ref_time(533_939 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: Identity SuperOf (r:0 w:100) /// The range of component `r` is `[1, 20]`. - /// The range of component `s` is `[1, 100]`. - /// The range of component `x` is `[1, 100]`. - fn kill_identity(r: u32, s: u32, _x: u32, ) -> Weight { - (46_356_000 as Weight) - // Standard Error: 11_000 - .saturating_add((93_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 2_000 - .saturating_add((932_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + /// The range of component `s` is `[0, 100]`. + /// The range of component `x` is `[0, 100]`. + fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight { + // Minimum execution time: 60_659 nanoseconds. + Weight::from_ref_time(46_125_203 as u64) + // Standard Error: 10_008 + .saturating_add(Weight::from_ref_time(120_794 as u64).saturating_mul(r as u64)) + // Standard Error: 1_954 + .saturating_add(Weight::from_ref_time(886_225 as u64).saturating_mul(s as u64)) + // Standard Error: 1_954 + .saturating_add(Weight::from_ref_time(151_157 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) - /// The range of component `s` is `[1, 99]`. + /// The range of component `s` is `[0, 99]`. fn add_sub(s: u32, ) -> Weight { - (33_155_000 as Weight) - // Standard Error: 0 - .saturating_add((87_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 30_363 nanoseconds. + Weight::from_ref_time(36_833_789 as u64) + // Standard Error: 2_192 + .saturating_add(Weight::from_ref_time(70_760 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn rename_sub(s: u32, ) -> Weight { - (12_099_000 as Weight) - // Standard Error: 0 - .saturating_add((28_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 12_991 nanoseconds. + Weight::from_ref_time(15_363_557 as u64) + // Standard Error: 690 + .saturating_add(Weight::from_ref_time(27_000 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn remove_sub(s: u32, ) -> Weight { - (34_432_000 as Weight) - // Standard Error: 1_000 - .saturating_add((72_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 34_425 nanoseconds. + Weight::from_ref_time(37_755_916 as u64) + // Standard Error: 1_179 + .saturating_add(Weight::from_ref_time(62_401 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) - /// The range of component `s` is `[1, 99]`. + /// The range of component `s` is `[0, 99]`. fn quit_sub(s: u32, ) -> Weight { - (23_989_000 as Weight) - // Standard Error: 0 - .saturating_add((72_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 23_829 nanoseconds. + Weight::from_ref_time(27_592_997 as u64) + // Standard Error: 1_188 + .saturating_add(Weight::from_ref_time(64_211 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_im_online.rs b/runtime/polkadot/src/weights/pallet_im_online.rs index 9d41e418bf23..24a74d371bf1 100644 --- a/runtime/polkadot/src/weights/pallet_im_online.rs +++ b/runtime/polkadot/src/weights/pallet_im_online.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_im_online` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_im_online.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -52,12 +52,13 @@ impl pallet_im_online::WeightInfo for WeightInfo { /// The range of component `k` is `[1, 1000]`. /// The range of component `e` is `[1, 100]`. fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight { - (75_125_000 as Weight) - // Standard Error: 0 - .saturating_add((26_000 as Weight).saturating_mul(k as Weight)) - // Standard Error: 3_000 - .saturating_add((309_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 96_686 nanoseconds. + Weight::from_ref_time(76_489_797 as u64) + // Standard Error: 194 + .saturating_add(Weight::from_ref_time(23_059 as u64).saturating_mul(k as u64)) + // Standard Error: 1_956 + .saturating_add(Weight::from_ref_time(297_116 as u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_indices.rs b/runtime/polkadot/src/weights/pallet_indices.rs index fb4ba4658bae..5ec530cb457e 100644 --- a/runtime/polkadot/src/weights/pallet_indices.rs +++ b/runtime/polkadot/src/weights/pallet_indices.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_indices` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_indices.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,34 +46,39 @@ pub struct WeightInfo(PhantomData); impl pallet_indices::WeightInfo for WeightInfo { // Storage: Indices Accounts (r:1 w:1) fn claim() -> Weight { - (23_458_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_307 nanoseconds. + Weight::from_ref_time(25_822_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (29_114_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 31_113 nanoseconds. + Weight::from_ref_time(32_000_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Indices Accounts (r:1 w:1) fn free() -> Weight { - (24_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_974 nanoseconds. + Weight::from_ref_time(26_285_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn force_transfer() -> Weight { - (23_959_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 26_185 nanoseconds. + Weight::from_ref_time(26_636_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Indices Accounts (r:1 w:1) fn freeze() -> Weight { - (26_773_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 31_130 nanoseconds. + Weight::from_ref_time(31_800_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_membership.rs b/runtime/polkadot/src/weights/pallet_membership.rs index 8d943929a46d..bf4c5cd4a445 100644 --- a/runtime/polkadot/src/weights/pallet_membership.rs +++ b/runtime/polkadot/src/weights/pallet_membership.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_membership` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_membership.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -50,11 +50,12 @@ impl pallet_membership::WeightInfo for WeightInfo { // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 99]`. fn add_member(m: u32, ) -> Weight { - (18_204_000 as Weight) - // Standard Error: 0 - .saturating_add((55_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 19_229 nanoseconds. + Weight::from_ref_time(20_166_733 as u64) + // Standard Error: 1_078 + .saturating_add(Weight::from_ref_time(36_764 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -63,11 +64,12 @@ impl pallet_membership::WeightInfo for WeightInfo { // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[2, 100]`. fn remove_member(m: u32, ) -> Weight { - (20_617_000 as Weight) - // Standard Error: 0 - .saturating_add((45_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 21_778 nanoseconds. + Weight::from_ref_time(22_484_271 as u64) + // Standard Error: 499 + .saturating_add(Weight::from_ref_time(34_154 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -76,11 +78,12 @@ impl pallet_membership::WeightInfo for WeightInfo { // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[2, 100]`. fn swap_member(m: u32, ) -> Weight { - (20_686_000 as Weight) - // Standard Error: 0 - .saturating_add((59_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 21_853 nanoseconds. + Weight::from_ref_time(22_718_867 as u64) + // Standard Error: 623 + .saturating_add(Weight::from_ref_time(43_677 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -89,11 +92,12 @@ impl pallet_membership::WeightInfo for WeightInfo { // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn reset_member(m: u32, ) -> Weight { - (20_032_000 as Weight) - // Standard Error: 0 - .saturating_add((179_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 20_805 nanoseconds. + Weight::from_ref_time(22_284_415 as u64) + // Standard Error: 764 + .saturating_add(Weight::from_ref_time(157_189 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: TechnicalMembership Members (r:1 w:1) // Storage: TechnicalCommittee Proposals (r:1 w:0) @@ -102,30 +106,33 @@ impl pallet_membership::WeightInfo for WeightInfo { // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn change_key(m: u32, ) -> Weight { - (21_386_000 as Weight) - // Standard Error: 0 - .saturating_add((56_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 22_056 nanoseconds. + Weight::from_ref_time(23_040_470 as u64) + // Standard Error: 601 + .saturating_add(Weight::from_ref_time(44_062 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: TechnicalMembership Members (r:1 w:0) // Storage: TechnicalMembership Prime (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn set_prime(m: u32, ) -> Weight { - (7_077_000 as Weight) - // Standard Error: 0 - .saturating_add((11_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 7_968 nanoseconds. + Weight::from_ref_time(8_412_859 as u64) + // Standard Error: 213 + .saturating_add(Weight::from_ref_time(9_618 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: TechnicalMembership Prime (r:0 w:1) // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn clear_prime(m: u32, ) -> Weight { - (3_931_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 4_511 nanoseconds. + Weight::from_ref_time(4_850_929 as u64) + // Standard Error: 183 + .saturating_add(Weight::from_ref_time(356 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_multisig.rs b/runtime/polkadot/src/weights/pallet_multisig.rs index e4a87b195411..cd8a795eeaa3 100644 --- a/runtime/polkadot/src/weights/pallet_multisig.rs +++ b/runtime/polkadot/src/weights/pallet_multisig.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_multisig` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -28,11 +28,11 @@ // --steps=50 // --repeat=20 // --pallet=pallet_multisig -// --extrinsic=* +// --extrinsic= // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_multisig.rs +// --output=runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,115 +46,81 @@ pub struct WeightInfo(PhantomData); impl pallet_multisig::WeightInfo for WeightInfo { /// The range of component `z` is `[0, 10000]`. fn as_multi_threshold_1(z: u32, ) -> Weight { - (13_989_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) + // Minimum execution time: 14_333 nanoseconds. + Weight::from_ref_time(14_680_513 as u64) + // Standard Error: 3 + .saturating_add(Weight::from_ref_time(478 as u64).saturating_mul(z as u64)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_create(s: u32, z: u32, ) -> Weight { - (30_373_000 as Weight) - // Standard Error: 0 - .saturating_add((104_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) - /// The range of component `s` is `[2, 100]`. - /// The range of component `z` is `[0, 10000]`. - fn as_multi_create_store(s: u32, z: u32, ) -> Weight { - (32_912_000 as Weight) - // Standard Error: 0 - .saturating_add((108_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 41_940 nanoseconds. + Weight::from_ref_time(34_164_952 as u64) + // Standard Error: 758 + .saturating_add(Weight::from_ref_time(84_361 as u64).saturating_mul(s as u64)) + // Standard Error: 7 + .saturating_add(Weight::from_ref_time(1_515 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) /// The range of component `s` is `[3, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_approve(s: u32, z: u32, ) -> Weight { - (19_525_000 as Weight) - // Standard Error: 0 - .saturating_add((106_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 32_061 nanoseconds. + Weight::from_ref_time(25_242_175 as u64) + // Standard Error: 488 + .saturating_add(Weight::from_ref_time(74_544 as u64).saturating_mul(s as u64)) + // Standard Error: 4 + .saturating_add(Weight::from_ref_time(1_451 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - /// The range of component `s` is `[3, 100]`. - /// The range of component `z` is `[0, 10000]`. - fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { - (31_081_000 as Weight) - // Standard Error: 0 - .saturating_add((126_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_complete(s: u32, z: u32, ) -> Weight { - (44_011_000 as Weight) - // Standard Error: 2_000 - .saturating_add((101_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 45_799 nanoseconds. + Weight::from_ref_time(36_673_371 as u64) + // Standard Error: 602 + .saturating_add(Weight::from_ref_time(105_602 as u64).saturating_mul(s as u64)) + // Standard Error: 5 + .saturating_add(Weight::from_ref_time(1_489 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_create(s: u32, ) -> Weight { - (29_889_000 as Weight) - // Standard Error: 0 - .saturating_add((105_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 30_746 nanoseconds. + Weight::from_ref_time(33_495_066 as u64) + // Standard Error: 1_027 + .saturating_add(Weight::from_ref_time(85_901 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:0) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_approve(s: u32, ) -> Weight { - (19_135_000 as Weight) - // Standard Error: 0 - .saturating_add((110_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - // Storage: System Account (r:1 w:1) - /// The range of component `s` is `[2, 100]`. - fn approve_as_multi_complete(s: u32, ) -> Weight { - (61_253_000 as Weight) - // Standard Error: 1_000 - .saturating_add((139_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 21_939 nanoseconds. + Weight::from_ref_time(23_359_812 as u64) + // Standard Error: 626 + .saturating_add(Weight::from_ref_time(86_183 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) /// The range of component `s` is `[2, 100]`. fn cancel_as_multi(s: u32, ) -> Weight { - (44_745_000 as Weight) - // Standard Error: 0 - .saturating_add((116_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 32_246 nanoseconds. + Weight::from_ref_time(33_400_827 as u64) + // Standard Error: 746 + .saturating_add(Weight::from_ref_time(85_743 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_nomination_pools.rs b/runtime/polkadot/src/weights/pallet_nomination_pools.rs index beb84b82f23b..4dedf1a4375c 100644 --- a/runtime/polkadot/src/weights/pallet_nomination_pools.rs +++ b/runtime/polkadot/src/weights/pallet_nomination_pools.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_nomination_pools` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_nomination_pools.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -58,9 +58,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn join() -> Weight { - (127_049_000 as Weight) - .saturating_add(T::DbWeight::get().reads(17 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) + // Minimum execution time: 137_659 nanoseconds. + Weight::from_ref_time(141_867_000 as u64) + .saturating_add(T::DbWeight::get().reads(17 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -72,9 +73,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn bond_extra_transfer() -> Weight { - (118_664_000 as Weight) - .saturating_add(T::DbWeight::get().reads(14 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) + // Minimum execution time: 135_584 nanoseconds. + Weight::from_ref_time(138_267_000 as u64) + .saturating_add(T::DbWeight::get().reads(14 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -86,18 +88,20 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListNodes (r:2 w:2) // Storage: VoterList ListBags (r:2 w:2) fn bond_extra_reward() -> Weight { - (128_259_000 as Weight) - .saturating_add(T::DbWeight::get().reads(13 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) + // Minimum execution time: 139_022 nanoseconds. + Weight::from_ref_time(141_990_000 as u64) + .saturating_add(T::DbWeight::get().reads(13 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) // Storage: NominationPools RewardPools (r:1 w:1) // Storage: System Account (r:1 w:1) fn claim_payout() -> Weight { - (48_002_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 55_953 nanoseconds. + Weight::from_ref_time(56_404_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -114,9 +118,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools SubPoolsStorage (r:1 w:1) // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) fn unbond() -> Weight { - (126_313_000 as Weight) - .saturating_add(T::DbWeight::get().reads(18 as Weight)) - .saturating_add(T::DbWeight::get().writes(13 as Weight)) + // Minimum execution time: 137_634 nanoseconds. + Weight::from_ref_time(138_697_000 as u64) + .saturating_add(T::DbWeight::get().reads(18 as u64)) + .saturating_add(T::DbWeight::get().writes(13 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -124,11 +129,12 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: Balances Locks (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn pool_withdraw_unbonded(s: u32, ) -> Weight { - (41_173_000 as Weight) - // Standard Error: 0 - .saturating_add((31_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 50_029 nanoseconds. + Weight::from_ref_time(51_873_509 as u64) + // Standard Error: 1_109 + .saturating_add(Weight::from_ref_time(8_889 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -140,11 +146,12 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools CounterForPoolMembers (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - (80_122_000 as Weight) - // Standard Error: 0 - .saturating_add((39_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 89_911 nanoseconds. + Weight::from_ref_time(92_313_754 as u64) + // Standard Error: 1_344 + .saturating_add(Weight::from_ref_time(21_018 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -163,15 +170,15 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools RewardPools (r:1 w:1) // Storage: NominationPools CounterForRewardPools (r:1 w:1) // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) + // Storage: NominationPools Metadata (r:1 w:1) // Storage: NominationPools CounterForBondedPools (r:1 w:1) // Storage: Staking Payee (r:0 w:1) /// The range of component `s` is `[0, 100]`. - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (137_635_000 as Weight) - // Standard Error: 1_000 - .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(19 as Weight)) - .saturating_add(T::DbWeight::get().writes(16 as Weight)) + fn withdraw_unbonded_kill(_s: u32, ) -> Weight { + // Minimum execution time: 142_501 nanoseconds. + Weight::from_ref_time(145_720_383 as u64) + .saturating_add(T::DbWeight::get().reads(20 as u64)) + .saturating_add(T::DbWeight::get().writes(17 as u64)) } // Storage: Staking MinNominatorBond (r:1 w:0) // Storage: NominationPools MinCreateBond (r:1 w:0) @@ -187,7 +194,6 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: Staking Ledger (r:1 w:1) // Storage: Staking Bonded (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: NominationPools RewardPools (r:1 w:1) // Storage: NominationPools CounterForRewardPools (r:1 w:1) @@ -196,9 +202,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools BondedPools (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn create() -> Weight { - (130_180_000 as Weight) - .saturating_add(T::DbWeight::get().reads(22 as Weight)) - .saturating_add(T::DbWeight::get().writes(15 as Weight)) + // Minimum execution time: 129_279 nanoseconds. + Weight::from_ref_time(130_518_000 as u64) + .saturating_add(T::DbWeight::get().reads(21 as u64)) + .saturating_add(T::DbWeight::get().writes(15 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -214,28 +221,33 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: Staking CounterForNominators (r:1 w:1) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - (49_620_000 as Weight) - // Standard Error: 7_000 - .saturating_add((2_222_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 60_954 nanoseconds. + Weight::from_ref_time(61_463_684 as u64) + // Standard Error: 4_901 + .saturating_add(Weight::from_ref_time(1_149_069 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: NominationPools BondedPools (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) fn set_state() -> Weight { - (25_600_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 34_554 nanoseconds. + Weight::from_ref_time(35_453_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: NominationPools Metadata (r:1 w:1) // Storage: NominationPools CounterForMetadata (r:1 w:1) /// The range of component `n` is `[1, 256]`. - fn set_metadata(_n: u32, ) -> Weight { - (14_190_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn set_metadata(n: u32, ) -> Weight { + // Minimum execution time: 16_327 nanoseconds. + Weight::from_ref_time(17_114_673 as u64) + // Standard Error: 135 + .saturating_add(Weight::from_ref_time(176 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: NominationPools MinJoinBond (r:0 w:1) // Storage: NominationPools MaxPoolMembers (r:0 w:1) @@ -243,14 +255,16 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools MinCreateBond (r:0 w:1) // Storage: NominationPools MaxPools (r:0 w:1) fn set_configs() -> Weight { - (6_590_000 as Weight) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 7_390 nanoseconds. + Weight::from_ref_time(7_595_000 as u64) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: NominationPools BondedPools (r:1 w:1) fn update_roles() -> Weight { - (21_132_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_740 nanoseconds. + Weight::from_ref_time(26_148_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -261,8 +275,9 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - (47_706_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 59_514 nanoseconds. + Weight::from_ref_time(60_304_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_preimage.rs b/runtime/polkadot/src/weights/pallet_preimage.rs index 417923f01a80..2c1d2d36766b 100644 --- a/runtime/polkadot/src/weights/pallet_preimage.rs +++ b/runtime/polkadot/src/weights/pallet_preimage.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_preimage` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_preimage.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -44,92 +44,103 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_preimage`. pub struct WeightInfo(PhantomData); impl pallet_preimage::WeightInfo for WeightInfo { - // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) /// The range of component `s` is `[0, 4194304]`. fn note_preimage(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 27_619 nanoseconds. + Weight::from_ref_time(27_814_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_277 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) /// The range of component `s` is `[0, 4194304]`. fn note_requested_preimage(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 19_875 nanoseconds. + Weight::from_ref_time(20_055_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_278 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) /// The range of component `s` is `[0, 4194304]`. fn note_no_deposit_preimage(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 18_167 nanoseconds. + Weight::from_ref_time(18_540_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(2_292 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_preimage() -> Weight { - (35_230_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 36_691 nanoseconds. + Weight::from_ref_time(38_570_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_no_deposit_preimage() -> Weight { - (23_166_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 25_920 nanoseconds. + Weight::from_ref_time(26_891_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_preimage() -> Weight { - (32_732_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_999 nanoseconds. + Weight::from_ref_time(27_810_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_no_deposit_preimage() -> Weight { - (21_601_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 13_968 nanoseconds. + Weight::from_ref_time(15_524_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_unnoted_preimage() -> Weight { - (16_024_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 17_087 nanoseconds. + Weight::from_ref_time(17_859_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_requested_preimage() -> Weight { - (6_304_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_840 nanoseconds. + Weight::from_ref_time(8_341_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_preimage() -> Weight { - (22_524_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 26_449 nanoseconds. + Weight::from_ref_time(27_824_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_unnoted_preimage() -> Weight { - (15_432_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 7_712 nanoseconds. + Weight::from_ref_time(8_055_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn unrequest_multi_referenced_preimage() -> Weight { - (6_208_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_883 nanoseconds. + Weight::from_ref_time(8_212_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_proxy.rs b/runtime/polkadot/src/weights/pallet_proxy.rs index cad0f35d84f5..f843992e5661 100644 --- a/runtime/polkadot/src/weights/pallet_proxy.rs +++ b/runtime/polkadot/src/weights/pallet_proxy.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_proxy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_proxy.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,10 +47,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Storage: Proxy Proxies (r:1 w:0) /// The range of component `p` is `[1, 31]`. fn proxy(p: u32, ) -> Weight { - (17_881_000 as Weight) - // Standard Error: 1_000 - .saturating_add((62_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + // Minimum execution time: 19_011 nanoseconds. + Weight::from_ref_time(20_076_741 as u64) + // Standard Error: 1_518 + .saturating_add(Weight::from_ref_time(55_831 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) @@ -58,39 +59,42 @@ impl pallet_proxy::WeightInfo for WeightInfo { /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn proxy_announced(a: u32, p: u32, ) -> Weight { - (33_622_000 as Weight) - // Standard Error: 1_000 - .saturating_add((160_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((43_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 37_088 nanoseconds. + Weight::from_ref_time(36_581_632 as u64) + // Standard Error: 1_964 + .saturating_add(Weight::from_ref_time(116_190 as u64).saturating_mul(a as u64)) + // Standard Error: 2_030 + .saturating_add(Weight::from_ref_time(41_547 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn remove_announcement(a: u32, p: u32, ) -> Weight { - (22_694_000 as Weight) - // Standard Error: 1_000 - .saturating_add((160_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((8_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 25_299 nanoseconds. + Weight::from_ref_time(26_801_993 as u64) + // Standard Error: 2_746 + .saturating_add(Weight::from_ref_time(102_732 as u64).saturating_mul(a as u64)) + // Standard Error: 2_837 + .saturating_add(Weight::from_ref_time(318 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn reject_announcement(a: u32, p: u32, ) -> Weight { - (23_041_000 as Weight) - // Standard Error: 1_000 - .saturating_add((152_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((3_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 25_178 nanoseconds. + Weight::from_ref_time(26_248_780 as u64) + // Standard Error: 1_710 + .saturating_add(Weight::from_ref_time(116_285 as u64).saturating_mul(a as u64)) + // Standard Error: 1_767 + .saturating_add(Weight::from_ref_time(1_860 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) @@ -98,58 +102,64 @@ impl pallet_proxy::WeightInfo for WeightInfo { /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn announce(a: u32, p: u32, ) -> Weight { - (30_007_000 as Weight) - // Standard Error: 1_000 - .saturating_add((164_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((46_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 32_878 nanoseconds. + Weight::from_ref_time(34_386_513 as u64) + // Standard Error: 1_955 + .saturating_add(Weight::from_ref_time(97_872 as u64).saturating_mul(a as u64)) + // Standard Error: 2_020 + .saturating_add(Weight::from_ref_time(25_879 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn add_proxy(p: u32, ) -> Weight { - (25_173_000 as Weight) - // Standard Error: 1_000 - .saturating_add((90_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_410 nanoseconds. + Weight::from_ref_time(27_653_752 as u64) + // Standard Error: 2_000 + .saturating_add(Weight::from_ref_time(57_860 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn remove_proxy(p: u32, ) -> Weight { - (25_002_000 as Weight) - // Standard Error: 2_000 - .saturating_add((113_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_506 nanoseconds. + Weight::from_ref_time(27_604_932 as u64) + // Standard Error: 1_863 + .saturating_add(Weight::from_ref_time(78_466 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn remove_proxies(p: u32, ) -> Weight { - (21_348_000 as Weight) - // Standard Error: 1_000 - .saturating_add((54_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 22_696 nanoseconds. + Weight::from_ref_time(23_736_641 as u64) + // Standard Error: 1_616 + .saturating_add(Weight::from_ref_time(50_577 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. - fn anonymous(p: u32, ) -> Weight { - (28_480_000 as Weight) - // Standard Error: 2_000 - .saturating_add((27_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn create_pure(p: u32, ) -> Weight { + // Minimum execution time: 29_461 nanoseconds. + Weight::from_ref_time(30_835_016 as u64) + // Standard Error: 1_587 + .saturating_add(Weight::from_ref_time(23_834 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[0, 30]`. - fn kill_anonymous(p: u32, ) -> Weight { - (22_099_000 as Weight) - // Standard Error: 1_000 - .saturating_add((71_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn kill_pure(p: u32, ) -> Weight { + // Minimum execution time: 24_319 nanoseconds. + Weight::from_ref_time(25_652_003 as u64) + // Standard Error: 1_697 + .saturating_add(Weight::from_ref_time(28_118 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_scheduler.rs b/runtime/polkadot/src/weights/pallet_scheduler.rs index db69454aee9e..5206f8b19506 100644 --- a/runtime/polkadot/src/weights/pallet_scheduler.rs +++ b/runtime/polkadot/src/weights/pallet_scheduler.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_scheduler` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_scheduler.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -44,164 +44,97 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_scheduler`. pub struct WeightInfo(PhantomData); impl pallet_scheduler::WeightInfo for WeightInfo { - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic_named_resolved(s: u32, ) -> Weight { - (3_445_000 as Weight) - // Standard Error: 39_000 - .saturating_add((25_402_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(s as Weight))) + // Storage: Scheduler IncompleteSince (r:1 w:1) + fn service_agendas_base() -> Weight { + // Minimum execution time: 4_236 nanoseconds. + Weight::from_ref_time(4_539_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_named_resolved(s: u32, ) -> Weight { - (3_668_000 as Weight) - // Standard Error: 35_000 - .saturating_add((20_334_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + /// The range of component `s` is `[0, 50]`. + fn service_agenda_base(s: u32, ) -> Weight { + // Minimum execution time: 3_651 nanoseconds. + Weight::from_ref_time(6_843_488 as u64) + // Standard Error: 1_965 + .saturating_add(Weight::from_ref_time(579_324 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic_resolved(s: u32, ) -> Weight { - (125_000 as Weight) - // Standard Error: 37_000 - .saturating_add((23_169_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + fn service_task_base() -> Weight { + // Minimum execution time: 9_244 nanoseconds. + Weight::from_ref_time(9_537_000 as u64) } - // Storage: Scheduler Agenda (r:1 w:1) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_resolved(s: u32, ) -> Weight { - (7_788_000 as Weight) - // Standard Error: 53_000 - .saturating_add((19_336_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) + /// The range of component `s` is `[128, 4194304]`. + fn service_task_fetched(s: u32, ) -> Weight { + // Minimum execution time: 20_377 nanoseconds. + Weight::from_ref_time(20_733_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(1_250 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:0) // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_named_aborted(s: u32, ) -> Weight { - (4_356_000 as Weight) - // Standard Error: 16_000 - .saturating_add((8_792_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:0) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_aborted(s: u32, ) -> Weight { - (5_559_000 as Weight) - // Standard Error: 12_000 - .saturating_add((6_664_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn service_task_named() -> Weight { + // Minimum execution time: 10_526 nanoseconds. + Weight::from_ref_time(10_839_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic_named(s: u32, ) -> Weight { - (10_201_000 as Weight) - // Standard Error: 24_000 - .saturating_add((15_168_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) - } - // Storage: Scheduler Agenda (r:2 w:2) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic(s: u32, ) -> Weight { - (10_698_000 as Weight) - // Standard Error: 20_000 - .saturating_add((12_938_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + fn service_task_periodic() -> Weight { + // Minimum execution time: 9_130 nanoseconds. + Weight::from_ref_time(9_476_000 as u64) } - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_named(s: u32, ) -> Weight { - (11_043_000 as Weight) - // Standard Error: 18_000 - .saturating_add((10_555_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + fn execute_dispatch_signed() -> Weight { + // Minimum execution time: 3_644 nanoseconds. + Weight::from_ref_time(3_761_000 as u64) } - // Storage: Scheduler Agenda (r:1 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize(s: u32, ) -> Weight { - (11_488_000 as Weight) - // Standard Error: 18_000 - .saturating_add((9_623_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn execute_dispatch_unsigned() -> Weight { + // Minimum execution time: 3_604 nanoseconds. + Weight::from_ref_time(3_738_000 as u64) } // Storage: Scheduler Agenda (r:1 w:1) - /// The range of component `s` is `[0, 50]`. + /// The range of component `s` is `[0, 49]`. fn schedule(s: u32, ) -> Weight { - (19_103_000 as Weight) - // Standard Error: 1_000 - .saturating_add((48_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 16_561 nanoseconds. + Weight::from_ref_time(20_688_245 as u64) + // Standard Error: 2_610 + .saturating_add(Weight::from_ref_time(602_897 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) /// The range of component `s` is `[1, 50]`. fn cancel(s: u32, ) -> Weight { - (18_526_000 as Weight) - // Standard Error: 5_000 - .saturating_add((1_845_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 18_830 nanoseconds. + Weight::from_ref_time(20_815_969 as u64) + // Standard Error: 2_132 + .saturating_add(Weight::from_ref_time(598_343 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) - /// The range of component `s` is `[0, 50]`. + /// The range of component `s` is `[0, 49]`. fn schedule_named(s: u32, ) -> Weight { - (22_422_000 as Weight) - // Standard Error: 1_000 - .saturating_add((59_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 18_755 nanoseconds. + Weight::from_ref_time(23_838_238 as u64) + // Standard Error: 3_430 + .saturating_add(Weight::from_ref_time(628_138 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) /// The range of component `s` is `[1, 50]`. fn cancel_named(s: u32, ) -> Weight { - (20_181_000 as Weight) - // Standard Error: 5_000 - .saturating_add((1_852_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 19_761 nanoseconds. + Weight::from_ref_time(22_583_852 as u64) + // Standard Error: 2_440 + .saturating_add(Weight::from_ref_time(612_208 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_session.rs b/runtime/polkadot/src/weights/pallet_session.rs index 81eb07cb0597..85494036559b 100644 --- a/runtime/polkadot/src/weights/pallet_session.rs +++ b/runtime/polkadot/src/weights/pallet_session.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_session` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_session.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -48,16 +48,18 @@ impl pallet_session::WeightInfo for WeightInfo { // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:6 w:6) fn set_keys() -> Weight { - (42_571_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 48_470 nanoseconds. + Weight::from_ref_time(49_717_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:0 w:6) fn purge_keys() -> Weight { - (26_667_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 36_565 nanoseconds. + Weight::from_ref_time(37_601_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_staking.rs b/runtime/polkadot/src/weights/pallet_staking.rs index 2f22ff8a4cb1..1dcaf61b515e 100644 --- a/runtime/polkadot/src/weights/pallet_staking.rs +++ b/runtime/polkadot/src/weights/pallet_staking.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_staking.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,13 +47,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn bond() -> Weight { - (38_939_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 45_040 nanoseconds. + Weight::from_ref_time(45_590_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -61,9 +61,10 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn bond_extra() -> Weight { - (69_559_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 81_298 nanoseconds. + Weight::from_ref_time(81_990_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) @@ -75,9 +76,10 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking Bonded (r:1 w:0) // Storage: VoterList ListBags (r:2 w:2) fn unbond() -> Weight { - (75_195_000 as Weight) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + // Minimum execution time: 84_548 nanoseconds. + Weight::from_ref_time(85_146_000 as u64) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -85,11 +87,12 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: System Account (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - (31_282_000 as Weight) - // Standard Error: 0 - .saturating_add((32_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 37_601 nanoseconds. + Weight::from_ref_time(39_116_442 as u64) + // Standard Error: 767 + .saturating_add(Weight::from_ref_time(26_871 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -106,9 +109,10 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking Payee (r:0 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(_s: u32, ) -> Weight { - (60_846_000 as Weight) - .saturating_add(T::DbWeight::get().reads(13 as Weight)) - .saturating_add(T::DbWeight::get().writes(11 as Weight)) + // Minimum execution time: 72_644 nanoseconds. + Weight::from_ref_time(74_496_831 as u64) + .saturating_add(T::DbWeight::get().reads(13 as u64)) + .saturating_add(T::DbWeight::get().writes(11 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinValidatorBond (r:1 w:0) @@ -122,20 +126,22 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList CounterForListNodes (r:1 w:1) // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { - (49_099_000 as Weight) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 57_094 nanoseconds. + Weight::from_ref_time(57_864_000 as u64) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) /// The range of component `k` is `[1, 128]`. fn kick(k: u32, ) -> Weight { - (11_488_000 as Weight) - // Standard Error: 12_000 - .saturating_add((8_257_000 as Weight).saturating_mul(k as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) + // Minimum execution time: 31_384 nanoseconds. + Weight::from_ref_time(29_774_315 as u64) + // Standard Error: 9_098 + .saturating_add(Weight::from_ref_time(6_166_589 as u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(k as u64))) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinNominatorBond (r:1 w:0) @@ -150,12 +156,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking CounterForNominators (r:1 w:1) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - (52_331_000 as Weight) - // Standard Error: 6_000 - .saturating_add((3_297_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 60_432 nanoseconds. + Weight::from_ref_time(60_326_458 as u64) + // Standard Error: 4_664 + .saturating_add(Weight::from_ref_time(2_269_163 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Validators (r:1 w:0) @@ -165,51 +172,59 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - (46_346_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 55_783 nanoseconds. + Weight::from_ref_time(56_371_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Payee (r:0 w:1) fn set_payee() -> Weight { - (9_573_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 15_149 nanoseconds. + Weight::from_ref_time(15_399_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (16_956_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 21_225 nanoseconds. + Weight::from_ref_time(21_686_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Staking ValidatorCount (r:0 w:1) fn set_validator_count() -> Weight { - (3_283_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_772 nanoseconds. + Weight::from_ref_time(3_966_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking ForceEra (r:0 w:1) fn force_no_eras() -> Weight { - (3_218_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_959 nanoseconds. + Weight::from_ref_time(4_119_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era() -> Weight { - (3_188_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_808 nanoseconds. + Weight::from_ref_time(4_101_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (3_254_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_910 nanoseconds. + Weight::from_ref_time(4_063_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking Invulnerables (r:0 w:1) /// The range of component `v` is `[0, 1000]`. fn set_invulnerables(v: u32, ) -> Weight { - (3_706_000 as Weight) - // Standard Error: 0 - .saturating_add((10_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_072 nanoseconds. + Weight::from_ref_time(4_438_712 as u64) + // Standard Error: 27 + .saturating_add(Weight::from_ref_time(10_935 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking SlashingSpans (r:1 w:0) @@ -226,62 +241,64 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking SpanSlash (r:0 w:2) /// The range of component `s` is `[0, 100]`. fn force_unstake(s: u32, ) -> Weight { - (58_154_000 as Weight) - // Standard Error: 1_000 - .saturating_add((894_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 67_363 nanoseconds. + Weight::from_ref_time(71_965_490 as u64) + // Standard Error: 1_701 + .saturating_add(Weight::from_ref_time(855_020 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Staking UnappliedSlashes (r:1 w:1) /// The range of component `s` is `[1, 1000]`. fn cancel_deferred_slash(s: u32, ) -> Weight { - (2_565_318_000 as Weight) - // Standard Error: 176_000 - .saturating_add((14_870_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 118_794 nanoseconds. + Weight::from_ref_time(1_322_525_367 as u64) + // Standard Error: 86_572 + .saturating_add(Weight::from_ref_time(7_367_119 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Payee (r:2 w:0) - // Storage: System Account (r:2 w:2) - /// The range of component `n` is `[1, 256]`. + // Storage: Staking Payee (r:1 w:0) + // Storage: System Account (r:1 w:1) + /// The range of component `n` is `[0, 256]`. fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (79_314_000 as Weight) - // Standard Error: 20_000 - .saturating_add((25_615_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + // Minimum execution time: 93_351 nanoseconds. + Weight::from_ref_time(136_464_127 as u64) + // Standard Error: 14_412 + .saturating_add(Weight::from_ref_time(19_706_774 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(n as u64))) } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking Ledger (r:2 w:2) + // Storage: Staking Bonded (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Payee (r:2 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Balances Locks (r:2 w:2) - /// The range of component `n` is `[1, 256]`. + // Storage: Staking Payee (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + /// The range of component `n` is `[0, 256]`. fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (100_678_000 as Weight) - // Standard Error: 26_000 - .saturating_add((34_451_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) + // Minimum execution time: 110_077 nanoseconds. + Weight::from_ref_time(154_566_932 as u64) + // Standard Error: 24_823 + .saturating_add(Weight::from_ref_time(27_771_550 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(n as u64))) } // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -291,29 +308,12 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListBags (r:2 w:2) /// The range of component `l` is `[1, 32]`. fn rebond(l: u32, ) -> Weight { - (68_008_000 as Weight) - // Standard Error: 2_000 - .saturating_add((68_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) - } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:1) - // Storage: Staking ErasStakersClipped (r:0 w:2) - // Storage: Staking ErasValidatorPrefs (r:0 w:2) - // Storage: Staking ErasValidatorReward (r:0 w:1) - // Storage: Staking ErasRewardPoints (r:0 w:1) - // Storage: Staking ErasStakers (r:0 w:2) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - /// The range of component `e` is `[1, 100]`. - fn set_history_depth(e: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 84_000 - .saturating_add((21_963_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) + // Minimum execution time: 78_666 nanoseconds. + Weight::from_ref_time(80_640_795 as u64) + // Standard Error: 5_372 + .saturating_add(Weight::from_ref_time(24_280 as u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } // Storage: System Account (r:1 w:1) // Storage: Staking Bonded (r:1 w:1) @@ -330,12 +330,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking SpanSlash (r:0 w:1) /// The range of component `s` is `[1, 100]`. fn reap_stash(s: u32, ) -> Weight { - (66_394_000 as Weight) - // Standard Error: 4_000 - .saturating_add((874_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 77_329 nanoseconds. + Weight::from_ref_time(79_360_425 as u64) + // Standard Error: 1_804 + .saturating_add(Weight::from_ref_time(852_649 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: VoterList CounterForListNodes (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0) @@ -350,25 +351,25 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking ValidatorCount (r:1 w:0) // Storage: Staking MinimumValidatorCount (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasStakersClipped (r:0 w:1) // Storage: Staking ErasValidatorPrefs (r:0 w:1) // Storage: Staking ErasStakers (r:0 w:1) // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) /// The range of component `v` is `[1, 10]`. - /// The range of component `n` is `[1, 100]`. + /// The range of component `n` is `[0, 100]`. fn new_era(v: u32, n: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_253_000 - .saturating_add((288_357_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 120_000 - .saturating_add((38_464_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(187 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + // Minimum execution time: 436_511 nanoseconds. + Weight::from_ref_time(439_015_000 as u64) + // Standard Error: 1_814_104 + .saturating_add(Weight::from_ref_time(60_907_169 as u64).saturating_mul(v as u64)) + // Standard Error: 180_765 + .saturating_add(Weight::from_ref_time(12_850_120 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(186 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().reads((4 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(v as u64))) } // Storage: VoterList CounterForListNodes (r:1 w:0) // Storage: Staking SlashingSpans (r:21 w:0) @@ -383,29 +384,30 @@ impl pallet_staking::WeightInfo for WeightInfo { /// The range of component `n` is `[500, 1000]`. /// The range of component `s` is `[1, 20]`. fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 117_000 - .saturating_add((25_453_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 117_000 - .saturating_add((22_630_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 2_987_000 - .saturating_add((45_604_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(181 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_507_250 nanoseconds. + Weight::from_ref_time(25_649_540_000 as u64) + // Standard Error: 501_634 + .saturating_add(Weight::from_ref_time(12_184_198 as u64).saturating_mul(v as u64)) + // Standard Error: 501_634 + .saturating_add(Weight::from_ref_time(10_028_550 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(181 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().reads((4 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } + // Storage: Staking CounterForValidators (r:1 w:0) // Storage: Staking Validators (r:501 w:0) // Storage: System BlockWeight (r:1 w:1) /// The range of component `v` is `[500, 1000]`. fn get_npos_targets(v: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 37_000 - .saturating_add((7_545_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_419_543 nanoseconds. + Weight::from_ref_time(112_565_697 as u64) + // Standard Error: 51_023 + .saturating_add(Weight::from_ref_time(6_975_412 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking MinCommission (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) @@ -414,8 +416,9 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_set() -> Weight { - (6_204_000 as Weight) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 6_970 nanoseconds. + Weight::from_ref_time(7_235_000 as u64) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking MinCommission (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) @@ -424,8 +427,9 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_remove() -> Weight { - (5_674_000 as Weight) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 6_338 nanoseconds. + Weight::from_ref_time(6_658_000 as u64) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) @@ -438,15 +442,17 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill_other() -> Weight { - (57_011_000 as Weight) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 66_980 nanoseconds. + Weight::from_ref_time(67_728_000 as u64) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking MinCommission (r:1 w:0) // Storage: Staking Validators (r:1 w:1) fn force_apply_min_commission() -> Weight { - (10_470_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 14_843 nanoseconds. + Weight::from_ref_time(15_160_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_timestamp.rs b/runtime/polkadot/src/weights/pallet_timestamp.rs index d1044a555ad0..4ab23d73847f 100644 --- a/runtime/polkadot/src/weights/pallet_timestamp.rs +++ b/runtime/polkadot/src/weights/pallet_timestamp.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_timestamp.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,11 +47,13 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Storage: Timestamp Now (r:1 w:1) // Storage: Babe CurrentSlot (r:1 w:0) fn set() -> Weight { - (7_506_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_597 nanoseconds. + Weight::from_ref_time(8_891_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } fn on_finalize() -> Weight { - (2_200_000 as Weight) + // Minimum execution time: 3_577 nanoseconds. + Weight::from_ref_time(3_822_000 as u64) } } diff --git a/runtime/polkadot/src/weights/pallet_tips.rs b/runtime/polkadot/src/weights/pallet_tips.rs index 5d3df3b3be21..d1ed1868bf98 100644 --- a/runtime/polkadot/src/weights/pallet_tips.rs +++ b/runtime/polkadot/src/weights/pallet_tips.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_tips` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_tips.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -48,18 +48,20 @@ impl pallet_tips::WeightInfo for WeightInfo { // Storage: Tips Tips (r:1 w:1) /// The range of component `r` is `[0, 16384]`. fn report_awesome(r: u32, ) -> Weight { - (27_718_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 28_913 nanoseconds. + Weight::from_ref_time(29_737_594 as u64) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(1_766 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) fn retract_tip() -> Weight { - (26_157_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 27_802 nanoseconds. + Weight::from_ref_time(28_839_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Members (r:1 w:0) // Storage: Tips Reasons (r:1 w:1) @@ -67,23 +69,25 @@ impl pallet_tips::WeightInfo for WeightInfo { /// The range of component `r` is `[0, 16384]`. /// The range of component `t` is `[1, 13]`. fn tip_new(r: u32, t: u32, ) -> Weight { - (18_664_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 3_000 - .saturating_add((63_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 21_545 nanoseconds. + Weight::from_ref_time(19_956_560 as u64) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(1_653 as u64).saturating_mul(r as u64)) + // Standard Error: 9_051 + .saturating_add(Weight::from_ref_time(273_746 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: PhragmenElection Members (r:1 w:0) // Storage: Tips Tips (r:1 w:1) /// The range of component `t` is `[1, 13]`. fn tip(t: u32, ) -> Weight { - (10_863_000 as Weight) - // Standard Error: 2_000 - .saturating_add((162_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 14_239 nanoseconds. + Weight::from_ref_time(14_637_145 as u64) + // Standard Error: 2_166 + .saturating_add(Weight::from_ref_time(160_076 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Tips Tips (r:1 w:1) // Storage: PhragmenElection Members (r:1 w:0) @@ -91,20 +95,22 @@ impl pallet_tips::WeightInfo for WeightInfo { // Storage: Tips Reasons (r:0 w:1) /// The range of component `t` is `[1, 13]`. fn close_tip(t: u32, ) -> Weight { - (41_570_000 as Weight) - // Standard Error: 5_000 - .saturating_add((195_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 42_946 nanoseconds. + Weight::from_ref_time(44_707_457 as u64) + // Standard Error: 6_862 + .saturating_add(Weight::from_ref_time(176_886 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Tips Tips (r:1 w:1) // Storage: Tips Reasons (r:0 w:1) /// The range of component `t` is `[1, 13]`. fn slash_tip(t: u32, ) -> Weight { - (16_365_000 as Weight) - // Standard Error: 2_000 - .saturating_add((11_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 18_242 nanoseconds. + Weight::from_ref_time(18_986_836 as u64) + // Standard Error: 2_134 + .saturating_add(Weight::from_ref_time(44_433 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_treasury.rs b/runtime/polkadot/src/weights/pallet_treasury.rs index cb62cb1670cb..46275e5efeb7 100644 --- a/runtime/polkadot/src/weights/pallet_treasury.rs +++ b/runtime/polkadot/src/weights/pallet_treasury.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_treasury` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_treasury.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -45,37 +45,42 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl pallet_treasury::WeightInfo for WeightInfo { fn spend() -> Weight { - (150_000 as Weight) + // Minimum execution time: 133 nanoseconds. + Weight::from_ref_time(163_000 as u64) } // Storage: Treasury ProposalCount (r:1 w:1) // Storage: Treasury Proposals (r:0 w:1) fn propose_spend() -> Weight { - (24_642_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 25_090 nanoseconds. + Weight::from_ref_time(25_847_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Treasury Proposals (r:1 w:1) // Storage: System Account (r:1 w:1) fn reject_proposal() -> Weight { - (34_552_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 36_063 nanoseconds. + Weight::from_ref_time(37_046_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Treasury Proposals (r:1 w:0) // Storage: Treasury Approvals (r:1 w:1) /// The range of component `p` is `[0, 99]`. fn approve_proposal(p: u32, ) -> Weight { - (9_927_000 as Weight) - // Standard Error: 0 - .saturating_add((38_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 9_380 nanoseconds. + Weight::from_ref_time(12_577_152 as u64) + // Standard Error: 1_050 + .saturating_add(Weight::from_ref_time(47_228 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Treasury Approvals (r:1 w:1) fn remove_approval() -> Weight { - (5_599_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_346 nanoseconds. + Weight::from_ref_time(7_802_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Treasury Approvals (r:1 w:1) // Storage: Bounties BountyApprovals (r:1 w:1) @@ -83,12 +88,13 @@ impl pallet_treasury::WeightInfo for WeightInfo { // Storage: System Account (r:4 w:4) /// The range of component `p` is `[0, 100]`. fn on_initialize_proposals(p: u32, ) -> Weight { - (17_797_000 as Weight) - // Standard Error: 28_000 - .saturating_add((29_621_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(p as Weight))) + // Minimum execution time: 33_748 nanoseconds. + Weight::from_ref_time(40_406_620 as u64) + // Standard Error: 16_502 + .saturating_add(Weight::from_ref_time(23_598_101 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(p as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(p as u64))) } } diff --git a/runtime/polkadot/src/weights/pallet_utility.rs b/runtime/polkadot/src/weights/pallet_utility.rs index 618ae0566235..69e332d728f3 100644 --- a/runtime/polkadot/src/weights/pallet_utility.rs +++ b/runtime/polkadot/src/weights/pallet_utility.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_utility.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,26 +46,31 @@ pub struct WeightInfo(PhantomData); impl pallet_utility::WeightInfo for WeightInfo { /// The range of component `c` is `[0, 1000]`. fn batch(c: u32, ) -> Weight { - (14_546_000 as Weight) - // Standard Error: 3_000 - .saturating_add((4_678_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 10_771 nanoseconds. + Weight::from_ref_time(16_778_329 as u64) + // Standard Error: 2_348 + .saturating_add(Weight::from_ref_time(3_322_539 as u64).saturating_mul(c as u64)) } fn as_derivative() -> Weight { - (5_507_000 as Weight) + // Minimum execution time: 5_265 nanoseconds. + Weight::from_ref_time(5_423_000 as u64) } /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32, ) -> Weight { - (12_316_000 as Weight) - // Standard Error: 4_000 - .saturating_add((4_969_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 10_866 nanoseconds. + Weight::from_ref_time(20_054_725 as u64) + // Standard Error: 3_715 + .saturating_add(Weight::from_ref_time(3_430_598 as u64).saturating_mul(c as u64)) } fn dispatch_as() -> Weight { - (12_904_000 as Weight) + // Minimum execution time: 12_698 nanoseconds. + Weight::from_ref_time(12_946_000 as u64) } /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32, ) -> Weight { - (15_799_000 as Weight) - // Standard Error: 3_000 - .saturating_add((4_646_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 10_671 nanoseconds. + Weight::from_ref_time(14_320_668 as u64) + // Standard Error: 3_720 + .saturating_add(Weight::from_ref_time(3_299_555 as u64).saturating_mul(c as u64)) } } diff --git a/runtime/polkadot/src/weights/pallet_vesting.rs b/runtime/polkadot/src/weights/pallet_vesting.rs index b7ecd72932c0..8140a7944b92 100644 --- a/runtime/polkadot/src/weights/pallet_vesting.rs +++ b/runtime/polkadot/src/weights/pallet_vesting.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_vesting` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/polkadot/src/weights/pallet_vesting.rs +// --output=./runtime/polkadot/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -49,26 +49,28 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_locked(l: u32, s: u32, ) -> Weight { - (28_194_000 as Weight) - // Standard Error: 0 - .saturating_add((75_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((161_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 36_655 nanoseconds. + Weight::from_ref_time(35_846_278 as u64) + // Standard Error: 1_164 + .saturating_add(Weight::from_ref_time(45_176 as u64).saturating_mul(l as u64)) + // Standard Error: 2_072 + .saturating_add(Weight::from_ref_time(73_745 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_unlocked(l: u32, s: u32, ) -> Weight { - (28_109_000 as Weight) - // Standard Error: 0 - .saturating_add((67_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((134_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 36_392 nanoseconds. + Weight::from_ref_time(36_115_437 as u64) + // Standard Error: 1_029 + .saturating_add(Weight::from_ref_time(32_852 as u64).saturating_mul(l as u64)) + // Standard Error: 1_832 + .saturating_add(Weight::from_ref_time(51_682 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -76,13 +78,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_other_locked(l: u32, s: u32, ) -> Weight { - (28_316_000 as Weight) - // Standard Error: 0 - .saturating_add((75_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((154_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 36_298 nanoseconds. + Weight::from_ref_time(35_732_602 as u64) + // Standard Error: 1_118 + .saturating_add(Weight::from_ref_time(43_483 as u64).saturating_mul(l as u64)) + // Standard Error: 1_989 + .saturating_add(Weight::from_ref_time(73_636 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -90,13 +93,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_other_unlocked(l: u32, s: u32, ) -> Weight { - (28_998_000 as Weight) - // Standard Error: 0 - .saturating_add((62_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((106_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 36_437 nanoseconds. + Weight::from_ref_time(35_896_377 as u64) + // Standard Error: 1_037 + .saturating_add(Weight::from_ref_time(35_148 as u64).saturating_mul(l as u64)) + // Standard Error: 1_845 + .saturating_add(Weight::from_ref_time(52_168 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -104,13 +108,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. fn vested_transfer(l: u32, s: u32, ) -> Weight { - (42_983_000 as Weight) - // Standard Error: 2_000 - .saturating_add((73_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 3_000 - .saturating_add((126_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 51_425 nanoseconds. + Weight::from_ref_time(51_893_961 as u64) + // Standard Error: 2_087 + .saturating_add(Weight::from_ref_time(33_253 as u64).saturating_mul(l as u64)) + // Standard Error: 3_713 + .saturating_add(Weight::from_ref_time(30_498 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:2 w:2) @@ -118,13 +123,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. fn force_vested_transfer(l: u32, s: u32, ) -> Weight { - (42_800_000 as Weight) - // Standard Error: 2_000 - .saturating_add((57_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 4_000 - .saturating_add((148_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 50_485 nanoseconds. + Weight::from_ref_time(50_157_092 as u64) + // Standard Error: 1_939 + .saturating_add(Weight::from_ref_time(46_153 as u64).saturating_mul(l as u64)) + // Standard Error: 3_450 + .saturating_add(Weight::from_ref_time(62_537 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -132,13 +138,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - (29_188_000 as Weight) - // Standard Error: 0 - .saturating_add((73_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((157_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 37_645 nanoseconds. + Weight::from_ref_time(38_128_587 as u64) + // Standard Error: 1_361 + .saturating_add(Weight::from_ref_time(41_839 as u64).saturating_mul(l as u64)) + // Standard Error: 2_514 + .saturating_add(Weight::from_ref_time(28_665 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -146,12 +153,13 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - (29_144_000 as Weight) - // Standard Error: 1_000 - .saturating_add((71_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((149_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 37_771 nanoseconds. + Weight::from_ref_time(36_095_240 as u64) + // Standard Error: 1_698 + .saturating_add(Weight::from_ref_time(56_877 as u64).saturating_mul(l as u64)) + // Standard Error: 3_136 + .saturating_add(Weight::from_ref_time(91_827 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/polkadot/src/weights/runtime_common_auctions.rs b/runtime/polkadot/src/weights/runtime_common_auctions.rs index 2cd204f0e973..e252c756f160 100644 --- a/runtime/polkadot/src/weights/runtime_common_auctions.rs +++ b/runtime/polkadot/src/weights/runtime_common_auctions.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::auctions` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -47,9 +47,10 @@ impl runtime_common::auctions::WeightInfo for WeightInf // Storage: Auctions AuctionInfo (r:1 w:1) // Storage: Auctions AuctionCounter (r:1 w:1) fn new_auction() -> Weight { - (15_720_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 16_106 nanoseconds. + Weight::from_ref_time(16_475_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Paras ParaLifecycles (r:1 w:0) // Storage: Auctions AuctionCounter (r:1 w:0) @@ -59,9 +60,10 @@ impl runtime_common::auctions::WeightInfo for WeightInf // Storage: Auctions ReservedAmounts (r:2 w:2) // Storage: System Account (r:1 w:1) fn bid() -> Weight { - (70_200_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 68_962 nanoseconds. + Weight::from_ref_time(70_680_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Auctions AuctionInfo (r:1 w:1) // Storage: Babe NextRandomness (r:1 w:0) @@ -76,17 +78,19 @@ impl runtime_common::auctions::WeightInfo for WeightInf // Storage: Paras ActionsQueue (r:1 w:1) // Storage: Registrar Paras (r:1 w:1) fn on_initialize() -> Weight { - (16_024_103_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3688 as Weight)) - .saturating_add(T::DbWeight::get().writes(3683 as Weight)) + // Minimum execution time: 14_584_826 nanoseconds. + Weight::from_ref_time(14_874_529_000 as u64) + .saturating_add(T::DbWeight::get().reads(3688 as u64)) + .saturating_add(T::DbWeight::get().writes(3683 as u64)) } // Storage: Auctions ReservedAmounts (r:37 w:36) // Storage: System Account (r:36 w:36) // Storage: Auctions Winning (r:0 w:3600) // Storage: Auctions AuctionInfo (r:0 w:1) fn cancel_auction() -> Weight { - (4_682_562_000 as Weight) - .saturating_add(T::DbWeight::get().reads(73 as Weight)) - .saturating_add(T::DbWeight::get().writes(3673 as Weight)) + // Minimum execution time: 4_529_670 nanoseconds. + Weight::from_ref_time(4_587_198_000 as u64) + .saturating_add(T::DbWeight::get().reads(73 as u64)) + .saturating_add(T::DbWeight::get().writes(3673 as u64)) } } diff --git a/runtime/polkadot/src/weights/runtime_common_claims.rs b/runtime/polkadot/src/weights/runtime_common_claims.rs index 8a4463aa0df5..5dd38068392c 100644 --- a/runtime/polkadot/src/weights/runtime_common_claims.rs +++ b/runtime/polkadot/src/weights/runtime_common_claims.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::claims` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -52,18 +52,20 @@ impl runtime_common::claims::WeightInfo for WeightInfo< // Storage: System Account (r:1 w:0) // Storage: Balances Locks (r:1 w:1) fn claim() -> Weight { - (138_843_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 141_861 nanoseconds. + Weight::from_ref_time(143_112_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Claims Total (r:1 w:1) // Storage: Claims Vesting (r:0 w:1) // Storage: Claims Claims (r:0 w:1) // Storage: Claims Signing (r:0 w:1) fn mint_claim() -> Weight { - (9_350_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 11_111 nanoseconds. + Weight::from_ref_time(11_500_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Claims Claims (r:1 w:1) // Storage: Claims Signing (r:1 w:1) @@ -73,9 +75,10 @@ impl runtime_common::claims::WeightInfo for WeightInfo< // Storage: System Account (r:1 w:0) // Storage: Balances Locks (r:1 w:1) fn claim_attest() -> Weight { - (141_991_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 143_305 nanoseconds. + Weight::from_ref_time(145_492_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Claims Preclaims (r:1 w:1) // Storage: Claims Signing (r:1 w:1) @@ -86,17 +89,19 @@ impl runtime_common::claims::WeightInfo for WeightInfo< // Storage: System Account (r:1 w:0) // Storage: Balances Locks (r:1 w:1) fn attest() -> Weight { - (63_600_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 64_919 nanoseconds. + Weight::from_ref_time(67_541_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Claims Claims (r:1 w:2) // Storage: Claims Vesting (r:1 w:2) // Storage: Claims Signing (r:1 w:2) // Storage: Claims Preclaims (r:1 w:1) fn move_claim() -> Weight { - (19_341_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 20_973 nanoseconds. + Weight::from_ref_time(21_378_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } } diff --git a/runtime/polkadot/src/weights/runtime_common_crowdloan.rs b/runtime/polkadot/src/weights/runtime_common_crowdloan.rs index a1e832c67e6d..d16e92d158d6 100644 --- a/runtime/polkadot/src/weights/runtime_common_crowdloan.rs +++ b/runtime/polkadot/src/weights/runtime_common_crowdloan.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::crowdloan` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -49,9 +49,10 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: Paras ParaLifecycles (r:1 w:0) // Storage: Crowdloan NextFundIndex (r:1 w:1) fn create() -> Weight { - (42_118_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 45_596 nanoseconds. + Weight::from_ref_time(47_441_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: Slots Leases (r:1 w:0) @@ -61,55 +62,62 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: Crowdloan NewRaise (r:1 w:1) // Storage: unknown [0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291] (r:1 w:1) fn contribute() -> Weight { - (112_357_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 114_254 nanoseconds. + Weight::from_ref_time(115_945_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: System Account (r:2 w:2) // Storage: unknown [0xc85982571aa615c788ef9b2c16f54f25773fd439e8ee1ed2aa3ae43d48e880f0] (r:1 w:1) fn withdraw() -> Weight { - (51_125_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 53_866 nanoseconds. + Weight::from_ref_time(54_896_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `k` is `[0, 1000]`. fn refund(k: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 17_000 - .saturating_add((19_562_000 as Weight).saturating_mul(k as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(k as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(k as Weight))) + // Minimum execution time: 53_179 nanoseconds. + Weight::from_ref_time(62_342_000 as u64) + // Standard Error: 13_922 + .saturating_add(Weight::from_ref_time(16_886_810 as u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(k as u64))) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: System Account (r:1 w:1) fn dissolve() -> Weight { - (31_834_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 35_590 nanoseconds. + Weight::from_ref_time(36_852_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) fn edit() -> Weight { - (20_820_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 23_016 nanoseconds. + Weight::from_ref_time(24_040_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Funds (r:1 w:0) // Storage: unknown [0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291] (r:1 w:1) fn add_memo() -> Weight { - (28_173_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 32_720 nanoseconds. + Weight::from_ref_time(33_735_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Funds (r:1 w:0) // Storage: Crowdloan NewRaise (r:1 w:1) fn poke() -> Weight { - (24_193_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_996 nanoseconds. + Weight::from_ref_time(25_803_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Auctions AuctionInfo (r:1 w:0) // Storage: Crowdloan EndingsCount (r:1 w:1) @@ -123,12 +131,13 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: System Account (r:2 w:2) /// The range of component `n` is `[2, 100]`. fn on_initialize(n: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 41_000 - .saturating_add((49_451_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(n as Weight))) + // Minimum execution time: 101_604 nanoseconds. + Weight::from_ref_time(9_838_939 as u64) + // Standard Error: 25_245 + .saturating_add(Weight::from_ref_time(38_848_064 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(n as u64))) } } diff --git a/runtime/polkadot/src/weights/runtime_common_paras_registrar.rs b/runtime/polkadot/src/weights/runtime_common_paras_registrar.rs index 41ba49e359d4..c9d09bce0b1f 100644 --- a/runtime/polkadot/src/weights/runtime_common_paras_registrar.rs +++ b/runtime/polkadot/src/weights/runtime_common_paras_registrar.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::paras_registrar` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -48,9 +48,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:0) fn reserve() -> Weight { - (27_099_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 30_439 nanoseconds. + Weight::from_ref_time(30_964_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -63,9 +64,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras CurrentCodeHash (r:0 w:1) // Storage: Paras UpcomingParasGenesis (r:0 w:1) fn register() -> Weight { - (8_586_789_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 7_299_578 nanoseconds. + Weight::from_ref_time(7_364_958_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -78,9 +80,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras CurrentCodeHash (r:0 w:1) // Storage: Paras UpcomingParasGenesis (r:0 w:1) fn force_register() -> Weight { - (8_584_794_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 7_280_658 nanoseconds. + Weight::from_ref_time(7_341_550_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -89,9 +92,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras ActionsQueue (r:1 w:1) // Storage: Registrar PendingSwap (r:0 w:1) fn deregister() -> Weight { - (42_239_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 48_210 nanoseconds. + Weight::from_ref_time(49_518_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Registrar Paras (r:1 w:0) // Storage: Paras ParaLifecycles (r:2 w:2) @@ -101,8 +105,38 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Crowdloan Funds (r:2 w:2) // Storage: Slots Leases (r:2 w:2) fn swap() -> Weight { - (37_029_000 as Weight) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + // Minimum execution time: 41_985 nanoseconds. + Weight::from_ref_time(43_341_000 as u64) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) + } + // Storage: Paras FutureCodeHash (r:1 w:1) + // Storage: Paras UpgradeRestrictionSignal (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Paras CurrentCodeHash (r:1 w:0) + // Storage: Paras UpgradeCooldowns (r:1 w:1) + // Storage: Paras PvfActiveVoteMap (r:1 w:0) + // Storage: Paras CodeByHash (r:1 w:1) + // Storage: Paras UpcomingUpgrades (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras FutureCodeUpgrades (r:0 w:1) + /// The range of component `b` is `[1, 3145728]`. + fn schedule_code_upgrade(b: u32, ) -> Weight { + // Minimum execution time: 41_205 nanoseconds. + Weight::from_ref_time(41_445_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_274 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) + } + // Storage: Paras Heads (r:0 w:1) + /// The range of component `b` is `[1, 1048576]`. + fn set_current_head(b: u32, ) -> Weight { + // Minimum execution time: 13_060 nanoseconds. + Weight::from_ref_time(13_271_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(903 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/polkadot/src/weights/runtime_common_slots.rs b/runtime/polkadot/src/weights/runtime_common_slots.rs index dffafd5df08e..3f8084b98ec1 100644 --- a/runtime/polkadot/src/weights/runtime_common_slots.rs +++ b/runtime/polkadot/src/weights/runtime_common_slots.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::slots` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -47,9 +47,10 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (28_307_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 29_416 nanoseconds. + Weight::from_ref_time(29_951_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Paras Parachains (r:1 w:0) // Storage: Slots Leases (r:101 w:100) @@ -60,24 +61,26 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (0 as Weight) - // Standard Error: 28_000 - .saturating_add((6_721_000 as Weight).saturating_mul(c as Weight)) - // Standard Error: 28_000 - .saturating_add((17_731_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(t as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(t as Weight))) + // Minimum execution time: 549_007 nanoseconds. + Weight::from_ref_time(553_067_000 as u64) + // Standard Error: 69_242 + .saturating_add(Weight::from_ref_time(1_978_452 as u64).saturating_mul(c as u64)) + // Standard Error: 69_242 + .saturating_add(Weight::from_ref_time(11_522_846 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(t as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(t as u64))) } // Storage: Slots Leases (r:1 w:1) // Storage: System Account (r:8 w:8) fn clear_all_leases() -> Weight { - (92_317_000 as Weight) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(9 as Weight)) + // Minimum execution time: 89_790 nanoseconds. + Weight::from_ref_time(90_964_000 as u64) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: Slots Leases (r:1 w:0) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -85,8 +88,9 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (21_444_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 28_418 nanoseconds. + Weight::from_ref_time(29_017_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/polkadot/src/weights/runtime_parachains_configuration.rs b/runtime/polkadot/src/weights/runtime_parachains_configuration.rs index da4469ada60a..f4d7607236b7 100644 --- a/runtime/polkadot/src/weights/runtime_parachains_configuration.rs +++ b/runtime/polkadot/src/weights/runtime_parachains_configuration.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::configuration` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -49,48 +49,54 @@ impl runtime_parachains::configuration::WeightInfo for // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_block_number() -> Weight { - (9_262_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 10_286 nanoseconds. + Weight::from_ref_time(10_978_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_u32() -> Weight { - (9_271_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 10_568 nanoseconds. + Weight::from_ref_time(11_052_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_option_u32() -> Weight { - (9_169_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 10_569 nanoseconds. + Weight::from_ref_time(10_956_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_weight() -> Weight { - (9_210_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 11_005 nanoseconds. + Weight::from_ref_time(11_394_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Benchmark Override (r:0 w:0) fn set_hrmp_open_request_ttl() -> Weight { - (2_000_000_000_000 as Weight) + // Minimum execution time: 2_000_000_000 nanoseconds. + Weight::from_ref_time(2_000_000_000_000 as u64) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_balance() -> Weight { - (9_213_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 10_792 nanoseconds. + Weight::from_ref_time(11_341_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/polkadot/src/weights/runtime_parachains_disputes.rs b/runtime/polkadot/src/weights/runtime_parachains_disputes.rs index 12dc18d5a4c3..cf30508fb78a 100644 --- a/runtime/polkadot/src/weights/runtime_parachains_disputes.rs +++ b/runtime/polkadot/src/weights/runtime_parachains_disputes.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::disputes` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -46,7 +46,8 @@ pub struct WeightInfo(PhantomData); impl runtime_parachains::disputes::WeightInfo for WeightInfo { // Storage: ParasDisputes Frozen (r:0 w:1) fn force_unfreeze() -> Weight { - (3_112_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_857 nanoseconds. + Weight::from_ref_time(4_013_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/polkadot/src/weights/runtime_parachains_hrmp.rs b/runtime/polkadot/src/weights/runtime_parachains_hrmp.rs index de6e57873b8a..b3ddc8251898 100644 --- a/runtime/polkadot/src/weights/runtime_parachains_hrmp.rs +++ b/runtime/polkadot/src/weights/runtime_parachains_hrmp.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2021 Parity Technologies (UK) Ltd. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. // This file is part of Polkadot. // Polkadot is free software: you can redistribute it and/or modify @@ -16,23 +16,23 @@ //! Autogenerated weights for `runtime_parachains::hrmp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-11-05, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128 +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: -// target/release/polkadot +// ./target/production/polkadot // benchmark -// --chain=kusama-dev +// pallet +// --chain=polkadot-dev // --steps=50 // --repeat=20 // --pallet=runtime_parachains::hrmp // --extrinsic=* // --execution=wasm // --wasm-execution=compiled -// --heap-pages=4096 // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/runtime_parachains_hrmp.rs - +// --output=./runtime/polkadot/src/weights/runtime_parachains_hrmp.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -54,9 +54,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_init_open_channel() -> Weight { - (54_952_000 as Weight) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 38_437 nanoseconds. + Weight::from_ref_time(39_247_000 as u64) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) @@ -66,9 +67,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_accept_open_channel() -> Weight { - (47_965_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 37_957 nanoseconds. + Weight::from_ref_time(38_348_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Hrmp HrmpChannels (r:1 w:0) // Storage: Hrmp HrmpCloseChannelRequests (r:1 w:1) @@ -77,9 +79,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_close_channel() -> Weight { - (44_369_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 34_872 nanoseconds. + Weight::from_ref_time(35_365_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Hrmp HrmpIngressChannelsIndex (r:128 w:127) // Storage: Hrmp HrmpEgressChannelsIndex (r:1 w:1) @@ -87,18 +90,21 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Hrmp HrmpAcceptedChannelRequestCount (r:0 w:1) // Storage: Hrmp HrmpChannelContents (r:0 w:127) // Storage: Hrmp HrmpOpenChannelRequestCount (r:0 w:1) + /// The range of component `i` is `[0, 127]`. + /// The range of component `e` is `[0, 127]`. fn force_clean_hrmp(i: u32, e: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 17_000 - .saturating_add((15_959_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 17_000 - .saturating_add((16_048_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(i as Weight))) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(e as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(i as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(e as Weight))) + // Minimum execution time: 855_200 nanoseconds. + Weight::from_ref_time(858_064_000 as u64) + // Standard Error: 77_590 + .saturating_add(Weight::from_ref_time(2_626_939 as u64).saturating_mul(i as u64)) + // Standard Error: 77_590 + .saturating_add(Weight::from_ref_time(2_688_959 as u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(i as u64))) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(e as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(i as u64))) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(e as u64))) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:0) @@ -109,14 +115,16 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Hrmp HrmpOpenChannelRequestCount (r:2 w:2) // Storage: Hrmp HrmpAcceptedChannelRequestCount (r:2 w:2) // Storage: Hrmp HrmpChannels (r:0 w:2) + /// The range of component `c` is `[0, 128]`. fn force_process_hrmp_open(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 26_000 - .saturating_add((35_598_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((7 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((6 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 8_849 nanoseconds. + Weight::from_ref_time(9_014_000 as u64) + // Standard Error: 7_867 + .saturating_add(Weight::from_ref_time(15_479_468 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((7 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((6 as u64).saturating_mul(c as u64))) } // Storage: Hrmp HrmpCloseChannelRequestsList (r:1 w:0) // Storage: Hrmp HrmpChannels (r:2 w:2) @@ -124,34 +132,57 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Hrmp HrmpIngressChannelsIndex (r:2 w:2) // Storage: Hrmp HrmpCloseChannelRequests (r:0 w:2) // Storage: Hrmp HrmpChannelContents (r:0 w:2) + /// The range of component `c` is `[0, 128]`. fn force_process_hrmp_close(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 15_000 - .saturating_add((20_510_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((5 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 5_664 nanoseconds. + Weight::from_ref_time(110_996 as u64) + // Standard Error: 10_270 + .saturating_add(Weight::from_ref_time(9_388_103 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((5 as u64).saturating_mul(c as u64))) } - // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) + // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequestCount (r:1 w:1) + /// The range of component `c` is `[0, 128]`. fn hrmp_cancel_open_request(c: u32, ) -> Weight { - (32_749_000 as Weight) - // Standard Error: 0 - .saturating_add((59_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 24_259 nanoseconds. + Weight::from_ref_time(30_040_803 as u64) + // Standard Error: 1_283 + .saturating_add(Weight::from_ref_time(93_082 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequests (r:2 w:2) + /// The range of component `c` is `[0, 128]`. fn clean_open_channel_requests(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 6_000 - .saturating_add((5_781_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 4_103 nanoseconds. + Weight::from_ref_time(1_950_408 as u64) + // Standard Error: 3_739 + .saturating_add(Weight::from_ref_time(2_548_927 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + } + // Storage: Paras ParaLifecycles (r:2 w:0) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) + // Storage: Hrmp HrmpChannels (r:1 w:0) + // Storage: Hrmp HrmpEgressChannelsIndex (r:1 w:0) + // Storage: Hrmp HrmpOpenChannelRequestCount (r:1 w:1) + // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:2 w:2) + // Storage: Dmp DownwardMessageQueues (r:2 w:2) + // Storage: Hrmp HrmpIngressChannelsIndex (r:1 w:0) + // Storage: Hrmp HrmpAcceptedChannelRequestCount (r:1 w:1) + fn force_open_hrmp_channel() -> Weight { + // Minimum execution time: 49_505 nanoseconds. + Weight::from_ref_time(51_263_000 as u64) + .saturating_add(T::DbWeight::get().reads(14 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } } diff --git a/runtime/polkadot/src/weights/runtime_parachains_initializer.rs b/runtime/polkadot/src/weights/runtime_parachains_initializer.rs index 498b1c77c296..37ffc7e53fe0 100644 --- a/runtime/polkadot/src/weights/runtime_parachains_initializer.rs +++ b/runtime/polkadot/src/weights/runtime_parachains_initializer.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::initializer` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -47,10 +47,11 @@ impl runtime_parachains::initializer::WeightInfo for We // Storage: System Digest (r:1 w:1) /// The range of component `d` is `[0, 65536]`. fn force_approve(d: u32, ) -> Weight { - (6_191_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_037 nanoseconds. + Weight::from_ref_time(9_934_606 as u64) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(1_316 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/polkadot/src/weights/runtime_parachains_paras.rs b/runtime/polkadot/src/weights/runtime_parachains_paras.rs index d43278d07fb9..3ae8038360e6 100644 --- a/runtime/polkadot/src/weights/runtime_parachains_paras.rs +++ b/runtime/polkadot/src/weights/runtime_parachains_paras.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::paras` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -52,19 +52,21 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras CodeByHash (r:0 w:1) /// The range of component `c` is `[1, 3145728]`. fn force_set_current_code(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 33_710 nanoseconds. + Weight::from_ref_time(33_974_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_259 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Paras Heads (r:0 w:1) /// The range of component `s` is `[1, 1048576]`. fn force_set_current_head(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 12_424 nanoseconds. + Weight::from_ref_time(12_683_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(904 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Paras FutureCodeHash (r:1 w:1) @@ -79,55 +81,61 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras UpgradeRestrictionSignal (r:0 w:1) /// The range of component `c` is `[1, 3145728]`. fn force_schedule_code_upgrade(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + // Minimum execution time: 56_907 nanoseconds. + Weight::from_ref_time(57_326_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(2_289 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } // Storage: Paras FutureCodeUpgrades (r:1 w:0) // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) /// The range of component `s` is `[1, 1048576]`. fn force_note_new_head(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 18_297 nanoseconds. + Weight::from_ref_time(18_498_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(903 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras ActionsQueue (r:1 w:1) fn force_queue_action() -> Weight { - (18_998_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 22_688 nanoseconds. + Weight::from_ref_time(23_185_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Paras PvfActiveVoteMap (r:1 w:0) // Storage: Paras CodeByHash (r:1 w:1) /// The range of component `c` is `[1, 3145728]`. fn add_trusted_validation_code(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_283 nanoseconds. + Weight::from_ref_time(8_421_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_269 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Paras CodeByHashRefs (r:1 w:0) // Storage: Paras CodeByHash (r:0 w:1) fn poke_unused_validation_code() -> Weight { - (4_773_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 6_271 nanoseconds. + Weight::from_ref_time(6_442_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras PvfActiveVoteMap (r:1 w:1) fn include_pvf_check_statement() -> Weight { - (92_826_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 92_849 nanoseconds. + Weight::from_ref_time(95_135_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) @@ -138,9 +146,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: System Digest (r:1 w:1) // Storage: Paras FutureCodeUpgrades (r:0 w:100) fn include_pvf_check_statement_finalize_upgrade_accept() -> Weight { - (682_896_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(104 as Weight)) + // Minimum execution time: 609_526 nanoseconds. + Weight::from_ref_time(615_900_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(104 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) @@ -152,9 +161,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras UpgradeGoAheadSignal (r:0 w:100) // Storage: Paras FutureCodeHash (r:0 w:100) fn include_pvf_check_statement_finalize_upgrade_reject() -> Weight { - (630_660_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(204 as Weight)) + // Minimum execution time: 578_583 nanoseconds. + Weight::from_ref_time(583_643_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(204 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) @@ -163,9 +173,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras PvfActiveVoteList (r:1 w:1) // Storage: Paras ActionsQueue (r:1 w:1) fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight { - (532_765_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 478_058 nanoseconds. + Weight::from_ref_time(484_139_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) @@ -178,8 +189,9 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras CurrentCodeHash (r:0 w:100) // Storage: Paras UpcomingParasGenesis (r:0 w:100) fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight { - (705_429_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(304 as Weight)) + // Minimum execution time: 645_823 nanoseconds. + Weight::from_ref_time(651_570_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(304 as u64)) } } diff --git a/runtime/polkadot/src/weights/runtime_parachains_paras_inherent.rs b/runtime/polkadot/src/weights/runtime_parachains_paras_inherent.rs index cecf8b4a72f7..5bdb5a69cf9e 100644 --- a/runtime/polkadot/src/weights/runtime_parachains_paras_inherent.rs +++ b/runtime/polkadot/src/weights/runtime_parachains_paras_inherent.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::paras_inherent` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024 // Executed Command: @@ -60,6 +60,7 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras Parachains (r:1 w:0) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) // Storage: Staking ActiveEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) @@ -77,11 +78,12 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) /// The range of component `v` is `[10, 200]`. fn enter_variable_disputes(v: u32, ) -> Weight { - (364_277_000 as Weight) - // Standard Error: 23_000 - .saturating_add((48_774_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(29 as Weight)) - .saturating_add(T::DbWeight::get().writes(18 as Weight)) + // Minimum execution time: 807_698 nanoseconds. + Weight::from_ref_time(341_101_514 as u64) + // Standard Error: 19_162 + .saturating_add(Weight::from_ref_time(48_114_458 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(30 as u64)) + .saturating_add(T::DbWeight::get().writes(18 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -95,6 +97,7 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: ParaInclusion PendingAvailability (r:2 w:1) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) // Storage: Staking ActiveEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) @@ -114,9 +117,10 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn enter_bitfields() -> Weight { - (361_620_000 as Weight) - .saturating_add(T::DbWeight::get().reads(26 as Weight)) - .saturating_add(T::DbWeight::get().writes(17 as Weight)) + // Minimum execution time: 323_534 nanoseconds. + Weight::from_ref_time(331_378_000 as u64) + .saturating_add(T::DbWeight::get().reads(27 as u64)) + .saturating_add(T::DbWeight::get().writes(17 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -130,6 +134,7 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: ParaInclusion PendingAvailability (r:2 w:1) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) // Storage: Staking ActiveEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) @@ -151,11 +156,12 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) /// The range of component `v` is `[101, 200]`. fn enter_backed_candidates_variable(v: u32, ) -> Weight { - (984_915_000 as Weight) - // Standard Error: 47_000 - .saturating_add((48_309_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(29 as Weight)) - .saturating_add(T::DbWeight::get().writes(16 as Weight)) + // Minimum execution time: 5_638_372 nanoseconds. + Weight::from_ref_time(862_604_609 as u64) + // Standard Error: 44_586 + .saturating_add(Weight::from_ref_time(47_777_322 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(30 as u64)) + .saturating_add(T::DbWeight::get().writes(16 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -169,6 +175,7 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: ParaInclusion PendingAvailability (r:2 w:1) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) // Storage: Staking ActiveEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) @@ -191,8 +198,9 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn enter_backed_candidate_code_upgrade() -> Weight { - (43_858_899_000 as Weight) - .saturating_add(T::DbWeight::get().reads(31 as Weight)) - .saturating_add(T::DbWeight::get().writes(16 as Weight)) + // Minimum execution time: 37_925_898 nanoseconds. + Weight::from_ref_time(38_042_479_000 as u64) + .saturating_add(T::DbWeight::get().reads(32 as u64)) + .saturating_add(T::DbWeight::get().writes(16 as u64)) } } diff --git a/runtime/polkadot/src/xcm_config.rs b/runtime/polkadot/src/xcm_config.rs index c34b70ce8e3a..9e1eeaa67f41 100644 --- a/runtime/polkadot/src/xcm_config.rs +++ b/runtime/polkadot/src/xcm_config.rs @@ -17,13 +17,12 @@ //! XCM configuration for Polkadot. use super::{ - parachains_origin, AccountId, AllPalletsWithSystem, Balances, Call, CouncilCollective, Event, - Origin, ParaId, Runtime, WeightToFee, XcmPallet, + parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, ParaId, + Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet, }; use frame_support::{ match_types, parameter_types, traits::{Everything, Nothing}, - weights::Weight, }; use runtime_common::{xcm_sender, ToAuthor}; use xcm::latest::prelude::*; @@ -80,18 +79,18 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< type LocalOriginConverter = ( // If the origin kind is `Sovereign`, then return a `Signed` origin with the account determined // by the `SovereignAccountOf` converter. - SovereignSignedViaLocation, + SovereignSignedViaLocation, // If the origin kind is `Native` and the XCM origin is a child parachain, then we can express // it with the special `parachains_origin::Origin` origin variant. - ChildParachainAsNative, + ChildParachainAsNative, // If the origin kind is `Native` and the XCM origin is the `AccountId32` location, then it can // be expressed using the `Signed` origin variant. - SignedAccountId32AsNative, + SignedAccountId32AsNative, ); parameter_types! { /// The amount of weight an XCM operation takes. This is a safe overestimate. - pub const BaseXcmWeight: Weight = 1_000_000_000; + pub const BaseXcmWeight: u64 = 1_000_000_000; /// Maximum number of instructions in a single XCM fragment. A sanity check against weight /// calculations getting too crazy. pub const MaxInstructions: u32 = 100; @@ -133,7 +132,7 @@ pub type Barrier = ( pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { - type Call = Call; + type RuntimeCall = RuntimeCall; type XcmSender = XcmRouter; type AssetTransactor = LocalAssetTransactor; type OriginConverter = LocalOriginConverter; @@ -142,7 +141,7 @@ impl xcm_executor::Config for XcmConfig { type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; // The weight trader piggybacks on the existing transaction-fee conversion logic. type Trader = UsingComponents>; @@ -158,6 +157,7 @@ impl xcm_executor::Config for XcmConfig { // No bridges yet... type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; } parameter_types! { @@ -166,7 +166,7 @@ parameter_types! { /// Type to convert a council origin to a Plurality `MultiLocation` value. pub type CouncilToPlurality = BackingToPlurality< - Origin, + RuntimeOrigin, pallet_collective::Origin, CouncilBodyId, >; @@ -178,25 +178,25 @@ pub type LocalOriginToLocation = ( // `Unit` body. CouncilToPlurality, // And a usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, + SignedToAccountId32, ); impl pallet_xcm::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; // Only allow the council to send messages. - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = XcmRouter; // Anyone can execute XCM messages locally... - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; + type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; // ...but they must match our filter, which rejects all. type XcmExecuteFilter = Nothing; // == Deny All type XcmExecutor = xcm_executor::XcmExecutor; type XcmTeleportFilter = Everything; // == Allow All type XcmReserveTransferFilter = Everything; // == Allow All - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type Currency = Balances; diff --git a/runtime/rococo/Cargo.toml b/runtime/rococo/Cargo.toml index 585be332d080..788f2d206450 100644 --- a/runtime/rococo/Cargo.toml +++ b/runtime/rococo/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rococo-runtime" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" build = "build.rs" @@ -8,190 +8,251 @@ build = "build.rs" [dependencies] parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } +log = { version = "0.4.17", default-features = false } serde = { version = "1.0.137", default-features = false } serde_derive = { version = "1.0.117", optional = true } +static_assertions = "1.1.0" smallvec = "1.8.0" -log = { version = "0.4.17", default-features = false } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } - -tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +beefy-merkle-tree = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +rococo-runtime-constants = { package = "rococo-runtime-constants", path = "./constants", default-features = false } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } -babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -beefy-merkle-tree = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-beefy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-im-online = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-indices = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-membership = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-mmr = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-offences = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-beefy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-beefy-mmr = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-child-bounties = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-gilt = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-im-online = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-indices = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-membership = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-mmr = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-offences = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-recovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-society = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system = {git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-tips = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false } +pallet-xcm-benchmarks = { path = "../../xcm/pallet-xcm-benchmarks", default-features = false, optional = true } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -rococo-runtime-constants = { package = "rococo-runtime-constants", path = "./constants", default-features = false } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +hex-literal = { version = "0.3.4", optional = true } runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false } +runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false } primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } polkadot-parachain = { path = "../../parachain", default-features = false } -runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false } xcm = { package = "xcm", path = "../../xcm", default-features = false } xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", default-features = false } xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default-features = false } -pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false } -# Benchmarking Dependencies -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -hex-literal = { version = "0.3.4", optional = true } -frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } +[dev-dependencies] +hex-literal = "0.3.4" +tiny-keccak = { version = "2.0.2", features = ["keccak"] } +keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +separator = "0.4.1" +serde_json = "1.0.81" [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] default = ["std"] no_std = [] std = [ "authority-discovery-primitives/std", - "babe-primitives/std", + "primitives/std", "parity-scale-codec/std", "scale-info/std", + "inherents/std", + "sp-core/std", + "sp-api/std", + "tx-pool-api/std", + "block-builder-api/std", + "offchain-primitives/std", + "sp-std/std", + "sp-io/std", + "frame-support/std", "frame-executive/std", "pallet-authority-discovery/std", "pallet-authorship/std", - "pallet-babe/std", - "beefy-primitives/std", "pallet-balances/std", - "pallet-collective/std", "pallet-beefy/std", "pallet-beefy-mmr/std", + "pallet-bounties/std", + "pallet-child-bounties/std", + "pallet-transaction-payment/std", + "pallet-transaction-payment-rpc-runtime-api/std", + "pallet-collective/std", + "pallet-elections-phragmen/std", + "pallet-democracy/std", + "pallet-gilt/std", "pallet-grandpa/std", - "pallet-sudo/std", + "pallet-identity/std", + "pallet-im-online/std", + "pallet-indices/std", "pallet-membership/std", "pallet-mmr/std", - "pallet-indices/std", - "pallet-im-online/std", - "pallet-session/std", - "pallet-staking/std", + "pallet-multisig/std", "pallet-offences/std", + "pallet-preimage/std", "pallet-proxy/std", + "pallet-recovery/std", + "pallet-scheduler/std", + "pallet-session/std", + "pallet-society/std", + "pallet-sudo/std", + "pallet-staking/std", "pallet-timestamp/std", - "pallet-transaction-payment/std", - "pallet-transaction-payment-rpc-runtime-api/std", - "inherents/std", - "frame-support/std", + "pallet-tips/std", + "pallet-treasury/std", + "pallet-utility/std", + "pallet-vesting/std", + "pallet-babe/std", + "pallet-xcm/std", "polkadot-parachain/std", - "primitives/std", - "runtime-common/std", - "runtime-parachains/std", - "sp-api/std", - "sp-core/std", - "sp-io/std", "sp-mmr-primitives/std", "sp-runtime/std", - "sp-session/std", "sp-staking/std", - "sp-std/std", "frame-system/std", "frame-system-rpc-runtime-api/std", - "offchain-primitives/std", - "block-builder-api/std", - "tx-pool-api/std", "sp-version/std", "serde_derive", "serde/std", + "log/std", + "babe-primitives/std", + "sp-session/std", + "runtime-common/std", + "runtime-parachains/std", + "beefy-primitives/std", + "rococo-runtime-constants/std", "xcm/std", "xcm-executor/std", "xcm-builder/std", - "pallet-xcm/std", - "pallet-utility/std", - "log/std", - "pallet-multisig/std", ] -# When enabled, the runtime API will not be build. -# -# This is required by Cumulus to access certain types of the -# runtime without clashing with the runtime API exported functions -# in WASM. -disable-runtime-api = [] runtime-benchmarks = [ "runtime-common/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "pallet-babe/runtime-benchmarks", "pallet-balances/runtime-benchmarks", + "pallet-bounties/runtime-benchmarks", + "pallet-child-bounties/runtime-benchmarks", "pallet-collective/runtime-benchmarks", + "pallet-democracy/runtime-benchmarks", + "pallet-elections-phragmen/runtime-benchmarks", + "pallet-gilt/runtime-benchmarks", "pallet-grandpa/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", "pallet-im-online/runtime-benchmarks", "pallet-indices/runtime-benchmarks", "pallet-membership/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", + "pallet-preimage/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", + "pallet-society/runtime-benchmarks", + "pallet-recovery/runtime-benchmarks", "pallet-staking/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", + "pallet-tips/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", "pallet-utility/runtime-benchmarks", + "pallet-vesting/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", - "xcm-builder/runtime-benchmarks", - "pallet-multisig/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", "hex-literal", - "frame-system-benchmarking", + "xcm-builder/runtime-benchmarks", "runtime-parachains/runtime-benchmarks", + "pallet-xcm-benchmarks/runtime-benchmarks", ] try-runtime = [ "frame-executive/try-runtime", - "frame-support/try-runtime", "frame-system/try-runtime", "pallet-authority-discovery/try-runtime", "pallet-authorship/try-runtime", - "pallet-babe/try-runtime", "pallet-balances/try-runtime", + "pallet-bounties/try-runtime", + "pallet-child-bounties/try-runtime", + "pallet-transaction-payment/try-runtime", "pallet-collective/try-runtime", + "pallet-elections-phragmen/try-runtime", + "pallet-democracy/try-runtime", "pallet-grandpa/try-runtime", - "pallet-sudo/try-runtime", - "pallet-indices/try-runtime", + "pallet-identity/try-runtime", "pallet-im-online/try-runtime", + "pallet-indices/try-runtime", "pallet-membership/try-runtime", - "pallet-session/try-runtime", + "pallet-multisig/try-runtime", + "pallet-offences/try-runtime", + "pallet-preimage/try-runtime", "pallet-proxy/try-runtime", + "pallet-recovery/try-runtime", + "pallet-scheduler/try-runtime", + "pallet-session/try-runtime", + "pallet-society/try-runtime", + "pallet-sudo/try-runtime", "pallet-staking/try-runtime", - "pallet-offences/try-runtime", "pallet-timestamp/try-runtime", - "pallet-transaction-payment/try-runtime", + "pallet-tips/try-runtime", + "pallet-treasury/try-runtime", + "pallet-utility/try-runtime", + "pallet-vesting/try-runtime", + "pallet-babe/try-runtime", "runtime-common/try-runtime", - "pallet-multisig/try-runtime", ] +# When enabled, the runtime API will not be build. +# +# This is required by Cumulus to access certain types of the +# runtime without clashing with the runtime API exported functions +# in WASM. +disable-runtime-api = [] # Set timing constants (e.g. session period) to faster versions to speed up testing. fast-runtime = [] diff --git a/runtime/rococo/constants/Cargo.toml b/runtime/rococo/constants/Cargo.toml index 698c15bd6942..6dd84ac500b7 100644 --- a/runtime/rococo/constants/Cargo.toml +++ b/runtime/rococo/constants/Cargo.toml @@ -1,19 +1,23 @@ [package] name = "rococo-runtime-constants" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] smallvec = "1.8.0" -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } primitives = { package = "polkadot-primitives", path = "../../../primitives", default-features = false } runtime-common = { package = "polkadot-runtime-common", path = "../../common", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } [features] default = ["std"] std = [ - "sp-runtime/std" + "sp-core/std", + "sp-runtime/std", + "sp-weights/std" ] diff --git a/runtime/rococo/constants/src/lib.rs b/runtime/rococo/constants/src/lib.rs index 5a39c3431e38..7893cada961d 100644 --- a/runtime/rococo/constants/src/lib.rs +++ b/runtime/rococo/constants/src/lib.rs @@ -22,13 +22,16 @@ pub mod weights; pub mod currency { use primitives::v2::Balance; + /// The existential deposit. + pub const EXISTENTIAL_DEPOSIT: Balance = 1 * CENTS; + pub const UNITS: Balance = 1_000_000_000_000; - pub const DOLLARS: Balance = UNITS; - pub const CENTS: Balance = DOLLARS / 100; + pub const CENTS: Balance = UNITS / 30_000; + pub const GRAND: Balance = CENTS * 100_000; pub const MILLICENTS: Balance = CENTS / 1_000; pub const fn deposit(items: u32, bytes: u32) -> Balance { - items as Balance * 1 * DOLLARS + (bytes as Balance) * 5 * MILLICENTS + items as Balance * 2_000 * CENTS + (bytes as Balance) * 100 * MILLICENTS } } @@ -36,7 +39,6 @@ pub mod currency { pub mod time { use primitives::v2::{BlockNumber, Moment}; use runtime_common::prod_or_fast; - pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; pub const DEFAULT_EPOCH_DURATION: BlockNumber = prod_or_fast!(1 * HOURS, 1 * MINUTES); @@ -48,8 +50,12 @@ pub mod time { pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = MINUTES * 60; pub const DAYS: BlockNumber = HOURS * 24; + pub const WEEKS: BlockNumber = DAYS * 7; // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. + // The choice of is done in accordance to the slot duration and expected target + // block time, for safely resisting network delays of maximum two seconds. + // pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); } @@ -80,9 +86,9 @@ pub mod fee { impl WeightToFeePolynomial for WeightToFee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { - // in Westend, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: + // in Rococo, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: let p = super::currency::CENTS; - let q = 10 * Balance::from(ExtrinsicBaseWeight::get()); + let q = 10 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); smallvec![WeightToFeeCoefficient { degree: 1, negative: false, @@ -96,7 +102,7 @@ pub mod fee { #[cfg(test)] mod tests { use super::{ - currency::{CENTS, DOLLARS, MILLICENTS}, + currency::{CENTS, MILLICENTS}, fee::WeightToFee, }; use crate::weights::ExtrinsicBaseWeight; @@ -106,10 +112,10 @@ mod tests { #[test] // Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds. fn full_block_fee_is_correct() { - // A full block should cost between 10 and 100 DOLLARS. + // A full block should cost between 1,000 and 10,000 CENTS. let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT); - assert!(full_block >= 10 * DOLLARS); - assert!(full_block <= 100 * DOLLARS); + assert!(full_block >= 1_000 * CENTS); + assert!(full_block <= 10_000 * CENTS); } #[test] diff --git a/runtime/rococo/constants/src/weights/block_weights.rs b/runtime/rococo/constants/src/weights/block_weights.rs index 901557d28e47..b1531e6a5a1e 100644 --- a/runtime/rococo/constants/src/weights/block_weights.rs +++ b/runtime/rococo/constants/src/weights/block_weights.rs @@ -1,28 +1,26 @@ -// This file is part of Substrate. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// 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. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// 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 . //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19 (Y/M/D) -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25 (Y/M/D) +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Development` //! WARMUPS: `10`, REPEAT: `100` //! WEIGHT-PATH: `runtime/rococo/constants/src/weights/` -//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1`, WEIGHT-ADD: `0` +//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` // Executed Command: // ./target/production/polkadot @@ -34,32 +32,31 @@ // --weight-path=runtime/rococo/constants/src/weights/ // --warmup=10 // --repeat=100 +// --header=./file_header.txt -use frame_support::{ - parameter_types, - weights::{constants::WEIGHT_PER_NANOS, Weight}, -}; +use sp_core::parameter_types; +use sp_weights::{constants::WEIGHT_PER_NANOS, Weight}; parameter_types! { /// Time to execute an empty block. - /// Calculated by multiplying the *Average* with `1` and adding `0`. + /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 4_039_227, 4_394_160 - /// Average: 4_084_738 - /// Median: 4_077_180 - /// Std-Dev: 44325.29 + /// Min, Max: 5_028_795, 5_299_376 + /// Average: 5_112_220 + /// Median: 5_112_316 + /// Std-Dev: 66397.03 /// /// Percentiles nanoseconds: - /// 99th: 4_189_094 - /// 95th: 4_152_261 - /// 75th: 4_098_529 - pub const BlockExecutionWeight: Weight = 4_084_738 * WEIGHT_PER_NANOS; + /// 99th: 5_294_206 + /// 95th: 5_220_039 + /// 75th: 5_149_614 + pub const BlockExecutionWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(5_112_220); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; + use sp_weights::constants; /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, @@ -69,8 +66,14 @@ mod test_weights { let w = super::BlockExecutionWeight::get(); // At least 100 µs. - assert!(w >= 100 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs."); + assert!( + w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(), + "Weight should be at least 100 µs." + ); // At most 50 ms. - assert!(w <= 50 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); + assert!( + w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(), + "Weight should be at most 50 ms." + ); } } diff --git a/runtime/rococo/constants/src/weights/extrinsic_weights.rs b/runtime/rococo/constants/src/weights/extrinsic_weights.rs index 57886463b465..fcca6b74ccee 100644 --- a/runtime/rococo/constants/src/weights/extrinsic_weights.rs +++ b/runtime/rococo/constants/src/weights/extrinsic_weights.rs @@ -1,27 +1,26 @@ -// This file is part of Substrate. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// 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. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// 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 . //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-05-25 (Y/M/D) +//! DATE: 2022-10-25 (Y/M/D) +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Development` //! WARMUPS: `10`, REPEAT: `100` //! WEIGHT-PATH: `runtime/rococo/constants/src/weights/` -//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1`, WEIGHT-ADD: `0` +//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` // Executed Command: // ./target/production/polkadot @@ -33,32 +32,31 @@ // --weight-path=runtime/rococo/constants/src/weights/ // --warmup=10 // --repeat=100 +// --header=./file_header.txt -use frame_support::{ - parameter_types, - weights::{constants::WEIGHT_PER_NANOS, Weight}, -}; +use sp_core::parameter_types; +use sp_weights::{constants::WEIGHT_PER_NANOS, Weight}; parameter_types! { /// Time to execute a NO-OP extrinsic, for example `System::remark`. - /// Calculated by multiplying the *Average* with `1` and adding `0`. + /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 77_945, 79_607 - /// Average: 78_269 - /// Median: 78_211 - /// Std-Dev: 259.27 + /// Min, Max: 88_402, 90_261 + /// Average: 88_851 + /// Median: 88_823 + /// Std-Dev: 315.42 /// /// Percentiles nanoseconds: - /// 99th: 79_591 - /// 95th: 78_730 - /// 75th: 78_272 - pub const ExtrinsicBaseWeight: Weight = 78_269 * WEIGHT_PER_NANOS; + /// 99th: 90_200 + /// 95th: 89_354 + /// 75th: 88_922 + pub const ExtrinsicBaseWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(88_851); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; + use sp_weights::constants; /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, @@ -68,8 +66,14 @@ mod test_weights { let w = super::ExtrinsicBaseWeight::get(); // At least 10 µs. - assert!(w >= 10 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); + assert!( + w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(), + "Weight should be at least 10 µs." + ); // At most 1 ms. - assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); + assert!( + w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), + "Weight should be at most 1 ms." + ); } } diff --git a/runtime/rococo/constants/src/weights/paritydb_weights.rs b/runtime/rococo/constants/src/weights/paritydb_weights.rs index 843823c1bf30..dca7d348310c 100644 --- a/runtime/rococo/constants/src/weights/paritydb_weights.rs +++ b/runtime/rococo/constants/src/weights/paritydb_weights.rs @@ -25,8 +25,8 @@ pub mod constants { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 8_000 * constants::WEIGHT_PER_NANOS, - write: 50_000 * constants::WEIGHT_PER_NANOS, + read: 8_000 * constants::WEIGHT_PER_NANOS.ref_time(), + write: 50_000 * constants::WEIGHT_PER_NANOS.ref_time(), }; } @@ -42,20 +42,20 @@ pub mod constants { fn sane() { // At least 1 µs. assert!( - W::get().reads(1) >= constants::WEIGHT_PER_MICROS, + W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Read weight should be at least 1 µs." ); assert!( - W::get().writes(1) >= constants::WEIGHT_PER_MICROS, + W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Write weight should be at least 1 µs." ); // At most 1 ms. assert!( - W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, + W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Read weight should be at most 1 ms." ); assert!( - W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, + W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Write weight should be at most 1 ms." ); } diff --git a/runtime/rococo/constants/src/weights/rocksdb_weights.rs b/runtime/rococo/constants/src/weights/rocksdb_weights.rs index 05e06b0eabe3..87867ebfe177 100644 --- a/runtime/rococo/constants/src/weights/rocksdb_weights.rs +++ b/runtime/rococo/constants/src/weights/rocksdb_weights.rs @@ -25,8 +25,8 @@ pub mod constants { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 25_000 * constants::WEIGHT_PER_NANOS, - write: 100_000 * constants::WEIGHT_PER_NANOS, + read: 25_000 * constants::WEIGHT_PER_NANOS.ref_time(), + write: 100_000 * constants::WEIGHT_PER_NANOS.ref_time(), }; } @@ -42,20 +42,20 @@ pub mod constants { fn sane() { // At least 1 µs. assert!( - W::get().reads(1) >= constants::WEIGHT_PER_MICROS, + W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Read weight should be at least 1 µs." ); assert!( - W::get().writes(1) >= constants::WEIGHT_PER_MICROS, + W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Write weight should be at least 1 µs." ); // At most 1 ms. assert!( - W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, + W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Read weight should be at most 1 ms." ); assert!( - W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, + W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Write weight should be at most 1 ms." ); } diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 14f67b162774..cfd1567cda46 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -20,59 +20,67 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; +use primitives::v2::{ + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, + CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId, + InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, + PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, + ValidationCodeHash, ValidatorId, ValidatorIndex, +}; +use runtime_common::{ + assigned_slots, auctions, claims, crowdloan, impl_runtime_weights, impls::ToAuthor, + paras_registrar, paras_sudo_wrapper, prod_or_fast, slots, BlockHashCount, BlockLength, + SlowAdjustingFeeUpdate, +}; +use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*}; + +use runtime_parachains::{ + configuration as parachains_configuration, disputes as parachains_disputes, + disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + inclusion as parachains_inclusion, initializer as parachains_initializer, + origin as parachains_origin, paras as parachains_paras, + paras_inherent as parachains_paras_inherent, + runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler, + session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, +}; + use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; use beefy_primitives::{ crypto::AuthorityId as BeefyId, mmr::{BeefyDataProvider, MmrLeafVersion}, }; + use frame_support::{ construct_runtime, parameter_types, - traits::{Contains, InstanceFilter, KeyOwnerProofSystem}, - PalletId, + traits::{ + Contains, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, + PrivilegeCmp, WithdrawReasons, + }, + weights::ConstantMultiplier, + PalletId, RuntimeDebug, }; use frame_system::EnsureRoot; use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId}; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_session::historical as session_historical; use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo}; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use primitives::v2::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash, Id as ParaId, - InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, - PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionInfo, Signature, - ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature, -}; -use runtime_common::{ - assigned_slots, auctions, crowdloan, impl_runtime_weights, impls::ToAuthor, paras_registrar, - paras_sudo_wrapper, slots, BlockHashCount, BlockLength, SlowAdjustingFeeUpdate, -}; -use runtime_parachains::{self, runtime_api_impl::v2 as runtime_api_impl}; -use scale_info::TypeInfo; -use sp_core::{OpaqueMetadata, RuntimeDebug, H256}; +use sp_core::{OpaqueMetadata, H256}; use sp_mmr_primitives as mmr; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ - AccountIdLookup, BlakeTwo256, Block as BlockT, Extrinsic as ExtrinsicT, Keccak256, - OpaqueKeys, SaturatedConversion, Verify, + AccountIdLookup, BlakeTwo256, Block as BlockT, ConstU32, ConvertInto, + Extrinsic as ExtrinsicT, Keccak256, OpaqueKeys, SaturatedConversion, Verify, }, transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, KeyTypeId, + ApplyExtrinsicResult, KeyTypeId, Perbill, Percent, Permill, }; use sp_staking::SessionIndex; -use sp_std::{collections::btree_map::BTreeMap, prelude::*}; #[cfg(any(feature = "std", test))] use sp_version::NativeVersion; use sp_version::RuntimeVersion; - -use runtime_parachains::{ - configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, - initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, - paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler, - session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, -}; +use static_assertions::const_assert; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; @@ -80,10 +88,14 @@ pub use pallet_balances::Call as BalancesCall; /// Constant values used within the runtime. use rococo_runtime_constants::{currency::*, fee::*, time::*}; -mod validator_manager; +// Weights used in the runtime. mod weights; + +// XCM configurations. pub mod xcm_config; +mod validator_manager; + impl_runtime_weights!(rococo_runtime_constants); // Make the WASM binary available. @@ -96,13 +108,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("rococo"), impl_name: create_runtime_str!("parity-rococo-v2.0"), authoring_version: 0, - spec_version: 9280, + spec_version: 9310, impl_version: 0, #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS, #[cfg(feature = "disable-runtime-api")] apis: sp_version::create_apis_vec![[]], - transaction_version: 1, + transaction_version: 15, state_version: 0, }; @@ -119,131 +131,10 @@ pub fn native_version() -> NativeVersion { NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } } -/// The address format for describing accounts. -pub type Address = sp_runtime::MultiAddress; -/// Block header type as expected by this runtime. -pub type Header = generic::Header; -/// Block type as expected by this runtime. -pub type Block = generic::Block; -/// A Block signed with a Justification -pub type SignedBlock = generic::SignedBlock; -/// `BlockId` type as expected by this runtime. -pub type BlockId = generic::BlockId; -/// The `SignedExtension` to the basic transaction logic. -pub type SignedExtra = ( - frame_system::CheckNonZeroSender, - frame_system::CheckSpecVersion, - frame_system::CheckTxVersion, - frame_system::CheckGenesis, - frame_system::CheckMortality, - frame_system::CheckNonce, - frame_system::CheckWeight, - pallet_transaction_payment::ChargeTransactionPayment, -); - -/// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -/// Executive: handles dispatch to the various modules. -pub type Executive = frame_executive::Executive< - Runtime, - Block, - frame_system::ChainContext, - Runtime, - AllPalletsWithSystem, ->; -/// The payload being signed in transactions. -pub type SignedPayload = generic::SignedPayload; - -impl_opaque_keys! { - pub struct SessionKeys { - pub grandpa: Grandpa, - pub babe: Babe, - pub im_online: ImOnline, - pub para_validator: Initializer, - pub para_assignment: ParaSessionInfo, - pub authority_discovery: AuthorityDiscovery, - pub beefy: Beefy, - } -} - -construct_runtime! { - pub enum Runtime where - Block = Block, - NodeBlock = primitives::v2::Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - System: frame_system, - - // Babe must be before session. - Babe: pallet_babe, - - Timestamp: pallet_timestamp, - Indices: pallet_indices, - Balances: pallet_balances, - TransactionPayment: pallet_transaction_payment, - - // Consensus support. - // Authorship must be before session in order to note author in the correct session for - // im-online. - Authorship: pallet_authorship, - Offences: pallet_offences, - Historical: session_historical, - Session: pallet_session, - Grandpa: pallet_grandpa, - ImOnline: pallet_im_online, - AuthorityDiscovery: pallet_authority_discovery, - - // Parachains modules. - ParachainsOrigin: parachains_origin, - Configuration: parachains_configuration, - ParasShared: parachains_shared, - ParaInclusion: parachains_inclusion, - ParaInherent: parachains_paras_inherent, - ParaScheduler: parachains_scheduler, - Paras: parachains_paras, - Initializer: parachains_initializer, - Dmp: parachains_dmp, - Ump: parachains_ump, - Hrmp: parachains_hrmp, - ParaSessionInfo: parachains_session_info, - ParasDisputes: parachains_disputes, - - // Parachain Onboarding Pallets - Registrar: paras_registrar::{Pallet, Call, Storage, Event, Config}, - Auctions: auctions::{Pallet, Call, Storage, Event}, - Crowdloan: crowdloan::{Pallet, Call, Storage, Event}, - Slots: slots::{Pallet, Call, Storage, Event}, - ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call}, - AssignedSlots: assigned_slots::{Pallet, Call, Storage, Event}, - - // Sudo - Sudo: pallet_sudo, - - // Bridges support. - Mmr: pallet_mmr, - Beefy: pallet_beefy, - MmrLeaf: pallet_beefy_mmr, - - // Validator Manager pallet. - ValidatorManager: validator_manager, - - // A "council" - Collective: pallet_collective = 80, - Membership: pallet_membership = 81, - - Utility: pallet_utility = 90, - Proxy: pallet_proxy = 91, - Multisig: pallet_multisig, - - // Pallet for sending XCM. - XcmPallet: pallet_xcm = 99, - - } -} - +/// We currently allow all calls. pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(_call: &Call) -> bool { +impl Contains for BaseFilter { + fn contains(_call: &RuntimeCall) -> bool { true } } @@ -258,8 +149,8 @@ impl frame_system::Config for Runtime { type BlockWeights = BlockWeights; type BlockLength = BlockLength; type DbWeight = RocksDbWeight; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = Nonce; type BlockNumber = BlockNumber; type Hash = Hash; @@ -267,7 +158,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = AccountIdLookup; type Header = generic::Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = Version; type PalletInfo = PalletInfo; @@ -281,110 +172,115 @@ impl frame_system::Config for Runtime { } parameter_types! { - pub const ValidationUpgradeFrequency: BlockNumber = 2 * DAYS; - pub const ValidationUpgradeDelay: BlockNumber = 8 * HOURS; - pub const SlashPeriod: BlockNumber = 7 * DAYS; + pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * + BlockWeights::get().max_block; + pub const MaxScheduledPerBlock: u32 = 50; + pub const NoPreimagePostponement: Option = Some(10); } -/// Submits a transaction with the node's public and signature type. Adheres to the signed extension -/// format of the chain. -impl frame_system::offchain::CreateSignedTransaction for Runtime -where - Call: From, -{ - fn create_transaction>( - call: Call, - public: ::Signer, - account: AccountId, - nonce: ::Index, - ) -> Option<(Call, ::SignaturePayload)> { - use sp_runtime::traits::StaticLookup; - // take the biggest period possible. - let period = - BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64; +type ScheduleOrigin = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, +>; - let current_block = System::block_number() - .saturated_into::() - // The `System::block_number` is initialized with `n+1`, - // so the actual block number is `n`. - .saturating_sub(1); - let tip = 0; - let extra: SignedExtra = ( - frame_system::CheckNonZeroSender::::new(), - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckMortality::::from(generic::Era::mortal( - period, - current_block, - )), - frame_system::CheckNonce::::from(nonce), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(tip), - ); - let raw_payload = SignedPayload::new(call, extra) - .map_err(|e| { - log::warn!("Unable to create signed payload: {:?}", e); - }) - .ok()?; - let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?; - let (call, extra, _) = raw_payload.deconstruct(); - let address = ::Lookup::unlookup(account); - Some((call, (address, signature, extra))) +/// Used the compare the privilege of an origin inside the scheduler. +pub struct OriginPrivilegeCmp; + +impl PrivilegeCmp for OriginPrivilegeCmp { + fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option { + if left == right { + return Some(Ordering::Equal) + } + + match (left, right) { + // Root is greater than anything. + (OriginCaller::system(frame_system::RawOrigin::Root), _) => Some(Ordering::Greater), + // Check which one has more yes votes. + ( + OriginCaller::Council(pallet_collective::RawOrigin::Members(l_yes_votes, l_count)), + OriginCaller::Council(pallet_collective::RawOrigin::Members(r_yes_votes, r_count)), + ) => Some((l_yes_votes * r_count).cmp(&(r_yes_votes * l_count))), + // For every other origin we don't care, as they are not used for `ScheduleOrigin`. + _ => None, + } } } -impl frame_system::offchain::SigningTypes for Runtime { - type Public = ::Signer; - type Signature = Signature; +impl pallet_scheduler::Config for Runtime { + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; + type PalletsOrigin = OriginCaller; + type RuntimeCall = RuntimeCall; + type MaximumWeight = MaximumSchedulerWeight; + type ScheduleOrigin = ScheduleOrigin; + type MaxScheduledPerBlock = MaxScheduledPerBlock; + type WeightInfo = weights::pallet_scheduler::WeightInfo; + type OriginPrivilegeCmp = OriginPrivilegeCmp; + type Preimages = Preimage; } -/// Special `FullIdentificationOf` implementation that is returning for every input `Some(Default::default())`. -pub struct FullIdentificationOf; -impl sp_runtime::traits::Convert> for FullIdentificationOf { - fn convert(_: AccountId) -> Option<()> { - Some(Default::default()) - } +parameter_types! { + pub const PreimageBaseDeposit: Balance = deposit(2, 64); + pub const PreimageByteDeposit: Balance = deposit(0, 1); } -impl pallet_session::historical::Config for Runtime { - type FullIdentification = (); - type FullIdentificationOf = FullIdentificationOf; +impl pallet_preimage::Config for Runtime { + type WeightInfo = weights::pallet_preimage::WeightInfo; + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type ManagerOrigin = EnsureRoot; + type BaseDeposit = PreimageBaseDeposit; + type ByteDeposit = PreimageByteDeposit; } -impl parachains_disputes::Config for Runtime { - type Event = Event; - type RewardValidators = (); - type PunishValidators = (); - type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; +parameter_types! { + pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK; + pub ReportLongevity: u64 = EpochDurationInBlocks::get() as u64 * 10; } -parameter_types! { - pub SessionDuration: BlockNumber = EpochDurationInBlocks::get() as _; +impl pallet_babe::Config for Runtime { + type EpochDuration = EpochDurationInBlocks; + type ExpectedBlockTime = ExpectedBlockTime; + + // session module is the trigger + type EpochChangeTrigger = pallet_babe::ExternalTrigger; + + type DisabledValidators = Session; + + type KeyOwnerProof = >::Proof; + + type KeyOwnerIdentification = >::IdentificationTuple; + + type KeyOwnerProofSystem = Historical; + + type HandleEquivocation = + pallet_babe::EquivocationHandler; + + type WeightInfo = (); + + type MaxAuthorities = MaxAuthorities; } parameter_types! { - pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); - pub const MaxKeys: u32 = 10_000; - pub const MaxPeerInHeartbeats: u32 = 10_000; - pub const MaxPeerDataEncodingSize: u32 = 1_000; + pub const IndexDeposit: Balance = 100 * CENTS; } -impl pallet_im_online::Config for Runtime { - type AuthorityId = ImOnlineId; - type Event = Event; - type ValidatorSet = Historical; - type NextSessionRotation = Babe; - type ReportUnresponsiveness = Offences; - type UnsignedPriority = ImOnlineUnsignedPriority; - type WeightInfo = weights::pallet_im_online::WeightInfo; - type MaxKeys = MaxKeys; - type MaxPeerInHeartbeats = MaxPeerInHeartbeats; - type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize; +impl pallet_indices::Config for Runtime { + type AccountIndex = AccountIndex; + type Currency = Balances; + type Deposit = IndexDeposit; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_indices::WeightInfo; } parameter_types! { - pub const ExistentialDeposit: Balance = 1 * CENTS; + pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT; pub const MaxLocks: u32 = 50; pub const MaxReserves: u32 = 50; } @@ -392,7 +288,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type Balance = Balance; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type MaxLocks = MaxLocks; @@ -401,27 +297,20 @@ impl pallet_balances::Config for Runtime { type WeightInfo = weights::pallet_balances::WeightInfo; } -impl frame_system::offchain::SendTransactionTypes for Runtime -where - Call: From, -{ - type OverarchingCall = Call; - type Extrinsic = UncheckedExtrinsic; -} - parameter_types! { - pub const MaxRetries: u32 = 3; - pub const MaxAuthorities: u32 = 100_000; -} - -impl pallet_offences::Config for Runtime { - type Event = Event; - type IdentificationTuple = pallet_session::historical::IdentificationTuple; - type OnOffenceHandler = (); + pub const TransactionByteFee: Balance = 10 * MILLICENTS; + /// This value increases the priority of `Operational` transactions by adding + /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`. + pub const OperationalFeeMultiplier: u8 = 5; } -impl pallet_authority_discovery::Config for Runtime { - type MaxAuthorities = MaxAuthorities; +impl pallet_transaction_payment::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OnChargeTransaction = CurrencyAdapter>; + type OperationalFeeMultiplier = OperationalFeeMultiplier; + type WeightToFee = WeightToFee; + type LengthToFee = ConstantMultiplier; + type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; } parameter_types! { @@ -435,31 +324,38 @@ impl pallet_timestamp::Config for Runtime { } parameter_types! { - pub const TransactionByteFee: Balance = 10 * MILLICENTS; - /// This value increases the priority of `Operational` transactions by adding - /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`. - pub const OperationalFeeMultiplier: u8 = 5; + pub const UncleGenerations: u32 = 0; } -impl pallet_transaction_payment::Config for Runtime { - type Event = Event; - type OnChargeTransaction = CurrencyAdapter>; - type OperationalFeeMultiplier = OperationalFeeMultiplier; - type WeightToFee = WeightToFee; - type LengthToFee = frame_support::weights::ConstantMultiplier; - type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; +impl pallet_authorship::Config for Runtime { + type FindAuthor = pallet_session::FindAccountFromAuthorIndex; + type UncleGenerations = UncleGenerations; + type FilterUncle = (); + type EventHandler = ImOnline; } -/// Special `ValidatorIdOf` implementation that is just returning the input as result. -pub struct ValidatorIdOf; -impl sp_runtime::traits::Convert> for ValidatorIdOf { - fn convert(a: AccountId) -> Option { - Some(a) +impl_opaque_keys! { + pub struct SessionKeys { + pub grandpa: Grandpa, + pub babe: Babe, + pub im_online: ImOnline, + pub para_validator: Initializer, + pub para_assignment: ParaSessionInfo, + pub authority_discovery: AuthorityDiscovery, + pub beefy: Beefy, + } +} + +/// Special `ValidatorIdOf` implementation that is just returning the input as result. +pub struct ValidatorIdOf; +impl sp_runtime::traits::Convert> for ValidatorIdOf { + fn convert(a: AccountId) -> Option { + Some(a) } } impl pallet_session::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = ValidatorIdOf; type ShouldEndSession = Babe; @@ -467,64 +363,304 @@ impl pallet_session::Config for Runtime { type SessionManager = pallet_session::historical::NoteHistoricalRoot; type SessionHandler = ::KeyTypeIdProviders; type Keys = SessionKeys; - type WeightInfo = (); + type WeightInfo = weights::pallet_session::WeightInfo; } -parameter_types! { - pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK; - pub ReportLongevity: u64 = EpochDurationInBlocks::get() as u64 * 10; +pub struct FullIdentificationOf; +impl sp_runtime::traits::Convert> for FullIdentificationOf { + fn convert(_: AccountId) -> Option<()> { + Some(Default::default()) + } } -impl pallet_babe::Config for Runtime { - type EpochDuration = EpochDurationInBlocks; - type ExpectedBlockTime = ExpectedBlockTime; +impl pallet_session::historical::Config for Runtime { + type FullIdentification = (); + type FullIdentificationOf = FullIdentificationOf; +} - // session module is the trigger - type EpochChangeTrigger = pallet_babe::ExternalTrigger; +parameter_types! { + pub const SessionsPerEra: SessionIndex = 6; + pub const BondingDuration: sp_staking::EraIndex = 28; +} - type DisabledValidators = Session; +parameter_types! { + pub LaunchPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1, "ROC_LAUNCH_PERIOD"); + pub VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES, "ROC_VOTING_PERIOD"); + pub FastTrackVotingPeriod: BlockNumber = prod_or_fast!(3 * HOURS, 1 * MINUTES, "ROC_FAST_TRACK_VOTING_PERIOD"); + pub const MinimumDeposit: Balance = 100 * CENTS; + pub EnactmentPeriod: BlockNumber = prod_or_fast!(8 * DAYS, 1, "ROC_ENACTMENT_PERIOD"); + pub CooloffPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES, "ROC_COOLOFF_PERIOD"); + pub const InstantAllowed: bool = true; + pub const MaxVotes: u32 = 100; + pub const MaxProposals: u32 = 100; +} - type KeyOwnerProofSystem = Historical; +impl pallet_democracy::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type EnactmentPeriod = EnactmentPeriod; + type VoteLockingPeriod = EnactmentPeriod; + type LaunchPeriod = LaunchPeriod; + type VotingPeriod = VotingPeriod; + type MinimumDeposit = MinimumDeposit; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = + pallet_collective::EnsureProportionAtLeast; + /// A majority can have the next scheduled referendum be a straight majority-carries vote. + type ExternalMajorityOrigin = + pallet_collective::EnsureProportionAtLeast; + /// A unanimous council can have the next scheduled referendum be a straight default-carries + /// (NTB) vote. + type ExternalDefaultOrigin = + pallet_collective::EnsureProportionAtLeast; + /// Two thirds of the technical committee can have an `ExternalMajority/ExternalDefault` vote + /// be tabled immediately and with a shorter voting/enactment period. + type FastTrackOrigin = + pallet_collective::EnsureProportionAtLeast; + type InstantOrigin = + pallet_collective::EnsureProportionAtLeast; + type InstantAllowed = InstantAllowed; + type FastTrackVotingPeriod = FastTrackVotingPeriod; + // To cancel a proposal which has been passed, 2/3 of the council must agree to it. + type CancellationOrigin = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, + >; + type BlacklistOrigin = EnsureRoot; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, + >; + // Any single technical committee member may veto a coming council proposal, however they can + // only do it once and it lasts only for the cooloff period. + type VetoOrigin = pallet_collective::EnsureMember; + type CooloffPeriod = CooloffPeriod; + type Slash = Treasury; + type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; + type MaxVotes = MaxVotes; + type WeightInfo = weights::pallet_democracy::WeightInfo; + type MaxProposals = MaxProposals; + type Preimages = Preimage; + type MaxDeposits = ConstU32<100>; + type MaxBlacklisted = ConstU32<100>; +} - type KeyOwnerProof = >::Proof; +parameter_types! { + pub CouncilMotionDuration: BlockNumber = prod_or_fast!(3 * DAYS, 2 * MINUTES, "ROC_MOTION_DURATION"); + pub const CouncilMaxProposals: u32 = 100; + pub const CouncilMaxMembers: u32 = 100; +} + +type CouncilCollective = pallet_collective::Instance1; +impl pallet_collective::Config for Runtime { + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type MotionDuration = CouncilMotionDuration; + type MaxProposals = CouncilMaxProposals; + type MaxMembers = CouncilMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = weights::pallet_collective_council::WeightInfo; +} - type KeyOwnerIdentification = >::IdentificationTuple; +parameter_types! { + pub const CandidacyBond: Balance = 100 * CENTS; + // 1 storage item created, key size is 32 bytes, value size is 16+16. + pub const VotingBondBase: Balance = deposit(1, 64); + // additional data per vote is 32 bytes (account id). + pub const VotingBondFactor: Balance = deposit(0, 32); + /// Daily council elections + pub TermDuration: BlockNumber = prod_or_fast!(24 * HOURS, 2 * MINUTES, "ROC_TERM_DURATION"); + pub const DesiredMembers: u32 = 19; + pub const DesiredRunnersUp: u32 = 19; + pub const MaxVoters: u32 = 10 * 1000; + pub const MaxCandidates: u32 = 1000; + pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect"; +} + +// Make sure that there are no more than MaxMembers members elected via phragmen. +const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); + +impl pallet_elections_phragmen::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type ChangeMembers = Council; + type InitializeMembers = Council; + type CurrencyToVote = frame_support::traits::U128CurrencyToVote; + type CandidacyBond = CandidacyBond; + type VotingBondBase = VotingBondBase; + type VotingBondFactor = VotingBondFactor; + type LoserCandidate = Treasury; + type KickedMember = Treasury; + type DesiredMembers = DesiredMembers; + type DesiredRunnersUp = DesiredRunnersUp; + type TermDuration = TermDuration; + type MaxVoters = MaxVoters; + type MaxCandidates = MaxCandidates; + type PalletId = PhragmenElectionPalletId; + type WeightInfo = weights::pallet_elections_phragmen::WeightInfo; +} - type HandleEquivocation = - pallet_babe::EquivocationHandler; +parameter_types! { + pub TechnicalMotionDuration: BlockNumber = prod_or_fast!(3 * DAYS, 2 * MINUTES, "ROC_MOTION_DURATION"); + pub const TechnicalMaxProposals: u32 = 100; + pub const TechnicalMaxMembers: u32 = 100; +} + +type TechnicalCollective = pallet_collective::Instance2; +impl pallet_collective::Config for Runtime { + type RuntimeOrigin = RuntimeOrigin; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type MotionDuration = TechnicalMotionDuration; + type MaxProposals = TechnicalMaxProposals; + type MaxMembers = TechnicalMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = weights::pallet_collective_technical_committee::WeightInfo; +} - type WeightInfo = (); +type MoreThanHalfCouncil = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionMoreThan, +>; - type MaxAuthorities = MaxAuthorities; +impl pallet_membership::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type AddOrigin = MoreThanHalfCouncil; + type RemoveOrigin = MoreThanHalfCouncil; + type SwapOrigin = MoreThanHalfCouncil; + type ResetOrigin = MoreThanHalfCouncil; + type PrimeOrigin = MoreThanHalfCouncil; + type MembershipInitialized = TechnicalCommittee; + type MembershipChanged = TechnicalCommittee; + type MaxMembers = TechnicalMaxMembers; + type WeightInfo = weights::pallet_membership::WeightInfo; } parameter_types! { - pub const IndexDeposit: Balance = 1 * DOLLARS; + pub const ProposalBond: Permill = Permill::from_percent(5); + pub const ProposalBondMinimum: Balance = 2000 * CENTS; + pub const ProposalBondMaximum: Balance = 1 * GRAND; + pub const SpendPeriod: BlockNumber = 6 * DAYS; + pub const Burn: Permill = Permill::from_perthousand(2); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); + + pub const TipCountdown: BlockNumber = 1 * DAYS; + pub const TipFindersFee: Percent = Percent::from_percent(20); + pub const TipReportDepositBase: Balance = 100 * CENTS; + pub const DataDepositPerByte: Balance = 1 * CENTS; + pub const MaxApprovals: u32 = 100; + pub const MaxAuthorities: u32 = 100_000; + pub const MaxKeys: u32 = 10_000; + pub const MaxPeerInHeartbeats: u32 = 10_000; + pub const MaxPeerDataEncodingSize: u32 = 1_000; } -impl pallet_indices::Config for Runtime { - type AccountIndex = AccountIndex; +type ApproveOrigin = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, +>; + +impl pallet_treasury::Config for Runtime { + type PalletId = TreasuryPalletId; type Currency = Balances; - type Deposit = IndexDeposit; - type Event = Event; - type WeightInfo = weights::pallet_indices::WeightInfo; + type ApproveOrigin = ApproveOrigin; + type RejectOrigin = MoreThanHalfCouncil; + type RuntimeEvent = RuntimeEvent; + type OnSlash = Treasury; + type ProposalBond = ProposalBond; + type ProposalBondMinimum = ProposalBondMinimum; + type ProposalBondMaximum = ProposalBondMaximum; + type SpendPeriod = SpendPeriod; + type Burn = Burn; + type BurnDestination = Society; + type MaxApprovals = MaxApprovals; + type WeightInfo = weights::pallet_treasury::WeightInfo; + type SpendFunds = Bounties; + type SpendOrigin = frame_support::traits::NeverEnsureOrigin; } parameter_types! { - pub const AttestationPeriod: BlockNumber = 50; + pub const BountyDepositBase: Balance = 100 * CENTS; + pub const BountyDepositPayoutDelay: BlockNumber = 4 * DAYS; + pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS; + pub const MaximumReasonLength: u32 = 16384; + pub const CuratorDepositMultiplier: Permill = Permill::from_percent(50); + pub const CuratorDepositMin: Balance = 10 * CENTS; + pub const CuratorDepositMax: Balance = 500 * CENTS; + pub const BountyValueMinimum: Balance = 200 * CENTS; +} + +impl pallet_bounties::Config for Runtime { + type BountyDepositBase = BountyDepositBase; + type BountyDepositPayoutDelay = BountyDepositPayoutDelay; + type BountyUpdatePeriod = BountyUpdatePeriod; + type CuratorDepositMultiplier = CuratorDepositMultiplier; + type CuratorDepositMin = CuratorDepositMin; + type CuratorDepositMax = CuratorDepositMax; + type BountyValueMinimum = BountyValueMinimum; + type ChildBountyManager = ChildBounties; + type DataDepositPerByte = DataDepositPerByte; + type RuntimeEvent = RuntimeEvent; + type MaximumReasonLength = MaximumReasonLength; + type WeightInfo = weights::pallet_bounties::WeightInfo; } -impl pallet_grandpa::Config for Runtime { - type Event = Event; - type Call = Call; +parameter_types! { + pub const MaxActiveChildBountyCount: u32 = 100; + pub const ChildBountyValueMinimum: Balance = BountyValueMinimum::get() / 10; +} - type KeyOwnerProofSystem = Historical; +impl pallet_child_bounties::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type MaxActiveChildBountyCount = MaxActiveChildBountyCount; + type ChildBountyValueMinimum = ChildBountyValueMinimum; + type WeightInfo = weights::pallet_child_bounties::WeightInfo; +} + +impl pallet_tips::Config for Runtime { + type MaximumReasonLength = MaximumReasonLength; + type DataDepositPerByte = DataDepositPerByte; + type Tippers = PhragmenElection; + type TipCountdown = TipCountdown; + type TipFindersFee = TipFindersFee; + type TipReportDepositBase = TipReportDepositBase; + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_tips::WeightInfo; +} + +impl pallet_offences::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type IdentificationTuple = pallet_session::historical::IdentificationTuple; + type OnOffenceHandler = (); +} + +impl pallet_authority_discovery::Config for Runtime { + type MaxAuthorities = MaxAuthorities; +} + +parameter_types! { + pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value(); +} + +impl pallet_im_online::Config for Runtime { + type AuthorityId = ImOnlineId; + type RuntimeEvent = RuntimeEvent; + type ValidatorSet = Historical; + type NextSessionRotation = Babe; + type ReportUnresponsiveness = Offences; + type UnsignedPriority = ImOnlineUnsignedPriority; + type WeightInfo = weights::pallet_im_online::WeightInfo; + type MaxKeys = MaxKeys; + type MaxPeerInHeartbeats = MaxPeerInHeartbeats; + type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize; +} + +impl pallet_grandpa::Config for Runtime { + type RuntimeEvent = RuntimeEvent; type KeyOwnerProof = >::Proof; @@ -534,6 +670,8 @@ impl pallet_grandpa::Config for Runtime { GrandpaId, )>>::IdentificationTuple; + type KeyOwnerProofSystem = Historical; + type HandleEquivocation = pallet_grandpa::EquivocationHandler< Self::KeyOwnerIdentification, Offences, @@ -544,15 +682,341 @@ impl pallet_grandpa::Config for Runtime { type MaxAuthorities = MaxAuthorities; } +/// Submits a transaction with the node's public and signature type. Adheres to the signed extension +/// format of the chain. +impl frame_system::offchain::CreateSignedTransaction for Runtime +where + RuntimeCall: From, +{ + fn create_transaction>( + call: RuntimeCall, + public: ::Signer, + account: AccountId, + nonce: ::Index, + ) -> Option<(RuntimeCall, ::SignaturePayload)> { + use sp_runtime::traits::StaticLookup; + // take the biggest period possible. + let period = + BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64; + + let current_block = System::block_number() + .saturated_into::() + // The `System::block_number` is initialized with `n+1`, + // so the actual block number is `n`. + .saturating_sub(1); + let tip = 0; + let extra: SignedExtra = ( + frame_system::CheckNonZeroSender::::new(), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckMortality::::from(generic::Era::mortal( + period, + current_block, + )), + frame_system::CheckNonce::::from(nonce), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::::from(tip), + ); + let raw_payload = SignedPayload::new(call, extra) + .map_err(|e| { + log::warn!("Unable to create signed payload: {:?}", e); + }) + .ok()?; + let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?; + let (call, extra, _) = raw_payload.deconstruct(); + let address = ::Lookup::unlookup(account); + Some((call, (address, signature, extra))) + } +} + +impl frame_system::offchain::SigningTypes for Runtime { + type Public = ::Signer; + type Signature = Signature; +} + +impl frame_system::offchain::SendTransactionTypes for Runtime +where + RuntimeCall: From, +{ + type Extrinsic = UncheckedExtrinsic; + type OverarchingCall = RuntimeCall; +} + parameter_types! { - pub const UncleGenerations: u32 = 0; + pub Prefix: &'static [u8] = b"Pay ROCs to the Rococo account:"; } -impl pallet_authorship::Config for Runtime { - type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type UncleGenerations = UncleGenerations; - type FilterUncle = (); - type EventHandler = ImOnline; +impl claims::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type VestingSchedule = Vesting; + type Prefix = Prefix; + type MoveClaimOrigin = + pallet_collective::EnsureProportionMoreThan; + type WeightInfo = weights::runtime_common_claims::WeightInfo; +} + +parameter_types! { + // Minimum 100 bytes/ROC deposited (1 CENT/byte) + pub const BasicDeposit: Balance = 1000 * CENTS; // 258 bytes on-chain + pub const FieldDeposit: Balance = 250 * CENTS; // 66 bytes on-chain + pub const SubAccountDeposit: Balance = 200 * CENTS; // 53 bytes on-chain + pub const MaxSubAccounts: u32 = 100; + pub const MaxAdditionalFields: u32 = 100; + pub const MaxRegistrars: u32 = 20; +} + +impl pallet_identity::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type BasicDeposit = BasicDeposit; + type FieldDeposit = FieldDeposit; + type SubAccountDeposit = SubAccountDeposit; + type MaxSubAccounts = MaxSubAccounts; + type MaxAdditionalFields = MaxAdditionalFields; + type MaxRegistrars = MaxRegistrars; + type Slashed = Treasury; + type ForceOrigin = MoreThanHalfCouncil; + type RegistrarOrigin = MoreThanHalfCouncil; + type WeightInfo = weights::pallet_identity::WeightInfo; +} + +impl pallet_utility::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type PalletsOrigin = OriginCaller; + type WeightInfo = weights::pallet_utility::WeightInfo; +} + +parameter_types! { + // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. + pub const DepositBase: Balance = deposit(1, 88); + // Additional storage item size of 32 bytes. + pub const DepositFactor: Balance = deposit(0, 32); + pub const MaxSignatories: u16 = 100; +} + +impl pallet_multisig::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type DepositBase = DepositBase; + type DepositFactor = DepositFactor; + type MaxSignatories = MaxSignatories; + type WeightInfo = weights::pallet_multisig::WeightInfo; +} + +parameter_types! { + pub const ConfigDepositBase: Balance = 500 * CENTS; + pub const FriendDepositFactor: Balance = 50 * CENTS; + pub const MaxFriends: u16 = 9; + pub const RecoveryDeposit: Balance = 500 * CENTS; +} + +impl pallet_recovery::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type ConfigDepositBase = ConfigDepositBase; + type FriendDepositFactor = FriendDepositFactor; + type MaxFriends = MaxFriends; + type RecoveryDeposit = RecoveryDeposit; +} + +parameter_types! { + pub const CandidateDeposit: Balance = 1000 * CENTS; + pub const WrongSideDeduction: Balance = 200 * CENTS; + pub const MaxStrikes: u32 = 10; + pub const RotationPeriod: BlockNumber = 7 * DAYS; + pub const PeriodSpend: Balance = 50000 * CENTS; + pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS; + pub const ChallengePeriod: BlockNumber = 7 * DAYS; + pub const MaxCandidateIntake: u32 = 1; + pub const SocietyPalletId: PalletId = PalletId(*b"py/socie"); +} + +impl pallet_society::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type Randomness = pallet_babe::RandomnessFromOneEpochAgo; + type CandidateDeposit = CandidateDeposit; + type WrongSideDeduction = WrongSideDeduction; + type MaxStrikes = MaxStrikes; + type PeriodSpend = PeriodSpend; + type MembershipChanged = (); + type RotationPeriod = RotationPeriod; + type MaxLockDuration = MaxLockDuration; + type FounderSetOrigin = + pallet_collective::EnsureProportionMoreThan; + type SuspensionJudgementOrigin = pallet_society::EnsureFounder; + type ChallengePeriod = ChallengePeriod; + type MaxCandidateIntake = MaxCandidateIntake; + type PalletId = SocietyPalletId; +} + +parameter_types! { + pub const MinVestedTransfer: Balance = 100 * CENTS; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); +} + +impl pallet_vesting::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type BlockNumberToBalance = ConvertInto; + type MinVestedTransfer = MinVestedTransfer; + type WeightInfo = weights::pallet_vesting::WeightInfo; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; + const MAX_VESTING_SCHEDULES: u32 = 28; +} + +parameter_types! { + // One storage item; key size 32, value size 8; . + pub const ProxyDepositBase: Balance = deposit(1, 8); + // Additional storage item size of 33 bytes. + pub const ProxyDepositFactor: Balance = deposit(0, 33); + pub const MaxProxies: u16 = 32; + pub const AnnouncementDepositBase: Balance = deposit(1, 8); + pub const AnnouncementDepositFactor: Balance = deposit(0, 66); + pub const MaxPending: u16 = 32; +} + +/// The type used to represent the kinds of proxying allowed. +#[derive( + Copy, + Clone, + Eq, + PartialEq, + Ord, + PartialOrd, + Encode, + Decode, + RuntimeDebug, + MaxEncodedLen, + scale_info::TypeInfo, +)] +pub enum ProxyType { + Any, + NonTransfer, + Governance, + IdentityJudgement, + CancelProxy, + Auction, + Society, +} +impl Default for ProxyType { + fn default() -> Self { + Self::Any + } +} +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { + match self { + ProxyType::Any => true, + ProxyType::NonTransfer => matches!( + c, + RuntimeCall::System(..) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(pallet_indices::Call::claim {..}) | + RuntimeCall::Indices(pallet_indices::Call::free {..}) | + RuntimeCall::Indices(pallet_indices::Call::freeze {..}) | + // Specifically omitting Indices `transfer`, `force_transfer` + // Specifically omitting the entire Balances pallet + RuntimeCall::Authorship(..) | + RuntimeCall::Session(..) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Democracy(..) | + RuntimeCall::Council(..) | + RuntimeCall::TechnicalCommittee(..) | + RuntimeCall::PhragmenElection(..) | + RuntimeCall::TechnicalMembership(..) | + RuntimeCall::Treasury(..) | + RuntimeCall::Bounties(..) | + RuntimeCall::ChildBounties(..) | + RuntimeCall::Tips(..) | + RuntimeCall::Claims(..) | + RuntimeCall::Utility(..) | + RuntimeCall::Identity(..) | + RuntimeCall::Society(..) | + RuntimeCall::Recovery(pallet_recovery::Call::as_recovered {..}) | + RuntimeCall::Recovery(pallet_recovery::Call::vouch_recovery {..}) | + RuntimeCall::Recovery(pallet_recovery::Call::claim_recovery {..}) | + RuntimeCall::Recovery(pallet_recovery::Call::close_recovery {..}) | + RuntimeCall::Recovery(pallet_recovery::Call::remove_recovery {..}) | + RuntimeCall::Recovery(pallet_recovery::Call::cancel_recovered {..}) | + // Specifically omitting Recovery `create_recovery`, `initiate_recovery` + RuntimeCall::Vesting(pallet_vesting::Call::vest {..}) | + RuntimeCall::Vesting(pallet_vesting::Call::vest_other {..}) | + // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` + RuntimeCall::Scheduler(..) | + RuntimeCall::Proxy(..) | + RuntimeCall::Multisig(..) | + RuntimeCall::Gilt(..) | + RuntimeCall::Registrar(paras_registrar::Call::register {..}) | + RuntimeCall::Registrar(paras_registrar::Call::deregister {..}) | + // Specifically omitting Registrar `swap` + RuntimeCall::Registrar(paras_registrar::Call::reserve {..}) | + RuntimeCall::Crowdloan(..) | + RuntimeCall::Slots(..) | + RuntimeCall::Auctions(..) // Specifically omitting the entire XCM Pallet + ), + ProxyType::Governance => + matches!( + c, + RuntimeCall::Democracy(..) | + RuntimeCall::Council(..) | RuntimeCall::TechnicalCommittee(..) | + RuntimeCall::PhragmenElection(..) | + RuntimeCall::Treasury(..) | + RuntimeCall::Bounties(..) | + RuntimeCall::Tips(..) | RuntimeCall::Utility(..) | + RuntimeCall::ChildBounties(..) + ), + ProxyType::IdentityJudgement => matches!( + c, + RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) | + RuntimeCall::Utility(..) + ), + ProxyType::CancelProxy => { + matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })) + }, + ProxyType::Auction => matches!( + c, + RuntimeCall::Auctions { .. } | + RuntimeCall::Crowdloan { .. } | + RuntimeCall::Registrar { .. } | + RuntimeCall::Multisig(..) | + RuntimeCall::Slots { .. } + ), + ProxyType::Society => matches!(c, RuntimeCall::Society(..)), + } + } + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + (ProxyType::NonTransfer, _) => true, + _ => false, + } + } +} + +impl pallet_proxy::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type ProxyType = ProxyType; + type ProxyDepositBase = ProxyDepositBase; + type ProxyDepositFactor = ProxyDepositFactor; + type MaxProxies = MaxProxies; + type WeightInfo = weights::pallet_proxy::WeightInfo; + type MaxPending = MaxPending; + type CallHasher = BlakeTwo256; + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositFactor; } impl parachains_origin::Config for Runtime {} @@ -563,6 +1027,10 @@ impl parachains_configuration::Config for Runtime { impl parachains_shared::Config for Runtime {} +impl parachains_session_info::Config for Runtime { + type ValidatorSet = Historical; +} + /// Special `RewardValidators` that does nothing ;) pub struct RewardValidators; impl runtime_parachains::inclusion::RewardValidators for RewardValidators { @@ -571,7 +1039,7 @@ impl runtime_parachains::inclusion::RewardValidators for RewardValidators { } impl parachains_inclusion::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DisputesHandler = ParasDisputes; type RewardValidators = RewardValidators; } @@ -581,22 +1049,18 @@ parameter_types! { } impl parachains_paras::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::runtime_parachains_paras::WeightInfo; type UnsignedPriority = ParasUnsignedPriority; type NextSessionRotation = Babe; } -impl parachains_session_info::Config for Runtime { - type ValidatorSet = Historical; -} - parameter_types! { pub const FirstMessageFactorPercent: u64 = 100; } impl parachains_ump::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type UmpSink = crate::parachains_ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; @@ -607,8 +1071,8 @@ impl parachains_ump::Config for Runtime { impl parachains_dmp::Config for Runtime {} impl parachains_hrmp::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo; } @@ -625,35 +1089,37 @@ impl parachains_initializer::Config for Runtime { type WeightInfo = weights::runtime_parachains_initializer::WeightInfo; } -impl paras_sudo_wrapper::Config for Runtime {} - -parameter_types! { - pub const PermanentSlotLeasePeriodLength: u32 = 365; - pub const TemporarySlotLeasePeriodLength: u32 = 3; - pub const MaxPermanentSlots: u32 = 25; - pub const MaxTemporarySlots: u32 = 20; - pub const MaxTemporarySlotPerLeasePeriod: u32 = 5; +impl parachains_disputes::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RewardValidators = (); + type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes; + type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } -impl assigned_slots::Config for Runtime { - type Event = Event; - type AssignSlotOrigin = EnsureRoot; - type Leaser = Slots; - type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength; - type TemporarySlotLeasePeriodLength = TemporarySlotLeasePeriodLength; - type MaxPermanentSlots = MaxPermanentSlots; - type MaxTemporarySlots = MaxTemporarySlots; - type MaxTemporarySlotPerLeasePeriod = MaxTemporarySlotPerLeasePeriod; +impl parachains_slashing::Config for Runtime { + type KeyOwnerProofSystem = Historical; + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type HandleReports = parachains_slashing::SlashingReportHandler< + Self::KeyOwnerIdentification, + Offences, + ReportLongevity, + >; + type WeightInfo = parachains_slashing::TestWeightInfo; + type BenchmarkingConfig = parachains_slashing::BenchConfig<200>; } parameter_types! { - pub const ParaDeposit: Balance = 5 * DOLLARS; - pub const DataDepositPerByte: Balance = deposit(0, 1); + pub const ParaDeposit: Balance = 40 * UNITS; } impl paras_registrar::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type OnSwap = (Crowdloan, Slots); type ParaDeposit = ParaDeposit; @@ -661,6 +1127,94 @@ impl paras_registrar::Config for Runtime { type WeightInfo = weights::runtime_common_paras_registrar::WeightInfo; } +parameter_types! { + pub LeasePeriod: BlockNumber = prod_or_fast!(1 * DAYS, 1 * DAYS, "ROC_LEASE_PERIOD"); +} + +impl slots::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type Registrar = Registrar; + type LeasePeriod = LeasePeriod; + type LeaseOffset = (); + type ForceOrigin = MoreThanHalfCouncil; + type WeightInfo = weights::runtime_common_slots::WeightInfo; +} + +parameter_types! { + pub const CrowdloanId: PalletId = PalletId(*b"py/cfund"); + pub const SubmissionDeposit: Balance = 3 * GRAND; + pub const MinContribution: Balance = 3_000 * CENTS; + pub const RemoveKeysLimit: u32 = 1000; + // Allow 32 bytes for an additional memo to a crowdloan. + pub const MaxMemoLength: u8 = 32; +} + +impl crowdloan::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type PalletId = CrowdloanId; + type SubmissionDeposit = SubmissionDeposit; + type MinContribution = MinContribution; + type RemoveKeysLimit = RemoveKeysLimit; + type Registrar = Registrar; + type Auctioneer = Auctions; + type MaxMemoLength = MaxMemoLength; + type WeightInfo = weights::runtime_common_crowdloan::WeightInfo; +} + +parameter_types! { + // The average auction is 7 days long, so this will be 70% for ending period. + // 5 Days = 72000 Blocks @ 6 sec per block + pub const EndingPeriod: BlockNumber = 5 * DAYS; + // ~ 1000 samples per day -> ~ 20 blocks per sample -> 2 minute samples + pub const SampleLength: BlockNumber = 2 * MINUTES; +} + +type AuctionInitiate = EitherOfDiverse< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, +>; + +impl auctions::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Leaser = Slots; + type Registrar = Registrar; + type EndingPeriod = EndingPeriod; + type SampleLength = SampleLength; + type Randomness = pallet_babe::RandomnessFromOneEpochAgo; + type InitiateOrigin = AuctionInitiate; + type WeightInfo = weights::runtime_common_auctions::WeightInfo; +} + +parameter_types! { + pub IgnoredIssuance: Balance = Treasury::pot(); + pub const QueueCount: u32 = 300; + pub const MaxQueueLen: u32 = 1000; + pub const FifoQueueLen: u32 = 250; + pub const GiltPeriod: BlockNumber = 30 * DAYS; + pub const MinFreeze: Balance = 10_000 * CENTS; + pub const IntakePeriod: BlockNumber = 5 * MINUTES; + pub const MaxIntakeBids: u32 = 100; +} + +impl pallet_gilt::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type CurrencyBalance = Balance; + type AdminOrigin = MoreThanHalfCouncil; + type Deficit = (); // Mint + type Surplus = (); // Burn + type IgnoredIssuance = IgnoredIssuance; + type QueueCount = QueueCount; + type MaxQueueLen = MaxQueueLen; + type FifoQueueLen = FifoQueueLen; + type Period = GiltPeriod; + type MinFreeze = MinFreeze; + type IntakePeriod = IntakePeriod; + type MaxIntakeBids = MaxIntakeBids; + type WeightInfo = weights::pallet_gilt::WeightInfo; +} + impl pallet_beefy::Config for Runtime { type BeefyId = BeefyId; type MaxAuthorities = MaxAuthorities; @@ -703,7 +1257,7 @@ impl BeefyDataProvider for ParasProvider { .filter_map(|id| Paras::para_head(&id).map(|head| (id.into(), head.0))) .collect(); para_heads.sort(); - beefy_merkle_tree::merkle_root::, _, _>( + beefy_merkle_tree::merkle_root::<::Hashing, _>( para_heads.into_iter().map(|pair| pair.encode()), ) .into() @@ -717,196 +1271,201 @@ impl pallet_beefy_mmr::Config for Runtime { type BeefyDataProvider = ParasProvider; } -parameter_types! { - pub const EndingPeriod: BlockNumber = 1 * HOURS; - pub const SampleLength: BlockNumber = 1; -} - -impl auctions::Config for Runtime { - type Event = Event; - type Leaser = Slots; - type Registrar = Registrar; - type EndingPeriod = EndingPeriod; - type SampleLength = SampleLength; - type Randomness = pallet_babe::RandomnessFromOneEpochAgo; - type InitiateOrigin = EnsureRoot; - type WeightInfo = weights::runtime_common_auctions::WeightInfo; -} - -parameter_types! { - pub const LeasePeriod: BlockNumber = 1 * DAYS; -} - -impl slots::Config for Runtime { - type Event = Event; - type Currency = Balances; - type Registrar = Registrar; - type LeasePeriod = LeasePeriod; - type LeaseOffset = (); - type ForceOrigin = EnsureRoot; - type WeightInfo = weights::runtime_common_slots::WeightInfo; -} - -parameter_types! { - pub const CrowdloanId: PalletId = PalletId(*b"py/cfund"); - pub const SubmissionDeposit: Balance = 100 * DOLLARS; - pub const MinContribution: Balance = 1 * DOLLARS; - pub const RemoveKeysLimit: u32 = 500; - // Allow 32 bytes for an additional memo to a crowdloan. - pub const MaxMemoLength: u8 = 32; -} - -impl crowdloan::Config for Runtime { - type Event = Event; - type PalletId = CrowdloanId; - type SubmissionDeposit = SubmissionDeposit; - type MinContribution = MinContribution; - type RemoveKeysLimit = RemoveKeysLimit; - type Registrar = Registrar; - type Auctioneer = Auctions; - type MaxMemoLength = MaxMemoLength; - type WeightInfo = weights::runtime_common_crowdloan::WeightInfo; -} - -impl pallet_sudo::Config for Runtime { - type Event = Event; - type Call = Call; -} - -impl validator_manager::Config for Runtime { - type Event = Event; - type PrivilegedOrigin = EnsureRoot; -} - -impl pallet_utility::Config for Runtime { - type Event = Event; - type Call = Call; - type PalletsOrigin = OriginCaller; - type WeightInfo = weights::pallet_utility::WeightInfo; -} +impl paras_sudo_wrapper::Config for Runtime {} parameter_types! { - // One storage item; key size 32, value size 8; . - pub const ProxyDepositBase: Balance = 10; - // Additional storage item size of 33 bytes. - pub const ProxyDepositFactor: Balance = 10; - pub const MaxProxies: u16 = 32; - pub const AnnouncementDepositBase: Balance = 10; - pub const AnnouncementDepositFactor: Balance = 10; - pub const MaxPending: u16 = 32; -} - -/// The type used to represent the kinds of proxying allowed. -#[derive( - Copy, - Clone, - Eq, - PartialEq, - Ord, - PartialOrd, - Encode, - Decode, - RuntimeDebug, - MaxEncodedLen, - TypeInfo, -)] -pub enum ProxyType { - Any, - CancelProxy, - Auction, -} -impl Default for ProxyType { - fn default() -> Self { - Self::Any - } -} -impl InstanceFilter for ProxyType { - fn filter(&self, c: &Call) -> bool { - match self { - ProxyType::Any => true, - ProxyType::CancelProxy => { - matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })) - }, - ProxyType::Auction => matches!( - c, - Call::Auctions { .. } | - Call::Crowdloan { .. } | - Call::Registrar { .. } | - Call::Multisig(..) | Call::Slots { .. } - ), - } - } - fn is_superset(&self, o: &Self) -> bool { - match (self, o) { - (ProxyType::Any, _) => true, - _ => false, - } - } + pub const PermanentSlotLeasePeriodLength: u32 = 365; + pub const TemporarySlotLeasePeriodLength: u32 = 3; + pub const MaxPermanentSlots: u32 = 40; + pub const MaxTemporarySlots: u32 = 40; + pub const MaxTemporarySlotPerLeasePeriod: u32 = 5; } -impl pallet_proxy::Config for Runtime { - type Event = Event; - type Call = Call; - type Currency = Balances; - type ProxyType = ProxyType; - type ProxyDepositBase = ProxyDepositBase; - type ProxyDepositFactor = ProxyDepositFactor; - type MaxProxies = MaxProxies; - type WeightInfo = weights::pallet_proxy::WeightInfo; - type MaxPending = MaxPending; - type CallHasher = BlakeTwo256; - type AnnouncementDepositBase = AnnouncementDepositBase; - type AnnouncementDepositFactor = AnnouncementDepositFactor; +impl assigned_slots::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type AssignSlotOrigin = EnsureRoot; + type Leaser = Slots; + type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength; + type TemporarySlotLeasePeriodLength = TemporarySlotLeasePeriodLength; + type MaxPermanentSlots = MaxPermanentSlots; + type MaxTemporarySlots = MaxTemporarySlots; + type MaxTemporarySlotPerLeasePeriod = MaxTemporarySlotPerLeasePeriod; } -parameter_types! { - pub const MotionDuration: BlockNumber = 5; - pub const MaxProposals: u32 = 100; - pub const MaxMembers: u32 = 100; +impl validator_manager::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type PrivilegedOrigin = EnsureRoot; } -impl pallet_collective::Config for Runtime { - type Origin = Origin; - type Proposal = Call; - type Event = Event; - type MotionDuration = MotionDuration; - type MaxProposals = MaxProposals; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type MaxMembers = MaxMembers; - type WeightInfo = weights::pallet_collective::WeightInfo; -} - -impl pallet_membership::Config for Runtime { - type Event = Event; - type AddOrigin = EnsureRoot; - type RemoveOrigin = EnsureRoot; - type SwapOrigin = EnsureRoot; - type ResetOrigin = EnsureRoot; - type PrimeOrigin = EnsureRoot; - type MembershipInitialized = Collective; - type MembershipChanged = Collective; - type MaxMembers = MaxMembers; - type WeightInfo = weights::pallet_membership::WeightInfo; +impl pallet_sudo::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; } -parameter_types! { - // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. - pub const DepositBase: Balance = deposit(1, 88); - // Additional storage item size of 32 bytes. - pub const DepositFactor: Balance = deposit(0, 32); - pub const MaxSignatories: u16 = 100; -} +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = primitives::v2::Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + // Basic stuff; balances is uncallable initially. + System: frame_system::{Pallet, Call, Storage, Config, Event} = 0, -impl pallet_multisig::Config for Runtime { - type Event = Event; - type Call = Call; - type Currency = Balances; - type DepositBase = DepositBase; - type DepositFactor = DepositFactor; - type MaxSignatories = MaxSignatories; - type WeightInfo = weights::pallet_multisig::WeightInfo; + // Babe must be before session. + Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned} = 1, + + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, + Indices: pallet_indices::{Pallet, Call, Storage, Config, Event} = 3, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 4, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event} = 33, + + // Consensus support. + // Authorship must be before session in order to note author in the correct session and era + // for im-online. + Authorship: pallet_authorship::{Pallet, Call, Storage} = 5, + Offences: pallet_offences::{Pallet, Storage, Event} = 7, + Historical: session_historical::{Pallet} = 34, + Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 8, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 10, + ImOnline: pallet_im_online::{Pallet, Call, Storage, Event, ValidateUnsigned, Config} = 11, + AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 12, + + // Governance stuff; uncallable initially. + Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event} = 13, + Council: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 14, + TechnicalCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 15, + PhragmenElection: pallet_elections_phragmen::{Pallet, Call, Storage, Event, Config} = 16, + TechnicalMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 17, + Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event} = 18, + + // Claims. Usable initially. + Claims: claims::{Pallet, Call, Storage, Event, Config, ValidateUnsigned} = 19, + + // Utility module. + Utility: pallet_utility::{Pallet, Call, Event} = 24, + + // Less simple identity module. + Identity: pallet_identity::{Pallet, Call, Storage, Event} = 25, + + // Society module. + Society: pallet_society::{Pallet, Call, Storage, Event} = 26, + + // Social recovery module. + Recovery: pallet_recovery::{Pallet, Call, Storage, Event} = 27, + + // Vesting. Usable initially, but removed once all vesting is finished. + Vesting: pallet_vesting::{Pallet, Call, Storage, Event, Config} = 28, + + // System scheduler. + Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 29, + + // Proxy module. Late addition. + Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 30, + + // Multisig module. Late addition. + Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 31, + + // Preimage registrar. + Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 32, + + // Bounties modules. + Bounties: pallet_bounties::{Pallet, Call, Storage, Event} = 35, + ChildBounties: pallet_child_bounties = 40, + + // Tips module. + Tips: pallet_tips::{Pallet, Call, Storage, Event} = 36, + + // Gilts pallet. + Gilt: pallet_gilt::{Pallet, Call, Storage, Event, Config} = 38, + + // Parachains pallets. Start indices at 50 to leave room. + ParachainsOrigin: parachains_origin::{Pallet, Origin} = 50, + Configuration: parachains_configuration::{Pallet, Call, Storage, Config} = 51, + ParasShared: parachains_shared::{Pallet, Call, Storage} = 52, + ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event} = 53, + ParaInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 54, + ParaScheduler: parachains_scheduler::{Pallet, Storage} = 55, + Paras: parachains_paras::{Pallet, Call, Storage, Event, Config, ValidateUnsigned} = 56, + Initializer: parachains_initializer::{Pallet, Call, Storage} = 57, + Dmp: parachains_dmp::{Pallet, Call, Storage} = 58, + Ump: parachains_ump::{Pallet, Call, Storage, Event} = 59, + Hrmp: parachains_hrmp::{Pallet, Call, Storage, Event, Config} = 60, + ParaSessionInfo: parachains_session_info::{Pallet, Storage} = 61, + ParasDisputes: parachains_disputes::{Pallet, Call, Storage, Event} = 62, + ParasSlashing: parachains_slashing::{Pallet, Call, Storage, ValidateUnsigned} = 63, + + // Parachain Onboarding Pallets. Start indices at 70 to leave room. + Registrar: paras_registrar::{Pallet, Call, Storage, Event, Config} = 70, + Slots: slots::{Pallet, Call, Storage, Event} = 71, + Auctions: auctions::{Pallet, Call, Storage, Event} = 72, + Crowdloan: crowdloan::{Pallet, Call, Storage, Event} = 73, + + // Pallet for sending XCM. + XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event, Origin, Config} = 99, + + // Rococo specific pallets (not included in Kusama). Start indices at 240 + // + // BEEFY Bridges support. + Beefy: pallet_beefy::{Pallet, Storage, Config} = 240, + Mmr: pallet_mmr::{Pallet, Storage} = 241, + MmrLeaf: pallet_beefy_mmr::{Pallet, Storage} = 242, + + ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call} = 250, + AssignedSlots: assigned_slots::{Pallet, Call, Storage, Event} = 251, + + // Validator Manager pallet. + ValidatorManager: validator_manager::{Pallet, Call, Storage, Event} = 252, + + // Sudo. + Sudo: pallet_sudo::{Pallet, Call, Storage, Event, Config} = 255, + } } +/// The address format for describing accounts. +pub type Address = sp_runtime::MultiAddress; +/// Block header type as expected by this runtime. +pub type Header = generic::Header; +/// Block type as expected by this runtime. +pub type Block = generic::Block; +/// A Block signed with a Justification +pub type SignedBlock = generic::SignedBlock; +/// `BlockId` type as expected by this runtime. +pub type BlockId = generic::BlockId; +/// The `SignedExtension` to the basic transaction logic. +pub type SignedExtra = ( + frame_system::CheckNonZeroSender, + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckMortality, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, +); + +/// Unchecked extrinsic type as expected by this runtime. +pub type UncheckedExtrinsic = + generic::UncheckedExtrinsic; +/// Executive: handles dispatch to the various modules. +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, + ( + // "Bound uses of call" + pallet_preimage::migration::v1::Migration, + pallet_scheduler::migration::v3::MigrateToV4, + pallet_democracy::migrations::v1::Migration, + pallet_multisig::migrations::v1::MigrateToV1, + // "Properly migrate weights to v2" + parachains_configuration::migration::v3::MigrateToV3, + ), +>; +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; + #[cfg(feature = "runtime-benchmarks")] #[macro_use] extern crate frame_benchmarking; @@ -919,27 +1478,44 @@ mod benches { // the that path resolves correctly in the generated file. [runtime_common::auctions, Auctions] [runtime_common::crowdloan, Crowdloan] - [runtime_common::paras_registrar, Registrar] + [runtime_common::claims, Claims] [runtime_common::slots, Slots] + [runtime_common::paras_registrar, Registrar] [runtime_parachains::configuration, Configuration] [runtime_parachains::hrmp, Hrmp] - [runtime_parachains::initializer, Initializer] - [runtime_parachains::paras, Paras] [runtime_parachains::disputes, ParasDisputes] + [runtime_parachains::initializer, Initializer] [runtime_parachains::paras_inherent, ParaInherent] + [runtime_parachains::paras, Paras] [runtime_parachains::ump, Ump] // Substrate - [frame_benchmarking::baseline, Baseline::] [pallet_balances, Balances] - [pallet_collective, Collective] + [frame_benchmarking::baseline, Baseline::] + [pallet_bounties, Bounties] + [pallet_child_bounties, ChildBounties] + [pallet_collective, Council] + [pallet_collective, TechnicalCommittee] + [pallet_democracy, Democracy] + [pallet_elections_phragmen, PhragmenElection] + [pallet_gilt, Gilt] + [pallet_identity, Identity] [pallet_im_online, ImOnline] [pallet_indices, Indices] - [pallet_membership, Membership] + [pallet_membership, TechnicalMembership] [pallet_multisig, Multisig] + [pallet_preimage, Preimage] [pallet_proxy, Proxy] + [pallet_recovery, Recovery] + [pallet_scheduler, Scheduler] [frame_system, SystemBench::] [pallet_timestamp, Timestamp] + [pallet_tips, Tips] + [pallet_treasury, Treasury] [pallet_utility, Utility] + [pallet_vesting, Vesting] + // XCM + [pallet_xcm_benchmarks::fungible, pallet_xcm_benchmarks::fungible::Pallet::] + [pallet_xcm_benchmarks::generic, pallet_xcm_benchmarks::generic::Pallet::] ); } @@ -1004,29 +1580,30 @@ sp_api::impl_runtime_apis! { } } + #[api_version(3)] impl primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { - runtime_api_impl::validators::() + parachains_runtime_api_impl::validators::() } fn validator_groups() -> (Vec>, GroupRotationInfo) { - runtime_api_impl::validator_groups::() + parachains_runtime_api_impl::validator_groups::() } fn availability_cores() -> Vec> { - runtime_api_impl::availability_cores::() + parachains_runtime_api_impl::availability_cores::() } fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption) -> Option> { - runtime_api_impl::persisted_validation_data::(para_id, assumption) + parachains_runtime_api_impl::persisted_validation_data::(para_id, assumption) } fn assumed_validation_data( para_id: ParaId, expected_persisted_validation_data_hash: Hash, ) -> Option<(PersistedValidationData, ValidationCodeHash)> { - runtime_api_impl::assumed_validation_data::( + parachains_runtime_api_impl::assumed_validation_data::( para_id, expected_persisted_validation_data_hash, ) @@ -1036,26 +1613,26 @@ sp_api::impl_runtime_apis! { para_id: ParaId, outputs: primitives::v2::CandidateCommitments, ) -> bool { - runtime_api_impl::check_validation_outputs::(para_id, outputs) + parachains_runtime_api_impl::check_validation_outputs::(para_id, outputs) } fn session_index_for_child() -> SessionIndex { - runtime_api_impl::session_index_for_child::() + parachains_runtime_api_impl::session_index_for_child::() } fn validation_code(para_id: ParaId, assumption: OccupiedCoreAssumption) -> Option { - runtime_api_impl::validation_code::(para_id, assumption) + parachains_runtime_api_impl::validation_code::(para_id, assumption) } fn candidate_pending_availability(para_id: ParaId) -> Option> { - runtime_api_impl::candidate_pending_availability::(para_id) + parachains_runtime_api_impl::candidate_pending_availability::(para_id) } fn candidate_events() -> Vec> { - runtime_api_impl::candidate_events::(|ev| { + parachains_runtime_api_impl::candidate_events::(|ev| { match ev { - Event::ParaInclusion(ev) => { + RuntimeEvent::ParaInclusion(ev) => { Some(ev) } _ => None, @@ -1064,43 +1641,132 @@ sp_api::impl_runtime_apis! { } fn session_info(index: SessionIndex) -> Option { - runtime_api_impl::session_info::(index) + parachains_runtime_api_impl::session_info::(index) } fn dmq_contents(recipient: ParaId) -> Vec> { - runtime_api_impl::dmq_contents::(recipient) + parachains_runtime_api_impl::dmq_contents::(recipient) } fn inbound_hrmp_channels_contents( recipient: ParaId ) -> BTreeMap>> { - runtime_api_impl::inbound_hrmp_channels_contents::(recipient) + parachains_runtime_api_impl::inbound_hrmp_channels_contents::(recipient) } fn validation_code_by_hash(hash: ValidationCodeHash) -> Option { - runtime_api_impl::validation_code_by_hash::(hash) + parachains_runtime_api_impl::validation_code_by_hash::(hash) } fn on_chain_votes() -> Option> { - runtime_api_impl::on_chain_votes::() + parachains_runtime_api_impl::on_chain_votes::() } - fn submit_pvf_check_statement(stmt: PvfCheckStatement, signature: ValidatorSignature) { - runtime_api_impl::submit_pvf_check_statement::(stmt, signature) + fn submit_pvf_check_statement( + stmt: primitives::v2::PvfCheckStatement, + signature: primitives::v2::ValidatorSignature + ) { + parachains_runtime_api_impl::submit_pvf_check_statement::(stmt, signature) } fn pvfs_require_precheck() -> Vec { - runtime_api_impl::pvfs_require_precheck::() + parachains_runtime_api_impl::pvfs_require_precheck::() } fn validation_code_hash(para_id: ParaId, assumption: OccupiedCoreAssumption) -> Option { - runtime_api_impl::validation_code_hash::(para_id, assumption) + parachains_runtime_api_impl::validation_code_hash::(para_id, assumption) + } + + fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + runtime_parachains::runtime_api_impl::vstaging::get_session_disputes::() + } + } + + impl beefy_primitives::BeefyApi for Runtime { + fn validator_set() -> Option> { + Beefy::validator_set() + } + } + + impl mmr::MmrApi for Runtime { + fn generate_proof(block_number: BlockNumber) + -> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof), mmr::Error> + { + Mmr::generate_batch_proof(vec![block_number]) + .and_then(|(leaves, proof)| Ok(( + mmr::EncodableOpaqueLeaf::from_leaf(&leaves[0]), + mmr::BatchProof::into_single_leaf_proof(proof)? + ))) + } + + fn verify_proof(leaf: mmr::EncodableOpaqueLeaf, proof: mmr::Proof) + -> Result<(), mmr::Error> + { + pub type MmrLeaf = <::LeafData as mmr::LeafDataProvider>::LeafData; + let leaf: MmrLeaf = leaf + .into_opaque_leaf() + .try_decode() + .ok_or(mmr::Error::Verify)?; + Mmr::verify_leaves(vec![leaf], mmr::Proof::into_batch_proof(proof)) + } + + fn verify_proof_stateless( + root: Hash, + leaf: mmr::EncodableOpaqueLeaf, + proof: mmr::Proof + ) -> Result<(), mmr::Error> { + let node = mmr::DataOrHash::Data(leaf.into_opaque_leaf()); + pallet_mmr::verify_leaves_proof::(root, vec![node], mmr::Proof::into_batch_proof(proof)) + } + + fn mmr_root() -> Result { + Ok(Mmr::mmr_root()) + } + + fn generate_batch_proof(block_numbers: Vec) + -> Result<(Vec, mmr::BatchProof), mmr::Error> + { + Mmr::generate_batch_proof(block_numbers) + .map(|(leaves, proof)| (leaves.into_iter().map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)).collect(), proof)) + } + + fn generate_historical_batch_proof( + block_numbers: Vec, + best_known_block_number: BlockNumber, + ) -> Result<(Vec, mmr::BatchProof), mmr::Error> { + Mmr::generate_historical_batch_proof(block_numbers, best_known_block_number).map( + |(leaves, proof)| { + ( + leaves + .into_iter() + .map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)) + .collect(), + proof, + ) + }, + ) + } + + fn verify_batch_proof(leaves: Vec, proof: mmr::BatchProof) + -> Result<(), mmr::Error> + { + pub type MmrLeaf = <::LeafData as mmr::LeafDataProvider>::LeafData; + let leaves = leaves.into_iter().map(|leaf| + leaf.into_opaque_leaf() + .try_decode() + .ok_or(mmr::Error::Verify)).collect::, mmr::Error>>()?; + Mmr::verify_leaves(leaves, proof) } - fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { - unimplemented!() + fn verify_batch_proof_stateless( + root: Hash, + leaves: Vec, + proof: mmr::BatchProof + ) -> Result<(), mmr::Error> { + let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect(); + pallet_mmr::verify_leaves_proof::(root, nodes, proof) } } @@ -1141,19 +1807,15 @@ sp_api::impl_runtime_apis! { } impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeGenesisConfiguration { - // The choice of `c` parameter (where `1 - c` represents the - // probability of a slot being empty), is done in accordance to the - // slot duration and expected target block time, for safely - // resisting network delays of maximum two seconds. - // - babe_primitives::BabeGenesisConfiguration { + fn configuration() -> babe_primitives::BabeConfiguration { + let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG); + babe_primitives::BabeConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDurationInBlocks::get().into(), - c: BABE_GENESIS_EPOCH_CONFIG.c, - genesis_authorities: Babe::authorities().to_vec(), + c: epoch_config.c, + authorities: Babe::authorities().to_vec(), randomness: Babe::randomness(), - allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots, + allowed_slots: epoch_config.allowed_slots, } } @@ -1195,7 +1857,7 @@ sp_api::impl_runtime_apis! { impl authority_discovery_primitives::AuthorityDiscoveryApi for Runtime { fn authorities() -> Vec { - runtime_api_impl::relevant_authority_ids::() + parachains_runtime_api_impl::relevant_authority_ids::() } } @@ -1211,85 +1873,6 @@ sp_api::impl_runtime_apis! { } } - impl beefy_primitives::BeefyApi for Runtime { - fn validator_set() -> Option> { - Beefy::validator_set() - } - } - - impl mmr::MmrApi for Runtime { - fn generate_proof(leaf_index: u64) - -> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof), mmr::Error> - { - Mmr::generate_batch_proof(vec![leaf_index]) - .and_then(|(leaves, proof)| Ok(( - mmr::EncodableOpaqueLeaf::from_leaf(&leaves[0]), - mmr::BatchProof::into_single_leaf_proof(proof)? - ))) - } - - fn verify_proof(leaf: mmr::EncodableOpaqueLeaf, proof: mmr::Proof) - -> Result<(), mmr::Error> - { - pub type MmrLeaf = <::LeafData as mmr::LeafDataProvider>::LeafData; - let leaf: MmrLeaf = leaf - .into_opaque_leaf() - .try_decode() - .ok_or(mmr::Error::Verify)?; - Mmr::verify_leaves(vec![leaf], mmr::Proof::into_batch_proof(proof)) - } - - fn verify_proof_stateless( - root: Hash, - leaf: mmr::EncodableOpaqueLeaf, - proof: mmr::Proof - ) -> Result<(), mmr::Error> { - let node = mmr::DataOrHash::Data(leaf.into_opaque_leaf()); - pallet_mmr::verify_leaves_proof::(root, vec![node], mmr::Proof::into_batch_proof(proof)) - } - - fn mmr_root() -> Result { - Ok(Mmr::mmr_root()) - } - - fn generate_batch_proof(leaf_indices: Vec) - -> Result<(Vec, mmr::BatchProof), mmr::Error> - { - Mmr::generate_batch_proof(leaf_indices) - .map(|(leaves, proof)| (leaves.into_iter().map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)).collect(), proof)) - } - - fn verify_batch_proof(leaves: Vec, proof: mmr::BatchProof) - -> Result<(), mmr::Error> - { - pub type MmrLeaf = <::LeafData as mmr::LeafDataProvider>::LeafData; - let leaves = leaves.into_iter().map(|leaf| - leaf.into_opaque_leaf() - .try_decode() - .ok_or(mmr::Error::Verify)).collect::, mmr::Error>>()?; - Mmr::verify_leaves(leaves, proof) - } - - fn verify_batch_proof_stateless( - root: Hash, - leaves: Vec, - proof: mmr::BatchProof - ) -> Result<(), mmr::Error> { - let nodes = leaves.into_iter().map(|leaf|mmr::DataOrHash::Data(leaf.into_opaque_leaf())).collect(); - pallet_mmr::verify_leaves_proof::(root, nodes, proof) - } - } - - impl beefy_merkle_tree::BeefyMmrApi for RuntimeApi { - fn authority_set_proof() -> beefy_primitives::mmr::BeefyAuthoritySet { - MmrLeaf::authority_set_proof() - } - - fn next_authority_set_proof() -> beefy_primitives::mmr::BeefyNextAuthoritySet { - MmrLeaf::next_authority_set_proof() - } - } - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { fn account_nonce(account: AccountId) -> Nonce { System::account_nonce(account) @@ -1308,14 +1891,13 @@ sp_api::impl_runtime_apis! { } } - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi - for Runtime - { - fn query_call_info(call: Call, len: u32) -> RuntimeDispatchInfo { - TransactionPayment::query_call_info(call, len) + impl beefy_merkle_tree::BeefyMmrApi for RuntimeApi { + fn authority_set_proof() -> beefy_primitives::mmr::BeefyAuthoritySet { + MmrLeaf::authority_set_proof() } - fn query_call_fee_details(call: Call, len: u32) -> FeeDetails { - TransactionPayment::query_call_fee_details(call, len) + + fn next_authority_set_proof() -> beefy_primitives::mmr::BeefyNextAuthoritySet { + MmrLeaf::next_authority_set_proof() } } @@ -1344,14 +1926,78 @@ sp_api::impl_runtime_apis! { Vec, sp_runtime::RuntimeString, > { - use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey, BenchmarkError}; use frame_system_benchmarking::Pallet as SystemBench; use frame_benchmarking::baseline::Pallet as Baseline; + use xcm::latest::prelude::*; + use xcm_config::{CheckAccount, RocLocation, SovereignAccountOf, Statemine, XcmConfig}; impl frame_system_benchmarking::Config for Runtime {} impl frame_benchmarking::baseline::Config for Runtime {} + impl pallet_xcm_benchmarks::Config for Runtime { + type XcmConfig = XcmConfig; + type AccountIdConverter = SovereignAccountOf; + fn valid_destination() -> Result { + Ok(Statemine::get()) + } + fn worst_case_holding() -> MultiAssets { + // Rococo only knows about ROC + vec![MultiAsset{ + id: Concrete(RocLocation::get()), + fun: Fungible(1_000_000 * UNITS), + }].into() + } + } + + parameter_types! { + pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( + Statemine::get(), + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(RocLocation::get()) }, + )); + pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( + Statemine::get(), + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(RocLocation::get()) }, + )); + } + + impl pallet_xcm_benchmarks::fungible::Config for Runtime { + type TransactAsset = Balances; + + type CheckedAccount = CheckAccount; + type TrustedTeleporter = TrustedTeleporter; + type TrustedReserve = TrustedReserve; + + fn get_multi_asset() -> MultiAsset { + MultiAsset { + id: Concrete(RocLocation::get()), + fun: Fungible(1 * UNITS), + } + } + } + + impl pallet_xcm_benchmarks::generic::Config for Runtime { + type RuntimeCall = RuntimeCall; + + fn worst_case_response() -> (u64, Response) { + (0u64, Response::Version(Default::default())) + } + + fn transact_origin() -> Result { + Ok(Statemine::get()) + } + + fn subscribe_origin() -> Result { + Ok(Statemine::get()) + } + + fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { + let origin = Statemine::get(); + let assets: MultiAssets = (Concrete(RocLocation::get()), 1_000 * UNITS).into(); + let ticket = MultiLocation { parents: 0, interior: Here }; + Ok((origin, ticket, assets)) + } + } - let mut batches = Vec::::new(); let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), @@ -1363,8 +2009,13 @@ sp_api::impl_runtime_apis! { hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(), // System Events hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), + // Treasury Account + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(), ]; + + let mut batches = Vec::::new(); let params = (&config, &whitelist); + add_benchmarks!(params, batches); Ok(batches) diff --git a/runtime/rococo/src/validator_manager.rs b/runtime/rococo/src/validator_manager.rs index 2fd60b682ea5..bb13bc823ca4 100644 --- a/runtime/rococo/src/validator_manager.rs +++ b/runtime/rococo/src/validator_manager.rs @@ -37,10 +37,10 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_session::Config { /// The overreaching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Privileged origin that can add or remove validators. - type PrivilegedOrigin: EnsureOrigin<::Origin>; + type PrivilegedOrigin: EnsureOrigin<::RuntimeOrigin>; } #[pallet::event] diff --git a/runtime/rococo/src/weights/frame_benchmarking_baseline.rs b/runtime/rococo/src/weights/frame_benchmarking_baseline.rs new file mode 100644 index 000000000000..cc96e30d7401 --- /dev/null +++ b/runtime/rococo/src/weights/frame_benchmarking_baseline.rs @@ -0,0 +1,97 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `frame_benchmarking::baseline` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=frame_benchmarking::baseline +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/frame_benchmarking_baseline.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `frame_benchmarking::baseline`. +pub struct WeightInfo(PhantomData); +impl frame_benchmarking::baseline::WeightInfo for WeightInfo { + /// The range of component `i` is `[0, 1000000]`. + fn addition(_i: u32, ) -> Weight { + // Minimum execution time: 100 nanoseconds. + Weight::from_ref_time(147_688 as u64) + } + /// The range of component `i` is `[0, 1000000]`. + fn subtraction(_i: u32, ) -> Weight { + // Minimum execution time: 100 nanoseconds. + Weight::from_ref_time(147_383 as u64) + } + /// The range of component `i` is `[0, 1000000]`. + fn multiplication(_i: u32, ) -> Weight { + // Minimum execution time: 90 nanoseconds. + Weight::from_ref_time(147_362 as u64) + } + /// The range of component `i` is `[0, 1000000]`. + fn division(_i: u32, ) -> Weight { + // Minimum execution time: 94 nanoseconds. + Weight::from_ref_time(142_468 as u64) + } + /// The range of component `i` is `[0, 100]`. + fn hashing(_i: u32, ) -> Weight { + // Minimum execution time: 19_076_234 nanoseconds. + Weight::from_ref_time(19_306_096_061 as u64) + } + /// The range of component `i` is `[0, 100]`. + fn sr25519_verification(i: u32, ) -> Weight { + // Minimum execution time: 152 nanoseconds. + Weight::from_ref_time(170_000 as u64) + // Standard Error: 22_217 + .saturating_add(Weight::from_ref_time(47_861_042 as u64).saturating_mul(i as u64)) + } + // Storage: Skipped Metadata (r:0 w:0) + /// The range of component `i` is `[0, 1000]`. + fn storage_read(i: u32, ) -> Weight { + // Minimum execution time: 130 nanoseconds. + Weight::from_ref_time(143_000 as u64) + // Standard Error: 3_691 + .saturating_add(Weight::from_ref_time(1_837_360 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(i as u64))) + } + // Storage: Skipped Metadata (r:0 w:0) + /// The range of component `i` is `[0, 1000]`. + fn storage_write(i: u32, ) -> Weight { + // Minimum execution time: 104 nanoseconds. + Weight::from_ref_time(124_000 as u64) + // Standard Error: 857 + .saturating_add(Weight::from_ref_time(315_739 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) + } +} diff --git a/runtime/rococo/src/weights/frame_system.rs b/runtime/rococo/src/weights/frame_system.rs index ed634c8c35bf..f69a95d86eb1 100644 --- a/runtime/rococo/src/weights/frame_system.rs +++ b/runtime/rococo/src/weights/frame_system.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `frame_system` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/rococo/src/weights/frame_system.rs +// --output=./runtime/rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,45 +46,51 @@ pub struct WeightInfo(PhantomData); impl frame_system::WeightInfo for WeightInfo { /// The range of component `b` is `[0, 3932160]`. fn remark(b: u32, ) -> Weight { - (0 as Weight) + // Minimum execution time: 3_577 nanoseconds. + Weight::from_ref_time(3_668_000 as u64) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(413 as u64).saturating_mul(b as u64)) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { - (0 as Weight) + // Minimum execution time: 12_303 nanoseconds. + Weight::from_ref_time(12_411_000 as u64) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(1_728 as u64).saturating_mul(b as u64)) } // Storage: System Digest (r:1 w:1) // Storage: unknown [0x3a686561707061676573] (r:0 w:1) fn set_heap_pages() -> Weight { - (4_572_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 7_559 nanoseconds. + Weight::from_ref_time(7_837_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[1, 1000]`. + /// The range of component `i` is `[0, 1000]`. fn set_storage(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((548_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 3_705 nanoseconds. + Weight::from_ref_time(3_820_000 as u64) + // Standard Error: 2_019 + .saturating_add(Weight::from_ref_time(604_466 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[1, 1000]`. + /// The range of component `i` is `[0, 1000]`. fn kill_storage(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((444_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 3_749 nanoseconds. + Weight::from_ref_time(3_791_000 as u64) + // Standard Error: 994 + .saturating_add(Weight::from_ref_time(433_769 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `p` is `[1, 1000]`. + /// The range of component `p` is `[0, 1000]`. fn kill_prefix(p: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((955_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + // Minimum execution time: 5_101 nanoseconds. + Weight::from_ref_time(5_266_000 as u64) + // Standard Error: 1_406 + .saturating_add(Weight::from_ref_time(941_250 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } } diff --git a/runtime/rococo/src/weights/mod.rs b/runtime/rococo/src/weights/mod.rs index ca5a5673e375..712783bc3e6c 100644 --- a/runtime/rococo/src/weights/mod.rs +++ b/runtime/rococo/src/weights/mod.rs @@ -17,16 +17,29 @@ pub mod frame_system; pub mod pallet_balances; -pub mod pallet_collective; +pub mod pallet_bounties; +pub mod pallet_child_bounties; +pub mod pallet_collective_council; +pub mod pallet_collective_technical_committee; +pub mod pallet_democracy; +pub mod pallet_elections_phragmen; +pub mod pallet_gilt; +pub mod pallet_identity; pub mod pallet_im_online; pub mod pallet_indices; pub mod pallet_membership; pub mod pallet_multisig; +pub mod pallet_preimage; pub mod pallet_proxy; +pub mod pallet_scheduler; pub mod pallet_session; pub mod pallet_timestamp; +pub mod pallet_tips; +pub mod pallet_treasury; pub mod pallet_utility; +pub mod pallet_vesting; pub mod runtime_common_auctions; +pub mod runtime_common_claims; pub mod runtime_common_crowdloan; pub mod runtime_common_paras_registrar; pub mod runtime_common_slots; @@ -37,3 +50,4 @@ pub mod runtime_parachains_initializer; pub mod runtime_parachains_paras; pub mod runtime_parachains_paras_inherent; pub mod runtime_parachains_ump; +pub mod xcm; diff --git a/runtime/rococo/src/weights/pallet_balances.rs b/runtime/rococo/src/weights/pallet_balances.rs index df97c6bbf663..6bd0bcedd863 100644 --- a/runtime/rococo/src/weights/pallet_balances.rs +++ b/runtime/rococo/src/weights/pallet_balances.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/rococo/src/weights/pallet_balances.rs +// --output=./runtime/rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,44 +46,51 @@ pub struct WeightInfo(PhantomData); impl pallet_balances::WeightInfo for WeightInfo { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (38_175_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 39_712 nanoseconds. + Weight::from_ref_time(40_827_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (29_538_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 30_010 nanoseconds. + Weight::from_ref_time(30_621_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (19_473_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 22_644 nanoseconds. + Weight::from_ref_time(23_092_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (22_442_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_591 nanoseconds. + Weight::from_ref_time(26_035_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (38_465_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 39_942 nanoseconds. + Weight::from_ref_time(40_712_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (34_577_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 34_653 nanoseconds. + Weight::from_ref_time(35_543_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn force_unreserve() -> Weight { - (17_476_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 19_879 nanoseconds. + Weight::from_ref_time(20_242_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/rococo/src/weights/pallet_bounties.rs b/runtime/rococo/src/weights/pallet_bounties.rs new file mode 100644 index 000000000000..37e297782917 --- /dev/null +++ b/runtime/rococo/src/weights/pallet_bounties.rs @@ -0,0 +1,150 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_bounties` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_bounties +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_bounties`. +pub struct WeightInfo(PhantomData); +impl pallet_bounties::WeightInfo for WeightInfo { + // Storage: Bounties BountyCount (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Bounties BountyDescriptions (r:0 w:1) + // Storage: Bounties Bounties (r:0 w:1) + /// The range of component `d` is `[0, 16384]`. + fn propose_bounty(d: u32, ) -> Weight { + // Minimum execution time: 27_804 nanoseconds. + Weight::from_ref_time(29_056_744 as u64) + // Standard Error: 5 + .saturating_add(Weight::from_ref_time(853 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: Bounties Bounties (r:1 w:1) + // Storage: Bounties BountyApprovals (r:1 w:1) + fn approve_bounty() -> Weight { + // Minimum execution time: 11_910 nanoseconds. + Weight::from_ref_time(12_122_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Bounties Bounties (r:1 w:1) + fn propose_curator() -> Weight { + // Minimum execution time: 11_663 nanoseconds. + Weight::from_ref_time(11_833_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Bounties Bounties (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn unassign_curator() -> Weight { + // Minimum execution time: 38_804 nanoseconds. + Weight::from_ref_time(40_115_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Bounties Bounties (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn accept_curator() -> Weight { + // Minimum execution time: 27_497 nanoseconds. + Weight::from_ref_time(27_869_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Bounties Bounties (r:1 w:1) + // Storage: ChildBounties ParentChildBounties (r:1 w:0) + fn award_bounty() -> Weight { + // Minimum execution time: 23_864 nanoseconds. + Weight::from_ref_time(24_073_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Bounties Bounties (r:1 w:1) + // Storage: System Account (r:3 w:3) + // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + // Storage: Bounties BountyDescriptions (r:0 w:1) + fn claim_bounty() -> Weight { + // Minimum execution time: 67_991 nanoseconds. + Weight::from_ref_time(68_966_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: Bounties Bounties (r:1 w:1) + // Storage: ChildBounties ParentChildBounties (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Bounties BountyDescriptions (r:0 w:1) + fn close_bounty_proposed() -> Weight { + // Minimum execution time: 42_844 nanoseconds. + Weight::from_ref_time(43_685_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Bounties Bounties (r:1 w:1) + // Storage: ChildBounties ParentChildBounties (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: Bounties BountyDescriptions (r:0 w:1) + fn close_bounty_active() -> Weight { + // Minimum execution time: 51_853 nanoseconds. + Weight::from_ref_time(52_609_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: Bounties Bounties (r:1 w:1) + fn extend_bounty_expiry() -> Weight { + // Minimum execution time: 20_967 nanoseconds. + Weight::from_ref_time(21_226_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Bounties BountyApprovals (r:1 w:1) + // Storage: Bounties Bounties (r:2 w:2) + // Storage: System Account (r:4 w:4) + /// The range of component `b` is `[0, 100]`. + fn spend_funds(b: u32, ) -> Weight { + // Minimum execution time: 6_700 nanoseconds. + Weight::from_ref_time(12_393_217 as u64) + // Standard Error: 25_027 + .saturating_add(Weight::from_ref_time(25_035_038 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(b as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(b as u64))) + } +} diff --git a/runtime/rococo/src/weights/pallet_child_bounties.rs b/runtime/rococo/src/weights/pallet_child_bounties.rs new file mode 100644 index 000000000000..f811ffcd32c1 --- /dev/null +++ b/runtime/rococo/src/weights/pallet_child_bounties.rs @@ -0,0 +1,131 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_child_bounties` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_child_bounties +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_child_bounties`. +pub struct WeightInfo(PhantomData); +impl pallet_child_bounties::WeightInfo for WeightInfo { + // Storage: ChildBounties ParentChildBounties (r:1 w:1) + // Storage: Bounties Bounties (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: ChildBounties ChildBountyCount (r:1 w:1) + // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + // Storage: ChildBounties ChildBounties (r:0 w:1) + /// The range of component `d` is `[0, 16384]`. + fn add_child_bounty(d: u32, ) -> Weight { + // Minimum execution time: 49_807 nanoseconds. + Weight::from_ref_time(50_899_264 as u64) + // Standard Error: 12 + .saturating_add(Weight::from_ref_time(927 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: Bounties Bounties (r:1 w:0) + // Storage: ChildBounties ChildBounties (r:1 w:1) + // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + fn propose_curator() -> Weight { + // Minimum execution time: 19_942 nanoseconds. + Weight::from_ref_time(20_503_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Bounties Bounties (r:1 w:0) + // Storage: ChildBounties ChildBounties (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn accept_curator() -> Weight { + // Minimum execution time: 35_241 nanoseconds. + Weight::from_ref_time(35_682_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: ChildBounties ChildBounties (r:1 w:1) + // Storage: Bounties Bounties (r:1 w:0) + // Storage: System Account (r:1 w:1) + fn unassign_curator() -> Weight { + // Minimum execution time: 47_679 nanoseconds. + Weight::from_ref_time(48_686_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Bounties Bounties (r:1 w:0) + // Storage: ChildBounties ChildBounties (r:1 w:1) + fn award_child_bounty() -> Weight { + // Minimum execution time: 26_401 nanoseconds. + Weight::from_ref_time(27_254_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: ChildBounties ChildBounties (r:1 w:1) + // Storage: System Account (r:3 w:3) + // Storage: ChildBounties ParentChildBounties (r:1 w:1) + // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + fn claim_child_bounty() -> Weight { + // Minimum execution time: 67_126 nanoseconds. + Weight::from_ref_time(67_652_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: Bounties Bounties (r:1 w:0) + // Storage: ChildBounties ChildBounties (r:1 w:1) + // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + // Storage: ChildBounties ParentChildBounties (r:1 w:1) + // Storage: System Account (r:2 w:2) + // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + fn close_child_bounty_added() -> Weight { + // Minimum execution time: 49_894 nanoseconds. + Weight::from_ref_time(50_434_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: Bounties Bounties (r:1 w:0) + // Storage: ChildBounties ChildBounties (r:1 w:1) + // Storage: System Account (r:3 w:3) + // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + // Storage: ChildBounties ParentChildBounties (r:1 w:1) + // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + fn close_child_bounty_active() -> Weight { + // Minimum execution time: 59_485 nanoseconds. + Weight::from_ref_time(59_939_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) + } +} diff --git a/runtime/rococo/src/weights/pallet_collective.rs b/runtime/rococo/src/weights/pallet_collective.rs index cf38499ba4ae..345c48607532 100644 --- a/runtime/rococo/src/weights/pallet_collective.rs +++ b/runtime/rococo/src/weights/pallet_collective.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_collective` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-09-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -32,13 +32,13 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/rococo/src/weights/pallet_collective.rs +// --output=./runtime/rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::Weight}; +use frame_support::{traits::Get, weights::{Weight}}; use sp_std::marker::PhantomData; /// Weight functions for `pallet_collective`. @@ -51,41 +51,39 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `m` is `[1, 100]`. /// The range of component `n` is `[1, 100]`. /// The range of component `p` is `[1, 100]`. - fn set_members(m: u32, n: u32, p: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 11_000 - .saturating_add((9_184_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 11_000 - .saturating_add((10_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 11_000 - .saturating_add((11_927_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { + Weight::from_ref_time(0 as u64) + // Standard Error: 15_000 + .saturating_add(Weight::from_ref_time(10_832_000 as u64).saturating_mul(m as u64)) + // Standard Error: 15_000 + .saturating_add(Weight::from_ref_time(12_894_000 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } // Storage: Collective Members (r:1 w:0) /// The range of component `b` is `[1, 1024]`. /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { - (16_514_000 as Weight) + Weight::from_ref_time(19_069_000 as u64) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(b as u64)) // Standard Error: 0 - .saturating_add((15_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(Weight::from_ref_time(13_000 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } // Storage: Collective Members (r:1 w:0) // Storage: Collective ProposalOf (r:1 w:0) /// The range of component `b` is `[1, 1024]`. /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { - (19_149_000 as Weight) + Weight::from_ref_time(20_794_000 as u64) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(b as u64)) // Standard Error: 0 - .saturating_add((20_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(Weight::from_ref_time(22_000 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) } // Storage: Collective Members (r:1 w:0) // Storage: Collective ProposalOf (r:1 w:1) @@ -96,25 +94,25 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (25_040_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((20_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((125_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(27_870_000 as u64) + // Standard Error: 0 + .saturating_add(Weight::from_ref_time(3_000 as u64).saturating_mul(b as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_ref_time(22_000 as u64).saturating_mul(m as u64)) + // Standard Error: 1_000 + .saturating_add(Weight::from_ref_time(94_000 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Collective Members (r:1 w:0) // Storage: Collective Voting (r:1 w:1) /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { - (23_127_000 as Weight) + Weight::from_ref_time(27_249_000 as u64) // Standard Error: 0 - .saturating_add((53_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(35_000 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Collective Voting (r:1 w:1) // Storage: Collective Members (r:1 w:0) @@ -123,13 +121,13 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (27_759_000 as Weight) + Weight::from_ref_time(30_754_000 as u64) // Standard Error: 0 - .saturating_add((25_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(28_000 as u64).saturating_mul(m as u64)) // Standard Error: 0 - .saturating_add((95_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(81_000 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Collective Voting (r:1 w:1) // Storage: Collective Members (r:1 w:0) @@ -139,15 +137,15 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (37_384_000 as Weight) + Weight::from_ref_time(39_508_000 as u64) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(b as u64)) // Standard Error: 0 - .saturating_add((29_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(29_000 as u64).saturating_mul(m as u64)) // Standard Error: 0 - .saturating_add((105_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(90_000 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Collective Voting (r:1 w:1) // Storage: Collective Members (r:1 w:0) @@ -157,13 +155,13 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { - (29_142_000 as Weight) + Weight::from_ref_time(32_769_000 as u64) // Standard Error: 0 - .saturating_add((32_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(31_000 as u64).saturating_mul(m as u64)) // Standard Error: 0 - .saturating_add((105_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(83_000 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Collective Voting (r:1 w:1) // Storage: Collective Members (r:1 w:0) @@ -174,25 +172,25 @@ impl pallet_collective::WeightInfo for WeightInfo { /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (40_384_000 as Weight) + Weight::from_ref_time(41_704_000 as u64) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(b as u64)) // Standard Error: 0 - .saturating_add((26_000 as Weight).saturating_mul(m as Weight)) + .saturating_add(Weight::from_ref_time(28_000 as u64).saturating_mul(m as u64)) // Standard Error: 0 - .saturating_add((103_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(92_000 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Collective Proposals (r:1 w:1) // Storage: Collective Voting (r:0 w:1) // Storage: Collective ProposalOf (r:0 w:1) /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { - (17_661_000 as Weight) - // Standard Error: 0 - .saturating_add((106_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(22_720_000 as u64) + // Standard Error: 2_000 + .saturating_add(Weight::from_ref_time(74_000 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/rococo/src/weights/pallet_collective_council.rs b/runtime/rococo/src/weights/pallet_collective_council.rs new file mode 100644 index 000000000000..b50a114c5446 --- /dev/null +++ b/runtime/rococo/src/weights/pallet_collective_council.rs @@ -0,0 +1,228 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_collective` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_collective +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_collective`. +pub struct WeightInfo(PhantomData); +impl pallet_collective::WeightInfo for WeightInfo { + // Storage: Council Members (r:1 w:1) + // Storage: Council Proposals (r:1 w:0) + // Storage: Council Prime (r:0 w:1) + // Storage: Council Voting (r:100 w:100) + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { + // Minimum execution time: 17_198 nanoseconds. + Weight::from_ref_time(17_384_000 as u64) + // Standard Error: 42_549 + .saturating_add(Weight::from_ref_time(4_789_978 as u64).saturating_mul(m as u64)) + // Standard Error: 42_549 + .saturating_add(Weight::from_ref_time(6_897_746 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) + } + // Storage: Council Members (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + fn execute(b: u32, m: u32, ) -> Weight { + // Minimum execution time: 19_159 nanoseconds. + Weight::from_ref_time(18_873_138 as u64) + // Standard Error: 20 + .saturating_add(Weight::from_ref_time(1_734 as u64).saturating_mul(b as u64)) + // Standard Error: 209 + .saturating_add(Weight::from_ref_time(13_414 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + } + // Storage: Council Members (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + fn propose_execute(b: u32, m: u32, ) -> Weight { + // Minimum execution time: 21_451 nanoseconds. + Weight::from_ref_time(20_640_157 as u64) + // Standard Error: 24 + .saturating_add(Weight::from_ref_time(1_781 as u64).saturating_mul(b as u64)) + // Standard Error: 251 + .saturating_add(Weight::from_ref_time(23_485 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + } + // Storage: Council Members (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:1) + // Storage: Council Proposals (r:1 w:1) + // Storage: Council ProposalCount (r:1 w:1) + // Storage: Council Voting (r:0 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. + fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { + // Minimum execution time: 27_077 nanoseconds. + Weight::from_ref_time(27_154_776 as u64) + // Standard Error: 69 + .saturating_add(Weight::from_ref_time(3_336 as u64).saturating_mul(b as u64)) + // Standard Error: 727 + .saturating_add(Weight::from_ref_time(22_804 as u64).saturating_mul(m as u64)) + // Standard Error: 718 + .saturating_add(Weight::from_ref_time(108_762 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: Council Members (r:1 w:0) + // Storage: Council Voting (r:1 w:1) + /// The range of component `m` is `[5, 100]`. + /// The range of component `m` is `[5, 100]`. + fn vote(m: u32, ) -> Weight { + // Minimum execution time: 26_405 nanoseconds. + Weight::from_ref_time(27_242_136 as u64) + // Standard Error: 283 + .saturating_add(Weight::from_ref_time(39_794 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council Proposals (r:1 w:1) + // Storage: Council ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + fn close_early_disapproved(m: u32, p: u32, ) -> Weight { + // Minimum execution time: 29_536 nanoseconds. + Weight::from_ref_time(31_574_900 as u64) + // Standard Error: 542 + .saturating_add(Weight::from_ref_time(23_451 as u64).saturating_mul(m as u64)) + // Standard Error: 529 + .saturating_add(Weight::from_ref_time(85_053 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:1) + // Storage: Council Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { + // Minimum execution time: 40_231 nanoseconds. + Weight::from_ref_time(40_496_273 as u64) + // Standard Error: 66 + .saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(b as u64)) + // Standard Error: 698 + .saturating_add(Weight::from_ref_time(22_943 as u64).saturating_mul(m as u64)) + // Standard Error: 681 + .saturating_add(Weight::from_ref_time(98_812 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council Prime (r:1 w:0) + // Storage: Council Proposals (r:1 w:1) + // Storage: Council ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + fn close_disapproved(m: u32, p: u32, ) -> Weight { + // Minimum execution time: 32_640 nanoseconds. + Weight::from_ref_time(33_861_599 as u64) + // Standard Error: 460 + .saturating_add(Weight::from_ref_time(25_138 as u64).saturating_mul(m as u64)) + // Standard Error: 448 + .saturating_add(Weight::from_ref_time(83_121 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Council Voting (r:1 w:1) + // Storage: Council Members (r:1 w:0) + // Storage: Council Prime (r:1 w:0) + // Storage: Council ProposalOf (r:1 w:1) + // Storage: Council Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { + // Minimum execution time: 42_282 nanoseconds. + Weight::from_ref_time(42_777_378 as u64) + // Standard Error: 56 + .saturating_add(Weight::from_ref_time(1_586 as u64).saturating_mul(b as u64)) + // Standard Error: 600 + .saturating_add(Weight::from_ref_time(27_257 as u64).saturating_mul(m as u64)) + // Standard Error: 585 + .saturating_add(Weight::from_ref_time(97_813 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Council Proposals (r:1 w:1) + // Storage: Council Voting (r:0 w:1) + // Storage: Council ProposalOf (r:0 w:1) + /// The range of component `p` is `[1, 100]`. + /// The range of component `p` is `[1, 100]`. + fn disapprove_proposal(p: u32, ) -> Weight { + // Minimum execution time: 17_821 nanoseconds. + Weight::from_ref_time(21_443_640 as u64) + // Standard Error: 815 + .saturating_add(Weight::from_ref_time(96_451 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } +} diff --git a/runtime/rococo/src/weights/pallet_collective_technical_committee.rs b/runtime/rococo/src/weights/pallet_collective_technical_committee.rs new file mode 100644 index 000000000000..97f0f5b650f5 --- /dev/null +++ b/runtime/rococo/src/weights/pallet_collective_technical_committee.rs @@ -0,0 +1,228 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_collective` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_collective +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_collective`. +pub struct WeightInfo(PhantomData); +impl pallet_collective::WeightInfo for WeightInfo { + // Storage: TechnicalCommittee Members (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:0) + // Storage: TechnicalCommittee Prime (r:0 w:1) + // Storage: TechnicalCommittee Voting (r:100 w:100) + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + /// The range of component `m` is `[0, 100]`. + /// The range of component `n` is `[0, 100]`. + /// The range of component `p` is `[0, 100]`. + fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { + // Minimum execution time: 17_528 nanoseconds. + Weight::from_ref_time(17_901_000 as u64) + // Standard Error: 43_125 + .saturating_add(Weight::from_ref_time(4_810_355 as u64).saturating_mul(m as u64)) + // Standard Error: 43_125 + .saturating_add(Weight::from_ref_time(7_024_302 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) + } + // Storage: TechnicalCommittee Members (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + fn execute(b: u32, m: u32, ) -> Weight { + // Minimum execution time: 19_706 nanoseconds. + Weight::from_ref_time(19_036_289 as u64) + // Standard Error: 20 + .saturating_add(Weight::from_ref_time(1_775 as u64).saturating_mul(b as u64)) + // Standard Error: 206 + .saturating_add(Weight::from_ref_time(14_332 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + } + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:0) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[1, 100]`. + fn propose_execute(b: u32, m: u32, ) -> Weight { + // Minimum execution time: 21_770 nanoseconds. + Weight::from_ref_time(21_071_371 as u64) + // Standard Error: 20 + .saturating_add(Weight::from_ref_time(1_882 as u64).saturating_mul(b as u64)) + // Standard Error: 207 + .saturating_add(Weight::from_ref_time(22_530 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + } + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee ProposalCount (r:1 w:1) + // Storage: TechnicalCommittee Voting (r:0 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[2, 100]`. + /// The range of component `p` is `[1, 100]`. + fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { + // Minimum execution time: 27_900 nanoseconds. + Weight::from_ref_time(28_420_350 as u64) + // Standard Error: 65 + .saturating_add(Weight::from_ref_time(3_419 as u64).saturating_mul(b as u64)) + // Standard Error: 680 + .saturating_add(Weight::from_ref_time(19_077 as u64).saturating_mul(m as u64)) + // Standard Error: 671 + .saturating_add(Weight::from_ref_time(114_674 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Voting (r:1 w:1) + /// The range of component `m` is `[5, 100]`. + /// The range of component `m` is `[5, 100]`. + fn vote(m: u32, ) -> Weight { + // Minimum execution time: 27_932 nanoseconds. + Weight::from_ref_time(28_884_621 as u64) + // Standard Error: 327 + .saturating_add(Weight::from_ref_time(40_552 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + fn close_early_disapproved(m: u32, p: u32, ) -> Weight { + // Minimum execution time: 30_909 nanoseconds. + Weight::from_ref_time(32_299_057 as u64) + // Standard Error: 468 + .saturating_add(Weight::from_ref_time(23_986 as u64).saturating_mul(m as u64)) + // Standard Error: 456 + .saturating_add(Weight::from_ref_time(85_238 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { + // Minimum execution time: 41_125 nanoseconds. + Weight::from_ref_time(41_496_038 as u64) + // Standard Error: 85 + .saturating_add(Weight::from_ref_time(1_920 as u64).saturating_mul(b as u64)) + // Standard Error: 900 + .saturating_add(Weight::from_ref_time(20_485 as u64).saturating_mul(m as u64)) + // Standard Error: 877 + .saturating_add(Weight::from_ref_time(99_758 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Prime (r:1 w:0) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee ProposalOf (r:0 w:1) + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + fn close_disapproved(m: u32, p: u32, ) -> Weight { + // Minimum execution time: 33_319 nanoseconds. + Weight::from_ref_time(34_385_990 as u64) + // Standard Error: 452 + .saturating_add(Weight::from_ref_time(27_482 as u64).saturating_mul(m as u64)) + // Standard Error: 441 + .saturating_add(Weight::from_ref_time(84_077 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: TechnicalCommittee Voting (r:1 w:1) + // Storage: TechnicalCommittee Members (r:1 w:0) + // Storage: TechnicalCommittee Prime (r:1 w:0) + // Storage: TechnicalCommittee ProposalOf (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + /// The range of component `b` is `[1, 1024]`. + /// The range of component `m` is `[4, 100]`. + /// The range of component `p` is `[1, 100]`. + fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { + // Minimum execution time: 42_399 nanoseconds. + Weight::from_ref_time(43_752_937 as u64) + // Standard Error: 57 + .saturating_add(Weight::from_ref_time(1_548 as u64).saturating_mul(b as u64)) + // Standard Error: 604 + .saturating_add(Weight::from_ref_time(25_138 as u64).saturating_mul(m as u64)) + // Standard Error: 589 + .saturating_add(Weight::from_ref_time(97_514 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: TechnicalCommittee Proposals (r:1 w:1) + // Storage: TechnicalCommittee Voting (r:0 w:1) + // Storage: TechnicalCommittee ProposalOf (r:0 w:1) + /// The range of component `p` is `[1, 100]`. + /// The range of component `p` is `[1, 100]`. + fn disapprove_proposal(p: u32, ) -> Weight { + // Minimum execution time: 18_277 nanoseconds. + Weight::from_ref_time(21_867_405 as u64) + // Standard Error: 758 + .saturating_add(Weight::from_ref_time(98_872 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } +} diff --git a/runtime/rococo/src/weights/pallet_democracy.rs b/runtime/rococo/src/weights/pallet_democracy.rs new file mode 100644 index 000000000000..6f48824dbaf7 --- /dev/null +++ b/runtime/rococo/src/weights/pallet_democracy.rs @@ -0,0 +1,262 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_democracy` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_democracy +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_democracy`. +pub struct WeightInfo(PhantomData); +impl pallet_democracy::WeightInfo for WeightInfo { + // Storage: Democracy PublicPropCount (r:1 w:1) + // Storage: Democracy PublicProps (r:1 w:1) + // Storage: Democracy Blacklist (r:1 w:0) + // Storage: Democracy DepositOf (r:0 w:1) + fn propose() -> Weight { + // Minimum execution time: 41_755 nanoseconds. + Weight::from_ref_time(43_134_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Democracy DepositOf (r:1 w:1) + fn second() -> Weight { + // Minimum execution time: 39_573 nanoseconds. + Weight::from_ref_time(40_193_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Democracy VotingOf (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + fn vote_new() -> Weight { + // Minimum execution time: 49_316 nanoseconds. + Weight::from_ref_time(49_938_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Democracy VotingOf (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + fn vote_existing() -> Weight { + // Minimum execution time: 49_518 nanoseconds. + Weight::from_ref_time(49_900_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Democracy Cancellations (r:1 w:1) + fn emergency_cancel() -> Weight { + // Minimum execution time: 21_261 nanoseconds. + Weight::from_ref_time(21_511_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Democracy PublicProps (r:1 w:1) + // Storage: Democracy DepositOf (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Democracy NextExternal (r:1 w:1) + // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Democracy Blacklist (r:0 w:1) + fn blacklist() -> Weight { + // Minimum execution time: 76_503 nanoseconds. + Weight::from_ref_time(77_929_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: Democracy NextExternal (r:1 w:1) + // Storage: Democracy Blacklist (r:1 w:0) + fn external_propose() -> Weight { + // Minimum execution time: 15_863 nanoseconds. + Weight::from_ref_time(16_354_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Democracy NextExternal (r:0 w:1) + fn external_propose_majority() -> Weight { + // Minimum execution time: 5_089 nanoseconds. + Weight::from_ref_time(5_254_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Democracy NextExternal (r:0 w:1) + fn external_propose_default() -> Weight { + // Minimum execution time: 5_069 nanoseconds. + Weight::from_ref_time(5_209_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Democracy NextExternal (r:1 w:1) + // Storage: Democracy ReferendumCount (r:1 w:1) + // Storage: Democracy ReferendumInfoOf (r:0 w:1) + fn fast_track() -> Weight { + // Minimum execution time: 20_253 nanoseconds. + Weight::from_ref_time(20_515_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Democracy NextExternal (r:1 w:1) + // Storage: Democracy Blacklist (r:1 w:1) + fn veto_external() -> Weight { + // Minimum execution time: 26_095 nanoseconds. + Weight::from_ref_time(26_879_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Democracy PublicProps (r:1 w:1) + // Storage: Democracy DepositOf (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn cancel_proposal() -> Weight { + // Minimum execution time: 64_771 nanoseconds. + Weight::from_ref_time(66_324_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Democracy ReferendumInfoOf (r:0 w:1) + fn cancel_referendum() -> Weight { + // Minimum execution time: 13_645 nanoseconds. + Weight::from_ref_time(14_111_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Democracy LowestUnbaked (r:1 w:1) + // Storage: Democracy ReferendumCount (r:1 w:0) + // Storage: Democracy ReferendumInfoOf (r:2 w:0) + /// The range of component `r` is `[0, 99]`. + fn on_initialize_base(r: u32, ) -> Weight { + // Minimum execution time: 6_099 nanoseconds. + Weight::from_ref_time(9_326_206 as u64) + // Standard Error: 3_862 + .saturating_add(Weight::from_ref_time(2_099_699 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Democracy LowestUnbaked (r:1 w:1) + // Storage: Democracy ReferendumCount (r:1 w:0) + // Storage: Democracy LastTabledWasExternal (r:1 w:0) + // Storage: Democracy NextExternal (r:1 w:0) + // Storage: Democracy PublicProps (r:1 w:0) + // Storage: Democracy ReferendumInfoOf (r:2 w:0) + /// The range of component `r` is `[0, 99]`. + fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { + // Minimum execution time: 8_538 nanoseconds. + Weight::from_ref_time(12_081_949 as u64) + // Standard Error: 4_231 + .saturating_add(Weight::from_ref_time(2_092_594 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Democracy VotingOf (r:3 w:3) + // Storage: Balances Locks (r:1 w:1) + // Storage: Democracy ReferendumInfoOf (r:2 w:2) + /// The range of component `r` is `[0, 99]`. + fn delegate(r: u32, ) -> Weight { + // Minimum execution time: 40_763 nanoseconds. + Weight::from_ref_time(47_624_671 as u64) + // Standard Error: 5_958 + .saturating_add(Weight::from_ref_time(3_011_398 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) + } + // Storage: Democracy VotingOf (r:2 w:2) + // Storage: Democracy ReferendumInfoOf (r:2 w:2) + /// The range of component `r` is `[0, 99]`. + fn undelegate(r: u32, ) -> Weight { + // Minimum execution time: 24_439 nanoseconds. + Weight::from_ref_time(26_378_140 as u64) + // Standard Error: 9_158 + .saturating_add(Weight::from_ref_time(3_034_925 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) + } + // Storage: Democracy PublicProps (r:0 w:1) + fn clear_public_proposals() -> Weight { + // Minimum execution time: 5_702 nanoseconds. + Weight::from_ref_time(5_854_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Democracy VotingOf (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + /// The range of component `r` is `[0, 99]`. + fn unlock_remove(r: u32, ) -> Weight { + // Minimum execution time: 23_168 nanoseconds. + Weight::from_ref_time(30_468_516 as u64) + // Standard Error: 1_663 + .saturating_add(Weight::from_ref_time(33_327 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Democracy VotingOf (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + /// The range of component `r` is `[0, 99]`. + fn unlock_set(r: u32, ) -> Weight { + // Minimum execution time: 28_828 nanoseconds. + Weight::from_ref_time(30_266_125 as u64) + // Standard Error: 700 + .saturating_add(Weight::from_ref_time(71_389 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Democracy VotingOf (r:1 w:1) + /// The range of component `r` is `[1, 100]`. + fn remove_vote(r: u32, ) -> Weight { + // Minimum execution time: 15_780 nanoseconds. + Weight::from_ref_time(18_485_254 as u64) + // Standard Error: 890 + .saturating_add(Weight::from_ref_time(73_643 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Democracy ReferendumInfoOf (r:1 w:1) + // Storage: Democracy VotingOf (r:1 w:1) + /// The range of component `r` is `[1, 100]`. + fn remove_other_vote(r: u32, ) -> Weight { + // Minimum execution time: 15_661 nanoseconds. + Weight::from_ref_time(18_442_344 as u64) + // Standard Error: 957 + .saturating_add(Weight::from_ref_time(75_374 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } +} diff --git a/runtime/rococo/src/weights/pallet_elections_phragmen.rs b/runtime/rococo/src/weights/pallet_elections_phragmen.rs new file mode 100644 index 000000000000..8aaf623a9abd --- /dev/null +++ b/runtime/rococo/src/weights/pallet_elections_phragmen.rs @@ -0,0 +1,196 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_elections_phragmen` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_elections_phragmen +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_elections_phragmen`. +pub struct WeightInfo(PhantomData); +impl pallet_elections_phragmen::WeightInfo for WeightInfo { + // Storage: PhragmenElection Candidates (r:1 w:0) + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: PhragmenElection RunnersUp (r:1 w:0) + // Storage: PhragmenElection Voting (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + /// The range of component `v` is `[1, 16]`. + fn vote_equal(v: u32, ) -> Weight { + // Minimum execution time: 30_460 nanoseconds. + Weight::from_ref_time(34_092_598 as u64) + // Standard Error: 15_458 + .saturating_add(Weight::from_ref_time(9_646 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: PhragmenElection Candidates (r:1 w:0) + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: PhragmenElection RunnersUp (r:1 w:0) + // Storage: PhragmenElection Voting (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + /// The range of component `v` is `[2, 16]`. + fn vote_more(v: u32, ) -> Weight { + // Minimum execution time: 40_039 nanoseconds. + Weight::from_ref_time(42_074_863 as u64) + // Standard Error: 4_200 + .saturating_add(Weight::from_ref_time(149_127 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: PhragmenElection Candidates (r:1 w:0) + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: PhragmenElection RunnersUp (r:1 w:0) + // Storage: PhragmenElection Voting (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + /// The range of component `v` is `[2, 16]`. + fn vote_less(v: u32, ) -> Weight { + // Minimum execution time: 39_892 nanoseconds. + Weight::from_ref_time(41_863_175 as u64) + // Standard Error: 7_944 + .saturating_add(Weight::from_ref_time(191_849 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: PhragmenElection Voting (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + fn remove_voter() -> Weight { + // Minimum execution time: 38_954 nanoseconds. + Weight::from_ref_time(39_459_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: PhragmenElection Candidates (r:1 w:1) + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: PhragmenElection RunnersUp (r:1 w:0) + /// The range of component `c` is `[1, 1000]`. + fn submit_candidacy(c: u32, ) -> Weight { + // Minimum execution time: 36_293 nanoseconds. + Weight::from_ref_time(27_988_157 as u64) + // Standard Error: 969 + .saturating_add(Weight::from_ref_time(94_416 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: PhragmenElection Candidates (r:1 w:1) + /// The range of component `c` is `[1, 1000]`. + fn renounce_candidacy_candidate(c: u32, ) -> Weight { + // Minimum execution time: 31_731 nanoseconds. + Weight::from_ref_time(23_893_126 as u64) + // Standard Error: 976 + .saturating_add(Weight::from_ref_time(68_105 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: PhragmenElection Members (r:1 w:1) + // Storage: PhragmenElection RunnersUp (r:1 w:1) + // Storage: Council Prime (r:1 w:1) + // Storage: Council Proposals (r:1 w:0) + // Storage: Council Members (r:0 w:1) + fn renounce_candidacy_members() -> Weight { + // Minimum execution time: 44_666 nanoseconds. + Weight::from_ref_time(45_740_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: PhragmenElection RunnersUp (r:1 w:1) + fn renounce_candidacy_runners_up() -> Weight { + // Minimum execution time: 34_151 nanoseconds. + Weight::from_ref_time(34_813_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Benchmark Override (r:0 w:0) + fn remove_member_without_replacement() -> Weight { + // Minimum execution time: 2_000_000_000 nanoseconds. + Weight::from_ref_time(2_000_000_000_000 as u64) + } + // Storage: PhragmenElection Members (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: PhragmenElection RunnersUp (r:1 w:1) + // Storage: Council Prime (r:1 w:1) + // Storage: Council Proposals (r:1 w:0) + // Storage: Council Members (r:0 w:1) + fn remove_member_with_replacement() -> Weight { + // Minimum execution time: 59_230 nanoseconds. + Weight::from_ref_time(60_055_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) + } + // Storage: PhragmenElection Voting (r:5001 w:5000) + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: PhragmenElection RunnersUp (r:1 w:0) + // Storage: PhragmenElection Candidates (r:1 w:0) + // Storage: Balances Locks (r:5000 w:5000) + // Storage: System Account (r:5000 w:5000) + /// The range of component `v` is `[5000, 10000]`. + /// The range of component `d` is `[0, 5000]`. + fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight { + // Minimum execution time: 278_626_833 nanoseconds. + Weight::from_ref_time(279_736_954_000 as u64) + // Standard Error: 239_547 + .saturating_add(Weight::from_ref_time(34_254_809 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(v as u64))) + } + // Storage: PhragmenElection Candidates (r:1 w:1) + // Storage: PhragmenElection Members (r:1 w:1) + // Storage: PhragmenElection RunnersUp (r:1 w:1) + // Storage: PhragmenElection Voting (r:10001 w:0) + // Storage: Council Proposals (r:1 w:0) + // Storage: PhragmenElection ElectionRounds (r:1 w:1) + // Storage: Council Members (r:0 w:1) + // Storage: Council Prime (r:0 w:1) + // Storage: System Account (r:3 w:3) + /// The range of component `c` is `[1, 1000]`. + /// The range of component `v` is `[1, 10000]`. + /// The range of component `e` is `[10000, 160000]`. + fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight { + // Minimum execution time: 28_441_420 nanoseconds. + Weight::from_ref_time(28_674_262_000 as u64) + // Standard Error: 546_104 + .saturating_add(Weight::from_ref_time(45_370_047 as u64).saturating_mul(v as u64)) + // Standard Error: 35_045 + .saturating_add(Weight::from_ref_time(2_344_981 as u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(265 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + } +} diff --git a/runtime/rococo/src/weights/pallet_gilt.rs b/runtime/rococo/src/weights/pallet_gilt.rs new file mode 100644 index 000000000000..d49582396034 --- /dev/null +++ b/runtime/rococo/src/weights/pallet_gilt.rs @@ -0,0 +1,127 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_gilt` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_gilt +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_gilt`. +pub struct WeightInfo(PhantomData); +impl pallet_gilt::WeightInfo for WeightInfo { + // Storage: Gilt Queues (r:1 w:1) + // Storage: Gilt QueueTotals (r:1 w:1) + /// The range of component `l` is `[0, 999]`. + fn place_bid(l: u32, ) -> Weight { + // Minimum execution time: 37_199 nanoseconds. + Weight::from_ref_time(34_701_639 as u64) + // Standard Error: 698 + .saturating_add(Weight::from_ref_time(80_025 as u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Gilt Queues (r:1 w:1) + // Storage: Gilt QueueTotals (r:1 w:1) + fn place_bid_max() -> Weight { + // Minimum execution time: 103_025 nanoseconds. + Weight::from_ref_time(104_609_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Gilt Queues (r:1 w:1) + // Storage: Gilt QueueTotals (r:1 w:1) + /// The range of component `l` is `[1, 1000]`. + fn retract_bid(l: u32, ) -> Weight { + // Minimum execution time: 38_232 nanoseconds. + Weight::from_ref_time(35_611_328 as u64) + // Standard Error: 682 + .saturating_add(Weight::from_ref_time(61_944 as u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Gilt ActiveTotal (r:1 w:1) + fn set_target() -> Weight { + // Minimum execution time: 6_921 nanoseconds. + Weight::from_ref_time(7_130_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Gilt Active (r:1 w:1) + // Storage: Gilt ActiveTotal (r:1 w:1) + fn thaw() -> Weight { + // Minimum execution time: 46_291 nanoseconds. + Weight::from_ref_time(46_762_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Gilt ActiveTotal (r:1 w:0) + fn pursue_target_noop() -> Weight { + // Minimum execution time: 3_116 nanoseconds. + Weight::from_ref_time(3_268_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + } + // Storage: Gilt ActiveTotal (r:1 w:1) + // Storage: Gilt QueueTotals (r:1 w:1) + // Storage: Gilt Queues (r:1 w:1) + // Storage: Gilt Active (r:0 w:20) + /// The range of component `b` is `[0, 1000]`. + fn pursue_target_per_item(b: u32, ) -> Weight { + // Minimum execution time: 28_468 nanoseconds. + Weight::from_ref_time(29_472_202 as u64) + // Standard Error: 3_145 + .saturating_add(Weight::from_ref_time(4_024_451 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(b as u64))) + } + // Storage: Gilt ActiveTotal (r:1 w:1) + // Storage: Gilt QueueTotals (r:1 w:1) + // Storage: Gilt Queues (r:6 w:6) + // Storage: Gilt Active (r:0 w:6) + /// The range of component `q` is `[0, 300]`. + fn pursue_target_per_queue(q: u32, ) -> Weight { + // Minimum execution time: 28_371 nanoseconds. + Weight::from_ref_time(26_392_395 as u64) + // Standard Error: 7_213 + .saturating_add(Weight::from_ref_time(6_686_202 as u64).saturating_mul(q as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(q as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(q as u64))) + } +} diff --git a/runtime/rococo/src/weights/pallet_identity.rs b/runtime/rococo/src/weights/pallet_identity.rs new file mode 100644 index 000000000000..70ebeb3504ed --- /dev/null +++ b/runtime/rococo/src/weights/pallet_identity.rs @@ -0,0 +1,253 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_identity` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_identity +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_identity`. +pub struct WeightInfo(PhantomData); +impl pallet_identity::WeightInfo for WeightInfo { + // Storage: Identity Registrars (r:1 w:1) + /// The range of component `r` is `[1, 19]`. + fn add_registrar(r: u32, ) -> Weight { + // Minimum execution time: 16_642 nanoseconds. + Weight::from_ref_time(18_035_521 as u64) + // Standard Error: 3_625 + .saturating_add(Weight::from_ref_time(148_827 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Identity IdentityOf (r:1 w:1) + /// The range of component `r` is `[1, 20]`. + /// The range of component `x` is `[0, 100]`. + fn set_identity(r: u32, x: u32, ) -> Weight { + // Minimum execution time: 34_747 nanoseconds. + Weight::from_ref_time(34_532_655 as u64) + // Standard Error: 3_411 + .saturating_add(Weight::from_ref_time(80_073 as u64).saturating_mul(r as u64)) + // Standard Error: 665 + .saturating_add(Weight::from_ref_time(308_527 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Identity IdentityOf (r:1 w:0) + // Storage: Identity SubsOf (r:1 w:1) + // Storage: Identity SuperOf (r:2 w:2) + /// The range of component `s` is `[0, 100]`. + fn set_subs_new(s: u32, ) -> Weight { + // Minimum execution time: 9_852 nanoseconds. + Weight::from_ref_time(27_573_957 as u64) + // Standard Error: 4_818 + .saturating_add(Weight::from_ref_time(2_092_485 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) + } + // Storage: Identity IdentityOf (r:1 w:0) + // Storage: Identity SubsOf (r:1 w:1) + // Storage: Identity SuperOf (r:0 w:2) + /// The range of component `p` is `[0, 100]`. + fn set_subs_old(p: u32, ) -> Weight { + // Minimum execution time: 9_954 nanoseconds. + Weight::from_ref_time(27_765_722 as u64) + // Standard Error: 4_213 + .saturating_add(Weight::from_ref_time(905_843 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) + } + // Storage: Identity SubsOf (r:1 w:1) + // Storage: Identity IdentityOf (r:1 w:1) + // Storage: Identity SuperOf (r:0 w:100) + /// The range of component `r` is `[1, 20]`. + /// The range of component `s` is `[0, 100]`. + /// The range of component `x` is `[0, 100]`. + fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { + // Minimum execution time: 49_507 nanoseconds. + Weight::from_ref_time(35_702_864 as u64) + // Standard Error: 6_439 + .saturating_add(Weight::from_ref_time(84_332 as u64).saturating_mul(r as u64)) + // Standard Error: 1_257 + .saturating_add(Weight::from_ref_time(871_228 as u64).saturating_mul(s as u64)) + // Standard Error: 1_257 + .saturating_add(Weight::from_ref_time(161_551 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) + } + // Storage: Identity Registrars (r:1 w:0) + // Storage: Identity IdentityOf (r:1 w:1) + /// The range of component `r` is `[1, 20]`. + /// The range of component `x` is `[0, 100]`. + fn request_judgement(r: u32, x: u32, ) -> Weight { + // Minimum execution time: 37_215 nanoseconds. + Weight::from_ref_time(35_730_521 as u64) + // Standard Error: 4_756 + .saturating_add(Weight::from_ref_time(142_311 as u64).saturating_mul(r as u64)) + // Standard Error: 928 + .saturating_add(Weight::from_ref_time(329_605 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Identity IdentityOf (r:1 w:1) + /// The range of component `r` is `[1, 20]`. + /// The range of component `x` is `[0, 100]`. + fn cancel_request(r: u32, x: u32, ) -> Weight { + // Minimum execution time: 34_136 nanoseconds. + Weight::from_ref_time(32_639_742 as u64) + // Standard Error: 3_750 + .saturating_add(Weight::from_ref_time(99_769 as u64).saturating_mul(r as u64)) + // Standard Error: 731 + .saturating_add(Weight::from_ref_time(325_990 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Identity Registrars (r:1 w:1) + /// The range of component `r` is `[1, 19]`. + fn set_fee(r: u32, ) -> Weight { + // Minimum execution time: 8_676 nanoseconds. + Weight::from_ref_time(9_604_692 as u64) + // Standard Error: 2_429 + .saturating_add(Weight::from_ref_time(143_010 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Identity Registrars (r:1 w:1) + /// The range of component `r` is `[1, 19]`. + fn set_account_id(r: u32, ) -> Weight { + // Minimum execution time: 9_001 nanoseconds. + Weight::from_ref_time(9_939_836 as u64) + // Standard Error: 2_336 + .saturating_add(Weight::from_ref_time(124_249 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Identity Registrars (r:1 w:1) + /// The range of component `r` is `[1, 19]`. + fn set_fields(r: u32, ) -> Weight { + // Minimum execution time: 8_532 nanoseconds. + Weight::from_ref_time(9_666_826 as u64) + // Standard Error: 2_421 + .saturating_add(Weight::from_ref_time(132_033 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Identity Registrars (r:1 w:0) + // Storage: Identity IdentityOf (r:1 w:1) + /// The range of component `r` is `[1, 19]`. + /// The range of component `x` is `[0, 100]`. + fn provide_judgement(r: u32, x: u32, ) -> Weight { + // Minimum execution time: 27_590 nanoseconds. + Weight::from_ref_time(27_728_670 as u64) + // Standard Error: 6_540 + .saturating_add(Weight::from_ref_time(64_407 as u64).saturating_mul(r as u64)) + // Standard Error: 1_210 + .saturating_add(Weight::from_ref_time(555_394 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Identity SubsOf (r:1 w:1) + // Storage: Identity IdentityOf (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Identity SuperOf (r:0 w:100) + /// The range of component `r` is `[1, 20]`. + /// The range of component `s` is `[0, 100]`. + /// The range of component `x` is `[0, 100]`. + fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight { + // Minimum execution time: 61_955 nanoseconds. + Weight::from_ref_time(46_510_774 as u64) + // Standard Error: 4_608 + .saturating_add(Weight::from_ref_time(86_445 as u64).saturating_mul(r as u64)) + // Standard Error: 899 + .saturating_add(Weight::from_ref_time(881_362 as u64).saturating_mul(s as u64)) + // Standard Error: 899 + .saturating_add(Weight::from_ref_time(163_552 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) + } + // Storage: Identity IdentityOf (r:1 w:0) + // Storage: Identity SuperOf (r:1 w:1) + // Storage: Identity SubsOf (r:1 w:1) + /// The range of component `s` is `[0, 99]`. + fn add_sub(s: u32, ) -> Weight { + // Minimum execution time: 30_847 nanoseconds. + Weight::from_ref_time(36_838_521 as u64) + // Standard Error: 1_693 + .saturating_add(Weight::from_ref_time(76_909 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Identity IdentityOf (r:1 w:0) + // Storage: Identity SuperOf (r:1 w:1) + /// The range of component `s` is `[1, 100]`. + fn rename_sub(s: u32, ) -> Weight { + // Minimum execution time: 13_510 nanoseconds. + Weight::from_ref_time(15_952_774 as u64) + // Standard Error: 770 + .saturating_add(Weight::from_ref_time(28_646 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Identity IdentityOf (r:1 w:0) + // Storage: Identity SuperOf (r:1 w:1) + // Storage: Identity SubsOf (r:1 w:1) + /// The range of component `s` is `[1, 100]`. + fn remove_sub(s: u32, ) -> Weight { + // Minimum execution time: 34_391 nanoseconds. + Weight::from_ref_time(38_454_498 as u64) + // Standard Error: 1_269 + .saturating_add(Weight::from_ref_time(63_899 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Identity SuperOf (r:1 w:1) + // Storage: Identity SubsOf (r:1 w:1) + /// The range of component `s` is `[0, 99]`. + fn quit_sub(s: u32, ) -> Weight { + // Minimum execution time: 24_290 nanoseconds. + Weight::from_ref_time(28_022_763 as u64) + // Standard Error: 1_224 + .saturating_add(Weight::from_ref_time(66_833 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } +} diff --git a/runtime/rococo/src/weights/pallet_im_online.rs b/runtime/rococo/src/weights/pallet_im_online.rs index 80026a35aa3e..a74b39b76898 100644 --- a/runtime/rococo/src/weights/pallet_im_online.rs +++ b/runtime/rococo/src/weights/pallet_im_online.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_im_online` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/rococo/src/weights/pallet_im_online.rs +// --output=./runtime/rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -53,12 +53,13 @@ impl pallet_im_online::WeightInfo for WeightInfo { /// The range of component `k` is `[1, 1000]`. /// The range of component `e` is `[1, 100]`. fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight { - (74_601_000 as Weight) - // Standard Error: 0 - .saturating_add((27_000 as Weight).saturating_mul(k as Weight)) - // Standard Error: 3_000 - .saturating_add((337_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 95_841 nanoseconds. + Weight::from_ref_time(77_009_555 as u64) + // Standard Error: 346 + .saturating_add(Weight::from_ref_time(24_371 as u64).saturating_mul(k as u64)) + // Standard Error: 3_490 + .saturating_add(Weight::from_ref_time(315_554 as u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/rococo/src/weights/pallet_indices.rs b/runtime/rococo/src/weights/pallet_indices.rs index f50130575cc4..34aba445dc17 100644 --- a/runtime/rococo/src/weights/pallet_indices.rs +++ b/runtime/rococo/src/weights/pallet_indices.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_indices` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/rococo/src/weights/pallet_indices.rs +// --output=./runtime/rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,34 +46,39 @@ pub struct WeightInfo(PhantomData); impl pallet_indices::WeightInfo for WeightInfo { // Storage: Indices Accounts (r:1 w:1) fn claim() -> Weight { - (23_133_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_145 nanoseconds. + Weight::from_ref_time(25_606_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (27_865_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 30_827 nanoseconds. + Weight::from_ref_time(31_599_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Indices Accounts (r:1 w:1) fn free() -> Weight { - (23_625_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_537 nanoseconds. + Weight::from_ref_time(26_081_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn force_transfer() -> Weight { - (24_179_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 26_069 nanoseconds. + Weight::from_ref_time(26_540_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Indices Accounts (r:1 w:1) fn freeze() -> Weight { - (26_857_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 31_344 nanoseconds. + Weight::from_ref_time(31_825_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/rococo/src/weights/pallet_membership.rs b/runtime/rococo/src/weights/pallet_membership.rs index caf5cd4e32ea..e890a40f28c0 100644 --- a/runtime/rococo/src/weights/pallet_membership.rs +++ b/runtime/rococo/src/weights/pallet_membership.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_membership` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/rococo/src/weights/pallet_membership.rs +// --output=./runtime/rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -44,88 +44,95 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_membership`. pub struct WeightInfo(PhantomData); impl pallet_membership::WeightInfo for WeightInfo { - // Storage: Membership Members (r:1 w:1) - // Storage: Collective Proposals (r:1 w:0) - // Storage: Collective Members (r:0 w:1) - // Storage: Collective Prime (r:0 w:1) + // Storage: TechnicalMembership Members (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:0) + // Storage: TechnicalCommittee Members (r:0 w:1) + // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 99]`. fn add_member(m: u32, ) -> Weight { - (16_814_000 as Weight) - // Standard Error: 0 - .saturating_add((60_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 20_314 nanoseconds. + Weight::from_ref_time(20_916_793 as u64) + // Standard Error: 390 + .saturating_add(Weight::from_ref_time(41_741 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Membership Members (r:1 w:1) - // Storage: Collective Proposals (r:1 w:0) - // Storage: Membership Prime (r:1 w:0) - // Storage: Collective Members (r:0 w:1) - // Storage: Collective Prime (r:0 w:1) + // Storage: TechnicalMembership Members (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:0) + // Storage: TechnicalMembership Prime (r:1 w:0) + // Storage: TechnicalCommittee Members (r:0 w:1) + // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[2, 100]`. fn remove_member(m: u32, ) -> Weight { - (19_124_000 as Weight) - // Standard Error: 0 - .saturating_add((51_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 23_137 nanoseconds. + Weight::from_ref_time(23_518_466 as u64) + // Standard Error: 465 + .saturating_add(Weight::from_ref_time(36_105 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Membership Members (r:1 w:1) - // Storage: Collective Proposals (r:1 w:0) - // Storage: Membership Prime (r:1 w:0) - // Storage: Collective Members (r:0 w:1) - // Storage: Collective Prime (r:0 w:1) + // Storage: TechnicalMembership Members (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:0) + // Storage: TechnicalMembership Prime (r:1 w:0) + // Storage: TechnicalCommittee Members (r:0 w:1) + // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[2, 100]`. fn swap_member(m: u32, ) -> Weight { - (19_143_000 as Weight) - // Standard Error: 0 - .saturating_add((63_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 22_933 nanoseconds. + Weight::from_ref_time(23_505_635 as u64) + // Standard Error: 555 + .saturating_add(Weight::from_ref_time(47_816 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Membership Members (r:1 w:1) - // Storage: Collective Proposals (r:1 w:0) - // Storage: Membership Prime (r:1 w:0) - // Storage: Collective Members (r:0 w:1) - // Storage: Collective Prime (r:0 w:1) + // Storage: TechnicalMembership Members (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:0) + // Storage: TechnicalMembership Prime (r:1 w:0) + // Storage: TechnicalCommittee Members (r:0 w:1) + // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn reset_member(m: u32, ) -> Weight { - (18_621_000 as Weight) - // Standard Error: 0 - .saturating_add((186_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 22_168 nanoseconds. + Weight::from_ref_time(23_311_086 as u64) + // Standard Error: 1_186 + .saturating_add(Weight::from_ref_time(163_040 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } - // Storage: Membership Members (r:1 w:1) - // Storage: Collective Proposals (r:1 w:0) - // Storage: Membership Prime (r:1 w:1) - // Storage: Collective Members (r:0 w:1) - // Storage: Collective Prime (r:0 w:1) + // Storage: TechnicalMembership Members (r:1 w:1) + // Storage: TechnicalCommittee Proposals (r:1 w:0) + // Storage: TechnicalMembership Prime (r:1 w:1) + // Storage: TechnicalCommittee Members (r:0 w:1) + // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn change_key(m: u32, ) -> Weight { - (19_913_000 as Weight) - // Standard Error: 0 - .saturating_add((58_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 22_971 nanoseconds. + Weight::from_ref_time(24_067_443 as u64) + // Standard Error: 566 + .saturating_add(Weight::from_ref_time(49_410 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } - // Storage: Membership Members (r:1 w:0) - // Storage: Membership Prime (r:0 w:1) - // Storage: Collective Prime (r:0 w:1) + // Storage: TechnicalMembership Members (r:1 w:0) + // Storage: TechnicalMembership Prime (r:0 w:1) + // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn set_prime(m: u32, ) -> Weight { - (6_445_000 as Weight) - // Standard Error: 0 - .saturating_add((10_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 8_505 nanoseconds. + Weight::from_ref_time(8_976_375 as u64) + // Standard Error: 220 + .saturating_add(Weight::from_ref_time(10_869 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } - // Storage: Membership Prime (r:0 w:1) - // Storage: Collective Prime (r:0 w:1) + // Storage: TechnicalMembership Prime (r:0 w:1) + // Storage: TechnicalCommittee Prime (r:0 w:1) /// The range of component `m` is `[1, 100]`. fn clear_prime(m: u32, ) -> Weight { - (3_524_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(m as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 5_032 nanoseconds. + Weight::from_ref_time(5_347_858 as u64) + // Standard Error: 156 + .saturating_add(Weight::from_ref_time(647 as u64).saturating_mul(m as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/rococo/src/weights/pallet_multisig.rs b/runtime/rococo/src/weights/pallet_multisig.rs index 59b75b9764b8..300e4704ef8d 100644 --- a/runtime/rococo/src/weights/pallet_multisig.rs +++ b/runtime/rococo/src/weights/pallet_multisig.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_multisig` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -28,11 +28,11 @@ // --steps=50 // --repeat=20 // --pallet=pallet_multisig -// --extrinsic=* +// --extrinsic= // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/rococo/src/weights/pallet_multisig.rs +// --output=runtime/rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,115 +46,81 @@ pub struct WeightInfo(PhantomData); impl pallet_multisig::WeightInfo for WeightInfo { /// The range of component `z` is `[0, 10000]`. fn as_multi_threshold_1(z: u32, ) -> Weight { - (14_606_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) + // Minimum execution time: 14_582 nanoseconds. + Weight::from_ref_time(15_014_888 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(490 as u64).saturating_mul(z as u64)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_create(s: u32, z: u32, ) -> Weight { - (29_880_000 as Weight) - // Standard Error: 0 - .saturating_add((100_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) - /// The range of component `s` is `[2, 100]`. - /// The range of component `z` is `[0, 10000]`. - fn as_multi_create_store(s: u32, z: u32, ) -> Weight { - (31_636_000 as Weight) - // Standard Error: 0 - .saturating_add((108_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 41_651 nanoseconds. + Weight::from_ref_time(34_224_425 as u64) + // Standard Error: 735 + .saturating_add(Weight::from_ref_time(80_357 as u64).saturating_mul(s as u64)) + // Standard Error: 7 + .saturating_add(Weight::from_ref_time(1_489 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) /// The range of component `s` is `[3, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_approve(s: u32, z: u32, ) -> Weight { - (19_551_000 as Weight) - // Standard Error: 0 - .saturating_add((104_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 31_520 nanoseconds. + Weight::from_ref_time(24_283_932 as u64) + // Standard Error: 615 + .saturating_add(Weight::from_ref_time(80_034 as u64).saturating_mul(s as u64)) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(1_490 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - /// The range of component `s` is `[3, 100]`. - /// The range of component `z` is `[0, 10000]`. - fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { - (31_196_000 as Weight) - // Standard Error: 0 - .saturating_add((123_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_complete(s: u32, z: u32, ) -> Weight { - (39_982_000 as Weight) - // Standard Error: 0 - .saturating_add((131_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 44_639 nanoseconds. + Weight::from_ref_time(35_788_014 as u64) + // Standard Error: 655 + .saturating_add(Weight::from_ref_time(103_738 as u64).saturating_mul(s as u64)) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(1_480 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_create(s: u32, ) -> Weight { - (28_767_000 as Weight) - // Standard Error: 0 - .saturating_add((113_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 30_092 nanoseconds. + Weight::from_ref_time(32_588_553 as u64) + // Standard Error: 1_203 + .saturating_add(Weight::from_ref_time(88_907 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:0) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_approve(s: u32, ) -> Weight { - (18_649_000 as Weight) - // Standard Error: 0 - .saturating_add((110_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - // Storage: System Account (r:1 w:1) - /// The range of component `s` is `[2, 100]`. - fn approve_as_multi_complete(s: u32, ) -> Weight { - (63_055_000 as Weight) - // Standard Error: 1_000 - .saturating_add((134_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 21_743 nanoseconds. + Weight::from_ref_time(23_807_430 as u64) + // Standard Error: 828 + .saturating_add(Weight::from_ref_time(75_548 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) /// The range of component `s` is `[2, 100]`. fn cancel_as_multi(s: u32, ) -> Weight { - (44_870_000 as Weight) - // Standard Error: 0 - .saturating_add((115_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 29_786 nanoseconds. + Weight::from_ref_time(32_090_251 as u64) + // Standard Error: 904 + .saturating_add(Weight::from_ref_time(84_395 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/rococo/src/weights/pallet_preimage.rs b/runtime/rococo/src/weights/pallet_preimage.rs new file mode 100644 index 000000000000..a3c15353ec6e --- /dev/null +++ b/runtime/rococo/src/weights/pallet_preimage.rs @@ -0,0 +1,146 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_preimage` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_preimage +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_preimage`. +pub struct WeightInfo(PhantomData); +impl pallet_preimage::WeightInfo for WeightInfo { + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + /// The range of component `s` is `[0, 4194304]`. + fn note_preimage(s: u32, ) -> Weight { + // Minimum execution time: 28_627 nanoseconds. + Weight::from_ref_time(28_863_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_343 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + /// The range of component `s` is `[0, 4194304]`. + fn note_requested_preimage(s: u32, ) -> Weight { + // Minimum execution time: 19_969 nanoseconds. + Weight::from_ref_time(20_415_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_343 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + /// The range of component `s` is `[0, 4194304]`. + fn note_no_deposit_preimage(s: u32, ) -> Weight { + // Minimum execution time: 18_634 nanoseconds. + Weight::from_ref_time(19_004_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_346 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn unnote_preimage() -> Weight { + // Minimum execution time: 41_505 nanoseconds. + Weight::from_ref_time(42_764_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn unnote_no_deposit_preimage() -> Weight { + // Minimum execution time: 28_640 nanoseconds. + Weight::from_ref_time(30_140_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_preimage() -> Weight { + // Minimum execution time: 26_358 nanoseconds. + Weight::from_ref_time(27_371_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_no_deposit_preimage() -> Weight { + // Minimum execution time: 14_281 nanoseconds. + Weight::from_ref_time(15_392_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_unnoted_preimage() -> Weight { + // Minimum execution time: 17_828 nanoseconds. + Weight::from_ref_time(18_469_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn request_requested_preimage() -> Weight { + // Minimum execution time: 8_776 nanoseconds. + Weight::from_ref_time(9_054_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) + fn unrequest_preimage() -> Weight { + // Minimum execution time: 26_343 nanoseconds. + Weight::from_ref_time(27_704_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn unrequest_unnoted_preimage() -> Weight { + // Minimum execution time: 8_730 nanoseconds. + Weight::from_ref_time(9_214_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Preimage StatusFor (r:1 w:1) + fn unrequest_multi_referenced_preimage() -> Weight { + // Minimum execution time: 8_970 nanoseconds. + Weight::from_ref_time(9_308_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } +} diff --git a/runtime/rococo/src/weights/pallet_proxy.rs b/runtime/rococo/src/weights/pallet_proxy.rs index 5c5474c8eb22..cace8999b42f 100644 --- a/runtime/rococo/src/weights/pallet_proxy.rs +++ b/runtime/rococo/src/weights/pallet_proxy.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_proxy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/rococo/src/weights/pallet_proxy.rs +// --output=./runtime/rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,10 +47,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Storage: Proxy Proxies (r:1 w:0) /// The range of component `p` is `[1, 31]`. fn proxy(p: u32, ) -> Weight { - (17_762_000 as Weight) - // Standard Error: 1_000 - .saturating_add((68_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + // Minimum execution time: 19_349 nanoseconds. + Weight::from_ref_time(20_710_623 as u64) + // Standard Error: 1_351 + .saturating_add(Weight::from_ref_time(52_752 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) @@ -58,37 +59,42 @@ impl pallet_proxy::WeightInfo for WeightInfo { /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn proxy_announced(a: u32, p: u32, ) -> Weight { - (33_577_000 as Weight) - // Standard Error: 1_000 - .saturating_add((188_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((42_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 37_890 nanoseconds. + Weight::from_ref_time(37_761_529 as u64) + // Standard Error: 2_006 + .saturating_add(Weight::from_ref_time(126_746 as u64).saturating_mul(a as u64)) + // Standard Error: 2_072 + .saturating_add(Weight::from_ref_time(28_850 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. - fn remove_announcement(a: u32, _p: u32, ) -> Weight { - (22_715_000 as Weight) - // Standard Error: 1_000 - .saturating_add((179_000 as Weight).saturating_mul(a as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn remove_announcement(a: u32, p: u32, ) -> Weight { + // Minimum execution time: 25_409 nanoseconds. + Weight::from_ref_time(27_189_943 as u64) + // Standard Error: 2_128 + .saturating_add(Weight::from_ref_time(106_009 as u64).saturating_mul(a as u64)) + // Standard Error: 2_199 + .saturating_add(Weight::from_ref_time(2_285 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn reject_announcement(a: u32, p: u32, ) -> Weight { - (22_349_000 as Weight) - // Standard Error: 1_000 - .saturating_add((179_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((5_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 25_412 nanoseconds. + Weight::from_ref_time(26_386_788 as u64) + // Standard Error: 1_834 + .saturating_add(Weight::from_ref_time(135_933 as u64).saturating_mul(a as u64)) + // Standard Error: 1_895 + .saturating_add(Weight::from_ref_time(11_946 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) @@ -96,58 +102,64 @@ impl pallet_proxy::WeightInfo for WeightInfo { /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn announce(a: u32, p: u32, ) -> Weight { - (29_863_000 as Weight) - // Standard Error: 2_000 - .saturating_add((182_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 2_000 - .saturating_add((55_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 33_674 nanoseconds. + Weight::from_ref_time(34_928_865 as u64) + // Standard Error: 1_877 + .saturating_add(Weight::from_ref_time(114_320 as u64).saturating_mul(a as u64)) + // Standard Error: 1_939 + .saturating_add(Weight::from_ref_time(33_723 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn add_proxy(p: u32, ) -> Weight { - (24_976_000 as Weight) - // Standard Error: 2_000 - .saturating_add((101_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_886 nanoseconds. + Weight::from_ref_time(28_261_342 as u64) + // Standard Error: 1_938 + .saturating_add(Weight::from_ref_time(84_834 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn remove_proxy(p: u32, ) -> Weight { - (24_934_000 as Weight) - // Standard Error: 2_000 - .saturating_add((118_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 27_043 nanoseconds. + Weight::from_ref_time(28_490_904 as u64) + // Standard Error: 2_037 + .saturating_add(Weight::from_ref_time(89_429 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn remove_proxies(p: u32, ) -> Weight { - (20_930_000 as Weight) - // Standard Error: 1_000 - .saturating_add((68_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 23_223 nanoseconds. + Weight::from_ref_time(24_336_319 as u64) + // Standard Error: 1_732 + .saturating_add(Weight::from_ref_time(62_231 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. - fn anonymous(p: u32, ) -> Weight { - (28_030_000 as Weight) - // Standard Error: 2_000 - .saturating_add((33_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn create_pure(p: u32, ) -> Weight { + // Minimum execution time: 29_651 nanoseconds. + Weight::from_ref_time(31_071_450 as u64) + // Standard Error: 1_749 + .saturating_add(Weight::from_ref_time(43_722 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[0, 30]`. - fn kill_anonymous(p: u32, ) -> Weight { - (21_753_000 as Weight) - // Standard Error: 1_000 - .saturating_add((69_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn kill_pure(p: u32, ) -> Weight { + // Minimum execution time: 24_984 nanoseconds. + Weight::from_ref_time(25_992_953 as u64) + // Standard Error: 1_517 + .saturating_add(Weight::from_ref_time(37_535 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/rococo/src/weights/pallet_scheduler.rs b/runtime/rococo/src/weights/pallet_scheduler.rs new file mode 100644 index 000000000000..9235b53bc99f --- /dev/null +++ b/runtime/rococo/src/weights/pallet_scheduler.rs @@ -0,0 +1,140 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_scheduler` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_scheduler +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_scheduler`. +pub struct WeightInfo(PhantomData); +impl pallet_scheduler::WeightInfo for WeightInfo { + // Storage: Scheduler IncompleteSince (r:1 w:1) + fn service_agendas_base() -> Weight { + // Minimum execution time: 4_557 nanoseconds. + Weight::from_ref_time(4_735_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Scheduler Agenda (r:1 w:1) + /// The range of component `s` is `[0, 50]`. + fn service_agenda_base(s: u32, ) -> Weight { + // Minimum execution time: 4_123 nanoseconds. + Weight::from_ref_time(7_485_674 as u64) + // Standard Error: 2_415 + .saturating_add(Weight::from_ref_time(707_572 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + fn service_task_base() -> Weight { + // Minimum execution time: 9_030 nanoseconds. + Weight::from_ref_time(9_340_000 as u64) + } + // Storage: Preimage PreimageFor (r:1 w:1) + // Storage: Preimage StatusFor (r:1 w:1) + /// The range of component `s` is `[128, 4194304]`. + fn service_task_fetched(s: u32, ) -> Weight { + // Minimum execution time: 20_581 nanoseconds. + Weight::from_ref_time(20_784_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(1_249 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Scheduler Lookup (r:0 w:1) + fn service_task_named() -> Weight { + // Minimum execution time: 10_448 nanoseconds. + Weight::from_ref_time(10_764_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + fn service_task_periodic() -> Weight { + // Minimum execution time: 9_244 nanoseconds. + Weight::from_ref_time(9_450_000 as u64) + } + fn execute_dispatch_signed() -> Weight { + // Minimum execution time: 4_183 nanoseconds. + Weight::from_ref_time(4_335_000 as u64) + } + fn execute_dispatch_unsigned() -> Weight { + // Minimum execution time: 4_242 nanoseconds. + Weight::from_ref_time(4_436_000 as u64) + } + // Storage: Scheduler Agenda (r:1 w:1) + /// The range of component `s` is `[0, 49]`. + fn schedule(s: u32, ) -> Weight { + // Minimum execution time: 16_915 nanoseconds. + Weight::from_ref_time(21_627_553 as u64) + // Standard Error: 2_885 + .saturating_add(Weight::from_ref_time(728_852 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Scheduler Agenda (r:1 w:1) + // Storage: Scheduler Lookup (r:0 w:1) + /// The range of component `s` is `[1, 50]`. + fn cancel(s: u32, ) -> Weight { + // Minimum execution time: 20_645 nanoseconds. + Weight::from_ref_time(21_916_728 as u64) + // Standard Error: 2_121 + .saturating_add(Weight::from_ref_time(726_255 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + /// The range of component `s` is `[0, 49]`. + fn schedule_named(s: u32, ) -> Weight { + // Minimum execution time: 19_875 nanoseconds. + Weight::from_ref_time(24_957_647 as u64) + // Standard Error: 3_447 + .saturating_add(Weight::from_ref_time(756_011 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + /// The range of component `s` is `[1, 50]`. + fn cancel_named(s: u32, ) -> Weight { + // Minimum execution time: 20_760 nanoseconds. + Weight::from_ref_time(23_427_367 as u64) + // Standard Error: 2_686 + .saturating_add(Weight::from_ref_time(741_188 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } +} diff --git a/runtime/rococo/src/weights/pallet_session.rs b/runtime/rococo/src/weights/pallet_session.rs index 5583fde83fae..e2ee85f0bba0 100644 --- a/runtime/rococo/src/weights/pallet_session.rs +++ b/runtime/rococo/src/weights/pallet_session.rs @@ -22,7 +22,7 @@ // Executed Command: // ./target/production/polkadot // benchmark -// --chain=polkadot-dev +// --chain=rococo-dev // --steps=50 // --repeat=20 // --pallet=pallet_session @@ -47,16 +47,16 @@ impl pallet_session::WeightInfo for WeightInfo { // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:6 w:6) fn set_keys() -> Weight { - (36_115_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(36_115_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:0 w:6) fn purge_keys() -> Weight { - (21_459_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(21_459_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } } diff --git a/runtime/rococo/src/weights/pallet_timestamp.rs b/runtime/rococo/src/weights/pallet_timestamp.rs index fff1e2c5457b..f4e3c4ef5f4b 100644 --- a/runtime/rococo/src/weights/pallet_timestamp.rs +++ b/runtime/rococo/src/weights/pallet_timestamp.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/rococo/src/weights/pallet_timestamp.rs +// --output=./runtime/rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,11 +47,13 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Storage: Timestamp Now (r:1 w:1) // Storage: Babe CurrentSlot (r:1 w:0) fn set() -> Weight { - (7_692_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 9_159 nanoseconds. + Weight::from_ref_time(9_363_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } fn on_finalize() -> Weight { - (2_091_000 as Weight) + // Minimum execution time: 3_854 nanoseconds. + Weight::from_ref_time(3_959_000 as u64) } } diff --git a/runtime/rococo/src/weights/pallet_tips.rs b/runtime/rococo/src/weights/pallet_tips.rs new file mode 100644 index 000000000000..40fcba022275 --- /dev/null +++ b/runtime/rococo/src/weights/pallet_tips.rs @@ -0,0 +1,116 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_tips` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_tips +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_tips`. +pub struct WeightInfo(PhantomData); +impl pallet_tips::WeightInfo for WeightInfo { + // Storage: Tips Reasons (r:1 w:1) + // Storage: Tips Tips (r:1 w:1) + /// The range of component `r` is `[0, 16384]`. + fn report_awesome(r: u32, ) -> Weight { + // Minimum execution time: 28_992 nanoseconds. + Weight::from_ref_time(30_902_302 as u64) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(1_812 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Tips Tips (r:1 w:1) + // Storage: Tips Reasons (r:0 w:1) + fn retract_tip() -> Weight { + // Minimum execution time: 28_865 nanoseconds. + Weight::from_ref_time(29_465_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: Tips Reasons (r:1 w:1) + // Storage: Tips Tips (r:0 w:1) + /// The range of component `r` is `[0, 16384]`. + /// The range of component `t` is `[1, 19]`. + fn tip_new(r: u32, t: u32, ) -> Weight { + // Minimum execution time: 22_554 nanoseconds. + Weight::from_ref_time(21_588_889 as u64) + // Standard Error: 5 + .saturating_add(Weight::from_ref_time(1_684 as u64).saturating_mul(r as u64)) + // Standard Error: 5_031 + .saturating_add(Weight::from_ref_time(137_050 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: Tips Tips (r:1 w:1) + /// The range of component `t` is `[1, 19]`. + fn tip(t: u32, ) -> Weight { + // Minimum execution time: 14_818 nanoseconds. + Weight::from_ref_time(15_146_027 as u64) + // Standard Error: 1_730 + .saturating_add(Weight::from_ref_time(153_924 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Tips Tips (r:1 w:1) + // Storage: PhragmenElection Members (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Tips Reasons (r:0 w:1) + /// The range of component `t` is `[1, 19]`. + fn close_tip(t: u32, ) -> Weight { + // Minimum execution time: 44_644 nanoseconds. + Weight::from_ref_time(46_503_793 as u64) + // Standard Error: 5_514 + .saturating_add(Weight::from_ref_time(136_316 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Tips Tips (r:1 w:1) + // Storage: Tips Reasons (r:0 w:1) + /// The range of component `t` is `[1, 19]`. + fn slash_tip(t: u32, ) -> Weight { + // Minimum execution time: 18_898 nanoseconds. + Weight::from_ref_time(19_650_499 as u64) + // Standard Error: 1_216 + .saturating_add(Weight::from_ref_time(39_484 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } +} diff --git a/runtime/rococo/src/weights/pallet_treasury.rs b/runtime/rococo/src/weights/pallet_treasury.rs new file mode 100644 index 000000000000..035eeb5080b2 --- /dev/null +++ b/runtime/rococo/src/weights/pallet_treasury.rs @@ -0,0 +1,100 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_treasury` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_treasury +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_treasury`. +pub struct WeightInfo(PhantomData); +impl pallet_treasury::WeightInfo for WeightInfo { + fn spend() -> Weight { + // Minimum execution time: 170 nanoseconds. + Weight::from_ref_time(193_000 as u64) + } + // Storage: Treasury ProposalCount (r:1 w:1) + // Storage: Treasury Proposals (r:0 w:1) + fn propose_spend() -> Weight { + // Minimum execution time: 26_763 nanoseconds. + Weight::from_ref_time(27_128_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Treasury Proposals (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn reject_proposal() -> Weight { + // Minimum execution time: 37_824 nanoseconds. + Weight::from_ref_time(38_527_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Treasury Proposals (r:1 w:0) + // Storage: Treasury Approvals (r:1 w:1) + /// The range of component `p` is `[0, 99]`. + fn approve_proposal(p: u32, ) -> Weight { + // Minimum execution time: 10_008 nanoseconds. + Weight::from_ref_time(13_421_017 as u64) + // Standard Error: 1_118 + .saturating_add(Weight::from_ref_time(41_405 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Treasury Approvals (r:1 w:1) + fn remove_approval() -> Weight { + // Minimum execution time: 7_923 nanoseconds. + Weight::from_ref_time(8_051_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: Treasury Approvals (r:1 w:1) + // Storage: Bounties BountyApprovals (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Treasury Proposals (r:2 w:2) + /// The range of component `p` is `[0, 100]`. + fn on_initialize_proposals(p: u32, ) -> Weight { + // Minimum execution time: 47_732 nanoseconds. + Weight::from_ref_time(57_707_558 as u64) + // Standard Error: 22_526 + .saturating_add(Weight::from_ref_time(24_251_356 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(p as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(p as u64))) + } +} diff --git a/runtime/rococo/src/weights/pallet_utility.rs b/runtime/rococo/src/weights/pallet_utility.rs index e0e949789c63..b40c3847fa1a 100644 --- a/runtime/rococo/src/weights/pallet_utility.rs +++ b/runtime/rococo/src/weights/pallet_utility.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/rococo/src/weights/pallet_utility.rs +// --output=./runtime/rococo/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,26 +46,31 @@ pub struct WeightInfo(PhantomData); impl pallet_utility::WeightInfo for WeightInfo { /// The range of component `c` is `[0, 1000]`. fn batch(c: u32, ) -> Weight { - (12_533_000 as Weight) - // Standard Error: 2_000 - .saturating_add((5_050_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 11_223 nanoseconds. + Weight::from_ref_time(20_119_148 as u64) + // Standard Error: 2_555 + .saturating_add(Weight::from_ref_time(3_607_766 as u64).saturating_mul(c as u64)) } fn as_derivative() -> Weight { - (5_794_000 as Weight) + // Minimum execution time: 6_008 nanoseconds. + Weight::from_ref_time(6_173_000 as u64) } /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32, ) -> Weight { - (12_581_000 as Weight) - // Standard Error: 2_000 - .saturating_add((5_336_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 11_021 nanoseconds. + Weight::from_ref_time(20_490_374 as u64) + // Standard Error: 2_716 + .saturating_add(Weight::from_ref_time(3_772_423 as u64).saturating_mul(c as u64)) } fn dispatch_as() -> Weight { - (12_912_000 as Weight) + // Minimum execution time: 13_528 nanoseconds. + Weight::from_ref_time(13_792_000 as u64) } /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32, ) -> Weight { - (7_075_000 as Weight) - // Standard Error: 3_000 - .saturating_add((5_067_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 11_349 nanoseconds. + Weight::from_ref_time(14_365_442 as u64) + // Standard Error: 2_571 + .saturating_add(Weight::from_ref_time(3_618_172 as u64).saturating_mul(c as u64)) } } diff --git a/runtime/rococo/src/weights/pallet_vesting.rs b/runtime/rococo/src/weights/pallet_vesting.rs new file mode 100644 index 000000000000..b080efd9fe5e --- /dev/null +++ b/runtime/rococo/src/weights/pallet_vesting.rs @@ -0,0 +1,165 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_vesting` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_vesting +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_vesting`. +pub struct WeightInfo(PhantomData); +impl pallet_vesting::WeightInfo for WeightInfo { + // Storage: Vesting Vesting (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + /// The range of component `l` is `[0, 49]`. + /// The range of component `s` is `[1, 28]`. + fn vest_locked(l: u32, s: u32, ) -> Weight { + // Minimum execution time: 36_043 nanoseconds. + Weight::from_ref_time(34_972_032 as u64) + // Standard Error: 1_941 + .saturating_add(Weight::from_ref_time(49_687 as u64).saturating_mul(l as u64)) + // Standard Error: 3_453 + .saturating_add(Weight::from_ref_time(83_831 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Vesting Vesting (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + /// The range of component `l` is `[0, 49]`. + /// The range of component `s` is `[1, 28]`. + fn vest_unlocked(l: u32, s: u32, ) -> Weight { + // Minimum execution time: 35_347 nanoseconds. + Weight::from_ref_time(34_849_877 as u64) + // Standard Error: 1_067 + .saturating_add(Weight::from_ref_time(44_302 as u64).saturating_mul(l as u64)) + // Standard Error: 1_899 + .saturating_add(Weight::from_ref_time(60_583 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: Vesting Vesting (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + /// The range of component `l` is `[0, 49]`. + /// The range of component `s` is `[1, 28]`. + fn vest_other_locked(l: u32, s: u32, ) -> Weight { + // Minimum execution time: 35_931 nanoseconds. + Weight::from_ref_time(34_563_114 as u64) + // Standard Error: 1_021 + .saturating_add(Weight::from_ref_time(51_575 as u64).saturating_mul(l as u64)) + // Standard Error: 1_817 + .saturating_add(Weight::from_ref_time(77_319 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Vesting Vesting (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + /// The range of component `l` is `[0, 49]`. + /// The range of component `s` is `[1, 28]`. + fn vest_other_unlocked(l: u32, s: u32, ) -> Weight { + // Minimum execution time: 35_236 nanoseconds. + Weight::from_ref_time(34_400_789 as u64) + // Standard Error: 1_024 + .saturating_add(Weight::from_ref_time(42_895 as u64).saturating_mul(l as u64)) + // Standard Error: 1_822 + .saturating_add(Weight::from_ref_time(63_821 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Vesting Vesting (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + /// The range of component `l` is `[0, 49]`. + /// The range of component `s` is `[0, 27]`. + fn vested_transfer(l: u32, s: u32, ) -> Weight { + // Minimum execution time: 49_264 nanoseconds. + Weight::from_ref_time(48_873_608 as u64) + // Standard Error: 4_414 + .saturating_add(Weight::from_ref_time(57_567 as u64).saturating_mul(l as u64)) + // Standard Error: 7_854 + .saturating_add(Weight::from_ref_time(59_806 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Vesting Vesting (r:1 w:1) + // Storage: System Account (r:2 w:2) + // Storage: Balances Locks (r:1 w:1) + /// The range of component `l` is `[0, 49]`. + /// The range of component `s` is `[0, 27]`. + fn force_vested_transfer(l: u32, s: u32, ) -> Weight { + // Minimum execution time: 48_572 nanoseconds. + Weight::from_ref_time(49_272_636 as u64) + // Standard Error: 2_054 + .saturating_add(Weight::from_ref_time(40_021 as u64).saturating_mul(l as u64)) + // Standard Error: 3_654 + .saturating_add(Weight::from_ref_time(27_590 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: Vesting Vesting (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + /// The range of component `l` is `[0, 49]`. + /// The range of component `s` is `[2, 28]`. + fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { + // Minimum execution time: 37_312 nanoseconds. + Weight::from_ref_time(36_432_962 as u64) + // Standard Error: 1_100 + .saturating_add(Weight::from_ref_time(45_567 as u64).saturating_mul(l as u64)) + // Standard Error: 2_032 + .saturating_add(Weight::from_ref_time(67_536 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: Vesting Vesting (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: System Account (r:1 w:1) + /// The range of component `l` is `[0, 49]`. + /// The range of component `s` is `[2, 28]`. + fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { + // Minimum execution time: 37_279 nanoseconds. + Weight::from_ref_time(36_099_205 as u64) + // Standard Error: 1_049 + .saturating_add(Weight::from_ref_time(46_654 as u64).saturating_mul(l as u64)) + // Standard Error: 1_939 + .saturating_add(Weight::from_ref_time(80_111 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } +} diff --git a/runtime/rococo/src/weights/runtime_common_auctions.rs b/runtime/rococo/src/weights/runtime_common_auctions.rs index c3f560c32f3c..9646ff3f7011 100644 --- a/runtime/rococo/src/weights/runtime_common_auctions.rs +++ b/runtime/rococo/src/weights/runtime_common_auctions.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::auctions` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -47,9 +47,10 @@ impl runtime_common::auctions::WeightInfo for WeightInf // Storage: Auctions AuctionInfo (r:1 w:1) // Storage: Auctions AuctionCounter (r:1 w:1) fn new_auction() -> Weight { - (15_406_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 16_469 nanoseconds. + Weight::from_ref_time(16_963_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Paras ParaLifecycles (r:1 w:0) // Storage: Auctions AuctionCounter (r:1 w:0) @@ -59,34 +60,37 @@ impl runtime_common::auctions::WeightInfo for WeightInf // Storage: Auctions ReservedAmounts (r:2 w:2) // Storage: System Account (r:1 w:1) fn bid() -> Weight { - (70_846_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 70_867 nanoseconds. + Weight::from_ref_time(71_812_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Auctions AuctionInfo (r:1 w:1) // Storage: Babe NextRandomness (r:1 w:0) // Storage: Babe EpochStart (r:1 w:0) // Storage: Auctions AuctionCounter (r:1 w:0) - // Storage: Auctions Winning (r:600 w:600) + // Storage: Auctions Winning (r:3600 w:3600) // Storage: Auctions ReservedAmounts (r:37 w:36) // Storage: System Account (r:36 w:36) - // Storage: Slots Leases (r:7 w:7) + // Storage: Slots Leases (r:2 w:2) // Storage: Paras ParaLifecycles (r:1 w:1) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras ActionsQueue (r:1 w:1) // Storage: Registrar Paras (r:1 w:1) fn on_initialize() -> Weight { - (2_965_000_000 as Weight) - .saturating_add(T::DbWeight::get().reads(688 as Weight)) - .saturating_add(T::DbWeight::get().writes(683 as Weight)) + // Minimum execution time: 14_379_395 nanoseconds. + Weight::from_ref_time(14_660_269_000 as u64) + .saturating_add(T::DbWeight::get().reads(3683 as u64)) + .saturating_add(T::DbWeight::get().writes(3678 as u64)) } // Storage: Auctions ReservedAmounts (r:37 w:36) // Storage: System Account (r:36 w:36) - // Storage: Auctions Winning (r:0 w:600) + // Storage: Auctions Winning (r:0 w:3600) // Storage: Auctions AuctionInfo (r:0 w:1) fn cancel_auction() -> Weight { - (1_202_383_000 as Weight) - .saturating_add(T::DbWeight::get().reads(73 as Weight)) - .saturating_add(T::DbWeight::get().writes(673 as Weight)) + // Minimum execution time: 4_503_529 nanoseconds. + Weight::from_ref_time(4_632_974_000 as u64) + .saturating_add(T::DbWeight::get().reads(73 as u64)) + .saturating_add(T::DbWeight::get().writes(3673 as u64)) } } diff --git a/runtime/rococo/src/weights/runtime_common_claims.rs b/runtime/rococo/src/weights/runtime_common_claims.rs new file mode 100644 index 000000000000..2819000fd44e --- /dev/null +++ b/runtime/rococo/src/weights/runtime_common_claims.rs @@ -0,0 +1,107 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `runtime_common::claims` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=runtime_common::claims +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/rococo/src/weights/runtime_common_claims.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `runtime_common::claims`. +pub struct WeightInfo(PhantomData); +impl runtime_common::claims::WeightInfo for WeightInfo { + // Storage: Claims Claims (r:1 w:1) + // Storage: Claims Signing (r:1 w:1) + // Storage: Claims Total (r:1 w:1) + // Storage: Claims Vesting (r:1 w:1) + // Storage: Vesting Vesting (r:1 w:1) + // Storage: System Account (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + fn claim() -> Weight { + // Minimum execution time: 139_048 nanoseconds. + Weight::from_ref_time(142_879_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: Claims Total (r:1 w:1) + // Storage: Claims Vesting (r:0 w:1) + // Storage: Claims Claims (r:0 w:1) + // Storage: Claims Signing (r:0 w:1) + fn mint_claim() -> Weight { + // Minimum execution time: 11_289 nanoseconds. + Weight::from_ref_time(11_526_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: Claims Claims (r:1 w:1) + // Storage: Claims Signing (r:1 w:1) + // Storage: Claims Total (r:1 w:1) + // Storage: Claims Vesting (r:1 w:1) + // Storage: Vesting Vesting (r:1 w:1) + // Storage: System Account (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + fn claim_attest() -> Weight { + // Minimum execution time: 142_402 nanoseconds. + Weight::from_ref_time(144_821_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: Claims Preclaims (r:1 w:1) + // Storage: Claims Signing (r:1 w:1) + // Storage: Claims Claims (r:1 w:1) + // Storage: Claims Total (r:1 w:1) + // Storage: Claims Vesting (r:1 w:1) + // Storage: Vesting Vesting (r:1 w:1) + // Storage: System Account (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + fn attest() -> Weight { + // Minimum execution time: 64_758 nanoseconds. + Weight::from_ref_time(66_207_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) + } + // Storage: Claims Claims (r:1 w:2) + // Storage: Claims Vesting (r:1 w:2) + // Storage: Claims Signing (r:1 w:2) + // Storage: Claims Preclaims (r:1 w:1) + fn move_claim() -> Weight { + // Minimum execution time: 21_449 nanoseconds. + Weight::from_ref_time(21_840_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) + } +} diff --git a/runtime/rococo/src/weights/runtime_common_crowdloan.rs b/runtime/rococo/src/weights/runtime_common_crowdloan.rs index 099623c46867..2340c33b1260 100644 --- a/runtime/rococo/src/weights/runtime_common_crowdloan.rs +++ b/runtime/rococo/src/weights/runtime_common_crowdloan.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::crowdloan` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -49,9 +49,10 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: Paras ParaLifecycles (r:1 w:0) // Storage: Crowdloan NextFundIndex (r:1 w:1) fn create() -> Weight { - (41_754_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 46_434 nanoseconds. + Weight::from_ref_time(47_883_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: Slots Leases (r:1 w:0) @@ -61,55 +62,62 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: Crowdloan NewRaise (r:1 w:1) // Storage: unknown [0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291] (r:1 w:1) fn contribute() -> Weight { - (110_907_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 115_616 nanoseconds. + Weight::from_ref_time(117_125_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: System Account (r:2 w:2) // Storage: unknown [0xc85982571aa615c788ef9b2c16f54f25773fd439e8ee1ed2aa3ae43d48e880f0] (r:1 w:1) fn withdraw() -> Weight { - (49_546_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 54_162 nanoseconds. + Weight::from_ref_time(55_016_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `k` is `[0, 500]`. + /// The range of component `k` is `[0, 1000]`. fn refund(k: u32, ) -> Weight { - (2_505_000 as Weight) - // Standard Error: 13_000 - .saturating_add((19_613_000 as Weight).saturating_mul(k as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(k as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(k as Weight))) + // Minimum execution time: 51_334 nanoseconds. + Weight::from_ref_time(52_592_000 as u64) + // Standard Error: 13_105 + .saturating_add(Weight::from_ref_time(17_374_051 as u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(k as u64))) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: System Account (r:1 w:1) fn dissolve() -> Weight { - (31_248_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 35_483 nanoseconds. + Weight::from_ref_time(36_509_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) fn edit() -> Weight { - (20_623_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_605 nanoseconds. + Weight::from_ref_time(25_894_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Funds (r:1 w:0) // Storage: unknown [0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291] (r:1 w:1) fn add_memo() -> Weight { - (26_451_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 31_157 nanoseconds. + Weight::from_ref_time(32_555_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Funds (r:1 w:0) // Storage: Crowdloan NewRaise (r:1 w:1) fn poke() -> Weight { - (21_215_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_592 nanoseconds. + Weight::from_ref_time(25_684_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Auctions AuctionInfo (r:1 w:0) // Storage: Crowdloan EndingsCount (r:1 w:1) @@ -123,12 +131,13 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: System Account (r:2 w:2) /// The range of component `n` is `[2, 100]`. fn on_initialize(n: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 25_000 - .saturating_add((51_756_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(n as Weight))) + // Minimum execution time: 102_130 nanoseconds. + Weight::from_ref_time(6_401_092 as u64) + // Standard Error: 46_468 + .saturating_add(Weight::from_ref_time(40_862_949 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(n as u64))) } } diff --git a/runtime/rococo/src/weights/runtime_common_paras_registrar.rs b/runtime/rococo/src/weights/runtime_common_paras_registrar.rs index 6c4547f49d32..5cc8749813f8 100644 --- a/runtime/rococo/src/weights/runtime_common_paras_registrar.rs +++ b/runtime/rococo/src/weights/runtime_common_paras_registrar.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::paras_registrar` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -48,9 +48,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:0) fn reserve() -> Weight { - (27_519_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 31_697 nanoseconds. + Weight::from_ref_time(32_209_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -63,9 +64,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras CurrentCodeHash (r:0 w:1) // Storage: Paras UpcomingParasGenesis (r:0 w:1) fn register() -> Weight { - (9_070_714_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 7_452_657 nanoseconds. + Weight::from_ref_time(7_575_304_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -78,9 +80,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras CurrentCodeHash (r:0 w:1) // Storage: Paras UpcomingParasGenesis (r:0 w:1) fn force_register() -> Weight { - (8_963_395_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 7_429_097 nanoseconds. + Weight::from_ref_time(7_573_259_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -89,9 +92,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras ActionsQueue (r:1 w:1) // Storage: Registrar PendingSwap (r:0 w:1) fn deregister() -> Weight { - (42_284_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 48_195 nanoseconds. + Weight::from_ref_time(49_027_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Registrar Paras (r:1 w:0) // Storage: Paras ParaLifecycles (r:2 w:2) @@ -101,8 +105,38 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Crowdloan Funds (r:2 w:2) // Storage: Slots Leases (r:2 w:2) fn swap() -> Weight { - (36_098_000 as Weight) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + // Minimum execution time: 43_201 nanoseconds. + Weight::from_ref_time(43_804_000 as u64) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) + } + // Storage: Paras FutureCodeHash (r:1 w:1) + // Storage: Paras UpgradeRestrictionSignal (r:1 w:1) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Paras CurrentCodeHash (r:1 w:0) + // Storage: Paras UpgradeCooldowns (r:1 w:1) + // Storage: Paras PvfActiveVoteMap (r:1 w:0) + // Storage: Paras CodeByHash (r:1 w:1) + // Storage: Paras UpcomingUpgrades (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras FutureCodeUpgrades (r:0 w:1) + /// The range of component `b` is `[1, 3145728]`. + fn schedule_code_upgrade(b: u32, ) -> Weight { + // Minimum execution time: 42_089 nanoseconds. + Weight::from_ref_time(42_743_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_339 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) + } + // Storage: Paras Heads (r:0 w:1) + /// The range of component `b` is `[1, 1048576]`. + fn set_current_head(b: u32, ) -> Weight { + // Minimum execution time: 13_554 nanoseconds. + Weight::from_ref_time(13_744_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(964 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/rococo/src/weights/runtime_common_slots.rs b/runtime/rococo/src/weights/runtime_common_slots.rs index d1971f13caa9..17723f9b93b0 100644 --- a/runtime/rococo/src/weights/runtime_common_slots.rs +++ b/runtime/rococo/src/weights/runtime_common_slots.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::slots` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -47,9 +47,10 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (28_337_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 30_626 nanoseconds. + Weight::from_ref_time(31_415_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Paras Parachains (r:1 w:0) // Storage: Slots Leases (r:101 w:100) @@ -60,24 +61,26 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (0 as Weight) - // Standard Error: 22_000 - .saturating_add((6_753_000 as Weight).saturating_mul(c as Weight)) - // Standard Error: 22_000 - .saturating_add((17_808_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(t as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(t as Weight))) + // Minimum execution time: 562_166 nanoseconds. + Weight::from_ref_time(566_185_000 as u64) + // Standard Error: 71_695 + .saturating_add(Weight::from_ref_time(2_078_821 as u64).saturating_mul(c as u64)) + // Standard Error: 71_695 + .saturating_add(Weight::from_ref_time(11_845_926 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(t as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(t as u64))) } // Storage: Slots Leases (r:1 w:1) // Storage: System Account (r:8 w:8) fn clear_all_leases() -> Weight { - (91_710_000 as Weight) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(9 as Weight)) + // Minimum execution time: 92_423 nanoseconds. + Weight::from_ref_time(94_128_000 as u64) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: Slots Leases (r:1 w:0) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -85,8 +88,9 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (21_040_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 28_988 nanoseconds. + Weight::from_ref_time(30_069_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/rococo/src/weights/runtime_parachains_configuration.rs b/runtime/rococo/src/weights/runtime_parachains_configuration.rs index 3f9afbf78a42..7f3057800067 100644 --- a/runtime/rococo/src/weights/runtime_parachains_configuration.rs +++ b/runtime/rococo/src/weights/runtime_parachains_configuration.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::configuration` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -49,48 +49,54 @@ impl runtime_parachains::configuration::WeightInfo for // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_block_number() -> Weight { - (9_728_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 12_597 nanoseconds. + Weight::from_ref_time(13_059_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_u32() -> Weight { - (9_825_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 12_590 nanoseconds. + Weight::from_ref_time(12_953_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_option_u32() -> Weight { - (9_905_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 12_263 nanoseconds. + Weight::from_ref_time(12_730_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_weight() -> Weight { - (9_968_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 12_258 nanoseconds. + Weight::from_ref_time(12_815_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Benchmark Override (r:0 w:0) fn set_hrmp_open_request_ttl() -> Weight { - (2_000_000_000_000 as Weight) + // Minimum execution time: 2_000_000_000 nanoseconds. + Weight::from_ref_time(2_000_000_000_000 as u64) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_balance() -> Weight { - (9_949_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 12_495 nanoseconds. + Weight::from_ref_time(12_971_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/rococo/src/weights/runtime_parachains_disputes.rs b/runtime/rococo/src/weights/runtime_parachains_disputes.rs index a0350d904fa2..7d611efb34fb 100644 --- a/runtime/rococo/src/weights/runtime_parachains_disputes.rs +++ b/runtime/rococo/src/weights/runtime_parachains_disputes.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::disputes` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -46,7 +46,8 @@ pub struct WeightInfo(PhantomData); impl runtime_parachains::disputes::WeightInfo for WeightInfo { // Storage: ParasDisputes Frozen (r:0 w:1) fn force_unfreeze() -> Weight { - (3_239_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_209 nanoseconds. + Weight::from_ref_time(4_281_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/rococo/src/weights/runtime_parachains_hrmp.rs b/runtime/rococo/src/weights/runtime_parachains_hrmp.rs index c651c63cb0b9..8937d4a88c9e 100644 --- a/runtime/rococo/src/weights/runtime_parachains_hrmp.rs +++ b/runtime/rococo/src/weights/runtime_parachains_hrmp.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::hrmp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -54,9 +54,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_init_open_channel() -> Weight { - (37_068_000 as Weight) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 39_625 nanoseconds. + Weight::from_ref_time(40_445_000 as u64) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) @@ -66,9 +67,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_accept_open_channel() -> Weight { - (32_234_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 39_703 nanoseconds. + Weight::from_ref_time(40_505_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Hrmp HrmpChannels (r:1 w:0) // Storage: Hrmp HrmpCloseChannelRequests (r:1 w:1) @@ -77,9 +79,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_close_channel() -> Weight { - (31_418_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 36_723 nanoseconds. + Weight::from_ref_time(37_406_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Hrmp HrmpIngressChannelsIndex (r:128 w:127) // Storage: Hrmp HrmpEgressChannelsIndex (r:1 w:1) @@ -90,17 +93,18 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf /// The range of component `i` is `[0, 127]`. /// The range of component `e` is `[0, 127]`. fn force_clean_hrmp(i: u32, e: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 20_000 - .saturating_add((9_760_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 20_000 - .saturating_add((9_813_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(i as Weight))) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(e as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(i as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(e as Weight))) + // Minimum execution time: 858_127 nanoseconds. + Weight::from_ref_time(867_315_000 as u64) + // Standard Error: 78_610 + .saturating_add(Weight::from_ref_time(2_628_159 as u64).saturating_mul(i as u64)) + // Standard Error: 78_610 + .saturating_add(Weight::from_ref_time(2_715_230 as u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(i as u64))) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(e as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(i as u64))) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(e as u64))) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:0) @@ -113,13 +117,14 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Hrmp HrmpChannels (r:0 w:2) /// The range of component `c` is `[0, 128]`. fn force_process_hrmp_open(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 27_000 - .saturating_add((22_813_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((7 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((6 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 9_591 nanoseconds. + Weight::from_ref_time(9_702_000 as u64) + // Standard Error: 11_345 + .saturating_add(Weight::from_ref_time(15_504_007 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((7 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((6 as u64).saturating_mul(c as u64))) } // Storage: Hrmp HrmpCloseChannelRequestsList (r:1 w:0) // Storage: Hrmp HrmpChannels (r:2 w:2) @@ -129,35 +134,55 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Hrmp HrmpChannelContents (r:0 w:2) /// The range of component `c` is `[0, 128]`. fn force_process_hrmp_close(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 16_000 - .saturating_add((12_842_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((5 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 6_100 nanoseconds. + Weight::from_ref_time(6_209_000 as u64) + // Standard Error: 8_660 + .saturating_add(Weight::from_ref_time(9_565_726 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((5 as u64).saturating_mul(c as u64))) } // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequestCount (r:1 w:1) /// The range of component `c` is `[0, 128]`. fn hrmp_cancel_open_request(c: u32, ) -> Weight { - (26_161_000 as Weight) - // Standard Error: 1_000 - .saturating_add((50_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 24_413 nanoseconds. + Weight::from_ref_time(30_943_685 as u64) + // Standard Error: 1_337 + .saturating_add(Weight::from_ref_time(83_692 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequests (r:2 w:2) /// The range of component `c` is `[0, 128]`. fn clean_open_channel_requests(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 7_000 - .saturating_add((3_723_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 4_110 nanoseconds. + Weight::from_ref_time(2_664_207 as u64) + // Standard Error: 3_639 + .saturating_add(Weight::from_ref_time(2_567_247 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + } + // Storage: Paras ParaLifecycles (r:2 w:0) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) + // Storage: Hrmp HrmpChannels (r:1 w:0) + // Storage: Hrmp HrmpEgressChannelsIndex (r:1 w:0) + // Storage: Hrmp HrmpOpenChannelRequestCount (r:1 w:1) + // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:2 w:2) + // Storage: Dmp DownwardMessageQueues (r:2 w:2) + // Storage: Hrmp HrmpIngressChannelsIndex (r:1 w:0) + // Storage: Hrmp HrmpAcceptedChannelRequestCount (r:1 w:1) + fn force_open_hrmp_channel() -> Weight { + // Minimum execution time: 51_110 nanoseconds. + Weight::from_ref_time(52_535_000 as u64) + .saturating_add(T::DbWeight::get().reads(14 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } } diff --git a/runtime/rococo/src/weights/runtime_parachains_initializer.rs b/runtime/rococo/src/weights/runtime_parachains_initializer.rs index f3ce56f92f09..b11f9ca3dedc 100644 --- a/runtime/rococo/src/weights/runtime_parachains_initializer.rs +++ b/runtime/rococo/src/weights/runtime_parachains_initializer.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::initializer` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -47,10 +47,11 @@ impl runtime_parachains::initializer::WeightInfo for We // Storage: System Digest (r:1 w:1) /// The range of component `d` is `[0, 65536]`. fn force_approve(d: u32, ) -> Weight { - (8_670_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_175 nanoseconds. + Weight::from_ref_time(10_442_900 as u64) + // Standard Error: 4 + .saturating_add(Weight::from_ref_time(1_297 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/rococo/src/weights/runtime_parachains_paras.rs b/runtime/rococo/src/weights/runtime_parachains_paras.rs index 0b27644c40cc..3daf4005d7b5 100644 --- a/runtime/rococo/src/weights/runtime_parachains_paras.rs +++ b/runtime/rococo/src/weights/runtime_parachains_paras.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::paras` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -52,19 +52,21 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras CodeByHash (r:0 w:1) /// The range of component `c` is `[1, 3145728]`. fn force_set_current_code(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 35_999 nanoseconds. + Weight::from_ref_time(36_498_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_327 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Paras Heads (r:0 w:1) /// The range of component `s` is `[1, 1048576]`. fn force_set_current_head(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 12_171 nanoseconds. + Weight::from_ref_time(12_504_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(964 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Paras FutureCodeHash (r:1 w:1) @@ -79,55 +81,61 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras UpgradeRestrictionSignal (r:0 w:1) /// The range of component `c` is `[1, 3145728]`. fn force_schedule_code_upgrade(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + // Minimum execution time: 60_066 nanoseconds. + Weight::from_ref_time(60_514_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_347 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } // Storage: Paras FutureCodeUpgrades (r:1 w:0) // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) /// The range of component `s` is `[1, 1048576]`. fn force_note_new_head(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 17_871 nanoseconds. + Weight::from_ref_time(18_032_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(965 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras ActionsQueue (r:1 w:1) fn force_queue_action() -> Weight { - (19_397_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 22_888 nanoseconds. + Weight::from_ref_time(23_397_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Paras PvfActiveVoteMap (r:1 w:0) // Storage: Paras CodeByHash (r:1 w:1) /// The range of component `c` is `[1, 3145728]`. fn add_trusted_validation_code(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_349 nanoseconds. + Weight::from_ref_time(8_438_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_334 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Paras CodeByHashRefs (r:1 w:0) // Storage: Paras CodeByHash (r:0 w:1) fn poke_unused_validation_code() -> Weight { - (4_787_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 6_533 nanoseconds. + Weight::from_ref_time(6_733_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras PvfActiveVoteMap (r:1 w:1) fn include_pvf_check_statement() -> Weight { - (91_856_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 93_496 nanoseconds. + Weight::from_ref_time(96_071_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) @@ -138,9 +146,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: System Digest (r:1 w:1) // Storage: Paras FutureCodeUpgrades (r:0 w:100) fn include_pvf_check_statement_finalize_upgrade_accept() -> Weight { - (701_025_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(104 as Weight)) + // Minimum execution time: 628_935 nanoseconds. + Weight::from_ref_time(637_577_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(104 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) @@ -152,9 +161,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras UpgradeGoAheadSignal (r:0 w:100) // Storage: Paras FutureCodeHash (r:0 w:100) fn include_pvf_check_statement_finalize_upgrade_reject() -> Weight { - (637_007_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(204 as Weight)) + // Minimum execution time: 605_260 nanoseconds. + Weight::from_ref_time(609_252_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(204 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) @@ -163,9 +173,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras PvfActiveVoteList (r:1 w:1) // Storage: Paras ActionsQueue (r:1 w:1) fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight { - (552_615_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 500_559 nanoseconds. + Weight::from_ref_time(504_952_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Configuration ActiveConfig (r:1 w:0) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) @@ -178,8 +189,9 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras CurrentCodeHash (r:0 w:100) // Storage: Paras UpcomingParasGenesis (r:0 w:100) fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight { - (705_948_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(304 as Weight)) + // Minimum execution time: 663_855 nanoseconds. + Weight::from_ref_time(673_507_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(304 as u64)) } } diff --git a/runtime/rococo/src/weights/runtime_parachains_paras_inherent.rs b/runtime/rococo/src/weights/runtime_parachains_paras_inherent.rs index e04a2fa9f95b..9f2a741c57e2 100644 --- a/runtime/rococo/src/weights/runtime_parachains_paras_inherent.rs +++ b/runtime/rococo/src/weights/runtime_parachains_paras_inherent.rs @@ -70,11 +70,11 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Hrmp HrmpWatermarks (r:0 w:1) // Storage: Paras Heads (r:0 w:1) fn enter_variable_disputes(v: u32, ) -> Weight { - (352_590_000 as Weight) + Weight::from_ref_time(352_590_000 as u64) // Standard Error: 13_000 - .saturating_add((49_254_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(24 as Weight)) - .saturating_add(T::DbWeight::get().writes(16 as Weight)) + .saturating_add(Weight::from_ref_time(49_254_000 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(24 as u64)) + .saturating_add(T::DbWeight::get().writes(16 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -102,9 +102,9 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Hrmp HrmpWatermarks (r:0 w:1) // Storage: Paras Heads (r:0 w:1) fn enter_bitfields() -> Weight { - (299_878_000 as Weight) - .saturating_add(T::DbWeight::get().reads(21 as Weight)) - .saturating_add(T::DbWeight::get().writes(15 as Weight)) + Weight::from_ref_time(299_878_000 as u64) + .saturating_add(T::DbWeight::get().reads(21 as u64)) + .saturating_add(T::DbWeight::get().writes(15 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -134,9 +134,9 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Hrmp HrmpWatermarks (r:0 w:1) // Storage: Paras Heads (r:0 w:1) fn enter_backed_candidates_variable(_v: u32) -> Weight { - (442_472_000 as Weight) - .saturating_add(T::DbWeight::get().reads(25 as Weight)) - .saturating_add(T::DbWeight::get().writes(14 as Weight)) + Weight::from_ref_time(442_472_000 as u64) + .saturating_add(T::DbWeight::get().reads(25 as u64)) + .saturating_add(T::DbWeight::get().writes(14 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -166,8 +166,8 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Hrmp HrmpWatermarks (r:0 w:1) // Storage: Paras Heads (r:0 w:1) fn enter_backed_candidate_code_upgrade() -> Weight { - (36_903_411_000 as Weight) - .saturating_add(T::DbWeight::get().reads(25 as Weight)) - .saturating_add(T::DbWeight::get().writes(14 as Weight)) + Weight::from_ref_time(36_903_411_000 as u64) + .saturating_add(T::DbWeight::get().reads(25 as u64)) + .saturating_add(T::DbWeight::get().writes(14 as u64)) } } diff --git a/runtime/rococo/src/weights/runtime_parachains_ump.rs b/runtime/rococo/src/weights/runtime_parachains_ump.rs index f009614dfae3..47a9de38d9b2 100644 --- a/runtime/rococo/src/weights/runtime_parachains_ump.rs +++ b/runtime/rococo/src/weights/runtime_parachains_ump.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::ump` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 // Executed Command: @@ -46,23 +46,26 @@ pub struct WeightInfo(PhantomData); impl runtime_parachains::ump::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 51200]`. fn process_upward_message(s: u32, ) -> Weight { - (4_717_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) + // Minimum execution time: 9_816 nanoseconds. + Weight::from_ref_time(4_361_319 as u64) + // Standard Error: 13 + .saturating_add(Weight::from_ref_time(1_893 as u64).saturating_mul(s as u64)) } // Storage: Ump NeedsDispatch (r:1 w:1) // Storage: Ump NextDispatchRoundStartWith (r:1 w:1) // Storage: Ump RelayDispatchQueues (r:0 w:1) // Storage: Ump RelayDispatchQueueSize (r:0 w:1) fn clean_ump_after_outgoing() -> Weight { - (6_656_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 8_725 nanoseconds. + Weight::from_ref_time(9_100_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Ump Overweight (r:1 w:1) fn service_overweight() -> Weight { - (21_672_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_444 nanoseconds. + Weight::from_ref_time(25_044_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/rococo/src/weights/xcm/mod.rs b/runtime/rococo/src/weights/xcm/mod.rs new file mode 100644 index 000000000000..e0221357d24a --- /dev/null +++ b/runtime/rococo/src/weights/xcm/mod.rs @@ -0,0 +1,270 @@ +mod pallet_xcm_benchmarks_fungible; +mod pallet_xcm_benchmarks_generic; + +use crate::Runtime; +use frame_support::weights::Weight; +use sp_std::prelude::*; +use xcm::{ + latest::{prelude::*, Weight as XCMWeight}, + DoubleEncoded, +}; + +use pallet_xcm_benchmarks_fungible::WeightInfo as XcmBalancesWeight; +use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; + +/// Types of asset supported by the Rococo runtime. +pub enum AssetTypes { + /// An asset backed by `pallet-balances`. + Balances, + /// Unknown asset. + Unknown, +} + +impl From<&MultiAsset> for AssetTypes { + fn from(asset: &MultiAsset) -> Self { + match asset { + MultiAsset { id: Concrete(MultiLocation { parents: 0, interior: Here }), .. } => + AssetTypes::Balances, + _ => AssetTypes::Unknown, + } + } +} + +trait WeighMultiAssets { + fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight; +} + +// Rococo only knows about one asset, the balances pallet. +const MAX_ASSETS: u32 = 1; + +impl WeighMultiAssets for MultiAssetFilter { + fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { + let weight = match self { + Self::Definite(assets) => assets + .inner() + .into_iter() + .map(From::from) + .map(|t| match t { + AssetTypes::Balances => balances_weight, + AssetTypes::Unknown => Weight::MAX, + }) + .fold(Weight::zero(), |acc, x| acc.saturating_add(x)), + Self::Wild(AllOf { .. } | AllOfCounted { .. }) => balances_weight, + Self::Wild(AllCounted(count)) => balances_weight.saturating_mul(*count as u64), + Self::Wild(All) => balances_weight.saturating_mul(MAX_ASSETS as u64), + }; + + weight.ref_time() + } +} + +impl WeighMultiAssets for MultiAssets { + fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { + let weight = self + .inner() + .into_iter() + .map(|m| >::from(m)) + .map(|t| match t { + AssetTypes::Balances => balances_weight, + AssetTypes::Unknown => Weight::MAX, + }) + .fold(Weight::zero(), |acc, x| acc.saturating_add(x)); + + weight.ref_time() + } +} + +pub struct RococoXcmWeight(core::marker::PhantomData); +impl XcmWeightInfo for RococoXcmWeight { + fn withdraw_asset(assets: &MultiAssets) -> XCMWeight { + assets.weigh_multi_assets(XcmBalancesWeight::::withdraw_asset()) + } + fn reserve_asset_deposited(assets: &MultiAssets) -> XCMWeight { + assets.weigh_multi_assets(XcmBalancesWeight::::reserve_asset_deposited()) + } + fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight { + assets.weigh_multi_assets(XcmBalancesWeight::::receive_teleported_asset()) + } + fn query_response( + _query_id: &u64, + _response: &Response, + _max_weight: &u64, + _querier: &Option, + ) -> XCMWeight { + XcmGeneric::::query_response().ref_time() + } + fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight { + assets.weigh_multi_assets(XcmBalancesWeight::::transfer_asset()) + } + fn transfer_reserve_asset( + assets: &MultiAssets, + _dest: &MultiLocation, + _xcm: &Xcm<()>, + ) -> XCMWeight { + assets.weigh_multi_assets(XcmBalancesWeight::::transfer_reserve_asset()) + } + fn transact( + _origin_type: &OriginKind, + _require_weight_at_most: &u64, + _call: &DoubleEncoded, + ) -> XCMWeight { + XcmGeneric::::transact().ref_time() + } + fn hrmp_new_channel_open_request( + _sender: &u32, + _max_message_size: &u32, + _max_capacity: &u32, + ) -> XCMWeight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX.ref_time() + } + fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX.ref_time() + } + fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX.ref_time() + } + fn clear_origin() -> XCMWeight { + XcmGeneric::::clear_origin().ref_time() + } + fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight { + XcmGeneric::::descend_origin().ref_time() + } + fn report_error(_query_response_info: &QueryResponseInfo) -> XCMWeight { + XcmGeneric::::report_error().ref_time() + } + + fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> XCMWeight { + assets.weigh_multi_assets(XcmBalancesWeight::::deposit_asset()) + } + fn deposit_reserve_asset( + assets: &MultiAssetFilter, + _dest: &MultiLocation, + _xcm: &Xcm<()>, + ) -> XCMWeight { + assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) + } + fn exchange_asset( + _give: &MultiAssetFilter, + _receive: &MultiAssets, + _maximal: &bool, + ) -> XCMWeight { + // Rococo does not currently support exchange asset operations + Weight::MAX.ref_time() + } + fn initiate_reserve_withdraw( + assets: &MultiAssetFilter, + _reserve: &MultiLocation, + _xcm: &Xcm<()>, + ) -> XCMWeight { + assets.weigh_multi_assets(XcmGeneric::::initiate_reserve_withdraw()) + } + fn initiate_teleport( + assets: &MultiAssetFilter, + _dest: &MultiLocation, + _xcm: &Xcm<()>, + ) -> XCMWeight { + assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) + } + fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> XCMWeight { + XcmGeneric::::report_holding().ref_time() + } + fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight { + XcmGeneric::::buy_execution().ref_time() + } + fn refund_surplus() -> XCMWeight { + XcmGeneric::::refund_surplus().ref_time() + } + fn set_error_handler(_xcm: &Xcm) -> XCMWeight { + XcmGeneric::::set_error_handler().ref_time() + } + fn set_appendix(_xcm: &Xcm) -> XCMWeight { + XcmGeneric::::set_appendix().ref_time() + } + fn clear_error() -> XCMWeight { + XcmGeneric::::clear_error().ref_time() + } + fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight { + XcmGeneric::::claim_asset().ref_time() + } + fn trap(_code: &u64) -> XCMWeight { + XcmGeneric::::trap().ref_time() + } + fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight { + XcmGeneric::::subscribe_version().ref_time() + } + fn unsubscribe_version() -> XCMWeight { + XcmGeneric::::unsubscribe_version().ref_time() + } + fn burn_asset(assets: &MultiAssets) -> XCMWeight { + assets.weigh_multi_assets(XcmGeneric::::burn_asset()) + } + fn expect_asset(assets: &MultiAssets) -> XCMWeight { + assets.weigh_multi_assets(XcmGeneric::::expect_asset()) + } + fn expect_origin(_origin: &Option) -> XCMWeight { + XcmGeneric::::expect_origin().ref_time() + } + fn expect_error(_error: &Option<(u32, XcmError)>) -> XCMWeight { + XcmGeneric::::expect_error().ref_time() + } + fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> XCMWeight { + XcmGeneric::::query_pallet().ref_time() + } + fn expect_pallet( + _index: &u32, + _name: &Vec, + _module_name: &Vec, + _crate_major: &u32, + _min_crate_minor: &u32, + ) -> XCMWeight { + XcmGeneric::::expect_pallet().ref_time() + } + fn report_transact_status(_response_info: &QueryResponseInfo) -> XCMWeight { + XcmGeneric::::report_transact_status().ref_time() + } + fn clear_transact_status() -> XCMWeight { + XcmGeneric::::clear_transact_status().ref_time() + } + fn universal_origin(_: &Junction) -> XCMWeight { + // Kusama does not currently support universal origin operations + Weight::MAX.ref_time() + } + fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> XCMWeight { + Weight::MAX.ref_time() // todo fix + } + fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + // Kusama does not currently support asset locking operations + Weight::MAX.ref_time() + } + fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + // Kusama does not currently support asset locking operations + Weight::MAX.ref_time() + } + fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + // Kusama does not currently support asset locking operations + Weight::MAX.ref_time() + } + fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { + // Kusama does not currently support asset locking operations + Weight::MAX.ref_time() + } + fn set_fees_mode(_: &bool) -> XCMWeight { + XcmGeneric::::set_fees_mode().ref_time() + } + fn set_topic(_topic: &[u8; 32]) -> XCMWeight { + XcmGeneric::::set_topic().ref_time() + } + fn clear_topic() -> XCMWeight { + XcmGeneric::::clear_topic().ref_time() + } + fn alias_origin(_: &MultiLocation) -> XCMWeight { + // XCM Executor does not currently support alias origin operations + Weight::MAX.ref_time() + } + fn unpaid_execution(_: &WeightLimit, _: &Option) -> XCMWeight { + XcmGeneric::::unpaid_execution().ref_time() + } +} diff --git a/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs new file mode 100644 index 000000000000..99eee16135ba --- /dev/null +++ b/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -0,0 +1,112 @@ +// Copyright 2022 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 . + +//! Autogenerated weights for `pallet_xcm_benchmarks::fungible` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-03-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot +// benchmark +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_xcm_benchmarks::fungible +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --template=./xcm/pallet-xcm-benchmarks/template.hbs +// --output=./runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weights for `pallet_xcm_benchmarks::fungible`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: System Account (r:1 w:1) + pub(crate) fn withdraw_asset() -> Weight { + Weight::from_ref_time(20_385_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: System Account (r:2 w:2) + pub(crate) fn transfer_asset() -> Weight { + Weight::from_ref_time(32_756_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: System Account (r:2 w:2) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn transfer_reserve_asset() -> Weight { + Weight::from_ref_time(50_645_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) + } + // Storage: Benchmark Override (r:0 w:0) + pub(crate) fn reserve_asset_deposited() -> Weight { + Weight::from_ref_time(2_000_000_000_000 as u64) + } + // Storage: System Account (r:1 w:1) + pub(crate) fn receive_teleported_asset() -> Weight { + Weight::from_ref_time(19_595_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: System Account (r:1 w:1) + pub(crate) fn deposit_asset() -> Weight { + Weight::from_ref_time(21_763_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: System Account (r:1 w:1) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn deposit_reserve_asset() -> Weight { + Weight::from_ref_time(40_930_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: System Account (r:1 w:1) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn initiate_teleport() -> Weight { + Weight::from_ref_time(40_788_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } +} diff --git a/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs new file mode 100644 index 000000000000..f2d786e85a46 --- /dev/null +++ b/runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -0,0 +1,186 @@ +// Copyright 2022 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 . + +//! Autogenerated weights for `pallet_xcm_benchmarks::generic` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-03-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024 + +// Executed Command: +// target/production/polkadot +// benchmark +// --chain=rococo-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_xcm_benchmarks::generic +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./file_header.txt +// --template=./xcm/pallet-xcm-benchmarks/template.hbs +// --output=./runtime/rococo/src/weights/xcm/pallet_xcm_benchmarks_generic.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weights for `pallet_xcm_benchmarks::generic`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn report_holding() -> Weight { + Weight::from_ref_time(21_822_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + pub(crate) fn buy_execution() -> Weight { + Weight::from_ref_time(3_109_000 as u64) + } + // Storage: XcmPallet Queries (r:1 w:0) + pub(crate) fn query_response() -> Weight { + Weight::from_ref_time(12_087_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + } + pub(crate) fn transact() -> Weight { + Weight::from_ref_time(12_398_000 as u64) + } + pub(crate) fn refund_surplus() -> Weight { + Weight::from_ref_time(3_247_000 as u64) + } + pub(crate) fn set_error_handler() -> Weight { + Weight::from_ref_time(3_086_000 as u64) + } + pub(crate) fn set_appendix() -> Weight { + Weight::from_ref_time(3_112_000 as u64) + } + pub(crate) fn clear_error() -> Weight { + Weight::from_ref_time(3_118_000 as u64) + } + pub(crate) fn descend_origin() -> Weight { + Weight::from_ref_time(4_054_000 as u64) + } + pub(crate) fn clear_origin() -> Weight { + Weight::from_ref_time(3_111_000 as u64) + } + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn report_error() -> Weight { + Weight::from_ref_time(18_425_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: XcmPallet AssetTraps (r:1 w:1) + pub(crate) fn claim_asset() -> Weight { + Weight::from_ref_time(7_144_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + pub(crate) fn trap() -> Weight { + Weight::from_ref_time(3_060_000 as u64) + } + // Storage: XcmPallet VersionNotifyTargets (r:1 w:1) + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn subscribe_version() -> Weight { + Weight::from_ref_time(21_642_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } + // Storage: XcmPallet VersionNotifyTargets (r:0 w:1) + pub(crate) fn unsubscribe_version() -> Weight { + Weight::from_ref_time(4_873_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn initiate_reserve_withdraw() -> Weight { + Weight::from_ref_time(22_809_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + pub(crate) fn burn_asset() -> Weight { + Weight::from_ref_time(5_259_000 as u64) + } + pub(crate) fn expect_asset() -> Weight { + Weight::from_ref_time(3_745_000 as u64) + } + pub(crate) fn expect_origin() -> Weight { + Weight::from_ref_time(3_847_000 as u64) + } + pub(crate) fn expect_error() -> Weight { + Weight::from_ref_time(3_633_000 as u64) + } + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn query_pallet() -> Weight { + Weight::from_ref_time(21_645_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + pub(crate) fn expect_pallet() -> Weight { + Weight::from_ref_time(4_017_000 as u64) + } + // Storage: XcmPallet SupportedVersion (r:1 w:0) + // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) + // Storage: XcmPallet SafeXcmVersion (r:1 w:0) + // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) + // Storage: Dmp DownwardMessageQueues (r:1 w:1) + pub(crate) fn report_transact_status() -> Weight { + Weight::from_ref_time(20_465_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + pub(crate) fn clear_transact_status() -> Weight { + Weight::from_ref_time(3_723_000 as u64) + } + pub(crate) fn set_topic() -> Weight { + Weight::from_ref_time(3_687_000 as u64) + } + pub(crate) fn clear_topic() -> Weight { + Weight::from_ref_time(3_654_000 as u64) + } + pub(crate) fn set_fees_mode() -> Weight { + Weight::from_ref_time(3_721_000 as u64) + } + pub(crate) fn unpaid_execution() -> Weight { + Weight::from_ref_time(3_111_000 as u64) + } +} diff --git a/runtime/rococo/src/xcm_config.rs b/runtime/rococo/src/xcm_config.rs index 85fd07ab8811..e7ffbe202485 100644 --- a/runtime/rococo/src/xcm_config.rs +++ b/runtime/rococo/src/xcm_config.rs @@ -17,22 +17,22 @@ //! XCM configuration for Rococo. use super::{ - parachains_origin, AccountId, AllPalletsWithSystem, Balances, Call, Event, Origin, ParaId, - Runtime, WeightToFee, XcmPallet, + parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, ParaId, + Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet, }; use frame_support::{ - parameter_types, - traits::{Everything, IsInVec, Nothing}, - weights::Weight, + match_types, parameter_types, + traits::{Everything, Nothing}, }; use runtime_common::{xcm_sender, ToAuthor}; -use sp_std::prelude::*; use xcm::latest::prelude::*; use xcm_builder::{ - AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, BackingToPlurality, + AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, + AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, - CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsConcrete, MintLocation, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, UsingComponents, + CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete, + MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + TakeWeightCredit, UsingComponents, }; use xcm_executor::XcmExecutor; @@ -46,6 +46,10 @@ parameter_types! { pub type LocationConverter = (ChildParachainConvertsVia, AccountId32Aliases); +/// Our asset transactor. This is what allows us to interest with the runtime facilities from the point of +/// view of XCM-only concepts like `MultiLocation` and `MultiAsset`. +/// +/// Ours is only aware of the Balances pallet, which is mapped to `RocLocation`. pub type LocalAssetTransactor = XcmCurrencyAdapter< // Use this currency: Balances, @@ -55,21 +59,26 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< LocationConverter, // Our chain's account ID type (we can't get away without mentioning it explicitly): AccountId, - // It's a native asset so we keep track of the teleports to maintain total issuance. + // We track our teleports in/out to keep total issuance correct. CheckAccount, >; +/// The means that we convert an the XCM message origin location into a local dispatch origin. type LocalOriginConverter = ( - SovereignSignedViaLocation, - ChildParachainAsNative, - SignedAccountId32AsNative, - ChildSystemParachainAsSuperuser, + // A `Signed` origin of the sovereign account that the original location controls. + SovereignSignedViaLocation, + // A child parachain, natively expressed, has the `Parachain` origin. + ChildParachainAsNative, + // The AccountId32 location type can be expressed natively as a `Signed` origin. + SignedAccountId32AsNative, + // A system child parachain, expressed as a Superuser, converts to the `Root` origin. + ChildSystemParachainAsSuperuser, ); parameter_types! { - pub const BaseXcmWeight: Weight = 1_000_000_000; + /// The amount of weight an XCM operation takes. This is a safe overestimate. + pub const BaseXcmWeight: u64 = 1_000_000_000; } - /// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our /// individual routers. pub type XcmRouter = ( @@ -79,12 +88,18 @@ pub type XcmRouter = ( parameter_types! { pub const Roc: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); - pub const RocForTick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(100).into_location()); - pub const RocForTrick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(110).into_location()); - pub const RocForTrack: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(120).into_location()); - pub const RocForRockmine: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(1000).into_location()); - pub const RocForCanvas: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(1002).into_location()); - pub const RocForEncointer: (MultiAssetFilter, MultiLocation) = (Roc::get(), Parachain(1003).into_location()); + pub const Statemine: MultiLocation = Parachain(1000).into_location(); + pub const Contracts: MultiLocation = Parachain(1002).into_location(); + pub const Encointer: MultiLocation = Parachain(1003).into_location(); + pub const Tick: MultiLocation = Parachain(100).into_location(); + pub const Trick: MultiLocation = Parachain(110).into_location(); + pub const Track: MultiLocation = Parachain(120).into_location(); + pub const RocForTick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Tick::get()); + pub const RocForTrick: (MultiAssetFilter, MultiLocation) = (Roc::get(), Trick::get()); + pub const RocForTrack: (MultiAssetFilter, MultiLocation) = (Roc::get(), Track::get()); + pub const RocForStatemine: (MultiAssetFilter, MultiLocation) = (Roc::get(), Statemine::get()); + pub const RocForContracts: (MultiAssetFilter, MultiLocation) = (Roc::get(), Contracts::get()); + pub const RocForEncointer: (MultiAssetFilter, MultiLocation) = (Roc::get(), Encointer::get()); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } @@ -92,37 +107,34 @@ pub type TrustedTeleporters = ( xcm_builder::Case, xcm_builder::Case, xcm_builder::Case, - xcm_builder::Case, - xcm_builder::Case, + xcm_builder::Case, + xcm_builder::Case, xcm_builder::Case, ); -parameter_types! { - pub AllowUnpaidFrom: Vec = - vec![ - Parachain(100).into(), - Parachain(110).into(), - Parachain(120).into(), - Parachain(1000).into(), - Parachain(1002).into(), - Parachain(1003).into(), - ]; +match_types! { + pub type OnlyParachains: impl Contains = { + MultiLocation { parents: 0, interior: X1(Parachain(_)) } + }; } -use xcm_builder::{AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, TakeWeightCredit}; +/// The barriers one of which must be passed for an XCM message to be executed. pub type Barrier = ( + // Weight that is paid for may be consumed. TakeWeightCredit, + // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - AllowUnpaidExecutionFrom>, // <- Trusted parachains get free execution + // Messages coming from system parachains need not pay for execution. + AllowUnpaidExecutionFrom>, // Expected responses are OK. AllowKnownQueryResponses, // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + AllowSubscriptionsFrom, ); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { - type Call = Call; + type RuntimeCall = RuntimeCall; type XcmSender = XcmRouter; type AssetTransactor = LocalAssetTransactor; type OriginConverter = LocalOriginConverter; @@ -130,7 +142,7 @@ impl xcm_executor::Config for XcmConfig { type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type Trader = UsingComponents>; type ResponseHandler = XcmPallet; @@ -144,37 +156,49 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; } parameter_types! { pub const CollectiveBodyId: BodyId = BodyId::Unit; } +parameter_types! { + pub const CouncilBodyId: BodyId = BodyId::Executive; +} + +/// Type to convert the council origin to a Plurality `MultiLocation` value. +pub type CouncilToPlurality = BackingToPlurality< + RuntimeOrigin, + pallet_collective::Origin, + CouncilBodyId, +>; + /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location /// of this chain. pub type LocalOriginToLocation = ( // We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the // `Unit` body. - BackingToPlurality, CollectiveBodyId>, + CouncilToPlurality, // And a usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, + SignedToAccountId32, ); - impl pallet_xcm::Config for Runtime { - type Event = Event; - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + type RuntimeEvent = RuntimeEvent; + type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = XcmRouter; - // Anyone can execute XCM messages locally... - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; - // ...but they must match our filter, which right now rejects everything. - type XcmExecuteFilter = Nothing; + // Anyone can execute XCM messages locally. + type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; + type XcmExecuteFilter = Everything; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; + // Anyone is able to use reserve transfers regardless of who they are and what they want to + // transfer. type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type Currency = Balances; diff --git a/runtime/test-runtime/Cargo.toml b/runtime/test-runtime/Cargo.toml index c84b72782a0a..c787a5347619 100644 --- a/runtime/test-runtime/Cargo.toml +++ b/runtime/test-runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polkadot-test-runtime" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" build = "build.rs" @@ -15,50 +15,50 @@ serde = { version = "1.0.137", default-features = false } serde_derive = { version = "1.0.117", optional = true } smallvec = "1.8.0" -authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-election-provider-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-election-provider-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } -pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-indices = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-offences = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-system = {git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-indices = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-offences = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-system = {git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } test-runtime-constants = { package = "test-runtime-constants", path = "./constants", default-features = false } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false } primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false } polkadot-parachain = { path = "../../parachain", default-features = false } -polkadot-runtime-parachains = { path = "../parachains", default-features = false, features = ["vstaging"]} +polkadot-runtime-parachains = { path = "../parachains", default-features = false } xcm-builder = { path = "../../xcm/xcm-builder", default-features = false } xcm-executor = { path = "../../xcm/xcm-executor", default-features = false } xcm = { path = "../../xcm", default-features = false } @@ -66,12 +66,12 @@ xcm = { path = "../../xcm", default-features = false } [dev-dependencies] hex-literal = "0.3.4" tiny-keccak = { version = "2.0.2", features = ["keccak"] } -keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } serde_json = "1.0.81" [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] default = ["std"] diff --git a/runtime/test-runtime/constants/Cargo.toml b/runtime/test-runtime/constants/Cargo.toml index 845831f36064..deaec1dd62fe 100644 --- a/runtime/test-runtime/constants/Cargo.toml +++ b/runtime/test-runtime/constants/Cargo.toml @@ -1,19 +1,23 @@ [package] name = "test-runtime-constants" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] smallvec = "1.8.0" -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } primitives = { package = "polkadot-primitives", path = "../../../primitives", default-features = false } runtime-common = { package = "polkadot-runtime-common", path = "../../common", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } [features] default = ["std"] std = [ - "sp-runtime/std" + "sp-core/std", + "sp-runtime/std", + "sp-weights/std" ] diff --git a/runtime/test-runtime/constants/src/lib.rs b/runtime/test-runtime/constants/src/lib.rs index 8fad190a6d32..0594062b4ddc 100644 --- a/runtime/test-runtime/constants/src/lib.rs +++ b/runtime/test-runtime/constants/src/lib.rs @@ -43,6 +43,9 @@ pub mod time { pub const DAYS: BlockNumber = HOURS * 24; // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. + // The choice of is done in accordance to the slot duration and expected target + // block time, for safely resisting network delays of maximum two seconds. + // pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); } @@ -74,7 +77,7 @@ pub mod fee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { let p = super::currency::CENTS; - let q = 10 * Balance::from(ExtrinsicBaseWeight::get()); + let q = 10 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); smallvec![WeightToFeeCoefficient { degree: 1, negative: false, diff --git a/runtime/test-runtime/constants/src/weights/block_weights.rs b/runtime/test-runtime/constants/src/weights/block_weights.rs index 4db90f0c0207..c004307336d9 100644 --- a/runtime/test-runtime/constants/src/weights/block_weights.rs +++ b/runtime/test-runtime/constants/src/weights/block_weights.rs @@ -23,7 +23,7 @@ pub mod constants { parameter_types! { /// Importing a block with 0 Extrinsics. - pub const BlockExecutionWeight: Weight = 5_000_000 * constants::WEIGHT_PER_NANOS; + pub const BlockExecutionWeight: Weight = constants::WEIGHT_PER_NANOS.saturating_mul(5_000_000); } #[cfg(test)] @@ -38,9 +38,15 @@ pub mod constants { let w = super::constants::BlockExecutionWeight::get(); // At least 100 µs. - assert!(w >= 100 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs."); + assert!( + w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(), + "Weight should be at least 100 µs." + ); // At most 50 ms. - assert!(w <= 50 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); + assert!( + w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(), + "Weight should be at most 50 ms." + ); } } } diff --git a/runtime/test-runtime/constants/src/weights/extrinsic_weights.rs b/runtime/test-runtime/constants/src/weights/extrinsic_weights.rs index 158ba99c6a4c..3ce6b73d5844 100644 --- a/runtime/test-runtime/constants/src/weights/extrinsic_weights.rs +++ b/runtime/test-runtime/constants/src/weights/extrinsic_weights.rs @@ -23,7 +23,7 @@ pub mod constants { parameter_types! { /// Executing a NO-OP `System::remarks` Extrinsic. - pub const ExtrinsicBaseWeight: Weight = 125_000 * constants::WEIGHT_PER_NANOS; + pub const ExtrinsicBaseWeight: Weight = constants::WEIGHT_PER_NANOS.saturating_mul(125_000); } #[cfg(test)] @@ -38,9 +38,15 @@ pub mod constants { let w = super::constants::ExtrinsicBaseWeight::get(); // At least 10 µs. - assert!(w >= 10 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); + assert!( + w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(), + "Weight should be at least 10 µs." + ); // At most 1 ms. - assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); + assert!( + w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), + "Weight should be at most 1 ms." + ); } } } diff --git a/runtime/test-runtime/constants/src/weights/paritydb_weights.rs b/runtime/test-runtime/constants/src/weights/paritydb_weights.rs index 843823c1bf30..dca7d348310c 100644 --- a/runtime/test-runtime/constants/src/weights/paritydb_weights.rs +++ b/runtime/test-runtime/constants/src/weights/paritydb_weights.rs @@ -25,8 +25,8 @@ pub mod constants { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 8_000 * constants::WEIGHT_PER_NANOS, - write: 50_000 * constants::WEIGHT_PER_NANOS, + read: 8_000 * constants::WEIGHT_PER_NANOS.ref_time(), + write: 50_000 * constants::WEIGHT_PER_NANOS.ref_time(), }; } @@ -42,20 +42,20 @@ pub mod constants { fn sane() { // At least 1 µs. assert!( - W::get().reads(1) >= constants::WEIGHT_PER_MICROS, + W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Read weight should be at least 1 µs." ); assert!( - W::get().writes(1) >= constants::WEIGHT_PER_MICROS, + W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Write weight should be at least 1 µs." ); // At most 1 ms. assert!( - W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, + W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Read weight should be at most 1 ms." ); assert!( - W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, + W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Write weight should be at most 1 ms." ); } diff --git a/runtime/test-runtime/constants/src/weights/rocksdb_weights.rs b/runtime/test-runtime/constants/src/weights/rocksdb_weights.rs index 05e06b0eabe3..87867ebfe177 100644 --- a/runtime/test-runtime/constants/src/weights/rocksdb_weights.rs +++ b/runtime/test-runtime/constants/src/weights/rocksdb_weights.rs @@ -25,8 +25,8 @@ pub mod constants { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 25_000 * constants::WEIGHT_PER_NANOS, - write: 100_000 * constants::WEIGHT_PER_NANOS, + read: 25_000 * constants::WEIGHT_PER_NANOS.ref_time(), + write: 100_000 * constants::WEIGHT_PER_NANOS.ref_time(), }; } @@ -42,20 +42,20 @@ pub mod constants { fn sane() { // At least 1 µs. assert!( - W::get().reads(1) >= constants::WEIGHT_PER_MICROS, + W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Read weight should be at least 1 µs." ); assert!( - W::get().writes(1) >= constants::WEIGHT_PER_MICROS, + W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Write weight should be at least 1 µs." ); // At most 1 ms. assert!( - W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, + W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Read weight should be at most 1 ms." ); assert!( - W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, + W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Write weight should be at most 1 ms." ); } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 36610b381c3b..dcbc83892154 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -38,19 +38,18 @@ use beefy_primitives::crypto::AuthorityId as BeefyId; use frame_election_provider_support::{onchain, SequentialPhragmen}; use frame_support::{ construct_runtime, parameter_types, - traits::{Everything, KeyOwnerProofSystem}, + traits::{Everything, KeyOwnerProofSystem, WithdrawReasons}, }; use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId}; use pallet_session::historical as session_historical; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use polkadot_runtime_parachains::reward_points::RewardValidatorsWithEraPoints; use primitives::v2::{ - AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash, - CommittedCandidateReceipt, CoreState, DisputeState, GroupRotationInfo, Hash as HashT, - Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, Nonce, - OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, - SessionInfo as SessionInfoData, Signature, ValidationCode, ValidationCodeHash, ValidatorId, - ValidatorIndex, + AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt, + CoreState, GroupRotationInfo, Hash as HashT, Id as ParaId, InboundDownwardMessage, + InboundHrmpMessage, Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, + ScrapedOnChainVotes, SessionInfo as SessionInfoData, Signature, ValidationCode, + ValidationCodeHash, ValidatorId, ValidatorIndex, }; use runtime_common::{ claims, impl_runtime_weights, paras_sudo_wrapper, BlockHashCount, BlockLength, @@ -136,8 +135,8 @@ impl frame_system::Config for Runtime { type BlockWeights = BlockWeights; type BlockLength = BlockLength; type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = Nonce; type BlockNumber = BlockNumber; type Hash = HashT; @@ -145,7 +144,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = Indices; type Header = generic::Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = Version; type PalletInfo = PalletInfo; @@ -160,9 +159,9 @@ impl frame_system::Config for Runtime { impl frame_system::offchain::SendTransactionTypes for Runtime where - Call: From, + RuntimeCall: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = UncheckedExtrinsic; } @@ -206,7 +205,7 @@ impl pallet_indices::Config for Runtime { type AccountIndex = AccountIndex; type Currency = Balances; type Deposit = IndexDeposit; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } @@ -219,7 +218,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type Balance = Balance; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type MaxLocks = MaxLocks; @@ -236,7 +235,7 @@ parameter_types! { } impl pallet_transaction_payment::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = WeightToFee; @@ -282,7 +281,7 @@ impl_opaque_keys! { } impl pallet_session::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = pallet_staking::StashOf; type ShouldEndSession = Babe; @@ -337,7 +336,7 @@ impl pallet_staking::Config for Runtime { type UnixTime = Timestamp; type CurrencyToVote = frame_support::traits::U128CurrencyToVote; type RewardRemainder = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Slash = (); type Reward = (); type SessionsPerEra = SessionsPerEra; @@ -355,15 +354,16 @@ impl pallet_staking::Config for Runtime { // Use the nominator map to iter voter AND no-ops for all SortedListProvider hooks. The migration // to bags-list is a no-op, but the storage version will be updated. type VoterList = pallet_staking::UseNominatorsAndValidatorsMap; + type TargetList = pallet_staking::UseValidatorsMap; type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; + type HistoryDepth = frame_support::traits::ConstU32<84>; type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; type OnStakerSlash = (); type WeightInfo = (); } impl pallet_grandpa::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; type KeyOwnerProofSystem = (); @@ -383,14 +383,14 @@ impl pallet_grandpa::Config for Runtime { impl frame_system::offchain::CreateSignedTransaction for Runtime where - Call: From, + RuntimeCall: From, { fn create_transaction>( - call: Call, + call: RuntimeCall, public: ::Signer, account: AccountId, nonce: ::Index, - ) -> Option<(Call, ::SignaturePayload)> { + ) -> Option<(RuntimeCall, ::SignaturePayload)> { let period = BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64; @@ -427,7 +427,7 @@ impl frame_system::offchain::SigningTypes for Runtime { } impl pallet_offences::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } @@ -446,7 +446,7 @@ parameter_types! { } impl claims::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type VestingSchedule = Vesting; type Prefix = Prefix; type MoveClaimOrigin = frame_system::EnsureRoot; @@ -455,20 +455,23 @@ impl claims::Config for Runtime { parameter_types! { pub storage MinVestedTransfer: Balance = 100 * DOLLARS; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } impl pallet_vesting::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BlockNumberToBalance = ConvertInto; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = (); + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; const MAX_VESTING_SCHEDULES: u32 = 28; } impl pallet_sudo::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; } impl parachains_configuration::Config for Runtime { @@ -478,15 +481,15 @@ impl parachains_configuration::Config for Runtime { impl parachains_shared::Config for Runtime {} impl parachains_inclusion::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DisputesHandler = ParasDisputes; type RewardValidators = RewardValidatorsWithEraPoints; } impl parachains_disputes::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type RewardValidators = (); - type PunishValidators = (); + type SlashingHandler = (); type WeightInfo = parachains_disputes::TestWeightInfo; } @@ -509,7 +512,7 @@ parameter_types! { } impl parachains_paras::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = parachains_paras::TestWeightInfo; type UnsignedPriority = ParasUnsignedPriority; type NextSessionRotation = Babe; @@ -522,7 +525,7 @@ parameter_types! { } impl parachains_ump::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type UmpSink = (); type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = frame_system::EnsureRoot; @@ -530,29 +533,30 @@ impl parachains_ump::Config for Runtime { } parameter_types! { - pub const BaseXcmWeight: frame_support::weights::Weight = 1_000; + pub const BaseXcmWeight: xcm::latest::Weight = 1_000; pub const AnyNetwork: Option = None; pub const MaxInstructions: u32 = 100; pub const UniversalLocation: xcm::latest::InteriorMultiLocation = xcm::latest::Junctions::Here; } -pub type LocalOriginToLocation = xcm_builder::SignedToAccountId32; +pub type LocalOriginToLocation = + xcm_builder::SignedToAccountId32; impl pallet_xcm::Config for Runtime { // The config types here are entirely configurable, since the only one that is sorely needed // is `XcmExecutor`, which will be used in unit tests located in xcm-executor. - type Event = Event; - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; + type RuntimeEvent = RuntimeEvent; + type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; type UniversalLocation = UniversalLocation; - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; - type Weigher = xcm_builder::FixedWeightBounds; + type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + type Weigher = xcm_builder::FixedWeightBounds; type XcmRouter = xcm_config::DoNothingRouter; type XcmExecuteFilter = Everything; type XcmExecutor = xcm_executor::XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type Currency = Balances; @@ -563,8 +567,8 @@ impl pallet_xcm::Config for Runtime { } impl parachains_hrmp::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type WeightInfo = parachains_hrmp::TestWeightInfo; } @@ -576,9 +580,9 @@ impl paras_sudo_wrapper::Config for Runtime {} impl parachains_origin::Config for Runtime {} impl pallet_test_notifier::Config for Runtime { - type Event = Event; - type Origin = Origin; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; } #[frame_support::pallet] @@ -595,10 +599,10 @@ pub mod pallet_test_notifier { #[pallet::config] pub trait Config: frame_system::Config + pallet_xcm::Config { - type Event: IsType<::Event> + From>; - type Origin: IsType<::Origin> - + Into::Origin>>; - type Call: IsType<::Call> + From>; + type RuntimeEvent: IsType<::RuntimeEvent> + From>; + type RuntimeOrigin: IsType<::RuntimeOrigin> + + Into::RuntimeOrigin>>; + type RuntimeCall: IsType<::RuntimeCall> + From>; } #[pallet::event] @@ -642,7 +646,7 @@ pub mod pallet_test_notifier { Call::::notification_received { query_id: 0, response: Default::default() }; let qid = pallet_xcm::Pallet::::new_notify_query( Junction::AccountId32 { network: None, id }, - ::Call::from(call), + ::RuntimeCall::from(call), 100u32.into(), Here, ); @@ -656,7 +660,7 @@ pub mod pallet_test_notifier { query_id: QueryId, response: Response, ) -> DispatchResult { - let responder = ensure_response(::Origin::from(origin))?; + let responder = ensure_response(::RuntimeOrigin::from(origin))?; Self::deposit_event(Event::::ResponseReceived(responder, query_id, response)); Ok(()) } @@ -700,7 +704,7 @@ construct_runtime! { ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event}, ParaInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent}, Initializer: parachains_initializer::{Pallet, Call, Storage}, - Paras: parachains_paras::{Pallet, Call, Storage, Event}, + Paras: parachains_paras::{Pallet, Call, Storage, Event, ValidateUnsigned}, ParasShared: parachains_shared::{Pallet, Call, Storage}, Scheduler: parachains_scheduler::{Pallet, Storage}, ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call}, @@ -740,7 +744,8 @@ pub type SignedExtra = ( pallet_transaction_payment::ChargeTransactionPayment, ); /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = + generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -750,7 +755,7 @@ pub type Executive = frame_executive::Executive< AllPalletsWithSystem, >; /// The payload being signed in transactions. -pub type SignedPayload = generic::SignedPayload; +pub type SignedPayload = generic::SignedPayload; pub type Hash = ::Hash; pub type Extrinsic = ::Extrinsic; @@ -913,10 +918,6 @@ sp_api::impl_runtime_apis! { { runtime_impl::validation_code_hash::(para_id, assumption) } - - fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { - polkadot_runtime_parachains::runtime_api_impl::vstaging::get_session_disputes::() - } } impl beefy_primitives::BeefyApi for Runtime { @@ -926,8 +927,8 @@ sp_api::impl_runtime_apis! { } } - impl mmr::MmrApi for Runtime { - fn generate_proof(_leaf_index: u64) + impl mmr::MmrApi for Runtime { + fn generate_proof(_block_number: BlockNumber) -> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof), mmr::Error> { Err(mmr::Error::PalletNotIncluded) @@ -951,12 +952,19 @@ sp_api::impl_runtime_apis! { Err(mmr::Error::PalletNotIncluded) } - fn generate_batch_proof(_leaf_indices: Vec) + fn generate_batch_proof(_block_numbers: Vec) -> Result<(Vec, mmr::BatchProof), mmr::Error> { Err(mmr::Error::PalletNotIncluded) } + fn generate_historical_batch_proof( + _block_numbers: Vec, + _best_known_block_number: BlockNumber, + ) -> Result<(Vec, mmr::BatchProof), mmr::Error> { + Err(mmr::Error::PalletNotIncluded) + } + fn verify_batch_proof(_leaves: Vec, _proof: mmr::BatchProof) -> Result<(), mmr::Error> { @@ -1000,19 +1008,15 @@ sp_api::impl_runtime_apis! { } impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeGenesisConfiguration { - // The choice of `c` parameter (where `1 - c` represents the - // probability of a slot being empty), is done in accordance to the - // slot duration and expected target block time, for safely - // resisting network delays of maximum two seconds. - // - babe_primitives::BabeGenesisConfiguration { + fn configuration() -> babe_primitives::BabeConfiguration { + let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG); + babe_primitives::BabeConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDuration::get(), - c: BABE_GENESIS_EPOCH_CONFIG.c, - genesis_authorities: Babe::authorities().to_vec(), + c: epoch_config.c, + authorities: Babe::authorities().to_vec(), randomness: Babe::randomness(), - allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots, + allowed_slots: epoch_config.allowed_slots, } } @@ -1073,13 +1077,13 @@ sp_api::impl_runtime_apis! { } } - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi for Runtime { - fn query_call_info(call: Call, len: u32) -> RuntimeDispatchInfo { + fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo { TransactionPayment::query_call_info(call, len) } - fn query_call_fee_details(call: Call, len: u32) -> FeeDetails { + fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails { TransactionPayment::query_call_fee_details(call, len) } } diff --git a/runtime/test-runtime/src/xcm_config.rs b/runtime/test-runtime/src/xcm_config.rs index 284a1d3dc21b..d3ad71f2724e 100644 --- a/runtime/test-runtime/src/xcm_config.rs +++ b/runtime/test-runtime/src/xcm_config.rs @@ -17,9 +17,8 @@ use frame_support::{ parameter_types, traits::{Everything, Nothing}, - weights::Weight, }; -use xcm::latest::prelude::*; +use xcm::latest::{prelude::*, Weight as XCMWeight}; use xcm_builder::{AllowUnpaidExecutionFrom, FixedWeightBounds, SignedToAccountId32}; use xcm_executor::{ traits::{TransactAsset, WeightTrader}, @@ -37,7 +36,7 @@ parameter_types! { /// of this chain. pub type LocalOriginToLocation = ( // And a usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, + SignedToAccountId32, ); pub struct DoNothingRouter; @@ -75,22 +74,22 @@ impl WeightTrader for DummyWeightTrader { DummyWeightTrader } - fn buy_weight(&mut self, _weight: Weight, _payment: Assets) -> Result { + fn buy_weight(&mut self, _weight: XCMWeight, _payment: Assets) -> Result { Ok(Assets::default()) } } pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { - type Call = super::Call; + type RuntimeCall = super::RuntimeCall; type XcmSender = DoNothingRouter; type AssetTransactor = DummyAssetTransactor; - type OriginConverter = pallet_xcm::XcmPassthrough; + type OriginConverter = pallet_xcm::XcmPassthrough; type IsReserve = (); type IsTeleporter = (); type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type Trader = DummyWeightTrader; type ResponseHandler = super::Xcm; type AssetTrap = super::Xcm; @@ -103,4 +102,5 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = super::RuntimeCall; } diff --git a/runtime/westend/Cargo.toml b/runtime/westend/Cargo.toml index 92e42df56335..f43e22249913 100644 --- a/runtime/westend/Cargo.toml +++ b/runtime/westend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "westend-runtime" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" build = "build.rs" @@ -15,79 +15,80 @@ serde = { version = "1.0.137", default-features = false } serde_derive = { version = "1.0.117", optional = true } smallvec = "1.8.0" -authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-npos-elections = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +beefy-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-mmr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-version = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +tx-pool-api = { package = "sp-transaction-pool", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +block-builder-api = { package = "sp-block-builder", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-npos-elections = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } -frame-election-provider-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +frame-election-provider-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } westend-runtime-constants = { package = "westend-runtime-constants", path = "./constants", default-features = false } -pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-bags-list = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-elections-phragmen = { package = "pallet-elections-phragmen", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-im-online = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-indices = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-membership = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-nomination-pools = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-offences = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-recovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-society = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-staking-reward-curve = { package = "pallet-staking-reward-curve", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +pallet-authority-discovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-babe = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-bags-list = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-elections-phragmen = { package = "pallet-elections-phragmen", git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-fast-unstake = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-im-online = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-indices = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-membership = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-nomination-pools = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-offences = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-recovery = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-scheduler = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-society = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-staking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-staking-reward-curve = { package = "pallet-staking-reward-curve", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-treasury = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-vesting = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false } pallet-xcm-benchmarks = { path = "../../xcm/pallet-xcm-benchmarks", default-features = false, optional = true } -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-election-provider-support-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } -pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-election-provider-support-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-nomination-pools-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } +pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } hex-literal = { version = "0.3.4", optional = true } runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false } primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false } polkadot-parachain = { path = "../../parachain", default-features = false } -runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false, features = ["vstaging"] } +runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false } xcm = { package = "xcm", path = "../../xcm", default-features = false } xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", default-features = false } @@ -96,15 +97,15 @@ xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default [dev-dependencies] hex-literal = "0.3.4" tiny-keccak = { version = "2.0.2", features = ["keccak"] } -keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } serde_json = "1.0.81" -remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } tokio = { version = "1.19.2", features = ["macros"] } -sp-tracing = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-tracing = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } [build-dependencies] -substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] default = ["std"] @@ -135,6 +136,7 @@ std = [ "pallet-collective/std", "pallet-elections-phragmen/std", "pallet-election-provider-multi-phase/std", + "pallet-fast-unstake/std", "pallet-democracy/std", "pallet-grandpa/std", "pallet-identity/std", @@ -196,12 +198,13 @@ runtime-benchmarks = [ "pallet-elections-phragmen/runtime-benchmarks", "pallet-election-provider-multi-phase/runtime-benchmarks", "pallet-election-provider-support-benchmarking/runtime-benchmarks", + "pallet-fast-unstake/runtime-benchmarks", "pallet-grandpa/runtime-benchmarks", "pallet-identity/runtime-benchmarks", "pallet-im-online/runtime-benchmarks", "pallet-indices/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", - "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-benchmarking/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", "pallet-recovery/runtime-benchmarks", @@ -212,13 +215,13 @@ runtime-benchmarks = [ "pallet-treasury/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", - "pallet-offences-benchmarking", - "pallet-session-benchmarking", + "pallet-offences-benchmarking/runtime-benchmarks", + "pallet-session-benchmarking/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", - "frame-system-benchmarking", + "frame-system-benchmarking/runtime-benchmarks", "hex-literal", "xcm-builder/runtime-benchmarks", - "pallet-xcm-benchmarks", + "pallet-xcm-benchmarks/runtime-benchmarks", "frame-election-provider-support/runtime-benchmarks", "pallet-bags-list/runtime-benchmarks", "runtime-parachains/runtime-benchmarks", @@ -227,14 +230,15 @@ try-runtime = [ "frame-executive/try-runtime", "frame-system/try-runtime", "frame-try-runtime", - "pallet-authorship/try-runtime", + "runtime-common/try-runtime", "pallet-authority-discovery/try-runtime", + "pallet-authorship/try-runtime", "pallet-balances/try-runtime", - "pallet-bags-list/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-collective/try-runtime", "pallet-elections-phragmen/try-runtime", "pallet-election-provider-multi-phase/try-runtime", + "pallet-fast-unstake/try-runtime", "pallet-democracy/try-runtime", "pallet-grandpa/try-runtime", "pallet-identity/try-runtime", @@ -256,8 +260,9 @@ try-runtime = [ "pallet-treasury/try-runtime", "pallet-utility/try-runtime", "pallet-vesting/try-runtime", + "pallet-xcm/try-runtime", "pallet-babe/try-runtime", - "runtime-common/try-runtime", + "pallet-bags-list/try-runtime", ] # When enabled, the runtime API will not be build. # diff --git a/runtime/westend/constants/Cargo.toml b/runtime/westend/constants/Cargo.toml index edcba00433f1..93a3ca44591f 100644 --- a/runtime/westend/constants/Cargo.toml +++ b/runtime/westend/constants/Cargo.toml @@ -1,19 +1,23 @@ [package] name = "westend-runtime-constants" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] smallvec = "1.8.0" -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } primitives = { package = "polkadot-primitives", path = "../../../primitives", default-features = false } runtime-common = { package = "polkadot-runtime-common", path = "../../common", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } [features] default = ["std"] std = [ - "sp-runtime/std" + "sp-core/std", + "sp-runtime/std", + "sp-weights/std" ] diff --git a/runtime/westend/constants/src/lib.rs b/runtime/westend/constants/src/lib.rs index 247876e4ffd0..d3fa1c501c3e 100644 --- a/runtime/westend/constants/src/lib.rs +++ b/runtime/westend/constants/src/lib.rs @@ -50,6 +50,9 @@ pub mod time { pub const DAYS: BlockNumber = HOURS * 24; // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. + // The choice of is done in accordance to the slot duration and expected target + // block time, for safely resisting network delays of maximum two seconds. + // pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); } @@ -82,7 +85,7 @@ pub mod fee { fn polynomial() -> WeightToFeeCoefficients { // in Westend, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: let p = super::currency::CENTS; - let q = 10 * Balance::from(ExtrinsicBaseWeight::get()); + let q = 10 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); smallvec![WeightToFeeCoefficient { degree: 1, negative: false, diff --git a/runtime/westend/constants/src/weights/block_weights.rs b/runtime/westend/constants/src/weights/block_weights.rs index 882fd3ffbc87..9ff4e96f0c48 100644 --- a/runtime/westend/constants/src/weights/block_weights.rs +++ b/runtime/westend/constants/src/weights/block_weights.rs @@ -1,28 +1,26 @@ -// This file is part of Substrate. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// 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. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// 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 . //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19 (Y/M/D) -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25 (Y/M/D) +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Development` //! WARMUPS: `10`, REPEAT: `100` //! WEIGHT-PATH: `runtime/westend/constants/src/weights/` -//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1`, WEIGHT-ADD: `0` +//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` // Executed Command: // ./target/production/polkadot @@ -34,32 +32,31 @@ // --weight-path=runtime/westend/constants/src/weights/ // --warmup=10 // --repeat=100 +// --header=./file_header.txt -use frame_support::{ - parameter_types, - weights::{constants::WEIGHT_PER_NANOS, Weight}, -}; +use sp_core::parameter_types; +use sp_weights::{constants::WEIGHT_PER_NANOS, Weight}; parameter_types! { /// Time to execute an empty block. - /// Calculated by multiplying the *Average* with `1` and adding `0`. + /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 4_929_970, 5_140_248 - /// Average: 4_970_728 - /// Median: 4_964_665 - /// Std-Dev: 37170.72 + /// Min, Max: 4_898_859, 5_130_799 + /// Average: 5_000_060 + /// Median: 5_005_375 + /// Std-Dev: 60863.28 /// /// Percentiles nanoseconds: - /// 99th: 5_084_427 - /// 95th: 5_039_369 - /// 75th: 4_991_020 - pub const BlockExecutionWeight: Weight = 4_970_728 * WEIGHT_PER_NANOS; + /// 99th: 5_119_528 + /// 95th: 5_095_268 + /// 75th: 5_040_113 + pub const BlockExecutionWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(5_000_060); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; + use sp_weights::constants; /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, @@ -69,8 +66,14 @@ mod test_weights { let w = super::BlockExecutionWeight::get(); // At least 100 µs. - assert!(w >= 100 * constants::WEIGHT_PER_MICROS, "Weight should be at least 100 µs."); + assert!( + w.ref_time() >= 100u64 * constants::WEIGHT_PER_MICROS.ref_time(), + "Weight should be at least 100 µs." + ); // At most 50 ms. - assert!(w <= 50 * constants::WEIGHT_PER_MILLIS, "Weight should be at most 50 ms."); + assert!( + w.ref_time() <= 50u64 * constants::WEIGHT_PER_MILLIS.ref_time(), + "Weight should be at most 50 ms." + ); } } diff --git a/runtime/westend/constants/src/weights/extrinsic_weights.rs b/runtime/westend/constants/src/weights/extrinsic_weights.rs index 1e5ba5515cf4..f52e2961660e 100644 --- a/runtime/westend/constants/src/weights/extrinsic_weights.rs +++ b/runtime/westend/constants/src/weights/extrinsic_weights.rs @@ -1,27 +1,26 @@ -// This file is part of Substrate. +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// 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. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// 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 . //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-05-26 (Y/M/D) +//! DATE: 2022-10-25 (Y/M/D) +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Development` //! WARMUPS: `10`, REPEAT: `100` //! WEIGHT-PATH: `runtime/westend/constants/src/weights/` -//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1`, WEIGHT-ADD: `0` +//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` // Executed Command: // ./target/production/polkadot @@ -33,32 +32,31 @@ // --weight-path=runtime/westend/constants/src/weights/ // --warmup=10 // --repeat=100 +// --header=./file_header.txt -use frame_support::{ - parameter_types, - weights::{constants::WEIGHT_PER_NANOS, Weight}, -}; +use sp_core::parameter_types; +use sp_weights::{constants::WEIGHT_PER_NANOS, Weight}; parameter_types! { /// Time to execute a NO-OP extrinsic, for example `System::remark`. - /// Calculated by multiplying the *Average* with `1` and adding `0`. + /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 78_822, 82_445 - /// Average: 79_088 - /// Median: 79_012 - /// Std-Dev: 422.84 + /// Min, Max: 87_511, 89_510 + /// Average: 87_998 + /// Median: 87_963 + /// Std-Dev: 317.63 /// /// Percentiles nanoseconds: - /// 99th: 80_770 - /// 95th: 79_394 - /// 75th: 79_071 - pub const ExtrinsicBaseWeight: Weight = 79_088 * WEIGHT_PER_NANOS; + /// 99th: 89_279 + /// 95th: 88_456 + /// 75th: 88_052 + pub const ExtrinsicBaseWeight: Weight = WEIGHT_PER_NANOS.saturating_mul(87_998); } #[cfg(test)] mod test_weights { - use frame_support::weights::constants; + use sp_weights::constants; /// Checks that the weight exists and is sane. // NOTE: If this test fails but you are sure that the generated values are fine, @@ -68,8 +66,14 @@ mod test_weights { let w = super::ExtrinsicBaseWeight::get(); // At least 10 µs. - assert!(w >= 10 * constants::WEIGHT_PER_MICROS, "Weight should be at least 10 µs."); + assert!( + w.ref_time() >= 10u64 * constants::WEIGHT_PER_MICROS.ref_time(), + "Weight should be at least 10 µs." + ); // At most 1 ms. - assert!(w <= constants::WEIGHT_PER_MILLIS, "Weight should be at most 1 ms."); + assert!( + w.ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), + "Weight should be at most 1 ms." + ); } } diff --git a/runtime/westend/constants/src/weights/paritydb_weights.rs b/runtime/westend/constants/src/weights/paritydb_weights.rs index 843823c1bf30..dca7d348310c 100644 --- a/runtime/westend/constants/src/weights/paritydb_weights.rs +++ b/runtime/westend/constants/src/weights/paritydb_weights.rs @@ -25,8 +25,8 @@ pub mod constants { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 8_000 * constants::WEIGHT_PER_NANOS, - write: 50_000 * constants::WEIGHT_PER_NANOS, + read: 8_000 * constants::WEIGHT_PER_NANOS.ref_time(), + write: 50_000 * constants::WEIGHT_PER_NANOS.ref_time(), }; } @@ -42,20 +42,20 @@ pub mod constants { fn sane() { // At least 1 µs. assert!( - W::get().reads(1) >= constants::WEIGHT_PER_MICROS, + W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Read weight should be at least 1 µs." ); assert!( - W::get().writes(1) >= constants::WEIGHT_PER_MICROS, + W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Write weight should be at least 1 µs." ); // At most 1 ms. assert!( - W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, + W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Read weight should be at most 1 ms." ); assert!( - W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, + W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Write weight should be at most 1 ms." ); } diff --git a/runtime/westend/constants/src/weights/rocksdb_weights.rs b/runtime/westend/constants/src/weights/rocksdb_weights.rs index 05e06b0eabe3..87867ebfe177 100644 --- a/runtime/westend/constants/src/weights/rocksdb_weights.rs +++ b/runtime/westend/constants/src/weights/rocksdb_weights.rs @@ -25,8 +25,8 @@ pub mod constants { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { - read: 25_000 * constants::WEIGHT_PER_NANOS, - write: 100_000 * constants::WEIGHT_PER_NANOS, + read: 25_000 * constants::WEIGHT_PER_NANOS.ref_time(), + write: 100_000 * constants::WEIGHT_PER_NANOS.ref_time(), }; } @@ -42,20 +42,20 @@ pub mod constants { fn sane() { // At least 1 µs. assert!( - W::get().reads(1) >= constants::WEIGHT_PER_MICROS, + W::get().reads(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Read weight should be at least 1 µs." ); assert!( - W::get().writes(1) >= constants::WEIGHT_PER_MICROS, + W::get().writes(1).ref_time() >= constants::WEIGHT_PER_MICROS.ref_time(), "Write weight should be at least 1 µs." ); // At most 1 ms. assert!( - W::get().reads(1) <= constants::WEIGHT_PER_MILLIS, + W::get().reads(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Read weight should be at most 1 ms." ); assert!( - W::get().writes(1) <= constants::WEIGHT_PER_MILLIS, + W::get().writes(1).ref_time() <= constants::WEIGHT_PER_MILLIS.ref_time(), "Write weight should be at most 1 ms." ); } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 1c04e96694f1..3ee7a65584a3 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -25,7 +25,7 @@ use beefy_primitives::crypto::AuthorityId as BeefyId; use frame_election_provider_support::{onchain, SequentialPhragmen}; use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU32, Contains, InstanceFilter, KeyOwnerProofSystem}, + traits::{ConstU32, InstanceFilter, KeyOwnerProofSystem, WithdrawReasons}, weights::ConstantMultiplier, PalletId, }; @@ -49,8 +49,9 @@ use runtime_common::{ }; use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, - initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, + disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + inclusion as parachains_inclusion, initializer as parachains_initializer, + origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, @@ -80,7 +81,9 @@ pub use pallet_balances::Call as BalancesCall; pub use pallet_election_provider_multi_phase::Call as EPMCall; #[cfg(feature = "std")] pub use pallet_staking::StakerStatus; +use pallet_staking::UseValidatorsMap; pub use pallet_timestamp::Call as TimestampCall; +use sp_runtime::traits::Get; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; @@ -106,13 +109,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("westend"), impl_name: create_runtime_str!("parity-westend"), authoring_version: 2, - spec_version: 9280, + spec_version: 9310, impl_version: 0, #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS, #[cfg(feature = "disable-runtime-api")] apis: sp_version::create_apis_vec![[]], - transaction_version: 11, + transaction_version: 14, state_version: 0, }; @@ -129,25 +132,17 @@ pub fn native_version() -> NativeVersion { NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } } -/// Allow everything. -pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(_: &Call) -> bool { - true - } -} - parameter_types! { pub const Version: RuntimeVersion = VERSION; pub const SS58Prefix: u8 = 42; } impl frame_system::Config for Runtime { - type BaseCallFilter = BaseFilter; + type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = BlockWeights; type BlockLength = BlockLength; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = Nonce; type BlockNumber = BlockNumber; type Hash = Hash; @@ -155,7 +150,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = AccountIdLookup; type Header = generic::Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = RocksDbWeight; type Version = Version; @@ -177,17 +172,16 @@ parameter_types! { } impl pallet_scheduler::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type PalletsOrigin = OriginCaller; - type Call = Call; + type RuntimeCall = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = weights::pallet_scheduler::WeightInfo; type OriginPrivilegeCmp = frame_support::traits::EqualPrivilegeOnly; - type PreimageProvider = Preimage; - type NoPreimagePostponement = NoPreimagePostponement; + type Preimages = Preimage; } parameter_types! { @@ -198,10 +192,9 @@ parameter_types! { impl pallet_preimage::Config for Runtime { type WeightInfo = weights::pallet_preimage::WeightInfo; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; - type MaxSize = PreimageMaxSize; type BaseDeposit = PreimageBaseDeposit; type ByteDeposit = PreimageByteDeposit; } @@ -253,7 +246,7 @@ impl pallet_indices::Config for Runtime { type AccountIndex = AccountIndex; type Currency = Balances; type Deposit = IndexDeposit; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::pallet_indices::WeightInfo; } @@ -266,7 +259,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type Balance = Balance; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type MaxLocks = MaxLocks; @@ -283,7 +276,7 @@ parameter_types! { } impl pallet_transaction_payment::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter>; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = WeightToFee; @@ -329,7 +322,7 @@ impl_opaque_keys! { } impl pallet_session::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = pallet_staking::StashOf; type ShouldEndSession = Babe; @@ -416,7 +409,7 @@ impl pallet_election_provider_multi_phase::MinerConfig for Runtime { } impl pallet_election_provider_multi_phase::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type EstimateCallFee = TransactionPayment; type SignedPhase = SignedPhase; @@ -437,6 +430,9 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type OffchainRepeat = OffchainRepeat; type MinerTxPriority = NposSolutionPriority; type DataProvider = Staking; + #[cfg(any(feature = "fast-runtime", feature = "runtime-benchmarks"))] + type Fallback = onchain::UnboundedExecution; + #[cfg(not(any(feature = "fast-runtime", feature = "runtime-benchmarks")))] type Fallback = pallet_election_provider_multi_phase::NoFallback; type GovernanceFallback = onchain::UnboundedExecution; type Solver = SequentialPhragmen< @@ -455,8 +451,9 @@ parameter_types! { pub const BagThresholds: &'static [u64] = &bag_thresholds::THRESHOLDS; } -impl pallet_bags_list::Config for Runtime { - type Event = Event; +type VoterBagsListInstance = pallet_bags_list::Instance1; +impl pallet_bags_list::Config for Runtime { + type RuntimeEvent = RuntimeEvent; type ScoreProvider = Staking; type WeightInfo = weights::pallet_bags_list::WeightInfo; type BagThresholds = BagThresholds; @@ -476,7 +473,7 @@ pallet_staking_reward_curve::build! { parameter_types! { // Six sessions in an era (6 hours). - pub const SessionsPerEra: SessionIndex = 6; + pub const SessionsPerEra: SessionIndex = prod_or_fast!(6, 1); // 2 eras for unbonding (12 hours). pub const BondingDuration: sp_staking::EraIndex = 2; // 1 era in which slashes can be cancelled (6 hours). @@ -494,7 +491,7 @@ impl pallet_staking::Config for Runtime { type UnixTime = Timestamp; type CurrencyToVote = CurrencyToVote; type RewardRemainder = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Slash = (); type Reward = (); type SessionsPerEra = SessionsPerEra; @@ -510,18 +507,28 @@ impl pallet_staking::Config for Runtime { type ElectionProvider = ElectionProviderMultiPhase; type GenesisElectionProvider = onchain::UnboundedExecution; type VoterList = VoterList; + type TargetList = UseValidatorsMap; type MaxUnlockingChunks = frame_support::traits::ConstU32<32>; + type HistoryDepth = frame_support::traits::ConstU32<84>; type BenchmarkingConfig = runtime_common::StakingBenchmarkingConfig; type OnStakerSlash = NominationPools; type WeightInfo = weights::pallet_staking::WeightInfo; } +impl pallet_fast_unstake::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type DepositCurrency = Balances; + type Deposit = frame_support::traits::ConstU128<{ UNITS }>; + type ControlOrigin = EnsureRoot; + type WeightInfo = weights::pallet_fast_unstake::WeightInfo; +} + parameter_types! { pub const MaxAuthorities: u32 = 100_000; } impl pallet_offences::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } @@ -540,7 +547,7 @@ parameter_types! { impl pallet_im_online::Config for Runtime { type AuthorityId = ImOnlineId; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorSet = Historical; type NextSessionRotation = Babe; type ReportUnresponsiveness = Offences; @@ -552,8 +559,7 @@ impl pallet_im_online::Config for Runtime { } impl pallet_grandpa::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; type KeyOwnerProofSystem = Historical; @@ -579,14 +585,14 @@ impl pallet_grandpa::Config for Runtime { /// format of the chain. impl frame_system::offchain::CreateSignedTransaction for Runtime where - Call: From, + RuntimeCall: From, { fn create_transaction>( - call: Call, + call: RuntimeCall, public: ::Signer, account: AccountId, nonce: ::Index, - ) -> Option<(Call, ::SignaturePayload)> { + ) -> Option<(RuntimeCall, ::SignaturePayload)> { use sp_runtime::traits::StaticLookup; // take the biggest period possible. let period = @@ -630,9 +636,9 @@ impl frame_system::offchain::SigningTypes for Runtime { impl frame_system::offchain::SendTransactionTypes for Runtime where - Call: From, + RuntimeCall: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = UncheckedExtrinsic; } @@ -647,7 +653,7 @@ parameter_types! { } impl pallet_identity::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type Slashed = (); type BasicDeposit = BasicDeposit; @@ -662,8 +668,8 @@ impl pallet_identity::Config for Runtime { } impl pallet_utility::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = weights::pallet_utility::WeightInfo; } @@ -677,8 +683,8 @@ parameter_types! { } impl pallet_multisig::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; @@ -694,9 +700,9 @@ parameter_types! { } impl pallet_recovery::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); - type Call = Call; + type RuntimeCall = RuntimeCall; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; @@ -706,20 +712,23 @@ impl pallet_recovery::Config for Runtime { parameter_types! { pub const MinVestedTransfer: Balance = 100 * CENTS; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); } impl pallet_vesting::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BlockNumberToBalance = ConvertInto; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = weights::pallet_vesting::WeightInfo; + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; const MAX_VESTING_SCHEDULES: u32 = 28; } impl pallet_sudo::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; } parameter_types! { @@ -761,71 +770,81 @@ impl Default for ProxyType { Self::Any } } -impl InstanceFilter for ProxyType { - fn filter(&self, c: &Call) -> bool { +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { match self { ProxyType::Any => true, ProxyType::NonTransfer => matches!( c, - Call::System(..) | - Call::Babe(..) | - Call::Timestamp(..) | - Call::Indices(pallet_indices::Call::claim{..}) | - Call::Indices(pallet_indices::Call::free{..}) | - Call::Indices(pallet_indices::Call::freeze{..}) | + RuntimeCall::System(..) | + RuntimeCall::Babe(..) | + RuntimeCall::Timestamp(..) | + RuntimeCall::Indices(pallet_indices::Call::claim{..}) | + RuntimeCall::Indices(pallet_indices::Call::free{..}) | + RuntimeCall::Indices(pallet_indices::Call::freeze{..}) | // Specifically omitting Indices `transfer`, `force_transfer` // Specifically omitting the entire Balances pallet - Call::Authorship(..) | - Call::Staking(..) | - Call::Session(..) | - Call::Grandpa(..) | - Call::ImOnline(..) | - Call::Utility(..) | - Call::Identity(..) | - Call::Recovery(pallet_recovery::Call::as_recovered{..}) | - Call::Recovery(pallet_recovery::Call::vouch_recovery{..}) | - Call::Recovery(pallet_recovery::Call::claim_recovery{..}) | - Call::Recovery(pallet_recovery::Call::close_recovery{..}) | - Call::Recovery(pallet_recovery::Call::remove_recovery{..}) | - Call::Recovery(pallet_recovery::Call::cancel_recovered{..}) | + RuntimeCall::Authorship(..) | + RuntimeCall::Staking(..) | + RuntimeCall::Session(..) | + RuntimeCall::Grandpa(..) | + RuntimeCall::ImOnline(..) | + RuntimeCall::Utility(..) | + RuntimeCall::Identity(..) | + RuntimeCall::Recovery(pallet_recovery::Call::as_recovered{..}) | + RuntimeCall::Recovery(pallet_recovery::Call::vouch_recovery{..}) | + RuntimeCall::Recovery(pallet_recovery::Call::claim_recovery{..}) | + RuntimeCall::Recovery(pallet_recovery::Call::close_recovery{..}) | + RuntimeCall::Recovery(pallet_recovery::Call::remove_recovery{..}) | + RuntimeCall::Recovery(pallet_recovery::Call::cancel_recovered{..}) | // Specifically omitting Recovery `create_recovery`, `initiate_recovery` - Call::Vesting(pallet_vesting::Call::vest{..}) | - Call::Vesting(pallet_vesting::Call::vest_other{..}) | + RuntimeCall::Vesting(pallet_vesting::Call::vest{..}) | + RuntimeCall::Vesting(pallet_vesting::Call::vest_other{..}) | // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` - Call::Scheduler(..) | + RuntimeCall::Scheduler(..) | // Specifically omitting Sudo pallet - Call::Proxy(..) | - Call::Multisig(..) | - Call::Registrar(paras_registrar::Call::register{..}) | - Call::Registrar(paras_registrar::Call::deregister{..}) | + RuntimeCall::Proxy(..) | + RuntimeCall::Multisig(..) | + RuntimeCall::Registrar(paras_registrar::Call::register{..}) | + RuntimeCall::Registrar(paras_registrar::Call::deregister{..}) | // Specifically omitting Registrar `swap` - Call::Registrar(paras_registrar::Call::reserve{..}) | - Call::Crowdloan(..) | - Call::Slots(..) | - Call::Auctions(..) | // Specifically omitting the entire XCM Pallet - Call::VoterList(..) | - Call::NominationPools(..) + RuntimeCall::Registrar(paras_registrar::Call::reserve{..}) | + RuntimeCall::Crowdloan(..) | + RuntimeCall::Slots(..) | + RuntimeCall::Auctions(..) | // Specifically omitting the entire XCM Pallet + RuntimeCall::VoterList(..) | + RuntimeCall::NominationPools(..) | + RuntimeCall::FastUnstake(..) ), ProxyType::Staking => { - matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)) + matches!( + c, + RuntimeCall::Staking(..) | + RuntimeCall::Session(..) | RuntimeCall::Utility(..) | + RuntimeCall::FastUnstake(..) + ) }, ProxyType::SudoBalances => match c { - Call::Sudo(pallet_sudo::Call::sudo { call: ref x }) => { - matches!(x.as_ref(), &Call::Balances(..)) + RuntimeCall::Sudo(pallet_sudo::Call::sudo { call: ref x }) => { + matches!(x.as_ref(), &RuntimeCall::Balances(..)) }, - Call::Utility(..) => true, + RuntimeCall::Utility(..) => true, _ => false, }, ProxyType::IdentityJudgement => matches!( c, - Call::Identity(pallet_identity::Call::provide_judgement { .. }) | Call::Utility(..) + RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) | + RuntimeCall::Utility(..) ), ProxyType::CancelProxy => { - matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })) + matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })) }, ProxyType::Auction => matches!( c, - Call::Auctions(..) | Call::Crowdloan(..) | Call::Registrar(..) | Call::Slots(..) + RuntimeCall::Auctions(..) | + RuntimeCall::Crowdloan(..) | + RuntimeCall::Registrar(..) | + RuntimeCall::Slots(..) ), } } @@ -841,8 +860,8 @@ impl InstanceFilter for ProxyType { } impl pallet_proxy::Config for Runtime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; @@ -868,7 +887,7 @@ impl parachains_session_info::Config for Runtime { } impl parachains_inclusion::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DisputesHandler = ParasDisputes; type RewardValidators = parachains_reward_points::RewardValidatorsWithEraPoints; } @@ -878,7 +897,7 @@ parameter_types! { } impl parachains_paras::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::runtime_parachains_paras::WeightInfo; type UnsignedPriority = ParasUnsignedPriority; type NextSessionRotation = Babe; @@ -889,7 +908,7 @@ parameter_types! { } impl parachains_ump::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type UmpSink = crate::parachains_ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; @@ -900,8 +919,8 @@ impl parachains_ump::Config for Runtime { impl parachains_dmp::Config for Runtime {} impl parachains_hrmp::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo; } @@ -929,7 +948,7 @@ parameter_types! { } impl assigned_slots::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type AssignSlotOrigin = EnsureRoot; type Leaser = Slots; type PermanentSlotLeasePeriodLength = PermanentSlotLeasePeriodLength; @@ -940,20 +959,37 @@ impl assigned_slots::Config for Runtime { } impl parachains_disputes::Config for Runtime { - type Event = Event; - type RewardValidators = (); - type PunishValidators = (); + type RuntimeEvent = RuntimeEvent; + type RewardValidators = parachains_reward_points::RewardValidatorsWithEraPoints; + type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes; type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } +impl parachains_slashing::Config for Runtime { + type KeyOwnerProofSystem = Historical; + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type HandleReports = parachains_slashing::SlashingReportHandler< + Self::KeyOwnerIdentification, + Offences, + ReportLongevity, + >; + type WeightInfo = weights::runtime_parachains_disputes_slashing::WeightInfo; + type BenchmarkingConfig = parachains_slashing::BenchConfig<300>; +} + parameter_types! { pub const ParaDeposit: Balance = 2000 * CENTS; pub const DataDepositPerByte: Balance = deposit(0, 1); } impl paras_registrar::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type OnSwap = (Crowdloan, Slots); type ParaDeposit = ParaDeposit; @@ -966,7 +1002,7 @@ parameter_types! { } impl slots::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type Registrar = Registrar; type LeasePeriod = LeasePeriod; @@ -985,7 +1021,7 @@ parameter_types! { } impl crowdloan::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type PalletId = CrowdloanId; type SubmissionDeposit = SubmissionDeposit; type MinContribution = MinContribution; @@ -1005,7 +1041,7 @@ parameter_types! { } impl auctions::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Leaser = Slots; type Registrar = Registrar; type EndingPeriod = EndingPeriod; @@ -1021,7 +1057,7 @@ parameter_types! { } impl pallet_nomination_pools::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type WeightInfo = weights::pallet_nomination_pools::WeightInfo; type Currency = Balances; type CurrencyBalance = Balance; @@ -1097,11 +1133,14 @@ construct_runtime! { ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event, ValidateUnsigned} = 24, // Provides a semi-sorted list of nominators for staking. - VoterList: pallet_bags_list::{Pallet, Call, Storage, Event} = 25, + VoterList: pallet_bags_list::::{Pallet, Call, Storage, Event} = 25, // Nomination pools for staking. NominationPools: pallet_nomination_pools::{Pallet, Call, Storage, Event, Config} = 29, + // Fast unstake pallet: extension to staking. + FastUnstake: pallet_fast_unstake = 30, + // Parachains pallets. Start indices at 40 to leave room. ParachainsOrigin: parachains_origin::{Pallet, Origin} = 41, Configuration: parachains_configuration::{Pallet, Call, Storage, Config} = 42, @@ -1109,13 +1148,14 @@ construct_runtime! { ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event} = 44, ParaInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 45, ParaScheduler: parachains_scheduler::{Pallet, Storage} = 46, - Paras: parachains_paras::{Pallet, Call, Storage, Event, Config} = 47, + Paras: parachains_paras::{Pallet, Call, Storage, Event, Config, ValidateUnsigned} = 47, Initializer: parachains_initializer::{Pallet, Call, Storage} = 48, Dmp: parachains_dmp::{Pallet, Call, Storage} = 49, Ump: parachains_ump::{Pallet, Call, Storage, Event} = 50, Hrmp: parachains_hrmp::{Pallet, Call, Storage, Event, Config} = 51, ParaSessionInfo: parachains_session_info::{Pallet, Storage} = 52, ParasDisputes: parachains_disputes::{Pallet, Call, Storage, Event} = 53, + ParasSlashing: parachains_slashing::{Pallet, Call, Storage, ValidateUnsigned} = 54, // Parachain Onboarding Pallets. Start indices at 60 to leave room. Registrar: paras_registrar::{Pallet, Call, Storage, Event, Config} = 60, @@ -1151,8 +1191,17 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, ); + +pub struct StakingMigrationV11OldPallet; +impl Get<&'static str> for StakingMigrationV11OldPallet { + fn get() -> &'static str { + "VoterList" + } +} + /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = + generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -1160,10 +1209,17 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - (), + ( + // "Bound uses of call" + pallet_preimage::migration::v1::Migration, + pallet_scheduler::migration::v3::MigrateToV4, + pallet_multisig::migrations::v1::MigrateToV1, + // "Properly migrate weights to v2" + parachains_configuration::migration::v3::MigrateToV3, + ), >; /// The payload being signed in transactions. -pub type SignedPayload = generic::SignedPayload; +pub type SignedPayload = generic::SignedPayload; #[cfg(feature = "runtime-benchmarks")] #[macro_use] @@ -1181,6 +1237,7 @@ mod benches { [runtime_common::slots, Slots] [runtime_parachains::configuration, Configuration] [runtime_parachains::disputes, ParasDisputes] + [runtime_parachains::disputes::slashing, ParasSlashing] [runtime_parachains::hrmp, Hrmp] [runtime_parachains::initializer, Initializer] [runtime_parachains::paras, Paras] @@ -1191,6 +1248,7 @@ mod benches { [pallet_balances, Balances] [pallet_election_provider_multi_phase, ElectionProviderMultiPhase] [frame_election_provider_support, ElectionProviderBench::] + [pallet_fast_unstake, FastUnstake] [pallet_identity, Identity] [pallet_im_online, ImOnline] [pallet_indices, Indices] @@ -1273,6 +1331,7 @@ sp_api::impl_runtime_apis! { } } + #[api_version(3)] impl primitives::runtime_api::ParachainHost for Runtime { fn validators() -> Vec { parachains_runtime_api_impl::validators::() @@ -1324,7 +1383,7 @@ sp_api::impl_runtime_apis! { fn candidate_events() -> Vec> { parachains_runtime_api_impl::candidate_events::(|ev| { match ev { - Event::ParaInclusion(ev) => { + RuntimeEvent::ParaInclusion(ev) => { Some(ev) } _ => None, @@ -1371,7 +1430,7 @@ sp_api::impl_runtime_apis! { parachains_runtime_api_impl::validation_code_hash::(para_id, assumption) } - fn staging_get_disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { + fn disputes() -> Vec<(SessionIndex, CandidateHash, DisputeState)> { runtime_parachains::runtime_api_impl::vstaging::get_session_disputes::() } } @@ -1383,8 +1442,8 @@ sp_api::impl_runtime_apis! { } } - impl mmr::MmrApi for Runtime { - fn generate_proof(_leaf_index: u64) + impl mmr::MmrApi for Runtime { + fn generate_proof(_block_number: BlockNumber) -> Result<(mmr::EncodableOpaqueLeaf, mmr::Proof), mmr::Error> { @@ -1412,10 +1471,16 @@ sp_api::impl_runtime_apis! { Err(mmr::Error::PalletNotIncluded) } - fn generate_batch_proof(_leaf_indices: Vec) + fn generate_batch_proof(_block_numbers: Vec) -> Result<(Vec, mmr::BatchProof), mmr::Error> { + Err(mmr::Error::PalletNotIncluded) + } + fn generate_historical_batch_proof( + _block_numbers: Vec, + _best_known_block_number: BlockNumber, + ) -> Result<(Vec, mmr::BatchProof), mmr::Error> { Err(mmr::Error::PalletNotIncluded) } @@ -1473,19 +1538,15 @@ sp_api::impl_runtime_apis! { } impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeGenesisConfiguration { - // The choice of `c` parameter (where `1 - c` represents the - // probability of a slot being empty), is done in accordance to the - // slot duration and expected target block time, for safely - // resisting network delays of maximum two seconds. - // - babe_primitives::BabeGenesisConfiguration { + fn configuration() -> babe_primitives::BabeConfiguration { + let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG); + babe_primitives::BabeConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDuration::get(), - c: BABE_GENESIS_EPOCH_CONFIG.c, - genesis_authorities: Babe::authorities().to_vec(), + c: epoch_config.c, + authorities: Babe::authorities().to_vec(), randomness: Babe::randomness(), - allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots, + allowed_slots: epoch_config.allowed_slots, } } @@ -1561,13 +1622,13 @@ sp_api::impl_runtime_apis! { } } - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi for Runtime { - fn query_call_info(call: Call, len: u32) -> RuntimeDispatchInfo { + fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo { TransactionPayment::query_call_info(call, len) } - fn query_call_fee_details(call: Call, len: u32) -> FeeDetails { + fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails { TransactionPayment::query_call_fee_details(call, len) } } @@ -1578,19 +1639,27 @@ sp_api::impl_runtime_apis! { Balance, > for Runtime { fn pending_rewards(member: AccountId) -> Balance { - NominationPools::pending_rewards(member) + NominationPools::pending_rewards(member).unwrap_or_default() } } #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { - fn on_runtime_upgrade() -> (frame_support::weights::Weight, frame_support::weights::Weight) { + fn on_runtime_upgrade() -> (Weight, Weight) { log::info!("try-runtime::on_runtime_upgrade westend."); let weight = Executive::try_runtime_upgrade().unwrap(); (weight, BlockWeights::get().max_block) } - fn execute_block_no_check(block: Block) -> frame_support::weights::Weight { - Executive::execute_block_no_check(block) + + fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight { + log::info!( + target: "runtime::westend", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}", + block.header.number, + block.header.hash(), + state_root_check, + select, + ); + Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed") } } @@ -1639,12 +1708,13 @@ sp_api::impl_runtime_apis! { impl pallet_election_provider_support_benchmarking::Config for Runtime {} impl frame_system_benchmarking::Config for Runtime {} impl pallet_nomination_pools_benchmarking::Config for Runtime {} + impl runtime_parachains::disputes::slashing::benchmarking::Config for Runtime {} use xcm::latest::{ - AssetId::*, Fungibility::*, Junction, Junctions::*, MultiAsset, MultiAssets, - MultiLocation, Response, + AssetId::*, Fungibility::*, Junctions::*, MultiAsset, MultiAssets, MultiLocation, + Response, }; - use xcm_config::{Westmint, TokenLocation}; + use xcm_config::{Westmint, WndLocation}; impl pallet_xcm_benchmarks::Config for Runtime { type XcmConfig = xcm_config::XcmConfig; @@ -1652,10 +1722,10 @@ sp_api::impl_runtime_apis! { fn valid_destination() -> Result { Ok(Westmint::get()) } - fn worst_case_holding(_depositable_count: u32) -> MultiAssets { + fn worst_case_holding() -> MultiAssets { // Westend only knows about WND. vec![MultiAsset{ - id: Concrete(TokenLocation::get()), + id: Concrete(WndLocation::get()), fun: Fungible(1_000_000 * UNITS), }].into() } @@ -1664,7 +1734,11 @@ sp_api::impl_runtime_apis! { parameter_types! { pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( Westmint::get(), - MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(TokenLocation::get()) }, + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WndLocation::get()) }, + )); + pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(( + Westmint::get(), + MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WndLocation::get()) }, )); } @@ -1673,32 +1747,23 @@ sp_api::impl_runtime_apis! { type CheckedAccount = xcm_config::CheckAccount; type TrustedTeleporter = TrustedTeleporter; + type TrustedReserve = TrustedReserve; fn get_multi_asset() -> MultiAsset { MultiAsset { - id: Concrete(TokenLocation::get()), + id: Concrete(WndLocation::get()), fun: Fungible(1 * UNITS), } } } impl pallet_xcm_benchmarks::generic::Config for Runtime { - type Call = Call; + type RuntimeCall = RuntimeCall; fn worst_case_response() -> (u64, Response) { (0u64, Response::Version(Default::default())) } - fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> { - // Westend doesn't support asset exchanges - Err(BenchmarkError::Skip) - } - - fn universal_alias() -> Result { - // The XCM executor of Westend doesn't have a configured `UniversalAliases` - Err(BenchmarkError::Skip) - } - fn transact_origin() -> Result { Ok(Westmint::get()) } @@ -1709,15 +1774,10 @@ sp_api::impl_runtime_apis! { fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> { let origin = Westmint::get(); - let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into(); + let assets: MultiAssets = (Concrete(WndLocation::get()), 1_000 * UNITS).into(); let ticket = MultiLocation { parents: 0, interior: Here }; Ok((origin, ticket, assets)) } - - fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> { - // Westend doesn't support asset locking - Err(BenchmarkError::Skip) - } } type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; diff --git a/runtime/westend/src/tests.rs b/runtime/westend/src/tests.rs index 60803d7a8e4c..401b575255a8 100644 --- a/runtime/westend/src/tests.rs +++ b/runtime/westend/src/tests.rs @@ -24,7 +24,7 @@ fn remove_keys_weight_is_sensible() { use runtime_common::crowdloan::WeightInfo; let max_weight = ::WeightInfo::refund(RemoveKeysLimit::get()); // Max remove keys limit should be no more than half the total block weight. - assert!(max_weight * 2 < BlockWeights::get().max_block); + assert!((max_weight * 2).all_lt(BlockWeights::get().max_block)); } #[test] @@ -35,19 +35,17 @@ fn sample_size_is_sensible() { let max_weight: frame_support::weights::Weight = RocksDbWeight::get().reads_writes(samples.into(), samples.into()); // Max sample cleanup should be no more than half the total block weight. - assert!(max_weight * 2 < BlockWeights::get().max_block); - assert!( - ::WeightInfo::on_initialize() * 2 < - BlockWeights::get().max_block - ); + assert!((max_weight * 2).all_lt(BlockWeights::get().max_block)); + assert!((::WeightInfo::on_initialize() * 2) + .all_lt(BlockWeights::get().max_block)); } #[test] fn call_size() { assert!( - core::mem::size_of::() <= 230, - "size of Call is more than 230 bytes: some calls have too big arguments, use Box to reduce \ - the size of Call. + core::mem::size_of::() <= 230, + "size of RuntimeCall is more than 230 bytes: some calls have too big arguments, use Box to reduce \ + the size of RuntimeCall. If the limit is too strong, maybe consider increase the limit to 300.", ); } @@ -67,5 +65,5 @@ fn sanity_check_teleport_assets_weight() { .get_dispatch_info() .weight; - assert!(weight * 50 < BlockWeights::get().max_block); + assert!((weight * 50).all_lt(BlockWeights::get().max_block)); } diff --git a/runtime/westend/src/weights/frame_election_provider_support.rs b/runtime/westend/src/weights/frame_election_provider_support.rs index 7605d35453ed..b202638d2817 100644 --- a/runtime/westend/src/weights/frame_election_provider_support.rs +++ b/runtime/westend/src/weights/frame_election_provider_support.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `frame_election_provider_support` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/frame_election_provider_support.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -48,20 +48,22 @@ impl frame_election_provider_support::WeightInfo for We /// The range of component `t` is `[500, 1000]`. /// The range of component `d` is `[5, 16]`. fn phragmen(v: u32, _t: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 91_000 - .saturating_add((21_885_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 7_862_000 - .saturating_add((3_527_431_000 as Weight).saturating_mul(d as Weight)) + // Minimum execution time: 5_449_895 nanoseconds. + Weight::from_ref_time(5_493_777_000 as u64) + // Standard Error: 137_519 + .saturating_add(Weight::from_ref_time(5_601_334 as u64).saturating_mul(v as u64)) + // Standard Error: 14_059_549 + .saturating_add(Weight::from_ref_time(1_555_417_760 as u64).saturating_mul(d as u64)) } /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. /// The range of component `d` is `[5, 16]`. fn phragmms(v: u32, _t: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 73_000 - .saturating_add((15_030_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 6_376_000 - .saturating_add((2_571_214_000 as Weight).saturating_mul(d as Weight)) + // Minimum execution time: 4_267_232 nanoseconds. + Weight::from_ref_time(4_311_499_000 as u64) + // Standard Error: 146_807 + .saturating_add(Weight::from_ref_time(5_470_097 as u64).saturating_mul(v as u64)) + // Standard Error: 15_009_027 + .saturating_add(Weight::from_ref_time(1_764_707_366 as u64).saturating_mul(d as u64)) } } diff --git a/runtime/westend/src/weights/frame_system.rs b/runtime/westend/src/weights/frame_system.rs index bf3d10266a80..039d8c6ccd56 100644 --- a/runtime/westend/src/weights/frame_system.rs +++ b/runtime/westend/src/weights/frame_system.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `frame_system` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/frame_system.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,45 +46,51 @@ pub struct WeightInfo(PhantomData); impl frame_system::WeightInfo for WeightInfo { /// The range of component `b` is `[0, 3932160]`. fn remark(b: u32, ) -> Weight { - (0 as Weight) + // Minimum execution time: 3_353 nanoseconds. + Weight::from_ref_time(3_505_000 as u64) // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(412 as u64).saturating_mul(b as u64)) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { - (0 as Weight) + // Minimum execution time: 12_086 nanoseconds. + Weight::from_ref_time(12_284_000 as u64) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add(Weight::from_ref_time(1_730 as u64).saturating_mul(b as u64)) } // Storage: System Digest (r:1 w:1) // Storage: unknown [0x3a686561707061676573] (r:0 w:1) fn set_heap_pages() -> Weight { - (4_936_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 7_570 nanoseconds. + Weight::from_ref_time(7_711_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[1, 1000]`. + /// The range of component `i` is `[0, 1000]`. fn set_storage(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((541_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 3_656 nanoseconds. + Weight::from_ref_time(3_725_000 as u64) + // Standard Error: 2_119 + .saturating_add(Weight::from_ref_time(602_695 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[1, 1000]`. + /// The range of component `i` is `[0, 1000]`. fn kill_storage(i: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((436_000 as Weight).saturating_mul(i as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight))) + // Minimum execution time: 3_631 nanoseconds. + Weight::from_ref_time(3_661_000 as u64) + // Standard Error: 1_080 + .saturating_add(Weight::from_ref_time(435_664 as u64).saturating_mul(i as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `p` is `[1, 1000]`. + /// The range of component `p` is `[0, 1000]`. fn kill_prefix(p: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((956_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + // Minimum execution time: 5_220 nanoseconds. + Weight::from_ref_time(5_369_000 as u64) + // Standard Error: 1_204 + .saturating_add(Weight::from_ref_time(933_358 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } } diff --git a/runtime/westend/src/weights/mod.rs b/runtime/westend/src/weights/mod.rs index 90394ea0fd16..216b3dcdf4ec 100644 --- a/runtime/westend/src/weights/mod.rs +++ b/runtime/westend/src/weights/mod.rs @@ -20,6 +20,7 @@ pub mod frame_system; pub mod pallet_bags_list; pub mod pallet_balances; pub mod pallet_election_provider_multi_phase; +pub mod pallet_fast_unstake; pub mod pallet_identity; pub mod pallet_im_online; pub mod pallet_indices; @@ -39,6 +40,7 @@ pub mod runtime_common_paras_registrar; pub mod runtime_common_slots; pub mod runtime_parachains_configuration; pub mod runtime_parachains_disputes; +pub mod runtime_parachains_disputes_slashing; pub mod runtime_parachains_hrmp; pub mod runtime_parachains_initializer; pub mod runtime_parachains_paras; diff --git a/runtime/westend/src/weights/pallet_bags_list.rs b/runtime/westend/src/weights/pallet_bags_list.rs index 41e72ecdff0e..dbea6151cd11 100644 --- a/runtime/westend/src/weights/pallet_bags_list.rs +++ b/runtime/westend/src/weights/pallet_bags_list.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_bags_list` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_bags_list.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -49,18 +49,20 @@ impl pallet_bags_list::WeightInfo for WeightInfo { // Storage: VoterList ListNodes (r:4 w:4) // Storage: VoterList ListBags (r:1 w:1) fn rebag_non_terminal() -> Weight { - (49_879_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 61_542 nanoseconds. + Weight::from_ref_time(62_218_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn rebag_terminal() -> Weight { - (48_552_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 60_842 nanoseconds. + Weight::from_ref_time(61_595_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: VoterList ListNodes (r:4 w:4) // Storage: Staking Bonded (r:2 w:0) @@ -68,8 +70,9 @@ impl pallet_bags_list::WeightInfo for WeightInfo { // Storage: VoterList CounterForListNodes (r:1 w:1) // Storage: VoterList ListBags (r:1 w:1) fn put_in_front_of() -> Weight { - (51_430_000 as Weight) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 60_377 nanoseconds. + Weight::from_ref_time(61_315_000 as u64) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_balances.rs b/runtime/westend/src/weights/pallet_balances.rs index d59a583fa729..c86f678b4573 100644 --- a/runtime/westend/src/weights/pallet_balances.rs +++ b/runtime/westend/src/weights/pallet_balances.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_balances` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_balances.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,44 +46,51 @@ pub struct WeightInfo(PhantomData); impl pallet_balances::WeightInfo for WeightInfo { // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (38_789_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 39_828 nanoseconds. + Weight::from_ref_time(40_284_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn transfer_keep_alive() -> Weight { - (29_986_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 29_216 nanoseconds. + Weight::from_ref_time(29_760_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn set_balance_creating() -> Weight { - (20_160_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 22_724 nanoseconds. + Weight::from_ref_time(23_242_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn set_balance_killing() -> Weight { - (23_146_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_275 nanoseconds. + Weight::from_ref_time(25_951_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:2 w:2) fn force_transfer() -> Weight { - (39_066_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 38_922 nanoseconds. + Weight::from_ref_time(39_926_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: System Account (r:1 w:1) fn transfer_all() -> Weight { - (34_523_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 34_624 nanoseconds. + Weight::from_ref_time(35_268_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) fn force_unreserve() -> Weight { - (18_078_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 19_457 nanoseconds. + Weight::from_ref_time(19_975_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_election_provider_multi_phase.rs b/runtime/westend/src/weights/pallet_election_provider_multi_phase.rs index d5a944ceca1b..4feebaedbcc6 100644 --- a/runtime/westend/src/weights/pallet_election_provider_multi_phase.rs +++ b/runtime/westend/src/weights/pallet_election_provider_multi_phase.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_election_provider_multi_phase` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_election_provider_multi_phase.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -53,48 +53,52 @@ impl pallet_election_provider_multi_phase::WeightInfo f // Storage: Staking ForceEra (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) fn on_initialize_nothing() -> Weight { - (12_779_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) + // Minimum execution time: 13_872 nanoseconds. + Weight::from_ref_time(14_158_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn on_initialize_open_signed() -> Weight { - (12_221_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 13_293 nanoseconds. + Weight::from_ref_time(13_707_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) fn on_initialize_open_unsigned() -> Weight { - (12_394_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 12_955 nanoseconds. + Weight::from_ref_time(13_378_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) // Storage: ElectionProviderMultiPhase QueuedSolution (r:0 w:1) fn finalize_signed_phase_accept_solution() -> Weight { - (25_652_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 28_501 nanoseconds. + Weight::from_ref_time(29_121_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: System Account (r:1 w:1) fn finalize_signed_phase_reject_solution() -> Weight { - (19_431_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 22_012 nanoseconds. + Weight::from_ref_time(22_395_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:0 w:1) // Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) // Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. - fn create_snapshot_internal(v: u32, t: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_000 - .saturating_add((397_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 3_000 - .saturating_add((100_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + fn create_snapshot_internal(v: u32, _t: u32, ) -> Weight { + // Minimum execution time: 417_221 nanoseconds. + Weight::from_ref_time(427_368_000 as u64) + // Standard Error: 2_342 + .saturating_add(Weight::from_ref_time(264_068 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) @@ -109,13 +113,14 @@ impl pallet_election_provider_multi_phase::WeightInfo f /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. fn elect_queued(a: u32, d: u32, ) -> Weight { - (9_172_000 as Weight) - // Standard Error: 6_000 - .saturating_add((413_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 9_000 - .saturating_add((176_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(9 as Weight)) + // Minimum execution time: 272_735 nanoseconds. + Weight::from_ref_time(101_494_679 as u64) + // Standard Error: 6_085 + .saturating_add(Weight::from_ref_time(306_319 as u64).saturating_mul(a as u64)) + // Standard Error: 9_122 + .saturating_add(Weight::from_ref_time(120_469 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) @@ -124,9 +129,10 @@ impl pallet_election_provider_multi_phase::WeightInfo f // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) // Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:0 w:1) fn submit() -> Weight { - (58_297_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 57_464 nanoseconds. + Weight::from_ref_time(58_191_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: ElectionProviderMultiPhase Round (r:1 w:0) @@ -139,16 +145,15 @@ impl pallet_election_provider_multi_phase::WeightInfo f /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. - fn submit_unsigned(v: u32, _t: u32, a: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 5_000 - .saturating_add((870_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 17_000 - .saturating_add((8_088_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 26_000 - .saturating_add((1_705_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn submit_unsigned(v: u32, _t: u32, a: u32, _d: u32, ) -> Weight { + // Minimum execution time: 4_705_189 nanoseconds. + Weight::from_ref_time(4_737_998_000 as u64) + // Standard Error: 14_252 + .saturating_add(Weight::from_ref_time(112_874 as u64).saturating_mul(v as u64)) + // Standard Error: 42_234 + .saturating_add(Weight::from_ref_time(4_421_938 as u64).saturating_mul(a as u64)) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ElectionProviderMultiPhase Round (r:1 w:0) // Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) @@ -158,16 +163,13 @@ impl pallet_election_provider_multi_phase::WeightInfo f /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. - fn feasibility_check(v: u32, t: u32, a: u32, d: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 4_000 - .saturating_add((829_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 8_000 - .saturating_add((46_000 as Weight).saturating_mul(t as Weight)) - // Standard Error: 14_000 - .saturating_add((5_960_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 21_000 - .saturating_add((1_202_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) + fn feasibility_check(v: u32, _t: u32, a: u32, _d: u32, ) -> Weight { + // Minimum execution time: 3_888_041 nanoseconds. + Weight::from_ref_time(3_911_372_000 as u64) + // Standard Error: 12_374 + .saturating_add(Weight::from_ref_time(216_707 as u64).saturating_mul(v as u64)) + // Standard Error: 36_671 + .saturating_add(Weight::from_ref_time(3_193_380 as u64).saturating_mul(a as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_fast_unstake.rs b/runtime/westend/src/weights/pallet_fast_unstake.rs new file mode 100644 index 000000000000..e3e49790c499 --- /dev/null +++ b/runtime/westend/src/weights/pallet_fast_unstake.rs @@ -0,0 +1,120 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `pallet_fast_unstake` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=westend-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_fast_unstake +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/westend/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_fast_unstake`. +pub struct WeightInfo(PhantomData); +impl pallet_fast_unstake::WeightInfo for WeightInfo { + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + // Storage: FastUnstake Head (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking SlashingSpans (r:1 w:0) + // Storage: Staking Bonded (r:1 w:1) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + // Storage: Staking Ledger (r:0 w:1) + // Storage: Staking Payee (r:0 w:1) + fn on_idle_unstake() -> Weight { + // Minimum execution time: 70_324 nanoseconds. + Weight::from_ref_time(71_121_000 as u64) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking ValidatorCount (r:1 w:0) + // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + // Storage: FastUnstake Head (r:1 w:1) + // Storage: FastUnstake Queue (r:2 w:1) + // Storage: FastUnstake CounterForQueue (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Staking ErasStakers (r:4 w:0) + /// The range of component `x` is `[2, 256]`. + fn on_idle_check(x: u32, ) -> Weight { + // Minimum execution time: 69_870 nanoseconds. + Weight::from_ref_time(31_444_073 as u64) + // Standard Error: 16_618 + .saturating_add(Weight::from_ref_time(13_785_536 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) + // Storage: FastUnstake Queue (r:1 w:1) + // Storage: FastUnstake Head (r:1 w:0) + // Storage: Staking Validators (r:1 w:0) + // Storage: Staking Nominators (r:1 w:1) + // Storage: Staking CounterForNominators (r:1 w:1) + // Storage: VoterList ListNodes (r:1 w:1) + // Storage: VoterList ListBags (r:1 w:1) + // Storage: VoterList CounterForListNodes (r:1 w:1) + // Storage: Staking CurrentEra (r:1 w:0) + // Storage: Balances Locks (r:1 w:1) + // Storage: FastUnstake CounterForQueue (r:1 w:1) + fn register_fast_unstake() -> Weight { + // Minimum execution time: 92_222 nanoseconds. + Weight::from_ref_time(93_069_000 as u64) + .saturating_add(T::DbWeight::get().reads(13 as u64)) + .saturating_add(T::DbWeight::get().writes(9 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) + // Storage: Staking Ledger (r:1 w:0) + // Storage: FastUnstake Queue (r:1 w:1) + // Storage: FastUnstake Head (r:1 w:0) + // Storage: FastUnstake CounterForQueue (r:1 w:1) + fn deregister() -> Weight { + // Minimum execution time: 39_901 nanoseconds. + Weight::from_ref_time(40_412_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + } + // Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1) + fn control() -> Weight { + // Minimum execution time: 4_152 nanoseconds. + Weight::from_ref_time(4_223_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + } +} diff --git a/runtime/westend/src/weights/pallet_identity.rs b/runtime/westend/src/weights/pallet_identity.rs index 3305470ef08c..e5f7182439fb 100644 --- a/runtime/westend/src/weights/pallet_identity.rs +++ b/runtime/westend/src/weights/pallet_identity.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_identity` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_identity.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,191 +47,207 @@ impl pallet_identity::WeightInfo for WeightInfo { // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn add_registrar(r: u32, ) -> Weight { - (15_117_000 as Weight) - // Standard Error: 2_000 - .saturating_add((173_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 16_193 nanoseconds. + Weight::from_ref_time(17_760_055 as u64) + // Standard Error: 3_798 + .saturating_add(Weight::from_ref_time(167_468 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn set_identity(r: u32, x: u32, ) -> Weight { - (28_060_000 as Weight) - // Standard Error: 6_000 - .saturating_add((191_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 1_000 - .saturating_add((334_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 35_137 nanoseconds. + Weight::from_ref_time(34_360_744 as u64) + // Standard Error: 3_823 + .saturating_add(Weight::from_ref_time(92_219 as u64).saturating_mul(r as u64)) + // Standard Error: 746 + .saturating_add(Weight::from_ref_time(291_632 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity SuperOf (r:1 w:1) - /// The range of component `s` is `[1, 100]`. + // Storage: Identity SuperOf (r:2 w:2) + /// The range of component `s` is `[0, 100]`. fn set_subs_new(s: u32, ) -> Weight { - (25_867_000 as Weight) - // Standard Error: 2_000 - .saturating_add((2_901_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 10_464 nanoseconds. + Weight::from_ref_time(28_442_904 as u64) + // Standard Error: 4_842 + .saturating_add(Weight::from_ref_time(2_085_306 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity SuperOf (r:0 w:1) - /// The range of component `p` is `[1, 100]`. + // Storage: Identity SuperOf (r:0 w:2) + /// The range of component `p` is `[0, 100]`. fn set_subs_old(p: u32, ) -> Weight { - (25_691_000 as Weight) - // Standard Error: 1_000 - .saturating_add((913_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) + // Minimum execution time: 10_026 nanoseconds. + Weight::from_ref_time(28_049_091 as u64) + // Standard Error: 4_248 + .saturating_add(Weight::from_ref_time(913_087 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) // Storage: Identity SuperOf (r:0 w:100) /// The range of component `r` is `[1, 20]`. - /// The range of component `s` is `[1, 100]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `s` is `[0, 100]`. + /// The range of component `x` is `[0, 100]`. fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { - (32_060_000 as Weight) - // Standard Error: 6_000 - .saturating_add((80_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 1_000 - .saturating_add((902_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 1_000 - .saturating_add((155_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 49_412 nanoseconds. + Weight::from_ref_time(36_040_592 as u64) + // Standard Error: 7_291 + .saturating_add(Weight::from_ref_time(84_806 as u64).saturating_mul(r as u64)) + // Standard Error: 1_423 + .saturating_add(Weight::from_ref_time(888_161 as u64).saturating_mul(s as u64)) + // Standard Error: 1_423 + .saturating_add(Weight::from_ref_time(160_244 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn request_judgement(r: u32, x: u32, ) -> Weight { - (30_325_000 as Weight) - // Standard Error: 4_000 - .saturating_add((154_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 0 - .saturating_add((339_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 37_198 nanoseconds. + Weight::from_ref_time(35_602_420 as u64) + // Standard Error: 6_208 + .saturating_add(Weight::from_ref_time(139_935 as u64).saturating_mul(r as u64)) + // Standard Error: 1_211 + .saturating_add(Weight::from_ref_time(318_552 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 20]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn cancel_request(r: u32, x: u32, ) -> Weight { - (27_573_000 as Weight) - // Standard Error: 3_000 - .saturating_add((133_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 0 - .saturating_add((329_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 33_660 nanoseconds. + Weight::from_ref_time(33_265_758 as u64) + // Standard Error: 4_249 + .saturating_add(Weight::from_ref_time(75_193 as u64).saturating_mul(r as u64)) + // Standard Error: 829 + .saturating_add(Weight::from_ref_time(313_336 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_fee(r: u32, ) -> Weight { - (6_656_000 as Weight) - // Standard Error: 1_000 - .saturating_add((140_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_557 nanoseconds. + Weight::from_ref_time(9_618_711 as u64) + // Standard Error: 3_167 + .saturating_add(Weight::from_ref_time(133_543 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_account_id(r: u32, ) -> Weight { - (6_675_000 as Weight) - // Standard Error: 1_000 - .saturating_add((136_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_921 nanoseconds. + Weight::from_ref_time(9_716_868 as u64) + // Standard Error: 2_614 + .saturating_add(Weight::from_ref_time(134_578 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:1) /// The range of component `r` is `[1, 19]`. fn set_fields(r: u32, ) -> Weight { - (6_816_000 as Weight) - // Standard Error: 1_000 - .saturating_add((127_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_737 nanoseconds. + Weight::from_ref_time(9_596_263 as u64) + // Standard Error: 2_774 + .saturating_add(Weight::from_ref_time(133_115 as u64).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity Registrars (r:1 w:0) // Storage: Identity IdentityOf (r:1 w:1) /// The range of component `r` is `[1, 19]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `x` is `[0, 100]`. fn provide_judgement(r: u32, x: u32, ) -> Weight { - (21_495_000 as Weight) - // Standard Error: 2_000 - .saturating_add((113_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 0 - .saturating_add((335_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 27_898 nanoseconds. + Weight::from_ref_time(28_261_231 as u64) + // Standard Error: 4_462 + .saturating_add(Weight::from_ref_time(63_546 as u64).saturating_mul(r as u64)) + // Standard Error: 825 + .saturating_add(Weight::from_ref_time(519_389 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity SubsOf (r:1 w:1) // Storage: Identity IdentityOf (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: Identity SuperOf (r:0 w:100) /// The range of component `r` is `[1, 20]`. - /// The range of component `s` is `[1, 100]`. - /// The range of component `x` is `[1, 100]`. + /// The range of component `s` is `[0, 100]`. + /// The range of component `x` is `[0, 100]`. fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight { - (35_711_000 as Weight) - // Standard Error: 3_000 - .saturating_add((77_000 as Weight).saturating_mul(r as Weight)) - // Standard Error: 0 - .saturating_add((914_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 54_613 nanoseconds. + Weight::from_ref_time(39_369_694 as u64) + // Standard Error: 4_703 + .saturating_add(Weight::from_ref_time(126_210 as u64).saturating_mul(r as u64)) + // Standard Error: 918 + .saturating_add(Weight::from_ref_time(895_761 as u64).saturating_mul(s as u64)) + // Standard Error: 918 + .saturating_add(Weight::from_ref_time(160_435 as u64).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) - /// The range of component `s` is `[1, 99]`. + /// The range of component `s` is `[0, 99]`. fn add_sub(s: u32, ) -> Weight { - (32_948_000 as Weight) - // Standard Error: 1_000 - .saturating_add((92_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 30_688 nanoseconds. + Weight::from_ref_time(37_399_108 as u64) + // Standard Error: 1_781 + .saturating_add(Weight::from_ref_time(70_488 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn rename_sub(s: u32, ) -> Weight { - (11_895_000 as Weight) - // Standard Error: 0 - .saturating_add((29_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 13_869 nanoseconds. + Weight::from_ref_time(16_257_327 as u64) + // Standard Error: 736 + .saturating_add(Weight::from_ref_time(25_702 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Identity IdentityOf (r:1 w:0) // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) /// The range of component `s` is `[1, 100]`. fn remove_sub(s: u32, ) -> Weight { - (33_683_000 as Weight) - // Standard Error: 0 - .saturating_add((79_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 34_965 nanoseconds. + Weight::from_ref_time(39_002_236 as u64) + // Standard Error: 1_713 + .saturating_add(Weight::from_ref_time(60_309 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Identity SuperOf (r:1 w:1) // Storage: Identity SubsOf (r:1 w:1) - /// The range of component `s` is `[1, 99]`. + /// The range of component `s` is `[0, 99]`. fn quit_sub(s: u32, ) -> Weight { - (23_476_000 as Weight) - // Standard Error: 0 - .saturating_add((81_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 25_199 nanoseconds. + Weight::from_ref_time(28_698_501 as u64) + // Standard Error: 1_176 + .saturating_add(Weight::from_ref_time(62_015 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_im_online.rs b/runtime/westend/src/weights/pallet_im_online.rs index c47a66039329..f2dff12e38c2 100644 --- a/runtime/westend/src/weights/pallet_im_online.rs +++ b/runtime/westend/src/weights/pallet_im_online.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_im_online` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_im_online.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -52,12 +52,13 @@ impl pallet_im_online::WeightInfo for WeightInfo { /// The range of component `k` is `[1, 1000]`. /// The range of component `e` is `[1, 100]`. fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight { - (73_650_000 as Weight) - // Standard Error: 0 - .saturating_add((26_000 as Weight).saturating_mul(k as Weight)) - // Standard Error: 3_000 - .saturating_add((316_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 96_317 nanoseconds. + Weight::from_ref_time(77_388_779 as u64) + // Standard Error: 260 + .saturating_add(Weight::from_ref_time(22_806 as u64).saturating_mul(k as u64)) + // Standard Error: 2_628 + .saturating_add(Weight::from_ref_time(312_410 as u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_indices.rs b/runtime/westend/src/weights/pallet_indices.rs index d8a295be8422..0e850d96405f 100644 --- a/runtime/westend/src/weights/pallet_indices.rs +++ b/runtime/westend/src/weights/pallet_indices.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_indices` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_indices.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,34 +46,39 @@ pub struct WeightInfo(PhantomData); impl pallet_indices::WeightInfo for WeightInfo { // Storage: Indices Accounts (r:1 w:1) fn claim() -> Weight { - (22_910_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_466 nanoseconds. + Weight::from_ref_time(25_778_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn transfer() -> Weight { - (28_812_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 31_634 nanoseconds. + Weight::from_ref_time(32_118_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Indices Accounts (r:1 w:1) fn free() -> Weight { - (24_455_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_841 nanoseconds. + Weight::from_ref_time(27_309_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Indices Accounts (r:1 w:1) // Storage: System Account (r:1 w:1) fn force_transfer() -> Weight { - (23_888_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 26_354 nanoseconds. + Weight::from_ref_time(26_911_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Indices Accounts (r:1 w:1) fn freeze() -> Weight { - (27_183_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 31_895 nanoseconds. + Weight::from_ref_time(32_621_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_multisig.rs b/runtime/westend/src/weights/pallet_multisig.rs index 18c8d90c54a7..e15f0973adae 100644 --- a/runtime/westend/src/weights/pallet_multisig.rs +++ b/runtime/westend/src/weights/pallet_multisig.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_multisig` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -28,11 +28,11 @@ // --steps=50 // --repeat=20 // --pallet=pallet_multisig -// --extrinsic=* +// --extrinsic= // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_multisig.rs +// --output=runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,115 +46,81 @@ pub struct WeightInfo(PhantomData); impl pallet_multisig::WeightInfo for WeightInfo { /// The range of component `z` is `[0, 10000]`. fn as_multi_threshold_1(z: u32, ) -> Weight { - (14_664_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(z as Weight)) + // Minimum execution time: 14_417 nanoseconds. + Weight::from_ref_time(14_932_092 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(482 as u64).saturating_mul(z as u64)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_create(s: u32, z: u32, ) -> Weight { - (30_606_000 as Weight) - // Standard Error: 0 - .saturating_add((99_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) - /// The range of component `s` is `[2, 100]`. - /// The range of component `z` is `[0, 10000]`. - fn as_multi_create_store(s: u32, z: u32, ) -> Weight { - (32_543_000 as Weight) - // Standard Error: 0 - .saturating_add((110_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 41_482 nanoseconds. + Weight::from_ref_time(34_353_792 as u64) + // Standard Error: 791 + .saturating_add(Weight::from_ref_time(81_017 as u64).saturating_mul(s as u64)) + // Standard Error: 7 + .saturating_add(Weight::from_ref_time(1_468 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) /// The range of component `s` is `[3, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_approve(s: u32, z: u32, ) -> Weight { - (19_984_000 as Weight) - // Standard Error: 0 - .saturating_add((102_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 32_410 nanoseconds. + Weight::from_ref_time(25_806_543 as u64) + // Standard Error: 602 + .saturating_add(Weight::from_ref_time(74_253 as u64).saturating_mul(s as u64)) + // Standard Error: 5 + .saturating_add(Weight::from_ref_time(1_463 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - /// The range of component `s` is `[3, 100]`. - /// The range of component `z` is `[0, 10000]`. - fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { - (32_058_000 as Weight) - // Standard Error: 0 - .saturating_add((121_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_complete(s: u32, z: u32, ) -> Weight { - (40_961_000 as Weight) - // Standard Error: 0 - .saturating_add((129_000 as Weight).saturating_mul(s as Weight)) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 46_059 nanoseconds. + Weight::from_ref_time(37_295_248 as u64) + // Standard Error: 604 + .saturating_add(Weight::from_ref_time(104_164 as u64).saturating_mul(s as u64)) + // Standard Error: 5 + .saturating_add(Weight::from_ref_time(1_489 as u64).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_create(s: u32, ) -> Weight { - (29_773_000 as Weight) - // Standard Error: 0 - .saturating_add((107_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 29_952 nanoseconds. + Weight::from_ref_time(32_697_678 as u64) + // Standard Error: 857 + .saturating_add(Weight::from_ref_time(86_644 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:0) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_approve(s: u32, ) -> Weight { - (19_460_000 as Weight) - // Standard Error: 0 - .saturating_add((106_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) - // Storage: System Account (r:1 w:1) - /// The range of component `s` is `[2, 100]`. - fn approve_as_multi_complete(s: u32, ) -> Weight { - (61_764_000 as Weight) - // Standard Error: 0 - .saturating_add((130_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 22_298 nanoseconds. + Weight::from_ref_time(23_997_404 as u64) + // Standard Error: 855 + .saturating_add(Weight::from_ref_time(82_455 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Multisig Multisigs (r:1 w:1) - // Storage: Multisig Calls (r:1 w:1) /// The range of component `s` is `[2, 100]`. fn cancel_as_multi(s: u32, ) -> Weight { - (45_239_000 as Weight) - // Standard Error: 0 - .saturating_add((110_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 31_615 nanoseconds. + Weight::from_ref_time(33_932_527 as u64) + // Standard Error: 823 + .saturating_add(Weight::from_ref_time(87_873 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_nomination_pools.rs b/runtime/westend/src/weights/pallet_nomination_pools.rs index b93b5c44ace7..f8db33c4cc95 100644 --- a/runtime/westend/src/weights/pallet_nomination_pools.rs +++ b/runtime/westend/src/weights/pallet_nomination_pools.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_nomination_pools` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_nomination_pools.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -58,9 +58,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn join() -> Weight { - (127_461_000 as Weight) - .saturating_add(T::DbWeight::get().reads(17 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) + // Minimum execution time: 137_881 nanoseconds. + Weight::from_ref_time(139_554_000 as u64) + .saturating_add(T::DbWeight::get().reads(17 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -72,9 +73,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn bond_extra_transfer() -> Weight { - (119_965_000 as Weight) - .saturating_add(T::DbWeight::get().reads(14 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) + // Minimum execution time: 135_618 nanoseconds. + Weight::from_ref_time(136_732_000 as u64) + .saturating_add(T::DbWeight::get().reads(14 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -86,18 +88,20 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListNodes (r:2 w:2) // Storage: VoterList ListBags (r:2 w:2) fn bond_extra_reward() -> Weight { - (126_924_000 as Weight) - .saturating_add(T::DbWeight::get().reads(13 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) + // Minimum execution time: 138_488 nanoseconds. + Weight::from_ref_time(139_721_000 as u64) + .saturating_add(T::DbWeight::get().reads(13 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) // Storage: NominationPools RewardPools (r:1 w:1) // Storage: System Account (r:1 w:1) fn claim_payout() -> Weight { - (48_168_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 54_599 nanoseconds. + Weight::from_ref_time(55_472_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: NominationPools BondedPools (r:1 w:1) @@ -114,9 +118,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools SubPoolsStorage (r:1 w:1) // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) fn unbond() -> Weight { - (124_841_000 as Weight) - .saturating_add(T::DbWeight::get().reads(18 as Weight)) - .saturating_add(T::DbWeight::get().writes(13 as Weight)) + // Minimum execution time: 137_493 nanoseconds. + Weight::from_ref_time(139_057_000 as u64) + .saturating_add(T::DbWeight::get().reads(18 as u64)) + .saturating_add(T::DbWeight::get().writes(13 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -124,11 +129,12 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: Balances Locks (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn pool_withdraw_unbonded(s: u32, ) -> Weight { - (41_129_000 as Weight) - // Standard Error: 0 - .saturating_add((33_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 50_487 nanoseconds. + Weight::from_ref_time(52_064_084 as u64) + // Standard Error: 994 + .saturating_add(Weight::from_ref_time(19_109 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -140,11 +146,12 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools CounterForPoolMembers (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - (78_870_000 as Weight) - // Standard Error: 1_000 - .saturating_add((49_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 90_722 nanoseconds. + Weight::from_ref_time(92_596_144 as u64) + // Standard Error: 1_246 + .saturating_add(Weight::from_ref_time(26_945 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: NominationPools PoolMembers (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -163,13 +170,17 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools RewardPools (r:1 w:1) // Storage: NominationPools CounterForRewardPools (r:1 w:1) // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) + // Storage: NominationPools Metadata (r:1 w:1) // Storage: NominationPools CounterForBondedPools (r:1 w:1) // Storage: Staking Payee (r:0 w:1) /// The range of component `s` is `[0, 100]`. - fn withdraw_unbonded_kill(_s: u32, ) -> Weight { - (137_414_000 as Weight) - .saturating_add(T::DbWeight::get().reads(19 as Weight)) - .saturating_add(T::DbWeight::get().writes(16 as Weight)) + fn withdraw_unbonded_kill(s: u32, ) -> Weight { + // Minimum execution time: 143_281 nanoseconds. + Weight::from_ref_time(146_070_579 as u64) + // Standard Error: 2_405 + .saturating_add(Weight::from_ref_time(6_142 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(20 as u64)) + .saturating_add(T::DbWeight::get().writes(17 as u64)) } // Storage: Staking MinNominatorBond (r:1 w:0) // Storage: NominationPools MinCreateBond (r:1 w:0) @@ -185,7 +196,6 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: Staking Ledger (r:1 w:1) // Storage: Staking Bonded (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: NominationPools RewardPools (r:1 w:1) // Storage: NominationPools CounterForRewardPools (r:1 w:1) @@ -194,9 +204,10 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools BondedPools (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn create() -> Weight { - (131_154_000 as Weight) - .saturating_add(T::DbWeight::get().reads(22 as Weight)) - .saturating_add(T::DbWeight::get().writes(15 as Weight)) + // Minimum execution time: 126_730 nanoseconds. + Weight::from_ref_time(128_187_000 as u64) + .saturating_add(T::DbWeight::get().reads(21 as u64)) + .saturating_add(T::DbWeight::get().writes(15 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -212,30 +223,33 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: Staking CounterForNominators (r:1 w:1) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - (50_310_000 as Weight) - // Standard Error: 4_000 - .saturating_add((2_137_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 61_915 nanoseconds. + Weight::from_ref_time(62_490_766 as u64) + // Standard Error: 6_804 + .saturating_add(Weight::from_ref_time(1_018_805 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: NominationPools BondedPools (r:1 w:1) // Storage: Staking Ledger (r:1 w:0) fn set_state() -> Weight { - (25_062_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 34_674 nanoseconds. + Weight::from_ref_time(35_021_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: NominationPools Metadata (r:1 w:1) // Storage: NominationPools CounterForMetadata (r:1 w:1) /// The range of component `n` is `[1, 256]`. fn set_metadata(n: u32, ) -> Weight { - (13_890_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 16_346 nanoseconds. + Weight::from_ref_time(17_028_773 as u64) + // Standard Error: 386 + .saturating_add(Weight::from_ref_time(2_707 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: NominationPools MinJoinBond (r:0 w:1) // Storage: NominationPools MaxPoolMembers (r:0 w:1) @@ -243,14 +257,16 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: NominationPools MinCreateBond (r:0 w:1) // Storage: NominationPools MaxPools (r:0 w:1) fn set_configs() -> Weight { - (6_811_000 as Weight) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 7_856 nanoseconds. + Weight::from_ref_time(8_041_000 as u64) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: NominationPools BondedPools (r:1 w:1) fn update_roles() -> Weight { - (21_056_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_630 nanoseconds. + Weight::from_ref_time(27_163_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: NominationPools BondedPools (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -261,8 +277,9 @@ impl pallet_nomination_pools::WeightInfo for WeightInfo // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - (48_506_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 61_492 nanoseconds. + Weight::from_ref_time(62_308_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_preimage.rs b/runtime/westend/src/weights/pallet_preimage.rs index d85380b9d1c8..ac0d76756fd1 100644 --- a/runtime/westend/src/weights/pallet_preimage.rs +++ b/runtime/westend/src/weights/pallet_preimage.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_preimage` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_preimage.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -44,92 +44,103 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_preimage`. pub struct WeightInfo(PhantomData); impl pallet_preimage::WeightInfo for WeightInfo { - // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) /// The range of component `s` is `[0, 4194304]`. fn note_preimage(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 28_355 nanoseconds. + Weight::from_ref_time(28_676_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_294 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) /// The range of component `s` is `[0, 4194304]`. fn note_requested_preimage(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 19_919 nanoseconds. + Weight::from_ref_time(20_111_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_289 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:0) + // Storage: Preimage StatusFor (r:1 w:1) + // Storage: Preimage PreimageFor (r:0 w:1) /// The range of component `s` is `[0, 4194304]`. fn note_no_deposit_preimage(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 18_568 nanoseconds. + Weight::from_ref_time(18_881_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_290 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_preimage() -> Weight { - (34_210_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 39_289 nanoseconds. + Weight::from_ref_time(40_546_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unnote_no_deposit_preimage() -> Weight { - (22_488_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 26_795 nanoseconds. + Weight::from_ref_time(27_740_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_preimage() -> Weight { - (33_292_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_599 nanoseconds. + Weight::from_ref_time(26_814_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_no_deposit_preimage() -> Weight { - (21_366_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 13_239 nanoseconds. + Weight::from_ref_time(14_310_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_unnoted_preimage() -> Weight { - (15_518_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 17_639 nanoseconds. + Weight::from_ref_time(18_295_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn request_requested_preimage() -> Weight { - (6_307_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_905 nanoseconds. + Weight::from_ref_time(9_273_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_preimage() -> Weight { - (22_313_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 26_257 nanoseconds. + Weight::from_ref_time(27_156_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) fn unrequest_unnoted_preimage() -> Weight { - (16_011_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 8_613 nanoseconds. + Weight::from_ref_time(8_924_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Preimage StatusFor (r:1 w:1) fn unrequest_multi_referenced_preimage() -> Weight { - (5_974_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_631 nanoseconds. + Weight::from_ref_time(9_177_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_proxy.rs b/runtime/westend/src/weights/pallet_proxy.rs index 60c75d650fe2..81a93cc4eb85 100644 --- a/runtime/westend/src/weights/pallet_proxy.rs +++ b/runtime/westend/src/weights/pallet_proxy.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_proxy` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_proxy.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,10 +47,11 @@ impl pallet_proxy::WeightInfo for WeightInfo { // Storage: Proxy Proxies (r:1 w:0) /// The range of component `p` is `[1, 31]`. fn proxy(p: u32, ) -> Weight { - (17_846_000 as Weight) - // Standard Error: 1_000 - .saturating_add((62_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + // Minimum execution time: 19_557 nanoseconds. + Weight::from_ref_time(20_990_890 as u64) + // Standard Error: 4_214 + .saturating_add(Weight::from_ref_time(49_337 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) @@ -58,39 +59,42 @@ impl pallet_proxy::WeightInfo for WeightInfo { /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn proxy_announced(a: u32, p: u32, ) -> Weight { - (33_547_000 as Weight) - // Standard Error: 1_000 - .saturating_add((173_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((49_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 36_963 nanoseconds. + Weight::from_ref_time(37_873_141 as u64) + // Standard Error: 2_376 + .saturating_add(Weight::from_ref_time(112_476 as u64).saturating_mul(a as u64)) + // Standard Error: 2_455 + .saturating_add(Weight::from_ref_time(25_228 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn remove_announcement(a: u32, p: u32, ) -> Weight { - (22_907_000 as Weight) - // Standard Error: 1_000 - .saturating_add((157_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((6_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 25_553 nanoseconds. + Weight::from_ref_time(26_789_457 as u64) + // Standard Error: 1_681 + .saturating_add(Weight::from_ref_time(111_064 as u64).saturating_mul(a as u64)) + // Standard Error: 1_737 + .saturating_add(Weight::from_ref_time(4_487 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Announcements (r:1 w:1) // Storage: System Account (r:1 w:1) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn reject_announcement(a: u32, p: u32, ) -> Weight { - (22_859_000 as Weight) - // Standard Error: 1_000 - .saturating_add((166_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((9_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 25_532 nanoseconds. + Weight::from_ref_time(26_555_150 as u64) + // Standard Error: 1_544 + .saturating_add(Weight::from_ref_time(114_475 as u64).saturating_mul(a as u64)) + // Standard Error: 1_595 + .saturating_add(Weight::from_ref_time(7_001 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Proxies (r:1 w:0) // Storage: Proxy Announcements (r:1 w:1) @@ -98,58 +102,64 @@ impl pallet_proxy::WeightInfo for WeightInfo { /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn announce(a: u32, p: u32, ) -> Weight { - (31_254_000 as Weight) - // Standard Error: 1_000 - .saturating_add((136_000 as Weight).saturating_mul(a as Weight)) - // Standard Error: 1_000 - .saturating_add((44_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 32_958 nanoseconds. + Weight::from_ref_time(34_690_880 as u64) + // Standard Error: 2_046 + .saturating_add(Weight::from_ref_time(98_030 as u64).saturating_mul(a as u64)) + // Standard Error: 2_114 + .saturating_add(Weight::from_ref_time(23_754 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn add_proxy(p: u32, ) -> Weight { - (25_519_000 as Weight) - // Standard Error: 1_000 - .saturating_add((81_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 26_983 nanoseconds. + Weight::from_ref_time(28_481_463 as u64) + // Standard Error: 2_047 + .saturating_add(Weight::from_ref_time(63_259 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn remove_proxy(p: u32, ) -> Weight { - (25_205_000 as Weight) - // Standard Error: 2_000 - .saturating_add((111_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 27_026 nanoseconds. + Weight::from_ref_time(28_423_344 as u64) + // Standard Error: 2_139 + .saturating_add(Weight::from_ref_time(80_532 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. fn remove_proxies(p: u32, ) -> Weight { - (21_393_000 as Weight) - // Standard Error: 2_000 - .saturating_add((62_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 23_688 nanoseconds. + Weight::from_ref_time(25_488_979 as u64) + // Standard Error: 2_380 + .saturating_add(Weight::from_ref_time(7_566 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[1, 31]`. - fn anonymous(p: u32, ) -> Weight { - (28_146_000 as Weight) - // Standard Error: 1_000 - .saturating_add((30_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn create_pure(p: u32, ) -> Weight { + // Minimum execution time: 28_914 nanoseconds. + Weight::from_ref_time(30_185_796 as u64) + // Standard Error: 1_784 + .saturating_add(Weight::from_ref_time(21_017 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Proxy Proxies (r:1 w:1) /// The range of component `p` is `[0, 30]`. - fn kill_anonymous(p: u32, ) -> Weight { - (22_187_000 as Weight) - // Standard Error: 1_000 - .saturating_add((68_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn kill_pure(p: u32, ) -> Weight { + // Minimum execution time: 24_534 nanoseconds. + Weight::from_ref_time(25_747_053 as u64) + // Standard Error: 1_940 + .saturating_add(Weight::from_ref_time(51_750 as u64).saturating_mul(p as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_scheduler.rs b/runtime/westend/src/weights/pallet_scheduler.rs index 29dd57c08c07..8e1e6ac2ad40 100644 --- a/runtime/westend/src/weights/pallet_scheduler.rs +++ b/runtime/westend/src/weights/pallet_scheduler.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_scheduler` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_scheduler.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -44,164 +44,97 @@ use sp_std::marker::PhantomData; /// Weight functions for `pallet_scheduler`. pub struct WeightInfo(PhantomData); impl pallet_scheduler::WeightInfo for WeightInfo { - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic_named_resolved(s: u32, ) -> Weight { - (2_582_000 as Weight) - // Standard Error: 32_000 - .saturating_add((25_444_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(s as Weight))) + // Storage: Scheduler IncompleteSince (r:1 w:1) + fn service_agendas_base() -> Weight { + // Minimum execution time: 4_370 nanoseconds. + Weight::from_ref_time(4_502_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_named_resolved(s: u32, ) -> Weight { - (4_112_000 as Weight) - // Standard Error: 29_000 - .saturating_add((20_456_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + /// The range of component `s` is `[0, 50]`. + fn service_agenda_base(s: u32, ) -> Weight { + // Minimum execution time: 3_700 nanoseconds. + Weight::from_ref_time(6_822_653 as u64) + // Standard Error: 1_792 + .saturating_add(Weight::from_ref_time(567_987 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic_resolved(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 32_000 - .saturating_add((23_106_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(s as Weight))) + fn service_task_base() -> Weight { + // Minimum execution time: 9_223 nanoseconds. + Weight::from_ref_time(9_738_000 as u64) } - // Storage: Scheduler Agenda (r:1 w:1) // Storage: Preimage PreimageFor (r:1 w:1) // Storage: Preimage StatusFor (r:1 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_resolved(s: u32, ) -> Weight { - (6_481_000 as Weight) - // Standard Error: 21_000 - .saturating_add((19_301_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) + /// The range of component `s` is `[128, 4194304]`. + fn service_task_fetched(s: u32, ) -> Weight { + // Minimum execution time: 21_101 nanoseconds. + Weight::from_ref_time(21_454_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(1_250 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:0) // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_named_aborted(s: u32, ) -> Weight { - (4_817_000 as Weight) - // Standard Error: 13_000 - .saturating_add((8_967_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) - } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Preimage PreimageFor (r:1 w:0) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_aborted(s: u32, ) -> Weight { - (6_222_000 as Weight) - // Standard Error: 11_000 - .saturating_add((6_779_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + fn service_task_named() -> Weight { + // Minimum execution time: 10_837 nanoseconds. + Weight::from_ref_time(11_168_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic_named(s: u32, ) -> Weight { - (3_607_000 as Weight) - // Standard Error: 79_000 - .saturating_add((15_590_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(s as Weight))) - } - // Storage: Scheduler Agenda (r:2 w:2) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_periodic(s: u32, ) -> Weight { - (11_226_000 as Weight) - // Standard Error: 17_000 - .saturating_add((12_726_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + fn service_task_periodic() -> Weight { + // Minimum execution time: 9_286 nanoseconds. + Weight::from_ref_time(9_582_000 as u64) } - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize_named(s: u32, ) -> Weight { - (12_159_000 as Weight) - // Standard Error: 13_000 - .saturating_add((10_436_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + fn execute_dispatch_signed() -> Weight { + // Minimum execution time: 4_038 nanoseconds. + Weight::from_ref_time(4_184_000 as u64) } - // Storage: Scheduler Agenda (r:1 w:1) - /// The range of component `s` is `[1, 50]`. - fn on_initialize(s: u32, ) -> Weight { - (12_359_000 as Weight) - // Standard Error: 26_000 - .saturating_add((9_593_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + fn execute_dispatch_unsigned() -> Weight { + // Minimum execution time: 3_949 nanoseconds. + Weight::from_ref_time(4_057_000 as u64) } // Storage: Scheduler Agenda (r:1 w:1) - /// The range of component `s` is `[0, 50]`. + /// The range of component `s` is `[0, 49]`. fn schedule(s: u32, ) -> Weight { - (18_686_000 as Weight) - // Standard Error: 1_000 - .saturating_add((49_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 16_889 nanoseconds. + Weight::from_ref_time(21_346_740 as u64) + // Standard Error: 2_567 + .saturating_add(Weight::from_ref_time(588_527 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Scheduler Agenda (r:1 w:1) // Storage: Scheduler Lookup (r:0 w:1) /// The range of component `s` is `[1, 50]`. fn cancel(s: u32, ) -> Weight { - (17_922_000 as Weight) - // Standard Error: 5_000 - .saturating_add((1_861_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 20_050 nanoseconds. + Weight::from_ref_time(21_672_769 as u64) + // Standard Error: 1_963 + .saturating_add(Weight::from_ref_time(584_093 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) - /// The range of component `s` is `[0, 50]`. + /// The range of component `s` is `[0, 49]`. fn schedule_named(s: u32, ) -> Weight { - (21_794_000 as Weight) - // Standard Error: 1_000 - .saturating_add((64_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 20_220 nanoseconds. + Weight::from_ref_time(24_461_622 as u64) + // Standard Error: 3_061 + .saturating_add(Weight::from_ref_time(616_499 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Scheduler Lookup (r:1 w:1) // Storage: Scheduler Agenda (r:1 w:1) /// The range of component `s` is `[1, 50]`. fn cancel_named(s: u32, ) -> Weight { - (19_726_000 as Weight) - // Standard Error: 5_000 - .saturating_add((1_854_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 20_855 nanoseconds. + Weight::from_ref_time(23_510_708 as u64) + // Standard Error: 2_186 + .saturating_add(Weight::from_ref_time(591_211 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_session.rs b/runtime/westend/src/weights/pallet_session.rs index 7c01c8729ac0..b0f5ab30a788 100644 --- a/runtime/westend/src/weights/pallet_session.rs +++ b/runtime/westend/src/weights/pallet_session.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_session` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_session.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -48,16 +48,18 @@ impl pallet_session::WeightInfo for WeightInfo { // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:6 w:6) fn set_keys() -> Weight { - (42_352_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 49_017 nanoseconds. + Weight::from_ref_time(50_530_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Session NextKeys (r:1 w:1) // Storage: Session KeyOwner (r:0 w:6) fn purge_keys() -> Weight { - (26_312_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 37_075 nanoseconds. + Weight::from_ref_time(38_290_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_staking.rs b/runtime/westend/src/weights/pallet_staking.rs index 9a39254529e6..125e45df12ef 100644 --- a/runtime/westend/src/weights/pallet_staking.rs +++ b/runtime/westend/src/weights/pallet_staking.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_staking` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_staking.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,13 +47,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Balances Locks (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn bond() -> Weight { - (39_056_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 44_919 nanoseconds. + Weight::from_ref_time(46_102_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -61,9 +61,10 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn bond_extra() -> Weight { - (70_307_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 80_191 nanoseconds. + Weight::from_ref_time(80_953_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking Nominators (r:1 w:0) @@ -75,9 +76,10 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking Bonded (r:1 w:0) // Storage: VoterList ListBags (r:2 w:2) fn unbond() -> Weight { - (75_717_000 as Weight) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + // Minimum execution time: 86_967 nanoseconds. + Weight::from_ref_time(87_679_000 as u64) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -85,11 +87,12 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: System Account (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - (31_047_000 as Weight) - // Standard Error: 0 - .saturating_add((31_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 37_885 nanoseconds. + Weight::from_ref_time(40_160_684 as u64) + // Standard Error: 962 + .saturating_add(Weight::from_ref_time(23_334 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Staking Ledger (r:1 w:1) // Storage: Staking CurrentEra (r:1 w:0) @@ -106,11 +109,12 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking Payee (r:0 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(s: u32, ) -> Weight { - (60_033_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(13 as Weight)) - .saturating_add(T::DbWeight::get().writes(11 as Weight)) + // Minimum execution time: 73_247 nanoseconds. + Weight::from_ref_time(75_284_540 as u64) + // Standard Error: 1_277 + .saturating_add(Weight::from_ref_time(2_814 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(13 as u64)) + .saturating_add(T::DbWeight::get().writes(11 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinValidatorBond (r:1 w:0) @@ -124,20 +128,22 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList CounterForListNodes (r:1 w:1) // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { - (48_953_000 as Weight) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 59_417 nanoseconds. + Weight::from_ref_time(60_321_000 as u64) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) /// The range of component `k` is `[1, 128]`. fn kick(k: u32, ) -> Weight { - (10_920_000 as Weight) - // Standard Error: 8_000 - .saturating_add((8_111_000 as Weight).saturating_mul(k as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight))) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight))) + // Minimum execution time: 32_309 nanoseconds. + Weight::from_ref_time(30_379_999 as u64) + // Standard Error: 9_757 + .saturating_add(Weight::from_ref_time(6_283_375 as u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(k as u64))) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking MinNominatorBond (r:1 w:0) @@ -152,12 +158,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking CounterForNominators (r:1 w:1) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - (52_622_000 as Weight) - // Standard Error: 11_000 - .saturating_add((3_092_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 61_031 nanoseconds. + Weight::from_ref_time(60_371_065 as u64) + // Standard Error: 5_826 + .saturating_add(Weight::from_ref_time(2_367_944 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Validators (r:1 w:0) @@ -167,51 +174,59 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - (46_206_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 55_977 nanoseconds. + Weight::from_ref_time(57_202_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Payee (r:0 w:1) fn set_payee() -> Weight { - (9_480_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 15_597 nanoseconds. + Weight::from_ref_time(15_845_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - (16_445_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 22_414 nanoseconds. + Weight::from_ref_time(22_860_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Staking ValidatorCount (r:0 w:1) fn set_validator_count() -> Weight { - (3_236_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_099 nanoseconds. + Weight::from_ref_time(4_249_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking ForceEra (r:0 w:1) fn force_no_eras() -> Weight { - (3_386_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_276 nanoseconds. + Weight::from_ref_time(4_378_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era() -> Weight { - (3_324_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_106 nanoseconds. + Weight::from_ref_time(4_214_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - (3_340_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_221 nanoseconds. + Weight::from_ref_time(4_402_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking Invulnerables (r:0 w:1) /// The range of component `v` is `[0, 1000]`. fn set_invulnerables(v: u32, ) -> Weight { - (3_676_000 as Weight) - // Standard Error: 0 - .saturating_add((10_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_150 nanoseconds. + Weight::from_ref_time(4_728_614 as u64) + // Standard Error: 32 + .saturating_add(Weight::from_ref_time(11_345 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking SlashingSpans (r:1 w:0) @@ -228,62 +243,64 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking SpanSlash (r:0 w:2) /// The range of component `s` is `[0, 100]`. fn force_unstake(s: u32, ) -> Weight { - (57_723_000 as Weight) - // Standard Error: 1_000 - .saturating_add((894_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 67_687 nanoseconds. + Weight::from_ref_time(72_720_204 as u64) + // Standard Error: 1_921 + .saturating_add(Weight::from_ref_time(878_716 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: Staking UnappliedSlashes (r:1 w:1) /// The range of component `s` is `[1, 1000]`. fn cancel_deferred_slash(s: u32, ) -> Weight { - (2_534_473_000 as Weight) - // Standard Error: 172_000 - .saturating_add((14_773_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 118_556 nanoseconds. + Weight::from_ref_time(1_335_997_093 as u64) + // Standard Error: 88_697 + .saturating_add(Weight::from_ref_time(7_439_050 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) + // Storage: Staking Bonded (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Payee (r:2 w:0) - // Storage: System Account (r:2 w:2) - /// The range of component `n` is `[1, 64]`. + // Storage: Staking Payee (r:1 w:0) + // Storage: System Account (r:1 w:1) + /// The range of component `n` is `[0, 64]`. fn payout_stakers_dead_controller(n: u32, ) -> Weight { - (74_433_000 as Weight) - // Standard Error: 22_000 - .saturating_add((24_296_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight))) + // Minimum execution time: 75_734 nanoseconds. + Weight::from_ref_time(89_504_336 as u64) + // Standard Error: 24_913 + .saturating_add(Weight::from_ref_time(19_162_630 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(n as u64))) } // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking Ledger (r:2 w:2) + // Storage: Staking Bonded (r:1 w:0) + // Storage: Staking Ledger (r:1 w:1) // Storage: Staking ErasStakersClipped (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:0) // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Payee (r:2 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Balances Locks (r:2 w:2) - /// The range of component `n` is `[1, 64]`. + // Storage: Staking Payee (r:1 w:0) + // Storage: System Account (r:1 w:1) + // Storage: Balances Locks (r:1 w:1) + /// The range of component `n` is `[0, 64]`. fn payout_stakers_alive_staked(n: u32, ) -> Weight { - (83_490_000 as Weight) - // Standard Error: 26_000 - .saturating_add((32_049_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight))) + // Minimum execution time: 87_803 nanoseconds. + Weight::from_ref_time(111_266_197 as u64) + // Standard Error: 36_584 + .saturating_add(Weight::from_ref_time(25_512_336 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(n as u64))) } // Storage: Staking Ledger (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -293,29 +310,12 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListBags (r:2 w:2) /// The range of component `l` is `[1, 32]`. fn rebond(l: u32, ) -> Weight { - (68_977_000 as Weight) - // Standard Error: 13_000 - .saturating_add((54_000 as Weight).saturating_mul(l as Weight)) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) - } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking HistoryDepth (r:1 w:1) - // Storage: Staking ErasStakersClipped (r:0 w:2) - // Storage: Staking ErasValidatorPrefs (r:0 w:2) - // Storage: Staking ErasValidatorReward (r:0 w:1) - // Storage: Staking ErasRewardPoints (r:0 w:1) - // Storage: Staking ErasStakers (r:0 w:2) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - /// The range of component `e` is `[1, 100]`. - fn set_history_depth(e: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 90_000 - .saturating_add((22_124_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight))) + // Minimum execution time: 79_272 nanoseconds. + Weight::from_ref_time(81_092_805 as u64) + // Standard Error: 4_327 + .saturating_add(Weight::from_ref_time(40_862 as u64).saturating_mul(l as u64)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } // Storage: System Account (r:1 w:1) // Storage: Staking Bonded (r:1 w:1) @@ -332,12 +332,13 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking SpanSlash (r:0 w:1) /// The range of component `s` is `[1, 100]`. fn reap_stash(s: u32, ) -> Weight { - (64_117_000 as Weight) - // Standard Error: 1_000 - .saturating_add((888_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight))) + // Minimum execution time: 79_673 nanoseconds. + Weight::from_ref_time(80_100_348 as u64) + // Standard Error: 2_843 + .saturating_add(Weight::from_ref_time(886_290 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().writes(12 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) } // Storage: VoterList CounterForListNodes (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0) @@ -352,25 +353,25 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking ValidatorCount (r:1 w:0) // Storage: Staking MinimumValidatorCount (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:1) - // Storage: Staking HistoryDepth (r:1 w:0) // Storage: Staking ErasStakersClipped (r:0 w:1) // Storage: Staking ErasValidatorPrefs (r:0 w:1) // Storage: Staking ErasStakers (r:0 w:1) // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) /// The range of component `v` is `[1, 10]`. - /// The range of component `n` is `[1, 100]`. + /// The range of component `n` is `[0, 100]`. fn new_era(v: u32, n: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 1_326_000 - .saturating_add((300_625_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 127_000 - .saturating_add((38_619_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(187 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight))) + // Minimum execution time: 444_099 nanoseconds. + Weight::from_ref_time(462_116_000 as u64) + // Standard Error: 1_825_380 + .saturating_add(Weight::from_ref_time(60_582_117 as u64).saturating_mul(v as u64)) + // Standard Error: 181_889 + .saturating_add(Weight::from_ref_time(12_617_609 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(186 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().reads((4 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(v as u64))) } // Storage: VoterList CounterForListNodes (r:1 w:0) // Storage: Staking SlashingSpans (r:21 w:0) @@ -385,29 +386,30 @@ impl pallet_staking::WeightInfo for WeightInfo { /// The range of component `n` is `[500, 1000]`. /// The range of component `s` is `[1, 20]`. fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 116_000 - .saturating_add((24_599_000 as Weight).saturating_mul(v as Weight)) - // Standard Error: 116_000 - .saturating_add((22_573_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 2_973_000 - .saturating_add((34_144_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(181 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(s as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 25_695_485 nanoseconds. + Weight::from_ref_time(25_860_451_000 as u64) + // Standard Error: 472_700 + .saturating_add(Weight::from_ref_time(11_577_066 as u64).saturating_mul(v as u64)) + // Standard Error: 472_700 + .saturating_add(Weight::from_ref_time(10_734_019 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(181 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().reads((4 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } + // Storage: Staking CounterForValidators (r:1 w:0) // Storage: Staking Validators (r:501 w:0) // Storage: System BlockWeight (r:1 w:1) /// The range of component `v` is `[500, 1000]`. fn get_npos_targets(v: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 34_000 - .saturating_add((7_766_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 3_409_575 nanoseconds. + Weight::from_ref_time(110_440_394 as u64) + // Standard Error: 43_738 + .saturating_add(Weight::from_ref_time(6_940_019 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(v as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Staking MinCommission (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) @@ -416,8 +418,9 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_set() -> Weight { - (6_082_000 as Weight) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 7_596 nanoseconds. + Weight::from_ref_time(7_822_000 as u64) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking MinCommission (r:0 w:1) // Storage: Staking MinValidatorBond (r:0 w:1) @@ -426,8 +429,9 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_remove() -> Weight { - (5_821_000 as Weight) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 6_748 nanoseconds. + Weight::from_ref_time(7_052_000 as u64) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Nominators (r:1 w:1) @@ -440,15 +444,17 @@ impl pallet_staking::WeightInfo for WeightInfo { // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill_other() -> Weight { - (55_078_000 as Weight) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 66_366 nanoseconds. + Weight::from_ref_time(66_789_000 as u64) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Staking MinCommission (r:1 w:0) // Storage: Staking Validators (r:1 w:1) fn force_apply_min_commission() -> Weight { - (10_492_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 15_138 nanoseconds. + Weight::from_ref_time(15_465_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/pallet_timestamp.rs b/runtime/westend/src/weights/pallet_timestamp.rs index f8fbd9a0ce39..9e2c99779daa 100644 --- a/runtime/westend/src/weights/pallet_timestamp.rs +++ b/runtime/westend/src/weights/pallet_timestamp.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_timestamp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_timestamp.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,11 +47,13 @@ impl pallet_timestamp::WeightInfo for WeightInfo { // Storage: Timestamp Now (r:1 w:1) // Storage: Babe CurrentSlot (r:1 w:0) fn set() -> Weight { - (7_984_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 9_068 nanoseconds. + Weight::from_ref_time(9_294_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } fn on_finalize() -> Weight { - (2_224_000 as Weight) + // Minimum execution time: 3_838 nanoseconds. + Weight::from_ref_time(4_004_000 as u64) } } diff --git a/runtime/westend/src/weights/pallet_utility.rs b/runtime/westend/src/weights/pallet_utility.rs index f01a44300513..f976ff6b788e 100644 --- a/runtime/westend/src/weights/pallet_utility.rs +++ b/runtime/westend/src/weights/pallet_utility.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_utility` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_utility.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,26 +46,31 @@ pub struct WeightInfo(PhantomData); impl pallet_utility::WeightInfo for WeightInfo { /// The range of component `c` is `[0, 1000]`. fn batch(c: u32, ) -> Weight { - (21_263_000 as Weight) - // Standard Error: 2_000 - .saturating_add((4_568_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 11_344 nanoseconds. + Weight::from_ref_time(15_084_816 as u64) + // Standard Error: 2_719 + .saturating_add(Weight::from_ref_time(3_318_885 as u64).saturating_mul(c as u64)) } fn as_derivative() -> Weight { - (5_489_000 as Weight) + // Minimum execution time: 5_807 nanoseconds. + Weight::from_ref_time(6_033_000 as u64) } /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32, ) -> Weight { - (12_474_000 as Weight) - // Standard Error: 3_000 - .saturating_add((4_877_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 11_444 nanoseconds. + Weight::from_ref_time(18_634_415 as u64) + // Standard Error: 3_166 + .saturating_add(Weight::from_ref_time(3_479_338 as u64).saturating_mul(c as u64)) } fn dispatch_as() -> Weight { - (12_745_000 as Weight) + // Minimum execution time: 13_410 nanoseconds. + Weight::from_ref_time(13_821_000 as u64) } /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32, ) -> Weight { - (21_712_000 as Weight) - // Standard Error: 2_000 - .saturating_add((4_569_000 as Weight).saturating_mul(c as Weight)) + // Minimum execution time: 11_023 nanoseconds. + Weight::from_ref_time(14_615_133 as u64) + // Standard Error: 2_404 + .saturating_add(Weight::from_ref_time(3_327_844 as u64).saturating_mul(c as u64)) } } diff --git a/runtime/westend/src/weights/pallet_vesting.rs b/runtime/westend/src/weights/pallet_vesting.rs index b0dfc4e0ae19..642836238f61 100644 --- a/runtime/westend/src/weights/pallet_vesting.rs +++ b/runtime/westend/src/weights/pallet_vesting.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `pallet_vesting` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -32,7 +32,7 @@ // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/pallet_vesting.rs +// --output=./runtime/westend/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -49,26 +49,28 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_locked(l: u32, s: u32, ) -> Weight { - (28_533_000 as Weight) - // Standard Error: 1_000 - .saturating_add((70_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((152_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 37_183 nanoseconds. + Weight::from_ref_time(36_684_277 as u64) + // Standard Error: 1_065 + .saturating_add(Weight::from_ref_time(40_600 as u64).saturating_mul(l as u64)) + // Standard Error: 1_895 + .saturating_add(Weight::from_ref_time(69_083 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_unlocked(l: u32, s: u32, ) -> Weight { - (28_491_000 as Weight) - // Standard Error: 0 - .saturating_add((61_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((128_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 37_040 nanoseconds. + Weight::from_ref_time(36_422_009 as u64) + // Standard Error: 1_110 + .saturating_add(Weight::from_ref_time(39_319 as u64).saturating_mul(l as u64)) + // Standard Error: 1_975 + .saturating_add(Weight::from_ref_time(57_199 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -76,13 +78,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_other_locked(l: u32, s: u32, ) -> Weight { - (28_340_000 as Weight) - // Standard Error: 0 - .saturating_add((71_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((150_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 37_003 nanoseconds. + Weight::from_ref_time(36_545_448 as u64) + // Standard Error: 1_175 + .saturating_add(Weight::from_ref_time(38_723 as u64).saturating_mul(l as u64)) + // Standard Error: 2_091 + .saturating_add(Weight::from_ref_time(68_390 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -90,13 +93,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_other_unlocked(l: u32, s: u32, ) -> Weight { - (28_558_000 as Weight) - // Standard Error: 0 - .saturating_add((64_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 1_000 - .saturating_add((120_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 36_641 nanoseconds. + Weight::from_ref_time(36_355_534 as u64) + // Standard Error: 1_145 + .saturating_add(Weight::from_ref_time(40_167 as u64).saturating_mul(l as u64)) + // Standard Error: 2_037 + .saturating_add(Weight::from_ref_time(45_324 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -104,13 +108,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. fn vested_transfer(l: u32, s: u32, ) -> Weight { - (43_102_000 as Weight) - // Standard Error: 2_000 - .saturating_add((65_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 4_000 - .saturating_add((130_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 50_555 nanoseconds. + Weight::from_ref_time(51_170_903 as u64) + // Standard Error: 1_907 + .saturating_add(Weight::from_ref_time(45_993 as u64).saturating_mul(l as u64)) + // Standard Error: 3_393 + .saturating_add(Weight::from_ref_time(22_249 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: System Account (r:2 w:2) @@ -118,13 +123,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. fn force_vested_transfer(l: u32, s: u32, ) -> Weight { - (42_364_000 as Weight) - // Standard Error: 2_000 - .saturating_add((78_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 5_000 - .saturating_add((137_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 50_181 nanoseconds. + Weight::from_ref_time(50_424_666 as u64) + // Standard Error: 1_780 + .saturating_add(Weight::from_ref_time(37_337 as u64).saturating_mul(l as u64)) + // Standard Error: 3_167 + .saturating_add(Weight::from_ref_time(43_062 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -132,13 +138,14 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - (29_492_000 as Weight) - // Standard Error: 1_000 - .saturating_add((64_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 2_000 - .saturating_add((154_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 38_284 nanoseconds. + Weight::from_ref_time(37_590_291 as u64) + // Standard Error: 1_161 + .saturating_add(Weight::from_ref_time(42_501 as u64).saturating_mul(l as u64)) + // Standard Error: 2_144 + .saturating_add(Weight::from_ref_time(70_327 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Vesting Vesting (r:1 w:1) // Storage: Balances Locks (r:1 w:1) @@ -146,12 +153,13 @@ impl pallet_vesting::WeightInfo for WeightInfo { /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - (29_532_000 as Weight) - // Standard Error: 1_000 - .saturating_add((58_000 as Weight).saturating_mul(l as Weight)) - // Standard Error: 2_000 - .saturating_add((155_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 38_261 nanoseconds. + Weight::from_ref_time(38_137_437 as u64) + // Standard Error: 1_243 + .saturating_add(Weight::from_ref_time(37_066 as u64).saturating_mul(l as u64)) + // Standard Error: 2_296 + .saturating_add(Weight::from_ref_time(48_166 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/westend/src/weights/runtime_common_auctions.rs b/runtime/westend/src/weights/runtime_common_auctions.rs index c6b0cb257d00..285c4e03fa47 100644 --- a/runtime/westend/src/weights/runtime_common_auctions.rs +++ b/runtime/westend/src/weights/runtime_common_auctions.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::auctions` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -47,9 +47,10 @@ impl runtime_common::auctions::WeightInfo for WeightInf // Storage: Auctions AuctionInfo (r:1 w:1) // Storage: Auctions AuctionCounter (r:1 w:1) fn new_auction() -> Weight { - (15_096_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 16_493 nanoseconds. + Weight::from_ref_time(17_345_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Paras ParaLifecycles (r:1 w:0) // Storage: Auctions AuctionCounter (r:1 w:0) @@ -59,9 +60,10 @@ impl runtime_common::auctions::WeightInfo for WeightInf // Storage: Auctions ReservedAmounts (r:2 w:2) // Storage: System Account (r:1 w:1) fn bid() -> Weight { - (69_901_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 70_142 nanoseconds. + Weight::from_ref_time(71_728_000 as u64) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Auctions AuctionInfo (r:1 w:1) // Storage: Babe NextRandomness (r:1 w:0) @@ -76,17 +78,19 @@ impl runtime_common::auctions::WeightInfo for WeightInf // Storage: Paras ActionsQueue (r:1 w:1) // Storage: Registrar Paras (r:1 w:1) fn on_initialize() -> Weight { - (15_323_740_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3688 as Weight)) - .saturating_add(T::DbWeight::get().writes(3683 as Weight)) + // Minimum execution time: 14_569_286 nanoseconds. + Weight::from_ref_time(14_838_470_000 as u64) + .saturating_add(T::DbWeight::get().reads(3688 as u64)) + .saturating_add(T::DbWeight::get().writes(3683 as u64)) } // Storage: Auctions ReservedAmounts (r:37 w:36) // Storage: System Account (r:36 w:36) // Storage: Auctions Winning (r:0 w:3600) // Storage: Auctions AuctionInfo (r:0 w:1) fn cancel_auction() -> Weight { - (4_582_728_000 as Weight) - .saturating_add(T::DbWeight::get().reads(73 as Weight)) - .saturating_add(T::DbWeight::get().writes(3673 as Weight)) + // Minimum execution time: 4_522_777 nanoseconds. + Weight::from_ref_time(4_617_937_000 as u64) + .saturating_add(T::DbWeight::get().reads(73 as u64)) + .saturating_add(T::DbWeight::get().writes(3673 as u64)) } } diff --git a/runtime/westend/src/weights/runtime_common_crowdloan.rs b/runtime/westend/src/weights/runtime_common_crowdloan.rs index 0ee0e2a1d385..96b147a6bbb3 100644 --- a/runtime/westend/src/weights/runtime_common_crowdloan.rs +++ b/runtime/westend/src/weights/runtime_common_crowdloan.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::crowdloan` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -49,9 +49,10 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: Paras ParaLifecycles (r:1 w:0) // Storage: Crowdloan NextFundIndex (r:1 w:1) fn create() -> Weight { - (40_904_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 47_331 nanoseconds. + Weight::from_ref_time(48_516_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: Slots Leases (r:1 w:0) @@ -61,55 +62,62 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: Crowdloan NewRaise (r:1 w:1) // Storage: unknown [0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291] (r:1 w:1) fn contribute() -> Weight { - (111_898_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 113_791 nanoseconds. + Weight::from_ref_time(115_542_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: System Account (r:2 w:2) // Storage: unknown [0xc85982571aa615c788ef9b2c16f54f25773fd439e8ee1ed2aa3ae43d48e880f0] (r:1 w:1) fn withdraw() -> Weight { - (48_847_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 53_602 nanoseconds. + Weight::from_ref_time(54_469_000 as u64) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `k` is `[0, 500]`. fn refund(k: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 14_000 - .saturating_add((18_621_000 as Weight).saturating_mul(k as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(k as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(k as Weight))) + // Minimum execution time: 50_291 nanoseconds. + Weight::from_ref_time(25_006_147 as u64) + // Standard Error: 12_114 + .saturating_add(Weight::from_ref_time(17_108_181 as u64).saturating_mul(k as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(k as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(k as u64))) } // Storage: Crowdloan Funds (r:1 w:1) // Storage: System Account (r:1 w:1) fn dissolve() -> Weight { - (31_423_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 35_498 nanoseconds. + Weight::from_ref_time(36_398_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Crowdloan Funds (r:1 w:1) fn edit() -> Weight { - (20_848_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_490 nanoseconds. + Weight::from_ref_time(25_285_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Funds (r:1 w:0) // Storage: unknown [0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291] (r:1 w:1) fn add_memo() -> Weight { - (26_978_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 31_245 nanoseconds. + Weight::from_ref_time(32_197_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Funds (r:1 w:0) // Storage: Crowdloan NewRaise (r:1 w:1) fn poke() -> Weight { - (22_016_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_309 nanoseconds. + Weight::from_ref_time(25_069_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Auctions AuctionInfo (r:1 w:0) // Storage: Crowdloan EndingsCount (r:1 w:1) @@ -123,12 +131,13 @@ impl runtime_common::crowdloan::WeightInfo for WeightIn // Storage: System Account (r:2 w:2) /// The range of component `n` is `[2, 100]`. fn on_initialize(n: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 28_000 - .saturating_add((48_794_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(n as Weight))) + // Minimum execution time: 99_726 nanoseconds. + Weight::from_ref_time(17_907_029 as u64) + // Standard Error: 36_455 + .saturating_add(Weight::from_ref_time(39_077_749 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(n as u64))) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(n as u64))) } } diff --git a/runtime/westend/src/weights/runtime_common_paras_registrar.rs b/runtime/westend/src/weights/runtime_common_paras_registrar.rs index eabb90616951..db1aca349373 100644 --- a/runtime/westend/src/weights/runtime_common_paras_registrar.rs +++ b/runtime/westend/src/weights/runtime_common_paras_registrar.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::paras_registrar` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -48,9 +48,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:0) fn reserve() -> Weight { - (28_424_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 32_661 nanoseconds. + Weight::from_ref_time(33_021_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -62,9 +63,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras CurrentCodeHash (r:0 w:1) // Storage: Paras UpcomingParasGenesis (r:0 w:1) fn register() -> Weight { - (8_625_943_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 7_278_260 nanoseconds. + Weight::from_ref_time(7_402_107_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -76,9 +78,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras CurrentCodeHash (r:0 w:1) // Storage: Paras UpcomingParasGenesis (r:0 w:1) fn force_register() -> Weight { - (8_608_547_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + // Minimum execution time: 7_254_460 nanoseconds. + Weight::from_ref_time(7_389_063_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(7 as u64)) } // Storage: Registrar Paras (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -87,9 +90,10 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Paras ActionsQueue (r:1 w:1) // Storage: Registrar PendingSwap (r:0 w:1) fn deregister() -> Weight { - (40_944_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 48_086 nanoseconds. + Weight::from_ref_time(49_772_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Registrar Paras (r:1 w:0) // Storage: Paras ParaLifecycles (r:2 w:2) @@ -99,8 +103,37 @@ impl runtime_common::paras_registrar::WeightInfo for We // Storage: Crowdloan Funds (r:2 w:2) // Storage: Slots Leases (r:2 w:2) fn swap() -> Weight { - (37_396_000 as Weight) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + // Minimum execution time: 42_929 nanoseconds. + Weight::from_ref_time(43_993_000 as u64) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) + } + // Storage: Paras FutureCodeHash (r:1 w:1) + // Storage: Paras UpgradeRestrictionSignal (r:1 w:1) + // Storage: Paras CurrentCodeHash (r:1 w:0) + // Storage: Paras UpgradeCooldowns (r:1 w:1) + // Storage: Paras PvfActiveVoteMap (r:1 w:0) + // Storage: Paras CodeByHash (r:1 w:1) + // Storage: Paras UpcomingUpgrades (r:1 w:1) + // Storage: System Digest (r:1 w:1) + // Storage: Paras CodeByHashRefs (r:1 w:1) + // Storage: Paras FutureCodeUpgrades (r:0 w:1) + /// The range of component `b` is `[1, 3145728]`. + fn schedule_code_upgrade(b: u32, ) -> Weight { + // Minimum execution time: 41_885 nanoseconds. + Weight::from_ref_time(42_261_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_287 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) + } + // Storage: Paras Heads (r:0 w:1) + /// The range of component `b` is `[1, 1048576]`. + fn set_current_head(b: u32, ) -> Weight { + // Minimum execution time: 13_794 nanoseconds. + Weight::from_ref_time(13_978_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(909 as u64).saturating_mul(b as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/runtime_common_slots.rs b/runtime/westend/src/weights/runtime_common_slots.rs index c439050108bc..a35984f6301f 100644 --- a/runtime/westend/src/weights/runtime_common_slots.rs +++ b/runtime/westend/src/weights/runtime_common_slots.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_common::slots` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -47,9 +47,10 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (28_225_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 30_044 nanoseconds. + Weight::from_ref_time(30_999_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Paras Parachains (r:1 w:0) // Storage: Slots Leases (r:101 w:100) @@ -60,24 +61,26 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (0 as Weight) - // Standard Error: 22_000 - .saturating_add((6_678_000 as Weight).saturating_mul(c as Weight)) - // Standard Error: 22_000 - .saturating_add((17_665_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(t as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(t as Weight))) + // Minimum execution time: 541_004 nanoseconds. + Weight::from_ref_time(544_395_000 as u64) + // Standard Error: 67_401 + .saturating_add(Weight::from_ref_time(2_009_663 as u64).saturating_mul(c as u64)) + // Standard Error: 67_401 + .saturating_add(Weight::from_ref_time(11_680_248 as u64).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(t as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(t as u64))) } // Storage: Slots Leases (r:1 w:1) // Storage: System Account (r:8 w:8) fn clear_all_leases() -> Weight { - (93_216_000 as Weight) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(9 as Weight)) + // Minimum execution time: 90_911 nanoseconds. + Weight::from_ref_time(92_388_000 as u64) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: Slots Leases (r:1 w:0) // Storage: Paras ParaLifecycles (r:1 w:1) @@ -85,8 +88,9 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (20_875_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 28_595 nanoseconds. + Weight::from_ref_time(29_454_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } } diff --git a/runtime/westend/src/weights/runtime_parachains_configuration.rs b/runtime/westend/src/weights/runtime_parachains_configuration.rs index d40d1f4e145c..6e5d038fb28f 100644 --- a/runtime/westend/src/weights/runtime_parachains_configuration.rs +++ b/runtime/westend/src/weights/runtime_parachains_configuration.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::configuration` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -48,44 +48,50 @@ impl runtime_parachains::configuration::WeightInfo for // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_block_number() -> Weight { - (9_098_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 11_758 nanoseconds. + Weight::from_ref_time(12_108_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_u32() -> Weight { - (9_160_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 11_677 nanoseconds. + Weight::from_ref_time(12_033_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_option_u32() -> Weight { - (9_127_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 11_585 nanoseconds. + Weight::from_ref_time(11_987_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_weight() -> Weight { - (9_415_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 11_946 nanoseconds. + Weight::from_ref_time(12_664_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Benchmark Override (r:0 w:0) fn set_hrmp_open_request_ttl() -> Weight { - (2_000_000_000_000 as Weight) + // Minimum execution time: 2_000_000_000 nanoseconds. + Weight::from_ref_time(2_000_000_000_000 as u64) } // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration BypassConsistencyCheck (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_balance() -> Weight { - (9_524_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 11_939 nanoseconds. + Weight::from_ref_time(12_308_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/runtime_parachains_disputes.rs b/runtime/westend/src/weights/runtime_parachains_disputes.rs index ab8c2b7b941c..51d07e29738d 100644 --- a/runtime/westend/src/weights/runtime_parachains_disputes.rs +++ b/runtime/westend/src/weights/runtime_parachains_disputes.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::disputes` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -46,7 +46,8 @@ pub struct WeightInfo(PhantomData); impl runtime_parachains::disputes::WeightInfo for WeightInfo { // Storage: ParasDisputes Frozen (r:0 w:1) fn force_unfreeze() -> Weight { - (3_175_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 4_324 nanoseconds. + Weight::from_ref_time(4_436_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs new file mode 100644 index 000000000000..d9f0c357924a --- /dev/null +++ b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs @@ -0,0 +1,68 @@ +// Copyright 2017-2022 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 . +//! Autogenerated weights for `runtime_parachains::disputes::slashing` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=westend-dev +// --steps=50 +// --repeat=20 +// --pallet=runtime_parachains::disputes::slashing +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `runtime_parachains::disputes::slashing`. +pub struct WeightInfo(PhantomData); +impl runtime_parachains::disputes::slashing::WeightInfo for WeightInfo { + // Storage: Session CurrentIndex (r:1 w:0) + // Storage: Historical HistoricalSessions (r:1 w:0) + // Storage: ParaSessionInfo Sessions (r:1 w:0) + // Storage: ParasSlashing UnappliedSlashes (r:1 w:1) + // Storage: Offences ReportsByKindIndex (r:1 w:1) + // Storage: Offences ConcurrentReportsIndex (r:1 w:1) + // Storage: Offences Reports (r:1 w:1) + // Storage: Staking SlashRewardFraction (r:1 w:0) + // Storage: Staking ActiveEra (r:1 w:0) + // Storage: Staking ErasStartSessionIndex (r:1 w:0) + // Storage: Staking Invulnerables (r:1 w:0) + // Storage: Staking ValidatorSlashInEra (r:1 w:0) + /// The range of component `n` is `[4, 300]`. + fn report_dispute_lost(n: u32, ) -> Weight { + // Minimum execution time: 84_907 nanoseconds. + Weight::from_ref_time(98_263_914 as u64) + // Standard Error: 2_933 + .saturating_add(Weight::from_ref_time(224_882 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(12 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + } +} diff --git a/runtime/westend/src/weights/runtime_parachains_hrmp.rs b/runtime/westend/src/weights/runtime_parachains_hrmp.rs index b5740fcc8055..22748116ec4c 100644 --- a/runtime/westend/src/weights/runtime_parachains_hrmp.rs +++ b/runtime/westend/src/weights/runtime_parachains_hrmp.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::hrmp` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -53,9 +53,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_init_open_channel() -> Weight { - (37_290_000 as Weight) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + // Minimum execution time: 39_666 nanoseconds. + Weight::from_ref_time(40_166_000 as u64) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) // Storage: Paras ParaLifecycles (r:1 w:0) @@ -64,9 +65,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_accept_open_channel() -> Weight { - (33_687_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 39_648 nanoseconds. + Weight::from_ref_time(39_947_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Hrmp HrmpChannels (r:1 w:0) // Storage: Hrmp HrmpCloseChannelRequests (r:1 w:1) @@ -74,9 +76,10 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) fn hrmp_close_channel() -> Weight { - (31_507_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 36_824 nanoseconds. + Weight::from_ref_time(37_134_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Hrmp HrmpIngressChannelsIndex (r:128 w:127) // Storage: Hrmp HrmpEgressChannelsIndex (r:1 w:1) @@ -87,17 +90,18 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf /// The range of component `i` is `[0, 127]`. /// The range of component `e` is `[0, 127]`. fn force_clean_hrmp(i: u32, e: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 18_000 - .saturating_add((9_857_000 as Weight).saturating_mul(i as Weight)) - // Standard Error: 18_000 - .saturating_add((9_902_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(i as Weight))) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(e as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(i as Weight))) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(e as Weight))) + // Minimum execution time: 847_678 nanoseconds. + Weight::from_ref_time(852_106_000 as u64) + // Standard Error: 76_785 + .saturating_add(Weight::from_ref_time(2_651_145 as u64).saturating_mul(i as u64)) + // Standard Error: 76_785 + .saturating_add(Weight::from_ref_time(2_718_986 as u64).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(i as u64))) + .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(e as u64))) + .saturating_add(T::DbWeight::get().writes(4 as u64)) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(i as u64))) + .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(e as u64))) } // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:0) // Storage: Hrmp HrmpOpenChannelRequests (r:2 w:2) @@ -109,13 +113,14 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Hrmp HrmpChannels (r:0 w:2) /// The range of component `c` is `[0, 128]`. fn force_process_hrmp_open(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 35_000 - .saturating_add((23_225_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((7 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((6 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 9_264 nanoseconds. + Weight::from_ref_time(9_446_000 as u64) + // Standard Error: 10_471 + .saturating_add(Weight::from_ref_time(15_482_563 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((7 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((6 as u64).saturating_mul(c as u64))) } // Storage: Hrmp HrmpCloseChannelRequestsList (r:1 w:0) // Storage: Hrmp HrmpChannels (r:2 w:2) @@ -125,35 +130,54 @@ impl runtime_parachains::hrmp::WeightInfo for WeightInf // Storage: Hrmp HrmpChannelContents (r:0 w:2) /// The range of component `c` is `[0, 128]`. fn force_process_hrmp_close(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 18_000 - .saturating_add((13_030_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((5 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 6_075 nanoseconds. + Weight::from_ref_time(6_228_000 as u64) + // Standard Error: 7_996 + .saturating_add(Weight::from_ref_time(9_374_518 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((5 as u64).saturating_mul(c as u64))) } // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequestCount (r:1 w:1) /// The range of component `c` is `[0, 128]`. fn hrmp_cancel_open_request(c: u32, ) -> Weight { - (26_560_000 as Weight) - // Standard Error: 1_000 - .saturating_add((49_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 24_597 nanoseconds. + Weight::from_ref_time(30_816_203 as u64) + // Standard Error: 1_397 + .saturating_add(Weight::from_ref_time(91_413 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) // Storage: Hrmp HrmpOpenChannelRequests (r:2 w:2) /// The range of component `c` is `[0, 128]`. fn clean_open_channel_requests(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 9_000 - .saturating_add((3_867_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight))) + // Minimum execution time: 4_151 nanoseconds. + Weight::from_ref_time(2_597_333 as u64) + // Standard Error: 3_958 + .saturating_add(Weight::from_ref_time(2_517_259 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) + .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + } + // Storage: Paras ParaLifecycles (r:2 w:0) + // Storage: Hrmp HrmpOpenChannelRequests (r:1 w:1) + // Storage: Hrmp HrmpChannels (r:1 w:0) + // Storage: Hrmp HrmpEgressChannelsIndex (r:1 w:0) + // Storage: Hrmp HrmpOpenChannelRequestCount (r:1 w:1) + // Storage: Hrmp HrmpOpenChannelRequestsList (r:1 w:1) + // Storage: Dmp DownwardMessageQueueHeads (r:2 w:2) + // Storage: Dmp DownwardMessageQueues (r:2 w:2) + // Storage: Hrmp HrmpIngressChannelsIndex (r:1 w:0) + // Storage: Hrmp HrmpAcceptedChannelRequestCount (r:1 w:1) + fn force_open_hrmp_channel() -> Weight { + // Minimum execution time: 51_284 nanoseconds. + Weight::from_ref_time(51_911_000 as u64) + .saturating_add(T::DbWeight::get().reads(13 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } } diff --git a/runtime/westend/src/weights/runtime_parachains_initializer.rs b/runtime/westend/src/weights/runtime_parachains_initializer.rs index 370afa635582..547ee04cc5b4 100644 --- a/runtime/westend/src/weights/runtime_parachains_initializer.rs +++ b/runtime/westend/src/weights/runtime_parachains_initializer.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::initializer` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -47,10 +47,11 @@ impl runtime_parachains::initializer::WeightInfo for We // Storage: System Digest (r:1 w:1) /// The range of component `d` is `[0, 65536]`. fn force_approve(d: u32, ) -> Weight { - (7_235_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(d as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 7_456 nanoseconds. + Weight::from_ref_time(10_280_250 as u64) + // Standard Error: 7 + .saturating_add(Weight::from_ref_time(1_325 as u64).saturating_mul(d as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/runtime_parachains_paras.rs b/runtime/westend/src/weights/runtime_parachains_paras.rs index f1ffe46ac241..9e8dbe1d2911 100644 --- a/runtime/westend/src/weights/runtime_parachains_paras.rs +++ b/runtime/westend/src/weights/runtime_parachains_paras.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::paras` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -52,19 +52,21 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras CodeByHash (r:0 w:1) /// The range of component `c` is `[1, 3145728]`. fn force_set_current_code(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + // Minimum execution time: 35_035 nanoseconds. + Weight::from_ref_time(35_691_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_273 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: Paras Heads (r:0 w:1) /// The range of component `s` is `[1, 1048576]`. fn force_set_current_head(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 13_034 nanoseconds. + Weight::from_ref_time(13_260_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(908 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Paras FutureCodeHash (r:1 w:1) // Storage: Paras CurrentCodeHash (r:1 w:0) @@ -78,54 +80,60 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras UpgradeRestrictionSignal (r:0 w:1) /// The range of component `c` is `[1, 3145728]`. fn force_schedule_code_upgrade(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + // Minimum execution time: 60_031 nanoseconds. + Weight::from_ref_time(60_460_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_296 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(8 as u64)) + .saturating_add(T::DbWeight::get().writes(8 as u64)) } // Storage: Paras FutureCodeUpgrades (r:1 w:0) // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) /// The range of component `s` is `[1, 1048576]`. fn force_note_new_head(s: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(s as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + // Minimum execution time: 18_669 nanoseconds. + Weight::from_ref_time(18_980_000 as u64) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(913 as u64).saturating_mul(s as u64)) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras ActionsQueue (r:1 w:1) fn force_queue_action() -> Weight { - (19_269_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 23_275 nanoseconds. + Weight::from_ref_time(23_770_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Paras PvfActiveVoteMap (r:1 w:0) // Storage: Paras CodeByHash (r:1 w:1) /// The range of component `c` is `[1, 3145728]`. fn add_trusted_validation_code(c: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(c as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 8_351 nanoseconds. + Weight::from_ref_time(8_516_000 as u64) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(2_277 as u64).saturating_mul(c as u64)) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Paras CodeByHashRefs (r:1 w:0) // Storage: Paras CodeByHash (r:0 w:1) fn poke_unused_validation_code() -> Weight { - (4_769_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 6_620 nanoseconds. + Weight::from_ref_time(6_767_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Paras PvfActiveVoteMap (r:1 w:1) fn include_pvf_check_statement() -> Weight { - (92_142_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 92_438 nanoseconds. + Weight::from_ref_time(94_776_000 as u64) + .saturating_add(T::DbWeight::get().reads(3 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) @@ -135,9 +143,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: System Digest (r:1 w:1) // Storage: Paras FutureCodeUpgrades (r:0 w:100) fn include_pvf_check_statement_finalize_upgrade_accept() -> Weight { - (680_774_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(104 as Weight)) + // Minimum execution time: 618_923 nanoseconds. + Weight::from_ref_time(622_876_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(104 as u64)) } // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) @@ -148,9 +157,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras UpgradeGoAheadSignal (r:0 w:100) // Storage: Paras FutureCodeHash (r:0 w:100) fn include_pvf_check_statement_finalize_upgrade_reject() -> Weight { - (630_172_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(204 as Weight)) + // Minimum execution time: 581_556 nanoseconds. + Weight::from_ref_time(592_174_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(204 as u64)) } // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) @@ -158,9 +168,10 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras PvfActiveVoteList (r:1 w:1) // Storage: Paras ActionsQueue (r:1 w:1) fn include_pvf_check_statement_finalize_onboarding_accept() -> Weight { - (535_446_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + // Minimum execution time: 482_129 nanoseconds. + Weight::from_ref_time(489_028_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) @@ -172,8 +183,9 @@ impl runtime_parachains::paras::WeightInfo for WeightIn // Storage: Paras CurrentCodeHash (r:0 w:100) // Storage: Paras UpcomingParasGenesis (r:0 w:100) fn include_pvf_check_statement_finalize_onboarding_reject() -> Weight { - (702_781_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(304 as Weight)) + // Minimum execution time: 653_424 nanoseconds. + Weight::from_ref_time(658_874_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(304 as u64)) } } diff --git a/runtime/westend/src/weights/runtime_parachains_paras_inherent.rs b/runtime/westend/src/weights/runtime_parachains_paras_inherent.rs index cd0696d7dbdc..2f61936f372a 100644 --- a/runtime/westend/src/weights/runtime_parachains_paras_inherent.rs +++ b/runtime/westend/src/weights/runtime_parachains_paras_inherent.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::paras_inherent` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -53,14 +53,15 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: ParasDisputes Included (r:1 w:1) // Storage: ParasDisputes SpamSlots (r:1 w:1) // Storage: ParaScheduler AvailabilityCores (r:1 w:1) + // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) + // Storage: Staking ActiveEra (r:1 w:0) + // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: ParasDisputes Frozen (r:1 w:0) // Storage: ParaInclusion PendingAvailability (r:2 w:1) // Storage: ParasShared ActiveValidatorKeys (r:1 w:0) // Storage: Paras Parachains (r:1 w:0) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) - // Storage: ParaSessionInfo AccountKeys (r:1 w:0) - // Storage: Staking ActiveEra (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) // Storage: Hrmp HrmpChannelDigests (r:1 w:1) // Storage: Paras FutureCodeUpgrades (r:1 w:0) @@ -74,13 +75,16 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Hrmp HrmpWatermarks (r:0 w:1) // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) + // Storage: Session CurrentIndex (r:1 w:0) + // Storage: ParasSlashing UnappliedSlashes (r:0 w:1) /// The range of component `v` is `[10, 200]`. fn enter_variable_disputes(v: u32, ) -> Weight { - (367_606_000 as Weight) - // Standard Error: 14_000 - .saturating_add((48_163_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(28 as Weight)) - .saturating_add(T::DbWeight::get().writes(18 as Weight)) + // Minimum execution time: 806_508 nanoseconds. + Weight::from_ref_time(337_261_198 as u64) + // Standard Error: 22_890 + .saturating_add(Weight::from_ref_time(48_582_166 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(29 as u64)) + .saturating_add(T::DbWeight::get().writes(18 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -93,6 +97,7 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: ParaInclusion PendingAvailability (r:2 w:1) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) // Storage: Staking ActiveEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) @@ -112,9 +117,10 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn enter_bitfields() -> Weight { - (355_084_000 as Weight) - .saturating_add(T::DbWeight::get().reads(25 as Weight)) - .saturating_add(T::DbWeight::get().writes(17 as Weight)) + // Minimum execution time: 323_004 nanoseconds. + Weight::from_ref_time(335_636_000 as u64) + .saturating_add(T::DbWeight::get().reads(26 as u64)) + .saturating_add(T::DbWeight::get().writes(17 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -127,6 +133,7 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: ParaInclusion PendingAvailability (r:2 w:1) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) // Storage: Staking ActiveEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) @@ -148,11 +155,12 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) /// The range of component `v` is `[101, 200]`. fn enter_backed_candidates_variable(v: u32, ) -> Weight { - (949_843_000 as Weight) - // Standard Error: 40_000 - .saturating_add((48_022_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(28 as Weight)) - .saturating_add(T::DbWeight::get().writes(16 as Weight)) + // Minimum execution time: 5_639_626 nanoseconds. + Weight::from_ref_time(858_049_168 as u64) + // Standard Error: 48_040 + .saturating_add(Weight::from_ref_time(48_211_579 as u64).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(29 as u64)) + .saturating_add(T::DbWeight::get().writes(16 as u64)) } // Storage: ParaInherent Included (r:1 w:1) // Storage: System ParentHash (r:1 w:0) @@ -165,6 +173,7 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: ParaInclusion PendingAvailability (r:2 w:1) // Storage: ParaInclusion PendingAvailabilityCommitments (r:1 w:1) // Storage: ParaSessionInfo AccountKeys (r:1 w:0) + // Storage: Session Validators (r:1 w:0) // Storage: Staking ActiveEra (r:1 w:0) // Storage: Staking ErasRewardPoints (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) @@ -187,8 +196,9 @@ impl runtime_parachains::paras_inherent::WeightInfo for // Storage: Paras Heads (r:0 w:1) // Storage: Paras UpgradeGoAheadSignal (r:0 w:1) fn enter_backed_candidate_code_upgrade() -> Weight { - (42_881_188_000 as Weight) - .saturating_add(T::DbWeight::get().reads(30 as Weight)) - .saturating_add(T::DbWeight::get().writes(16 as Weight)) + // Minimum execution time: 38_038_548 nanoseconds. + Weight::from_ref_time(38_312_200_000 as u64) + .saturating_add(T::DbWeight::get().reads(31 as u64)) + .saturating_add(T::DbWeight::get().writes(16 as u64)) } } diff --git a/runtime/westend/src/weights/runtime_parachains_ump.rs b/runtime/westend/src/weights/runtime_parachains_ump.rs index 467477a5def0..3643473c5592 100644 --- a/runtime/westend/src/weights/runtime_parachains_ump.rs +++ b/runtime/westend/src/weights/runtime_parachains_ump.rs @@ -16,8 +16,8 @@ //! Autogenerated weights for `runtime_parachains::ump` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm5`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -46,23 +46,26 @@ pub struct WeightInfo(PhantomData); impl runtime_parachains::ump::WeightInfo for WeightInfo { /// The range of component `s` is `[0, 51200]`. fn process_upward_message(s: u32, ) -> Weight { - (5_203_000 as Weight) - // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(s as Weight)) + // Minimum execution time: 10_148 nanoseconds. + Weight::from_ref_time(4_501_650 as u64) + // Standard Error: 13 + .saturating_add(Weight::from_ref_time(1_889 as u64).saturating_mul(s as u64)) } // Storage: Ump NeedsDispatch (r:1 w:1) // Storage: Ump NextDispatchRoundStartWith (r:1 w:1) // Storage: Ump RelayDispatchQueues (r:0 w:1) // Storage: Ump RelayDispatchQueueSize (r:0 w:1) fn clean_ump_after_outgoing() -> Weight { - (7_378_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + // Minimum execution time: 9_117 nanoseconds. + Weight::from_ref_time(9_367_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: Ump Overweight (r:1 w:1) fn service_overweight() -> Weight { - (22_049_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + // Minimum execution time: 24_649 nanoseconds. + Weight::from_ref_time(25_163_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } } diff --git a/runtime/westend/src/weights/xcm/mod.rs b/runtime/westend/src/weights/xcm/mod.rs index 7079546d5f76..4913ea15ae92 100644 --- a/runtime/westend/src/weights/xcm/mod.rs +++ b/runtime/westend/src/weights/xcm/mod.rs @@ -5,7 +5,7 @@ use crate::Runtime; use frame_support::weights::Weight; use sp_std::prelude::*; use xcm::{ - latest::{prelude::*, QueryResponseInfo}, + latest::{prelude::*, QueryResponseInfo, Weight as XCMWeight}, DoubleEncoded, }; @@ -31,15 +31,15 @@ impl From<&MultiAsset> for AssetTypes { } trait WeighMultiAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight; + fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight; } // Westend only knows about one asset, the balances pallet. const MAX_ASSETS: u32 = 1; impl WeighMultiAssets for MultiAssetFilter { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { - match self { + fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { + let weight = match self { Self::Definite(assets) => assets .inner() .into_iter() @@ -48,34 +48,41 @@ impl WeighMultiAssets for MultiAssetFilter { AssetTypes::Balances => balances_weight, AssetTypes::Unknown => Weight::MAX, }) - .fold(0, |acc, x| acc.saturating_add(x)), - Self::Wild(_) => (MAX_ASSETS as Weight).saturating_mul(balances_weight), - } + .fold(Weight::zero(), |acc, x| acc.saturating_add(x)), + Self::Wild(AllOf { .. } | AllOfCounted { .. }) => balances_weight, + Self::Wild(AllCounted(count)) => balances_weight.saturating_mul(*count as u64), + Self::Wild(All) => balances_weight.saturating_mul(MAX_ASSETS as u64), + }; + + weight.ref_time() } } impl WeighMultiAssets for MultiAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { - self.inner() + fn weigh_multi_assets(&self, balances_weight: Weight) -> XCMWeight { + let weight = self + .inner() .into_iter() .map(|m| >::from(m)) .map(|t| match t { AssetTypes::Balances => balances_weight, AssetTypes::Unknown => Weight::MAX, }) - .fold(0, |acc, x| acc.saturating_add(x)) + .fold(Weight::zero(), |acc, x| acc.saturating_add(x)); + + weight.ref_time() } } -pub struct WestendXcmWeight(core::marker::PhantomData); -impl XcmWeightInfo for WestendXcmWeight { - fn withdraw_asset(assets: &MultiAssets) -> Weight { +pub struct WestendXcmWeight(core::marker::PhantomData); +impl XcmWeightInfo for WestendXcmWeight { + fn withdraw_asset(assets: &MultiAssets) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::withdraw_asset()) } - fn reserve_asset_deposited(assets: &MultiAssets) -> Weight { + fn reserve_asset_deposited(assets: &MultiAssets) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::reserve_asset_deposited()) } - fn receive_teleported_asset(assets: &MultiAssets) -> Weight { + fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::receive_teleported_asset()) } fn query_response( @@ -83,124 +90,128 @@ impl XcmWeightInfo for WestendXcmWeight { _response: &Response, _max_weight: &u64, _querier: &Option, - ) -> Weight { - XcmGeneric::::query_response() + ) -> XCMWeight { + XcmGeneric::::query_response().ref_time() } - fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight { + fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_asset()) } fn transfer_reserve_asset( assets: &MultiAssets, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> Weight { + ) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::transfer_reserve_asset()) } fn transact( _origin_kind: &OriginKind, _require_weight_at_most: &u64, - _call: &DoubleEncoded, - ) -> Weight { - XcmGeneric::::transact() + _call: &DoubleEncoded, + ) -> XCMWeight { + XcmGeneric::::transact().ref_time() } fn hrmp_new_channel_open_request( _sender: &u32, _max_message_size: &u32, _max_capacity: &u32, - ) -> Weight { + ) -> XCMWeight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX + Weight::MAX.ref_time() } - fn hrmp_channel_accepted(_recipient: &u32) -> Weight { + fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX + Weight::MAX.ref_time() } - fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight { + fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight { // XCM Executor does not currently support HRMP channel operations - Weight::MAX + Weight::MAX.ref_time() } - fn clear_origin() -> Weight { - XcmGeneric::::clear_origin() + fn clear_origin() -> XCMWeight { + XcmGeneric::::clear_origin().ref_time() } - fn descend_origin(_who: &InteriorMultiLocation) -> Weight { - XcmGeneric::::descend_origin() + fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight { + XcmGeneric::::descend_origin().ref_time() } - fn report_error(_query_repsonse_info: &QueryResponseInfo) -> Weight { - XcmGeneric::::report_error() + fn report_error(_query_repsonse_info: &QueryResponseInfo) -> XCMWeight { + XcmGeneric::::report_error().ref_time() } - fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight { + fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_asset()) } fn deposit_reserve_asset( assets: &MultiAssetFilter, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> Weight { + ) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) } - fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight { + fn exchange_asset( + _give: &MultiAssetFilter, + _receive: &MultiAssets, + _maximal: &bool, + ) -> XCMWeight { // Westend does not currently support exchange asset operations - Weight::MAX + Weight::MAX.ref_time() } fn initiate_reserve_withdraw( assets: &MultiAssetFilter, _reserve: &MultiLocation, _xcm: &Xcm<()>, - ) -> Weight { + ) -> XCMWeight { assets.weigh_multi_assets(XcmGeneric::::initiate_reserve_withdraw()) } fn initiate_teleport( assets: &MultiAssetFilter, _dest: &MultiLocation, _xcm: &Xcm<()>, - ) -> Weight { + ) -> XCMWeight { assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) } - fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight { - XcmGeneric::::report_holding() + fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> XCMWeight { + XcmGeneric::::report_holding().ref_time() } - fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight { - XcmGeneric::::buy_execution() + fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight { + XcmGeneric::::buy_execution().ref_time() } - fn refund_surplus() -> Weight { - XcmGeneric::::refund_surplus() + fn refund_surplus() -> XCMWeight { + XcmGeneric::::refund_surplus().ref_time() } - fn set_error_handler(_xcm: &Xcm) -> Weight { - XcmGeneric::::set_error_handler() + fn set_error_handler(_xcm: &Xcm) -> XCMWeight { + XcmGeneric::::set_error_handler().ref_time() } - fn set_appendix(_xcm: &Xcm) -> Weight { - XcmGeneric::::set_appendix() + fn set_appendix(_xcm: &Xcm) -> XCMWeight { + XcmGeneric::::set_appendix().ref_time() } - fn clear_error() -> Weight { - XcmGeneric::::clear_error() + fn clear_error() -> XCMWeight { + XcmGeneric::::clear_error().ref_time() } - fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight { - XcmGeneric::::claim_asset() + fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight { + XcmGeneric::::claim_asset().ref_time() } - fn trap(_code: &u64) -> Weight { - XcmGeneric::::trap() + fn trap(_code: &u64) -> XCMWeight { + XcmGeneric::::trap().ref_time() } - fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> Weight { - XcmGeneric::::subscribe_version() + fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight { + XcmGeneric::::subscribe_version().ref_time() } - fn unsubscribe_version() -> Weight { - XcmGeneric::::unsubscribe_version() + fn unsubscribe_version() -> XCMWeight { + XcmGeneric::::unsubscribe_version().ref_time() } - fn burn_asset(assets: &MultiAssets) -> Weight { + fn burn_asset(assets: &MultiAssets) -> XCMWeight { assets.weigh_multi_assets(XcmGeneric::::burn_asset()) } - fn expect_asset(assets: &MultiAssets) -> Weight { + fn expect_asset(assets: &MultiAssets) -> XCMWeight { assets.weigh_multi_assets(XcmGeneric::::expect_asset()) } - fn expect_origin(_origin: &Option) -> Weight { - XcmGeneric::::expect_origin() + fn expect_origin(_origin: &Option) -> XCMWeight { + XcmGeneric::::expect_origin().ref_time() } - fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight { - XcmGeneric::::expect_error() + fn expect_error(_error: &Option<(u32, XcmError)>) -> XCMWeight { + XcmGeneric::::expect_error().ref_time() } - fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> Weight { - XcmGeneric::::query_pallet() + fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> XCMWeight { + XcmGeneric::::query_pallet().ref_time() } fn expect_pallet( _index: &u32, @@ -208,52 +219,53 @@ impl XcmWeightInfo for WestendXcmWeight { _module_name: &Vec, _crate_major: &u32, _min_crate_minor: &u32, - ) -> Weight { - XcmGeneric::::expect_pallet() + ) -> XCMWeight { + XcmGeneric::::expect_pallet().ref_time() } - fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight { - XcmGeneric::::report_transact_status() + fn report_transact_status(_response_info: &QueryResponseInfo) -> XCMWeight { + XcmGeneric::::report_transact_status().ref_time() } - fn clear_transact_status() -> Weight { - XcmGeneric::::clear_transact_status() + fn clear_transact_status() -> XCMWeight { + XcmGeneric::::clear_transact_status().ref_time() } - fn universal_origin(_: &Junction) -> Weight { + fn universal_origin(_: &Junction) -> XCMWeight { // Westend does not currently support universal origin operations - Weight::MAX + Weight::MAX.ref_time() } - fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { - Weight::MAX // todo fix + fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> XCMWeight { + // Westend does not currently support export message operations + Weight::MAX.ref_time() } - fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { + fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { // Westend does not currently support asset locking operations - Weight::MAX + Weight::MAX.ref_time() } - fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight { + fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { // Westend does not currently support asset locking operations - Weight::MAX + Weight::MAX.ref_time() } - fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight { + fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { // Westend does not currently support asset locking operations - Weight::MAX + Weight::MAX.ref_time() } - fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight { + fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> XCMWeight { // Westend does not currently support asset locking operations - Weight::MAX + Weight::MAX.ref_time() } - fn set_fees_mode(_: &bool) -> Weight { - XcmGeneric::::set_fees_mode() + fn set_fees_mode(_: &bool) -> XCMWeight { + XcmGeneric::::set_fees_mode().ref_time() } - fn set_topic(_topic: &[u8; 32]) -> Weight { - XcmGeneric::::set_topic() + fn set_topic(_topic: &[u8; 32]) -> XCMWeight { + XcmGeneric::::set_topic().ref_time() } - fn clear_topic() -> Weight { - XcmGeneric::::clear_topic() + fn clear_topic() -> XCMWeight { + XcmGeneric::::clear_topic().ref_time() } - fn alias_origin(_: &MultiLocation) -> Weight { + fn alias_origin(_: &MultiLocation) -> XCMWeight { // XCM Executor does not currently support alias origin operations - Weight::MAX + Weight::MAX.ref_time() } - fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { - Weight::MAX + fn unpaid_execution(_: &WeightLimit, _: &Option) -> XCMWeight { + XcmGeneric::::unpaid_execution().ref_time() } } diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index 13a8514f6d05..5a5426efd57f 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -47,15 +47,15 @@ pub struct WeightInfo(PhantomData); impl WeightInfo { // Storage: System Account (r:1 w:1) pub(crate) fn withdraw_asset() -> Weight { - (20_308_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(20_308_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:2 w:2) pub(crate) fn transfer_asset() -> Weight { - (32_193_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_193_000 as u64) + .saturating_add(T::DbWeight::get().reads(2 as u64)) + .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: System Account (r:2 w:2) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -64,25 +64,25 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn transfer_reserve_asset() -> Weight { - (50_731_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(50_731_000 as u64) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: Benchmark Override (r:0 w:0) pub(crate) fn reserve_asset_deposited() -> Weight { - (2_000_000_000_000 as Weight) + Weight::from_ref_time(2_000_000_000_000 as u64) } // Storage: System Account (r:1 w:1) pub(crate) fn receive_teleported_asset() -> Weight { - (19_622_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(19_622_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) pub(crate) fn deposit_asset() -> Weight { - (22_433_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_433_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: System Account (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -91,9 +91,9 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn deposit_reserve_asset() -> Weight { - (41_765_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(41_765_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: System Account (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -102,8 +102,8 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn initiate_teleport() -> Weight { - (41_204_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(41_204_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } } diff --git a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 73a615cf0dee..2a811ac3d2f0 100644 --- a/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -52,38 +52,38 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_holding() -> Weight { - (24_686_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(24_686_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn buy_execution() -> Weight { - (3_620_000 as Weight) + Weight::from_ref_time(3_620_000 as u64) } // Storage: XcmPallet Queries (r:1 w:0) pub(crate) fn query_response() -> Weight { - (12_946_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(12_946_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) } pub(crate) fn transact() -> Weight { - (13_206_000 as Weight) + Weight::from_ref_time(13_206_000 as u64) } pub(crate) fn refund_surplus() -> Weight { - (3_879_000 as Weight) + Weight::from_ref_time(3_879_000 as u64) } pub(crate) fn set_error_handler() -> Weight { - (3_659_000 as Weight) + Weight::from_ref_time(3_659_000 as u64) } pub(crate) fn set_appendix() -> Weight { - (3_743_000 as Weight) + Weight::from_ref_time(3_743_000 as u64) } pub(crate) fn clear_error() -> Weight { - (3_711_000 as Weight) + Weight::from_ref_time(3_711_000 as u64) } pub(crate) fn descend_origin() -> Weight { - (4_618_000 as Weight) + Weight::from_ref_time(4_618_000 as u64) } pub(crate) fn clear_origin() -> Weight { - (3_588_000 as Weight) + Weight::from_ref_time(3_588_000 as u64) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -91,18 +91,18 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_error() -> Weight { - (20_331_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(20_331_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: XcmPallet AssetTraps (r:1 w:1) pub(crate) fn claim_asset() -> Weight { - (7_650_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(7_650_000 as u64) + .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } pub(crate) fn trap() -> Weight { - (3_617_000 as Weight) + Weight::from_ref_time(3_617_000 as u64) } // Storage: XcmPallet VersionNotifyTargets (r:1 w:1) // Storage: XcmPallet SupportedVersion (r:1 w:0) @@ -111,14 +111,14 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn subscribe_version() -> Weight { - (28_613_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + Weight::from_ref_time(28_613_000 as u64) + .saturating_add(T::DbWeight::get().reads(6 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: XcmPallet VersionNotifyTargets (r:0 w:1) pub(crate) fn unsubscribe_version() -> Weight { - (5_443_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(5_443_000 as u64) + .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -126,21 +126,21 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn initiate_reserve_withdraw() -> Weight { - (24_401_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(24_401_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn burn_asset() -> Weight { - (5_259_000 as Weight) + Weight::from_ref_time(5_259_000 as u64) } pub(crate) fn expect_asset() -> Weight { - (3_745_000 as Weight) + Weight::from_ref_time(3_745_000 as u64) } pub(crate) fn expect_origin() -> Weight { - (3_847_000 as Weight) + Weight::from_ref_time(3_847_000 as u64) } pub(crate) fn expect_error() -> Weight { - (3_633_000 as Weight) + Weight::from_ref_time(3_633_000 as u64) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -148,12 +148,12 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn query_pallet() -> Weight { - (21_645_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(21_645_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn expect_pallet() -> Weight { - (4_017_000 as Weight) + Weight::from_ref_time(4_017_000 as u64) } // Storage: XcmPallet SupportedVersion (r:1 w:0) // Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1) @@ -161,20 +161,23 @@ impl WeightInfo { // Storage: Dmp DownwardMessageQueueHeads (r:1 w:1) // Storage: Dmp DownwardMessageQueues (r:1 w:1) pub(crate) fn report_transact_status() -> Weight { - (20_465_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(20_465_000 as u64) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } pub(crate) fn clear_transact_status() -> Weight { - (3_723_000 as Weight) + Weight::from_ref_time(3_723_000 as u64) } pub(crate) fn set_topic() -> Weight { - (3_687_000 as Weight) + Weight::from_ref_time(3_687_000 as u64) } pub(crate) fn clear_topic() -> Weight { - (3_654_000 as Weight) + Weight::from_ref_time(3_654_000 as u64) } pub(crate) fn set_fees_mode() -> Weight { - (3_721_000 as Weight) + Weight::from_ref_time(3_721_000 as u64) + } + pub(crate) fn unpaid_execution() -> Weight { + Weight::from_ref_time(3_111_000 as u64) } } diff --git a/runtime/westend/src/xcm_config.rs b/runtime/westend/src/xcm_config.rs index f0af1f7d033d..94098bbfc406 100644 --- a/runtime/westend/src/xcm_config.rs +++ b/runtime/westend/src/xcm_config.rs @@ -17,8 +17,8 @@ //! XCM configurations for Westend. use super::{ - parachains_origin, weights, AccountId, AllPalletsWithSystem, Balances, Call, Event, Origin, - ParaId, Runtime, WeightToFee, XcmPallet, + parachains_origin, weights, AccountId, AllPalletsWithSystem, Balances, ParaId, Runtime, + RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet, }; use frame_support::{ parameter_types, @@ -60,10 +60,10 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< >; type LocalOriginConverter = ( - SovereignSignedViaLocation, - ChildParachainAsNative, - SignedAccountId32AsNative, - ChildSystemParachainAsSuperuser, + SovereignSignedViaLocation, + ChildParachainAsNative, + SignedAccountId32AsNative, + ChildSystemParachainAsSuperuser, ); /// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our @@ -75,15 +75,15 @@ pub type XcmRouter = ( parameter_types! { pub const Westmint: MultiLocation = Parachain(1000).into_location(); - pub const Encointer: MultiLocation = Parachain(1001).into_location(); + pub const Collectives: MultiLocation = Parachain(1001).into_location(); pub const Wnd: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) }); pub const WndForWestmint: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Westmint::get()); - pub const WndForEncointer: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Encointer::get()); + pub const WndForCollectives: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Collectives::get()); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; } pub type TrustedTeleporters = - (xcm_builder::Case, xcm_builder::Case); + (xcm_builder::Case, xcm_builder::Case); /// The barriers one of which must be passed for an XCM message to be executed. pub type Barrier = ( @@ -101,7 +101,7 @@ pub type Barrier = ( pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { - type Call = Call; + type RuntimeCall = RuntimeCall; type XcmSender = XcmRouter; type AssetTransactor = LocalAssetTransactor; type OriginConverter = LocalOriginConverter; @@ -109,7 +109,8 @@ impl xcm_executor::Config for XcmConfig { type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = WeightInfoBounds, Call, MaxInstructions>; + type Weigher = + WeightInfoBounds, RuntimeCall, MaxInstructions>; type Trader = UsingComponents>; type ResponseHandler = XcmPallet; @@ -123,30 +124,32 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location /// of this chain. pub type LocalOriginToLocation = ( // And a usual Signed origin to be used in XCM as a corresponding AccountId32 - SignedToAccountId32, + SignedToAccountId32, ); impl pallet_xcm::Config for Runtime { - type Event = Event; - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + type RuntimeEvent = RuntimeEvent; + type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = XcmRouter; // Anyone can execute XCM messages locally... - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; + type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; // ...but they must match our filter, which rejects everything. type XcmExecuteFilter = Nothing; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; - type Weigher = WeightInfoBounds, Call, MaxInstructions>; + type Weigher = + WeightInfoBounds, RuntimeCall, MaxInstructions>; type UniversalLocation = UniversalLocation; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type Currency = Balances; diff --git a/scripts/ci/gitlab/lingua.dic b/scripts/ci/gitlab/lingua.dic index 021d0302c033..66bd8aaf70fa 100644 --- a/scripts/ci/gitlab/lingua.dic +++ b/scripts/ci/gitlab/lingua.dic @@ -51,6 +51,7 @@ Debian/M decodable/MS decrement deduplicated +deduplication deinitializing dequeue/SD dequeuing @@ -137,6 +138,7 @@ KYC/M lib libp2p lifecycle/MS +liveness lookahead/MS lookup/MS LRU @@ -203,6 +205,7 @@ PoV/MS PoW/MS PR precheck +prechecking preconfigured preimage/MS preopen @@ -223,10 +226,12 @@ redhat/M register/CD relayer repo/MS +requesters reservable responder/SM retriability reverify +ROC roundtrip/MS routable rpc @@ -285,6 +290,7 @@ typesystem ubuntu/M UDP UI +unapplied unassign unconcluded unexpectable diff --git a/scripts/ci/gitlab/pipeline/build.yml b/scripts/ci/gitlab/pipeline/build.yml new file mode 100644 index 000000000000..791b01c2b632 --- /dev/null +++ b/scripts/ci/gitlab/pipeline/build.yml @@ -0,0 +1,194 @@ +# This file is part of .gitlab-ci.yml +# Here are all jobs that are executed during "build" stage + +build-linux-stable: + stage: build + # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs + # the job can be found in check.yml + needs: + - job: job-starter + artifacts: false + extends: + - .docker-env + - .common-refs + - .compiler-info + - .collect-artifacts + variables: + RUST_TOOLCHAIN: stable + # Enable debug assertions since we are running optimized builds for testing + # but still want to have debug assertions. + RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" + # Ensure we run the UI tests. + RUN_UI_TESTS: 1 + script: + - time cargo build --profile testnet --features pyroscope --verbose --bin polkadot + - sccache -s + # pack artifacts + - mkdir -p ./artifacts + - VERSION="${CI_COMMIT_REF_NAME}" # will be tag or branch name + - mv ./target/testnet/polkadot ./artifacts/. + - pushd artifacts + - sha256sum polkadot | tee polkadot.sha256 + - shasum -c polkadot.sha256 + - popd + - EXTRATAG="${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}" + - echo "Polkadot version = ${VERSION} (EXTRATAG = ${EXTRATAG})" + - echo -n ${VERSION} > ./artifacts/VERSION + - echo -n ${EXTRATAG} > ./artifacts/EXTRATAG + - echo -n ${CI_JOB_ID} > ./artifacts/BUILD_LINUX_JOB_ID + - RELEASE_VERSION=$(./artifacts/polkadot -V | awk '{print $2}'| awk -F "-" '{print $1}') + - echo -n "v${RELEASE_VERSION}" > ./artifacts/BUILD_RELEASE_VERSION + - cp -r scripts/* ./artifacts + +check-transaction-versions: + stage: build + extends: + - .docker-env + - .test-refs + image: node:15 + needs: + - job: build-linux-stable + artifacts: true + before_script: + - apt-get -y update; apt-get -y install jq lsof + - npm install --ignore-scripts -g @polkadot/metadata-cmp + # Set git config + - git config remote.origin.url "https://github.com/paritytech/polkadot.git" + - git fetch origin release + script: + - ./scripts/ci/gitlab/check_extrinsics_ordering.sh + +build-test-collators: + stage: build + # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs + # the job can be found in check.yml + needs: + - job: job-starter + artifacts: false + extends: + - .docker-env + - .common-refs + - .compiler-info + - .collect-artifacts + script: + - time cargo build --profile testnet --verbose -p test-parachain-adder-collator + - time cargo build --profile testnet --verbose -p test-parachain-undying-collator + - sccache -s + # pack artifacts + - mkdir -p ./artifacts + - mv ./target/testnet/adder-collator ./artifacts/. + - mv ./target/testnet/undying-collator ./artifacts/. + - echo -n "${CI_COMMIT_REF_NAME}" > ./artifacts/VERSION + - echo -n "${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}" > ./artifacts/EXTRATAG + - echo "adder-collator version = $(cat ./artifacts/VERSION) (EXTRATAG = $(cat ./artifacts/EXTRATAG))" + - echo "undying-collator version = $(cat ./artifacts/VERSION) (EXTRATAG = $(cat ./artifacts/EXTRATAG))" + - cp -r ./scripts/* ./artifacts + +build-malus: + stage: build + # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs + # the job can be found in check.yml + needs: + - job: job-starter + artifacts: false + extends: + - .docker-env + - .common-refs + - .compiler-info + - .collect-artifacts + script: + - time cargo build --profile testnet --verbose -p polkadot-test-malus + - sccache -s + # pack artifacts + - mkdir -p ./artifacts + - mv ./target/testnet/malus ./artifacts/. + - echo -n "${CI_COMMIT_REF_NAME}" > ./artifacts/VERSION + - echo -n "${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}" > ./artifacts/EXTRATAG + - echo "polkadot-test-malus = $(cat ./artifacts/VERSION) (EXTRATAG = $(cat ./artifacts/EXTRATAG))" + - cp -r ./scripts/* ./artifacts + +build-staking-miner: + stage: build + # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs + # the job can be found in check.yml + needs: + - job: job-starter + artifacts: false + extends: + - .docker-env + - .common-refs + - .compiler-info + - .collect-artifacts + script: + - time cargo build --locked --release --package staking-miner + # pack artifacts + - mkdir -p ./artifacts + - mv ./target/release/staking-miner ./artifacts/. + - echo -n "${CI_COMMIT_REF_NAME}" > ./artifacts/VERSION + - echo -n "${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}" > ./artifacts/EXTRATAG + - echo "staking-miner = $(cat ./artifacts/VERSION) (EXTRATAG = $(cat ./artifacts/EXTRATAG))" + - cp -r ./scripts/* ./artifacts + +build-rustdoc: + stage: build + # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs + # the job can be found in test.yml + needs: + - job: test-deterministic-wasm + artifacts: false + extends: + - .docker-env + - .test-refs + variables: + SKIP_WASM_BUILD: 1 + artifacts: + name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}-doc" + when: on_success + expire_in: 1 days + paths: + - ./crate-docs/ + script: + # FIXME: it fails with `RUSTDOCFLAGS="-Dwarnings"` and `--all-features` + # FIXME: return to stable when https://github.com/rust-lang/rust/issues/96937 gets into stable + - time cargo +nightly doc --workspace --verbose --no-deps + - rm -f ./target/doc/.lock + - mv ./target/doc ./crate-docs + # FIXME: remove me after CI image gets nonroot + - chown -R nonroot:nonroot ./crate-docs + - echo "" > ./crate-docs/index.html + +build-implementers-guide: + stage: build + # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs + # the job can be found in test.yml + needs: + - job: test-deterministic-wasm + artifacts: false + extends: + - .docker-env + - .test-refs + - .collect-artifacts-short + script: + - apt-get -y update; apt-get install -y graphviz + - cargo install mdbook mdbook-mermaid mdbook-linkcheck mdbook-graphviz + - mdbook build ./roadmap/implementers-guide + - mkdir -p artifacts + - mv roadmap/implementers-guide/book artifacts/ + # FIXME: remove me after CI image gets nonroot + - chown -R nonroot:nonroot artifacts/ + +build-short-benchmark: + stage: build + # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs + # the job can be found in check.yml + needs: + - job: job-starter + artifacts: false + extends: + - .docker-env + - .test-refs + - .collect-artifacts + script: + - cargo +nightly build --profile release --locked --features=runtime-benchmarks + - mkdir artifacts + - cp ./target/release/polkadot ./artifacts/ diff --git a/scripts/ci/gitlab/pipeline/check.yml b/scripts/ci/gitlab/pipeline/check.yml new file mode 100644 index 000000000000..0e435d604821 --- /dev/null +++ b/scripts/ci/gitlab/pipeline/check.yml @@ -0,0 +1,97 @@ +# This file is part of .gitlab-ci.yml +# Here are all jobs that are executed during "check" stage + +check-runtime: + stage: check + image: paritytech/tools:latest + extends: + - .kubernetes-env + rules: + - if: $CI_COMMIT_REF_NAME =~ /^release-v[0-9]+\.[0-9]+.*$/ # i.e. release-v0.9.27 + variables: + GITLAB_API: "https://gitlab.parity.io/api/v4" + GITHUB_API_PROJECT: "parity%2Finfrastructure%2Fgithub-api" + script: + - ./scripts/ci/gitlab/check_runtime.sh + allow_failure: true + +cargo-fmt: + stage: check + extends: + - .docker-env + - .test-refs + script: + - cargo +nightly --version + - cargo +nightly fmt --all -- --check + allow_failure: true + +spellcheck: + stage: check + extends: + - .docker-env + - .test-refs + script: + - cargo spellcheck --version + # compare with the commit parent to the PR, given it's from a default branch + - git fetch origin +${CI_DEFAULT_BRANCH}:${CI_DEFAULT_BRANCH} + - echo "___Spellcheck is going to check your diff___" + - cargo spellcheck list-files -vvv $(git diff --diff-filter=AM --name-only $(git merge-base ${CI_COMMIT_SHA} ${CI_DEFAULT_BRANCH} -- :^bridges)) + - time cargo spellcheck check -vvv --cfg=scripts/ci/gitlab/spellcheck.toml --checkers hunspell --code 1 + $(git diff --diff-filter=AM --name-only $(git merge-base ${CI_COMMIT_SHA} ${CI_DEFAULT_BRANCH} -- :^bridges)) + allow_failure: true + +check-try-runtime: + stage: check + extends: + - .docker-env + - .test-refs + - .compiler-info + script: + # Check that everything compiles with `try-runtime` feature flag. + - cargo check --features try-runtime --all + +# More info can be found here: https://github.com/paritytech/polkadot/pull/5865 +# Works only in PRs +check-runtime-migration: + stage: check + extends: + - .docker-env + - .test-pr-refs + - .compiler-info + script: + - | + export has_runtimemigration_label=$(curl -sS -H "Accept: application/vnd.github+json" \ + -H "Authorization: token $GITHUB_PR_TOKEN" \ + https://api.github.com/repos/paritytech/polkadot/issues/$CI_COMMIT_REF_NAME/labels | grep "E1" | wc -l) + - | + if [[ $has_runtimemigration_label != 0 ]]; then + echo "Found label runtimemigration. Running tests" + export RUST_LOG=remote-ext=debug,runtime=debug + time cargo test --release -p westend-runtime -p polkadot-runtime -p kusama-runtime --features try-runtime + else + echo "runtimemigration label not found. Skipping" + fi + allow_failure: true + +# is broken, need to fix +check-no-default-features: + stage: check + extends: + - .docker-env + - .test-refs + - .compiler-info + script: + # Check that polkadot-cli will compile no default features. + - pushd ./node/service && cargo check --no-default-features && popd + - pushd ./cli && cargo check --no-default-features --features "service" && popd + - exit 0 + +# this is artificial job to run some build and tests using DAG +job-starter: + stage: check + image: paritytech/tools:latest + extends: + - .kubernetes-env + - .common-refs + script: + - echo ok diff --git a/scripts/ci/gitlab/pipeline/publish.yml b/scripts/ci/gitlab/pipeline/publish.yml new file mode 100644 index 000000000000..12e087e188d1 --- /dev/null +++ b/scripts/ci/gitlab/pipeline/publish.yml @@ -0,0 +1,209 @@ +# This file is part of .gitlab-ci.yml +# Here are all jobs that are executed during "publish" stage + +# This image is used in testnets +# Release image is handled by the Github Action here: +# .github/workflows/publish-docker-release.yml +publish-polkadot-debug-image: + stage: publish + extends: + - .build-push-image + rules: + # Don't run when triggered from another pipeline + - if: $CI_PIPELINE_SOURCE == "pipeline" + when: never + - if: $CI_PIPELINE_SOURCE == "web" + - if: $CI_PIPELINE_SOURCE == "schedule" + - if: $CI_COMMIT_REF_NAME == "master" + - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs + - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 + variables: + GIT_STRATEGY: none + DOCKER_USER: ${PARITYPR_USER} + DOCKER_PASS: ${PARITYPR_PASS} + # scripts/ci/dockerfiles/polkadot_injected_debug.Dockerfile + DOCKERFILE: ci/dockerfiles/polkadot_injected_debug.Dockerfile + IMAGE_NAME: docker.io/paritypr/polkadot-debug + needs: + - job: build-linux-stable + artifacts: true + after_script: + # pass artifacts to the zombienet-tests job + # https://docs.gitlab.com/ee/ci/multi_project_pipelines.html#with-variable-inheritance + - echo "PARACHAINS_IMAGE_NAME=${IMAGE_NAME}" > ./artifacts/parachains.env + - echo "PARACHAINS_IMAGE_TAG=$(cat ./artifacts/EXTRATAG)" >> ./artifacts/parachains.env + artifacts: + reports: + # this artifact is used in zombienet-tests job + dotenv: ./artifacts/parachains.env + expire_in: 1 days + +publish-test-collators-image: + # service image for Simnet + stage: publish + extends: + - .build-push-image + - .zombienet-refs + variables: + GIT_STRATEGY: none + DOCKER_USER: ${PARITYPR_USER} + DOCKER_PASS: ${PARITYPR_PASS} + # scripts/ci/dockerfiles/collator_injected.Dockerfile + DOCKERFILE: ci/dockerfiles/collator_injected.Dockerfile + IMAGE_NAME: docker.io/paritypr/colander + needs: + - job: build-test-collators + artifacts: true + after_script: + - buildah logout --all + # pass artifacts to the zombienet-tests job + - echo "COLLATOR_IMAGE_NAME=${IMAGE_NAME}" > ./artifacts/collator.env + - echo "COLLATOR_IMAGE_TAG=$(cat ./artifacts/EXTRATAG)" >> ./artifacts/collator.env + artifacts: + reports: + # this artifact is used in zombienet-tests job + dotenv: ./artifacts/collator.env + +publish-malus-image: + # service image for Simnet + stage: publish + extends: + - .build-push-image + - .zombienet-refs + variables: + GIT_STRATEGY: none + DOCKER_USER: ${PARITYPR_USER} + DOCKER_PASS: ${PARITYPR_PASS} + # scripts/ci/dockerfiles/malus_injected.Dockerfile + DOCKERFILE: ci/dockerfiles/malus_injected.Dockerfile + IMAGE_NAME: docker.io/paritypr/malus + needs: + - job: build-malus + artifacts: true + after_script: + - buildah logout "$IMAGE_NAME" + # pass artifacts to the zombienet-tests job + - echo "MALUS_IMAGE_NAME=${IMAGE_NAME}" > ./artifacts/malus.env + - echo "MALUS_IMAGE_TAG=$(cat ./artifacts/EXTRATAG)" >> ./artifacts/malus.env + artifacts: + reports: + # this artifact is used in zombienet-tests job + dotenv: ./artifacts/malus.env + +publish-staking-miner-image: + stage: publish + extends: + - .build-push-image + - .publish-refs + variables: + # scripts/ci/dockerfiles/staking-miner/staking-miner_injected.Dockerfile + DOCKERFILE: ci/dockerfiles/staking-miner/staking-miner_injected.Dockerfile + IMAGE_NAME: docker.io/paritytech/staking-miner + GIT_STRATEGY: none + DOCKER_USER: ${Docker_Hub_User_Parity} + DOCKER_PASS: ${Docker_Hub_Pass_Parity} + needs: + - job: build-staking-miner + artifacts: true + + +publish-s3-release: + stage: publish + extends: + - .kubernetes-env + needs: + - job: build-linux-stable + artifacts: true + image: paritytech/awscli:latest + variables: + GIT_STRATEGY: none + PREFIX: "builds/polkadot/${ARCH}-${DOCKER_OS}" + rules: + - if: $CI_PIPELINE_SOURCE == "pipeline" + when: never + # publishing binaries nightly + - if: $CI_PIPELINE_SOURCE == "schedule" + before_script: + - !reference [.build-push-image, before_script] + script: + - echo "uploading objects to https://releases.parity.io/${PREFIX}/${VERSION}" + - aws s3 sync --acl public-read ./artifacts/ s3://${AWS_BUCKET}/${PREFIX}/${VERSION}/ + - echo "update objects at https://releases.parity.io/${PREFIX}/${EXTRATAG}" + - find ./artifacts -type f | while read file; do + name="${file#./artifacts/}"; + aws s3api copy-object + --copy-source ${AWS_BUCKET}/${PREFIX}/${VERSION}/${name} + --bucket ${AWS_BUCKET} --key ${PREFIX}/${EXTRATAG}/${name}; + done + - | + cat <<-EOM + | + | polkadot binary paths: + | + | - https://releases.parity.io/${PREFIX}/${EXTRATAG}/polkadot + | - https://releases.parity.io/${PREFIX}/${VERSION}/polkadot + | + EOM + after_script: + - aws s3 ls s3://${AWS_BUCKET}/${PREFIX}/${EXTRATAG}/ + --recursive --human-readable --summarize + +publish-rustdoc: + stage: publish + extends: + - .kubernetes-env + image: paritytech/tools:latest + variables: + GIT_DEPTH: 100 + rules: + - if: $CI_PIPELINE_SOURCE == "pipeline" + when: never + - if: $CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_REF_NAME == "master" + - if: $CI_COMMIT_REF_NAME == "master" + # `needs:` can be removed after CI image gets nonroot. In this case `needs:` stops other + # artifacts from being dowloaded by this job. + needs: + - job: build-rustdoc + artifacts: true + - job: build-implementers-guide + artifacts: true + script: + # Save README and docs + - cp -r ./crate-docs/ /tmp/doc/ + - cp -r ./artifacts/book/ /tmp/ + # setup ssh + - eval $(ssh-agent) + - ssh-add - <<< ${GITHUB_SSH_PRIV_KEY} + - mkdir ~/.ssh && touch ~/.ssh/known_hosts + - ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts + # Set git config + - git config user.email "devops-team@parity.io" + - git config user.name "${GITHUB_USER}" + - git config remote.origin.url "git@github.com:/paritytech/${CI_PROJECT_NAME}.git" + - git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" + - git fetch origin gh-pages + - git checkout gh-pages + # Remove everything and restore generated docs and README + - cp index.html /tmp + - cp README.md /tmp + - rm -rf ./* + # dir for rustdoc + - mkdir -p doc + # dir for implementors guide + - mkdir -p book + - mv /tmp/doc/* doc/ + - mv /tmp/book/html/* book/ + - mv /tmp/index.html . + - mv /tmp/README.md . + # Upload files + - git add --all --force + # `git commit` has an exit code of > 0 if there is nothing to commit. + # This causes GitLab to exit immediately and marks this job failed. + # We don't want to mark the entire job failed if there's nothing to + # publish though, hence the `|| true`. + - git commit -m "Updated docs for ${CI_COMMIT_REF_NAME}" || + echo "___Nothing to commit___" + - git push origin gh-pages --force + - echo "___Rustdoc was successfully published to https://paritytech.github.io/polkadot/___" + after_script: + - rm -rf .git/ ./* diff --git a/scripts/ci/gitlab/pipeline/short-benchmarks.yml b/scripts/ci/gitlab/pipeline/short-benchmarks.yml new file mode 100644 index 000000000000..52a4074470f0 --- /dev/null +++ b/scripts/ci/gitlab/pipeline/short-benchmarks.yml @@ -0,0 +1,27 @@ +# This file is part of .gitlab-ci.yml +# Here are all jobs that are executed during "short-benchmarks" stage + +# Run all pallet benchmarks only once to check if there are any errors +short-benchmark-polkadot: &short-bench + stage: short-benchmarks + extends: + - .test-pr-refs + - .docker-env + # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs + needs: + - job: build-short-benchmark + artifacts: true + variables: + RUNTIME: polkadot + script: + - ./artifacts/polkadot benchmark pallet --execution wasm --wasm-execution compiled --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1 + +short-benchmark-kusama: + <<: *short-bench + variables: + RUNTIME: kusama + +short-benchmark-westend: + <<: *short-bench + variables: + RUNTIME: westend diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml new file mode 100644 index 000000000000..9a3dd0270fbb --- /dev/null +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -0,0 +1,74 @@ +# This file is part of .gitlab-ci.yml +# Here are all jobs that are executed during "test" stage + +test-linux-stable: + stage: test + # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs + # the job can be found in check.yml + needs: + - job: job-starter + artifacts: false + extends: + - .docker-env + - .common-refs + - .pipeline-stopper-artifacts + before_script: + - rustup show + - cargo --version + - !reference [.pipeline-stopper-vars, before_script] + variables: + RUST_TOOLCHAIN: stable + # Enable debug assertions since we are running optimized builds for testing + # but still want to have debug assertions. + RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" + script: + - time cargo test --workspace --profile testnet --verbose --locked --features=runtime-benchmarks,runtime-metrics + +.check-dependent-project: &check-dependent-project + stage: test + extends: + - .docker-env + - .test-pr-refs + script: + - git clone + --depth=1 + "--branch=$PIPELINE_SCRIPTS_TAG" + https://github.com/paritytech/pipeline-scripts + - ./pipeline-scripts/check_dependent_project.sh + --org paritytech + --dependent-repo "$DEPENDENT_REPO" + --github-api-token "$GITHUB_PR_TOKEN" + --extra-dependencies "$EXTRA_DEPENDENCIES" + --companion-overrides "$COMPANION_OVERRIDES" + +check-dependent-cumulus: + <<: *check-dependent-project + variables: + DEPENDENT_REPO: cumulus + EXTRA_DEPENDENCIES: substrate + COMPANION_OVERRIDES: | + polkadot: release-v* + cumulus: polkadot-v* + +test-node-metrics: + stage: test + extends: + - .docker-env + - .test-refs + - .compiler-info + variables: + RUST_TOOLCHAIN: stable + # Enable debug assertions since we are running optimized builds for testing + # but still want to have debug assertions. + RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" + script: + - time cargo test --profile testnet --verbose --locked --features=runtime-metrics -p polkadot-node-metrics + +test-deterministic-wasm: + stage: test + extends: + - .docker-env + - .test-refs + - .compiler-info + script: + - ./scripts/ci/gitlab/test_deterministic_wasm.sh diff --git a/scripts/ci/gitlab/pipeline/weights.yml b/scripts/ci/gitlab/pipeline/weights.yml new file mode 100644 index 000000000000..38b223ce57ab --- /dev/null +++ b/scripts/ci/gitlab/pipeline/weights.yml @@ -0,0 +1,33 @@ +# This file is part of .gitlab-ci.yml +# Here are all jobs that are executed during "weights" stage + +update_polkadot_weights: &update-weights + stage: weights + timeout: 1d + when: manual + variables: + RUNTIME: polkadot + artifacts: + paths: + - ${RUNTIME}_weights_${CI_COMMIT_SHORT_SHA}.patch + script: + - ./scripts/ci/run_benches_for_runtime.sh $RUNTIME + - git diff -P > ${RUNTIME}_weights_${CI_COMMIT_SHORT_SHA}.patch + # uses the "shell" executors + tags: + - weights + +update_kusama_weights: + <<: *update-weights + variables: + RUNTIME: kusama + +update_westend_weights: + <<: *update-weights + variables: + RUNTIME: westend + +update_rococo_weights: + <<: *update-weights + variables: + RUNTIME: rococo diff --git a/scripts/ci/gitlab/pipeline/zombienet.yml b/scripts/ci/gitlab/pipeline/zombienet.yml new file mode 100644 index 000000000000..5c6215aad2c4 --- /dev/null +++ b/scripts/ci/gitlab/pipeline/zombienet.yml @@ -0,0 +1,302 @@ +# This file is part of .gitlab-ci.yml +# Here are all jobs that are executed during "zombienet" stage + +zombienet-tests-parachains-smoke-test: + stage: zombienet + image: "${ZOMBIENET_IMAGE}" + extends: + - .kubernetes-env + - .zombienet-refs + needs: + - job: publish-polkadot-debug-image + - job: publish-malus-image + - job: publish-test-collators-image + variables: + GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/smoke" + before_script: + - echo "Zombie-net Tests Config" + - echo "${ZOMBIENET_IMAGE}" + - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" + - echo "${MALUS_IMAGE_NAME} ${MALUS_IMAGE_TAG}" + - echo "${GH_DIR}" + - export DEBUG=zombie,zombie::network-node + - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} + - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} + - export COL_IMAGE="docker.io/paritypr/colander:4519" # The collator image is fixed + script: + - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh + --github-remote-dir="${GH_DIR}" + --test="0001-parachains-smoke-test.zndsl" + allow_failure: false + retry: 2 + tags: + - zombienet-polkadot-integration-test + +zombienet-tests-parachains-pvf: + stage: zombienet + image: "${ZOMBIENET_IMAGE}" + extends: + - .kubernetes-env + - .zombienet-refs + needs: + - job: publish-polkadot-debug-image + - job: publish-test-collators-image + variables: + GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/functional" + before_script: + - echo "Zombie-net Tests Config" + - echo "${ZOMBIENET_IMAGE}" + - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" + - echo "COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG}" + - echo "${GH_DIR}" + - export DEBUG=zombie,zombie::network-node + - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} + - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} + - export COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG} + script: + - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh + --github-remote-dir="${GH_DIR}" + --test="0001-parachains-pvf.zndsl" + allow_failure: false + retry: 2 + tags: + - zombienet-polkadot-integration-test + +zombienet-tests-parachains-disputes: + stage: zombienet + image: "${ZOMBIENET_IMAGE}" + extends: + - .kubernetes-env + - .zombienet-refs + needs: + - job: publish-polkadot-debug-image + - job: publish-test-collators-image + - job: publish-malus-image + variables: + GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/functional" + before_script: + - echo "Zombie-net Tests Config" + - echo "${ZOMBIENET_IMAGE_NAME}" + - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" + - echo "${MALUS_IMAGE_NAME} ${MALUS_IMAGE_TAG}" + - echo "${GH_DIR}" + - export DEBUG=zombie,zombie::network-node + - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} + - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} + - export COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG} + script: + - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh + --github-remote-dir="${GH_DIR}" + --test="0002-parachains-disputes.zndsl" + allow_failure: false + retry: 2 + tags: + - zombienet-polkadot-integration-test + +zombienet-tests-parachains-disputes-garbage-candidate: + stage: zombienet + image: "${ZOMBIENET_IMAGE}" + extends: + - .kubernetes-env + - .zombienet-refs + needs: + - job: publish-polkadot-debug-image + - job: publish-test-collators-image + - job: publish-malus-image + variables: + GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/functional" + before_script: + - echo "Zombie-net Tests Config" + - echo "${ZOMBIENET_IMAGE_NAME}" + - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" + - echo "${MALUS_IMAGE_NAME} ${MALUS_IMAGE_TAG}" + - echo "${GH_DIR}" + - export DEBUG=zombie,zombie::network-node + - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} + - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} + - export COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG} + script: + - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh + --github-remote-dir="${GH_DIR}" + --test="0003-parachains-garbage-candidate.zndsl" + allow_failure: false + retry: 2 + tags: + - zombienet-polkadot-integration-test + +zombienet-test-parachains-upgrade-smoke-test: + stage: zombienet + image: "${ZOMBIENET_IMAGE}" + extends: + - .kubernetes-env + - .zombienet-refs + needs: + - job: publish-polkadot-debug-image + - job: publish-malus-image + - job: publish-test-collators-image + variables: + GH_DIR: 'https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/smoke' + before_script: + - echo "ZombieNet Tests Config" + - echo "${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG}" + - echo "docker.io/parity/polkadot-collator:latest" + - echo "${ZOMBIENET_IMAGE}" + - echo "${GH_DIR}" + - export DEBUG=zombie,zombie::network-node + - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} + - export COL_IMAGE="docker.io/parity/polkadot-collator:latest" # Use cumulus lastest image + script: + - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh + --github-remote-dir="${GH_DIR}" + --test="0002-parachains-upgrade-smoke-test.zndsl" + allow_failure: true + retry: 2 + tags: + - zombienet-polkadot-integration-test + +zombienet-tests-misc-paritydb: + stage: zombienet + image: "${ZOMBIENET_IMAGE}" + extends: + - .kubernetes-env + - .zombienet-refs + needs: + - job: publish-polkadot-debug-image + - job: publish-test-collators-image + artifacts: true + variables: + GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/misc" + before_script: + - echo "Zombie-net Tests Config" + - echo "${ZOMBIENET_IMAGE_NAME}" + - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" + - echo "${GH_DIR}" + - export DEBUG=zombie,zombie::network-node + - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} + - export COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG} + script: + - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh + --github-remote-dir="${GH_DIR}" + --test="0001-paritydb.zndsl" + allow_failure: false + retry: 2 + tags: + - zombienet-polkadot-integration-test + +zombienet-tests-misc-upgrade-node: + stage: zombienet + image: "${ZOMBIENET_IMAGE}" + extends: + - .kubernetes-env + - .zombienet-refs + needs: + - job: publish-polkadot-debug-image + - job: publish-test-collators-image + - job: build-linux-stable + artifacts: true + variables: + GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/misc" + before_script: + - echo "Zombie-net Tests Config" + - echo "${ZOMBIENET_IMAGE_NAME}" + - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" + - echo "${GH_DIR}" + - export DEBUG=zombie,zombie::network-node + - BUILD_RELEASE_VERSION="$(cat ./artifacts/BUILD_RELEASE_VERSION)" + - export ZOMBIENET_INTEGRATION_TEST_IMAGE="docker.io/parity/polkadot:${BUILD_RELEASE_VERSION}" + - export COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG} + - BUILD_LINUX_JOB_ID="$(cat ./artifacts/BUILD_LINUX_JOB_ID)" + - export POLKADOT_PR_BIN_URL="https://gitlab.parity.io/parity/mirrors/polkadot/-/jobs/${BUILD_LINUX_JOB_ID}/artifacts/raw/artifacts/polkadot" + script: + - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh + --github-remote-dir="${GH_DIR}" + --test="0002-upgrade-node.zndsl" + allow_failure: false + retry: 2 + tags: + - zombienet-polkadot-integration-test + +zombienet-tests-malus-dispute-valid: + stage: zombienet + image: "${ZOMBIENET_IMAGE}" + extends: + - .kubernetes-env + - .zombienet-refs + needs: + - job: publish-polkadot-debug-image + - job: publish-malus-image + - job: publish-test-collators-image + variables: + GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/node/malus/integrationtests" + before_script: + - echo "Zombie-net Tests Config" + - echo "${ZOMBIENET_IMAGE_NAME}" + - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" + - echo "${MALUS_IMAGE_NAME} ${MALUS_IMAGE_TAG}" + - echo "${GH_DIR}" + - export DEBUG=zombie* + - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} + - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} + - export COL_IMAGE=${COLLATOR_IMAGE_NAME}:${COLLATOR_IMAGE_TAG} + script: + - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh + --github-remote-dir="${GH_DIR}" + --test="0001-dispute-valid-block.zndsl" + allow_failure: false + retry: 2 + tags: + - zombienet-polkadot-integration-test + +zombienet-tests-deregister-register-validator: + stage: zombienet + image: "${ZOMBIENET_IMAGE}" + extends: + - .kubernetes-env + - .zombienet-refs + needs: + - job: publish-polkadot-debug-image + artifacts: true + variables: + GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/smoke" + before_script: + - echo "Zombie-net Tests Config" + - echo "${ZOMBIENET_IMAGE_NAME}" + - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" + - echo "${GH_DIR}" + - export DEBUG=zombie* + - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} + - export MALUS_IMAGE=${MALUS_IMAGE_NAME}:${MALUS_IMAGE_TAG} + script: + - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh + --github-remote-dir="${GH_DIR}" + --test="0003-deregister-register-validator-smoke.zndsl" + allow_failure: false + retry: 2 + tags: + - zombienet-polkadot-integration-test + +zombienet-tests-beefy-and-mmr: + stage: zombienet + image: "${ZOMBIENET_IMAGE}" + extends: + - .kubernetes-env + - .zombienet-refs + needs: + - job: publish-polkadot-debug-image + variables: + GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/functional" + before_script: + - echo "Zombie-net Tests Config" + - echo "${ZOMBIENET_IMAGE_NAME}" + - echo "${PARACHAINS_IMAGE_NAME} ${PARACHAINS_IMAGE_TAG}" + - echo "${GH_DIR}" + - export DEBUG=zombie* + - export ZOMBIENET_INTEGRATION_TEST_IMAGE=${PARACHAINS_IMAGE_NAME}:${PARACHAINS_IMAGE_TAG} + script: + - /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh + --github-remote-dir="${GH_DIR}" + --test="0003-beefy-and-mmr.zndsl" + allow_failure: true + retry: 2 + tags: + - zombienet-polkadot-integration-test diff --git a/scripts/ci/run_benches_for_runtime.sh b/scripts/ci/run_benches_for_runtime.sh index 8149195c82c4..d88ca343d6cf 100755 --- a/scripts/ci/run_benches_for_runtime.sh +++ b/scripts/ci/run_benches_for_runtime.sh @@ -29,6 +29,12 @@ rm -f $ERR_FILE for PALLET in "${PALLETS[@]}"; do echo "[+] Benchmarking $PALLET for $runtime"; + output_file="" + if [[ $PALLET == *"::"* ]]; then + # translates e.g. "pallet_foo::bar" to "pallet_foo_bar" + output_file="${PALLET//::/_}.rs" + fi + OUTPUT=$( ./target/production/polkadot benchmark pallet \ --chain="${runtime}-dev" \ @@ -39,7 +45,7 @@ for PALLET in "${PALLETS[@]}"; do --execution=wasm \ --wasm-execution=compiled \ --header=./file_header.txt \ - --output="./runtime/${runtime}/src/weights/${PALLET/::/_}.rs" 2>&1 + --output="./runtime/${runtime}/src/weights/${output_file}" 2>&1 ) if [ $? -ne 0 ]; then echo "$OUTPUT" >> "$ERR_FILE" @@ -56,7 +62,8 @@ OUTPUT=$( --wasm-execution=compiled \ --weight-path="runtime/${runtime}/constants/src/weights/" \ --warmup=10 \ - --repeat=100 + --repeat=100 \ + --header=./file_header.txt ) if [ $? -ne 0 ]; then echo "$OUTPUT" >> "$ERR_FILE" diff --git a/statement-table/Cargo.toml b/statement-table/Cargo.toml index f0cc34684172..d61f4110825d 100644 --- a/statement-table/Cargo.toml +++ b/statement-table/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "polkadot-statement-table" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } primitives = { package = "polkadot-primitives", path = "../primitives" } diff --git a/tests/common.rs b/tests/common.rs index 0a25b0334848..3f040208972c 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -14,14 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use polkadot_core_primitives::Block; -use remote_externalities::rpc_api::get_finalized_head; +use polkadot_core_primitives::{Block, Hash, Header}; use std::{ io::{BufRead, BufReader, Read}, process::{Child, ExitStatus}, thread, time::Duration, }; +use substrate_rpc_client::{ws_client, ChainApi}; use tokio::time::timeout; /// Wait for the given `child` the given amount of `secs`. @@ -56,7 +56,12 @@ async fn wait_n_finalized_blocks_from(n: usize, url: &str) { let mut interval = tokio::time::interval(Duration::from_secs(6)); loop { - if let Ok(block) = get_finalized_head::(url).await { + let rpc = match ws_client(url).await { + Ok(rpc_service) => rpc_service, + Err(_) => continue, + }; + + if let Ok(block) = ChainApi::<(), Hash, Header, Block>::finalized_head(&rpc).await { built_blocks.insert(block); if built_blocks.len() > n { break diff --git a/utils/generate-bags/Cargo.toml b/utils/generate-bags/Cargo.toml index 9520909c4a36..387f35f4e614 100644 --- a/utils/generate-bags/Cargo.toml +++ b/utils/generate-bags/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "polkadot-voter-bags" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] -clap = { version = "3.1", features = ["derive"] } +clap = { version = "4.0.9", features = ["derive"] } -generate-bags = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +generate-bags = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } westend-runtime = { path = "../../runtime/westend" } kusama-runtime = { path = "../../runtime/kusama" } diff --git a/utils/generate-bags/src/main.rs b/utils/generate-bags/src/main.rs index 9f5dbada3e93..409b28b5b79d 100644 --- a/utils/generate-bags/src/main.rs +++ b/utils/generate-bags/src/main.rs @@ -20,15 +20,15 @@ //! touched again. It can be reused to regenerate a wholly different //! quantity of bags, or if the existential deposit changes, etc. -use clap::{ArgEnum, Parser}; +use clap::{Parser, ValueEnum}; use generate_bags::generate_thresholds; use kusama_runtime::Runtime as KusamaRuntime; use polkadot_runtime::Runtime as PolkadotRuntime; use std::path::{Path, PathBuf}; use westend_runtime::Runtime as WestendRuntime; -#[derive(Clone, Debug, ArgEnum)] -#[clap(rename_all = "PascalCase")] +#[derive(Clone, Debug, ValueEnum)] +#[value(rename_all = "PascalCase")] enum Runtime { Westend, Kusama, @@ -50,22 +50,22 @@ impl Runtime { #[derive(Debug, Parser)] struct Opt { /// How many bags to generate. - #[clap(long, default_value = "200")] + #[arg(long, default_value_t = 200)] n_bags: usize, /// Which runtime to generate. - #[clap(long, ignore_case = true, arg_enum, default_value = "Polkadot")] + #[arg(long, ignore_case = true, value_enum, default_value_t = Runtime::Polkadot)] runtime: Runtime, /// Where to write the output. output: PathBuf, /// The total issuance of the native currency. - #[clap(short, long)] + #[arg(short, long)] total_issuance: u128, /// The minimum account balance (i.e. existential deposit) for the native currency. - #[clap(short, long)] + #[arg(short, long)] minimum_balance: u128, } diff --git a/utils/remote-ext-tests/bags-list/Cargo.toml b/utils/remote-ext-tests/bags-list/Cargo.toml index e3b7dace297b..a81a0eccc26e 100644 --- a/utils/remote-ext-tests/bags-list/Cargo.toml +++ b/utils/remote-ext-tests/bags-list/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "remote-ext-tests-bags-list" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" @@ -12,11 +12,11 @@ polkadot-runtime-constants = { path = "../../../runtime/polkadot/constants" } kusama-runtime-constants = { path = "../../../runtime/kusama/constants" } westend-runtime-constants = { path = "../../../runtime/westend/constants" } -pallet-bags-list-remote-tests = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +pallet-bags-list-remote-tests = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } -clap = { version = "3.1", features = ["derive"] } +clap = { version = "4.0.9", features = ["derive"] } log = "0.4.17" tokio = { version = "1.19.2", features = ["macros"] } diff --git a/utils/remote-ext-tests/bags-list/src/main.rs b/utils/remote-ext-tests/bags-list/src/main.rs index 2c0bc6aeacd0..53d81c4b4e05 100644 --- a/utils/remote-ext-tests/bags-list/src/main.rs +++ b/utils/remote-ext-tests/bags-list/src/main.rs @@ -16,18 +16,18 @@ //! Remote tests for bags-list pallet. -use clap::{ArgEnum, Parser}; +use clap::{Parser, ValueEnum}; -#[derive(Clone, Debug, ArgEnum)] -#[clap(rename_all = "PascalCase")] +#[derive(Clone, Debug, ValueEnum)] +#[value(rename_all = "PascalCase")] enum Command { CheckMigration, SanityCheck, Snapshot, } -#[derive(Clone, Debug, ArgEnum)] -#[clap(rename_all = "PascalCase")] +#[derive(Clone, Debug, ValueEnum)] +#[value(rename_all = "PascalCase")] enum Runtime { Polkadot, Kusama, @@ -36,13 +36,13 @@ enum Runtime { #[derive(Parser)] struct Cli { - #[clap(long, short, default_value = "wss://kusama-rpc.polkadot.io:443")] + #[arg(long, short, default_value = "wss://kusama-rpc.polkadot.io:443")] uri: String, - #[clap(long, short, ignore_case = true, arg_enum, default_value = "kusama")] + #[arg(long, short, ignore_case = true, value_enum, default_value_t = Runtime::Kusama)] runtime: Runtime, - #[clap(long, short, ignore_case = true, arg_enum, default_value = "SanityCheck")] + #[arg(long, short, ignore_case = true, value_enum, default_value_t = Command::SanityCheck)] command: Command, - #[clap(long, short)] + #[arg(long, short)] snapshot_limit: Option, } @@ -86,7 +86,7 @@ async fn main() { (Runtime::Kusama, Command::SanityCheck) => { use kusama_runtime::{Block, Runtime}; use kusama_runtime_constants::currency::UNITS; - sanity_check::execute::(UNITS as u64, "KSM", options.uri.clone()).await; + try_state::execute::(UNITS as u64, "KSM", options.uri.clone()).await; }, (Runtime::Kusama, Command::Snapshot) => { use kusama_runtime::{Block, Runtime}; @@ -107,7 +107,7 @@ async fn main() { (Runtime::Westend, Command::SanityCheck) => { use westend_runtime::{Block, Runtime}; use westend_runtime_constants::currency::UNITS; - sanity_check::execute::(UNITS as u64, "WND", options.uri.clone()).await; + try_state::execute::(UNITS as u64, "WND", options.uri.clone()).await; }, (Runtime::Westend, Command::Snapshot) => { use westend_runtime::{Block, Runtime}; @@ -128,7 +128,7 @@ async fn main() { (Runtime::Polkadot, Command::SanityCheck) => { use polkadot_runtime::{Block, Runtime}; use polkadot_runtime_constants::currency::UNITS; - sanity_check::execute::(UNITS as u64, "DOT", options.uri.clone()).await; + try_state::execute::(UNITS as u64, "DOT", options.uri.clone()).await; }, (Runtime::Polkadot, Command::Snapshot) => { use polkadot_runtime::{Block, Runtime}; diff --git a/utils/staking-miner/Cargo.toml b/utils/staking-miner/Cargo.toml index 7396aa929e71..a0aecbc09add 100644 --- a/utils/staking-miner/Cargo.toml +++ b/utils/staking-miner/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "staking-miner" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0" } -clap = { version = "3.1", features = ["derive", "env"] } +clap = { version = "4.0.9", features = ["derive", "env"] } tracing-subscriber = { version = "0.3.11", features = ["env-filter"] } jsonrpsee = { version = "0.15.1", features = ["ws-client", "macros"] } log = "0.4.17" @@ -15,22 +15,22 @@ serde = "1.0.137" serde_json = "1.0" thiserror = "1.0.31" tokio = { version = "1.19.2", features = ["macros", "rt-multi-thread", "sync"] } -remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-version = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-version = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-election-provider-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-election-provider-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-election-provider-multi-phase = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } core-primitives = { package = "polkadot-core-primitives", path = "../../core-primitives" } diff --git a/utils/staking-miner/src/main.rs b/utils/staking-miner/src/main.rs index 971e771e0073..4a7784f371e0 100644 --- a/utils/staking-miner/src/main.rs +++ b/utils/staking-miner/src/main.rs @@ -57,7 +57,7 @@ use signal_hook::consts::signal::*; use signal_hook_tokio::Signals; use sp_npos_elections::BalancingConfig; use sp_runtime::{traits::Block as BlockT, DeserializeOwned}; -use std::{ops::Deref, sync::Arc}; +use std::{ops::Deref, sync::Arc, time::Duration}; use tracing_subscriber::{fmt, EnvFilter}; pub(crate) enum AnyRuntime { @@ -94,7 +94,7 @@ macro_rules! construct_runtime_prelude { let crate::signer::Signer { account, pair, .. } = signer; let local_call = EPMCall::::submit { raw_solution: Box::new(raw_solution) }; - let call: Call = as std::convert::TryInto>::try_into(local_call) + let call: RuntimeCall = as std::convert::TryInto>::try_into(local_call) .expect("election provider pallet must exist in the runtime, thus \ inner call can be converted, qed." ); @@ -295,11 +295,16 @@ frame_support::parameter_types! { /// Build the Ext at hash with all the data of `ElectionProviderMultiPhase` and any additional /// pallets. -async fn create_election_ext( +async fn create_election_ext( client: SharedRpcClient, at: Option, additional: Vec, -) -> Result> { +) -> Result> +where + T: EPM::Config, + B: BlockT, + B::Header: DeserializeOwned, +{ use frame_support::{storage::generator::StorageMap, traits::PalletInfo}; use sp_core::hashing::twox_128; @@ -485,7 +490,7 @@ async fn handle_signals(mut signals: Signals) { async fn main() { fmt().with_env_filter(EnvFilter::from_default_env()).init(); - let Opt { uri, command } = Opt::parse(); + let Opt { uri, command, connection_timeout, request_timeout } = Opt::parse(); log::debug!(target: LOG_TARGET, "attempting to connect to {:?}", uri); let signals = Signals::new(&[SIGTERM, SIGINT, SIGQUIT]).expect("Failed initializing Signals"); @@ -493,7 +498,13 @@ async fn main() { let signals_task = tokio::spawn(handle_signals(signals)); let rpc = loop { - match SharedRpcClient::new(&uri).await { + match SharedRpcClient::new( + &uri, + Duration::from_secs(connection_timeout as u64), + Duration::from_secs(request_timeout as u64), + ) + .await + { Ok(client) => break client, Err(why) => { log::warn!( diff --git a/utils/staking-miner/src/monitor.rs b/utils/staking-miner/src/monitor.rs index 0553693a84ef..30f1b2ded908 100644 --- a/utils/staking-miner/src/monitor.rs +++ b/utils/staking-miner/src/monitor.rs @@ -370,14 +370,14 @@ macro_rules! monitor_cmd_for { ($runtime:tt) => { paste::paste! { TransactionStatus::Ready | TransactionStatus::Broadcast(_) | TransactionStatus::Future => continue, - TransactionStatus::InBlock(hash) => { + TransactionStatus::InBlock((hash, _)) => { log::info!(target: LOG_TARGET, "included at {:?}", hash); let key = StorageKey( frame_support::storage::storage_prefix(b"System", b"Events").to_vec(), ); let events = match rpc.get_storage_and_decode::< - Vec::Hash>>, + Vec::Hash>>, >(&key, Some(hash)) .await { Ok(rp) => rp.unwrap_or_default(), @@ -399,7 +399,7 @@ macro_rules! monitor_cmd_for { ($runtime:tt) => { paste::paste! { TransactionStatus::Retracted(hash) => { log::info!(target: LOG_TARGET, "Retracted at {:?}", hash); }, - TransactionStatus::Finalized(hash) => { + TransactionStatus::Finalized((hash, _)) => { log::info!(target: LOG_TARGET, "Finalized at {:?}", hash); break }, diff --git a/utils/staking-miner/src/opts.rs b/utils/staking-miner/src/opts.rs index 1e7b1f2ba294..0a6c50cda90a 100644 --- a/utils/staking-miner/src/opts.rs +++ b/utils/staking-miner/src/opts.rs @@ -21,13 +21,21 @@ use std::str::FromStr; #[derive(Debug, Clone, Parser)] #[cfg_attr(test, derive(PartialEq))] -#[clap(author, version, about)] +#[command(author, version, about)] pub(crate) struct Opt { /// The `ws` node to connect to. - #[clap(long, short, default_value = DEFAULT_URI, env = "URI", global = true)] + #[arg(long, short, default_value = DEFAULT_URI, env = "URI", global = true)] pub uri: String, - #[clap(subcommand)] + /// WS connection timeout in number of seconds. + #[arg(long, default_value_t = 60)] + pub connection_timeout: usize, + + /// WS request timeout in number of seconds. + #[arg(long, default_value_t = 60 * 10)] + pub request_timeout: usize, + + #[command(subcommand)] pub command: Command, } @@ -57,7 +65,7 @@ pub(crate) struct MonitorConfig { /// /// WARNING: Don't use an account with a large stash for this. Based on how the bot is /// configured, it might re-try and lose funds through transaction fees/deposits. - #[clap(long, short, env = "SEED")] + #[arg(long, short, env = "SEED")] pub seed_or_path: String, /// They type of event to listen to. @@ -65,11 +73,11 @@ pub(crate) struct MonitorConfig { /// Typically, finalized is safer and there is no chance of anything going wrong, but it can be /// slower. It is recommended to use finalized, if the duration of the signed phase is longer /// than the the finality delay. - #[clap(long, default_value = "head", possible_values = &["head", "finalized"])] + #[arg(long, default_value = "head", value_parser = ["head", "finalized"])] pub listen: String, /// The solver algorithm to use. - #[clap(subcommand)] + #[command(subcommand)] pub solver: Solver, /// Submission strategy to use. @@ -81,7 +89,7 @@ pub(crate) struct MonitorConfig { /// `--submission-strategy always`: always submit. /// /// `--submission-strategy "percent-better "`: submit if the submission is `n` percent better. - #[clap(long, parse(try_from_str), default_value = "if-leading")] + #[arg(long, default_value = "if-leading")] pub submission_strategy: SubmissionStrategy, /// Delay in number seconds to wait until starting mining a solution. @@ -92,7 +100,7 @@ pub(crate) struct MonitorConfig { /// /// When this is enabled and there are competing solutions, your solution might not be submitted /// if the scores are equal. - #[clap(long, parse(try_from_str), default_value_t = 0)] + #[arg(long, default_value_t = 0)] pub delay: usize, } @@ -106,19 +114,19 @@ pub(crate) struct DryRunConfig { /// /// WARNING: Don't use an account with a large stash for this. Based on how the bot is /// configured, it might re-try and lose funds through transaction fees/deposits. - #[clap(long, short, env = "SEED")] + #[arg(long, short, env = "SEED")] pub seed_or_path: String, /// The block hash at which scraping happens. If none is provided, the latest head is used. - #[clap(long)] + #[arg(long)] pub at: Option, /// The solver algorithm to use. - #[clap(subcommand)] + #[command(subcommand)] pub solver: Solver, /// Force create a new snapshot, else expect one to exist onchain. - #[clap(long)] + #[arg(long)] pub force_snapshot: bool, } @@ -126,11 +134,11 @@ pub(crate) struct DryRunConfig { #[cfg_attr(test, derive(PartialEq))] pub(crate) struct EmergencySolutionConfig { /// The block hash at which scraping happens. If none is provided, the latest head is used. - #[clap(long)] + #[arg(long)] pub at: Option, /// The solver algorithm to use. - #[clap(subcommand)] + #[command(subcommand)] pub solver: Solver, /// The number of top backed winners to take. All are taken, if not provided. @@ -141,7 +149,7 @@ pub(crate) struct EmergencySolutionConfig { #[cfg_attr(test, derive(PartialEq))] pub(crate) struct InfoOpts { /// Serialize the output as json - #[clap(long, short)] + #[arg(long, short)] pub json: bool, } @@ -162,11 +170,11 @@ pub enum SubmissionStrategy { #[cfg_attr(test, derive(PartialEq))] pub(crate) enum Solver { SeqPhragmen { - #[clap(long, default_value = "10")] + #[arg(long, default_value_t = 10)] iterations: usize, }, PhragMMS { - #[clap(long, default_value = "10")] + #[arg(long, default_value_t = 10)] iterations: usize, }, } @@ -223,6 +231,8 @@ mod test_super { opt, Opt { uri: "hi".to_string(), + connection_timeout: 60, + request_timeout: 10 * 60, command: Command::Monitor(MonitorConfig { seed_or_path: "//Alice".to_string(), listen: "head".to_string(), @@ -251,6 +261,8 @@ mod test_super { opt, Opt { uri: "hi".to_string(), + connection_timeout: 60, + request_timeout: 10 * 60, command: Command::DryRun(DryRunConfig { seed_or_path: "//Alice".to_string(), at: None, @@ -279,6 +291,8 @@ mod test_super { opt, Opt { uri: "hi".to_string(), + connection_timeout: 60, + request_timeout: 10 * 60, command: Command::EmergencySolution(EmergencySolutionConfig { take: Some(99), at: None, @@ -294,7 +308,37 @@ mod test_super { assert_eq!( opt, - Opt { uri: "hi".to_string(), command: Command::Info(InfoOpts { json: false }) } + Opt { + uri: "hi".to_string(), + connection_timeout: 60, + request_timeout: 10 * 60, + command: Command::Info(InfoOpts { json: false }) + } + ); + } + + #[test] + fn cli_request_conn_timeout_works() { + let opt = Opt::try_parse_from([ + env!("CARGO_PKG_NAME"), + "--uri", + "hi", + "--request-timeout", + "10", + "--connection-timeout", + "9", + "info", + ]) + .unwrap(); + + assert_eq!( + opt, + Opt { + uri: "hi".to_string(), + connection_timeout: 9, + request_timeout: 10, + command: Command::Info(InfoOpts { json: false }) + } ); } diff --git a/utils/staking-miner/src/rpc.rs b/utils/staking-miner/src/rpc.rs index 4cf10f9ffef7..8929afcbe656 100644 --- a/utils/staking-miner/src/rpc.rs +++ b/utils/staking-miner/src/rpc.rs @@ -27,9 +27,6 @@ use sp_core::{storage::StorageKey, Bytes}; use sp_version::RuntimeVersion; use std::{future::Future, time::Duration}; -const MAX_CONNECTION_DURATION: Duration = Duration::from_secs(20); -const MAX_REQUEST_DURATION: Duration = Duration::from_secs(60); - #[derive(frame_support::DebugNoBound, thiserror::Error)] pub(crate) enum RpcHelperError { JsonRpsee(#[from] jsonrpsee::core::Error), @@ -125,11 +122,15 @@ impl SharedRpcClient { } /// Create a new shared JSON-RPC web-socket client. - pub(crate) async fn new(uri: &str) -> Result { + pub(crate) async fn new( + uri: &str, + connection_timeout: Duration, + request_timeout: Duration, + ) -> Result { let client = WsClientBuilder::default() - .connection_timeout(MAX_CONNECTION_DURATION) + .connection_timeout(connection_timeout) .max_request_body_size(u32::MAX) - .request_timeout(MAX_REQUEST_DURATION) + .request_timeout(request_timeout) .build(uri) .await?; Ok(Self(Arc::new(client))) diff --git a/xcm/Cargo.toml b/xcm/Cargo.toml index 468266eaa03f..543a6a704fb4 100644 --- a/xcm/Cargo.toml +++ b/xcm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xcm" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "The basic XCM datastructures." edition = "2021" @@ -9,10 +9,11 @@ edition = "2021" impl-trait-for-tuples = "0.2.2" parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } derivative = {version = "2.2.0", default-features = false, features = [ "use_core" ] } log = { version = "0.4.17", default-features = false } -serde = { version = "1.0.137", features = ["derive"] } +serde = { version = "1.0.137", optional = true, features = ["derive"] } xcm-procedural = { path = "procedural" } [features] @@ -24,5 +25,7 @@ runtime-benchmarks = [ std = [ "parity-scale-codec/std", "scale-info/std", + "serde", + "sp-io/std", "sp-runtime/std", ] diff --git a/xcm/pallet-xcm-benchmarks/Cargo.toml b/xcm/pallet-xcm-benchmarks/Cargo.toml index 3912f22e0654..2610f04859c5 100644 --- a/xcm/pallet-xcm-benchmarks/Cargo.toml +++ b/xcm/pallet-xcm-benchmarks/Cargo.toml @@ -2,7 +2,7 @@ name = "pallet-xcm-benchmarks" authors = ["Parity Technologies "] edition = "2021" -version = "0.9.28" +version = "0.9.31" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -10,21 +10,21 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.28" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.28" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.28" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.28" } -xcm-executor = { path = "../xcm-executor", default-features = false, features = ["runtime-benchmarks"] } -frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.28" } -xcm = { path = "..", default-features = false, features = ["runtime-benchmarks"] } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.31" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.31" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.31" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.31" } +xcm-executor = { path = "../xcm-executor", default-features = false } +frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.31" } +xcm = { path = "..", default-features = false } log = "0.4.17" [dev-dependencies] -pallet-balances = { git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.28" } -pallet-assets = { git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.28" } -sp-tracing = { git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.28" } +pallet-balances = { git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.31" } +pallet-assets = { git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.31" } +sp-tracing = { git = "https://github.com/paritytech/substrate" , branch = "polkadot-v0.9.31" } xcm-builder = { path = "../xcm-builder" } xcm = { path = ".." } # temp @@ -43,3 +43,10 @@ std = [ "sp-runtime/std", "sp-std/std" ] +runtime-benchmarks = [ + "xcm/runtime-benchmarks", + "xcm-executor/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", +] diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs index 7a68e7ed939e..fade0d4869b3 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs @@ -136,7 +136,7 @@ benchmarks_instance_pallet! { let (trusted_teleporter, teleportable_asset) = T::TrustedTeleporter::get() .ok_or(BenchmarkError::Skip)?; - if let Some(checked_account) = T::CheckedAccount::get() { + if let Some((checked_account, _)) = T::CheckedAccount::get() { T::TransactAsset::mint_into( &checked_account, < @@ -223,7 +223,7 @@ benchmarks_instance_pallet! { holding.push(asset.clone()); // Checked account starts at zero - assert!(T::CheckedAccount::get().map_or(true, |c| T::TransactAsset::balance(&c).is_zero())); + assert!(T::CheckedAccount::get().map_or(true, |(c, _)| T::TransactAsset::balance(&c).is_zero())); let mut executor = new_executor::(Default::default()); executor.set_holding(holding.into()); @@ -236,7 +236,7 @@ benchmarks_instance_pallet! { }: { executor.bench_process(xcm)?; } verify { - if let Some(checked_account) = T::CheckedAccount::get() { + if let Some((checked_account, _)) = T::CheckedAccount::get() { // teleport checked account should have received some asset. assert!(!T::TransactAsset::balance(&checked_account).is_zero()); } diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs index 8a657c5163bf..b1004818e685 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mock.rs @@ -21,6 +21,7 @@ use frame_benchmarking::BenchmarkError; use frame_support::{ parameter_types, traits::{Everything, Nothing}, + weights::Weight, }; use sp_core::H256; use sp_runtime::{ @@ -29,7 +30,7 @@ use sp_runtime::{ BuildStorage, }; use xcm::latest::prelude::*; -use xcm_builder::AllowUnpaidExecutionFrom; +use xcm_builder::{AllowUnpaidExecutionFrom, MintLocation}; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -50,23 +51,25 @@ frame_support::construct_runtime!( parameter_types! { pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max( + Weight::from_ref_time(1024).set_proof_size(u64::MAX), + ); } impl frame_system::Config for Test { type BaseCallFilter = Everything; type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -89,7 +92,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u64; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); @@ -120,7 +123,7 @@ pub type AssetTransactor = xcm_builder::CurrencyAdapter< MatchAnyFungible, AccountIdConverter, u64, - CheckedAccount, + CheckingAccount, >; parameter_types! { @@ -132,7 +135,7 @@ parameter_types! { pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { - type Call = Call; + type RuntimeCall = RuntimeCall; type XcmSender = DevNull; type AssetTransactor = AssetTransactor; type OriginConverter = (); @@ -140,7 +143,7 @@ impl xcm_executor::Config for XcmConfig { type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = AllowUnpaidExecutionFrom; - type Weigher = xcm_builder::FixedWeightBounds; + type Weigher = xcm_builder::FixedWeightBounds; type Trader = xcm_builder::FixedRateOfFungible; type ResponseHandler = DevNull; type AssetTrap = (); @@ -153,6 +156,7 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; } impl crate::Config for Test { @@ -175,7 +179,7 @@ impl crate::Config for Test { pub type TrustedTeleporters = (xcm_builder::Case,); parameter_types! { - pub const CheckedAccount: Option = Some(100); + pub const CheckingAccount: Option<(u64, MintLocation)> = Some((100, MintLocation::Local)); pub const ChildTeleporter: MultiLocation = Parachain(1000).into_location(); pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some(( ChildTeleporter::get(), @@ -189,7 +193,7 @@ parameter_types! { impl xcm_balances_benchmark::Config for Test { type TransactAsset = Balances; - type CheckedAccount = CheckedAccount; + type CheckedAccount = CheckingAccount; type TrustedTeleporter = TrustedTeleporter; fn get_multi_asset() -> MultiAsset { diff --git a/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs b/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs index e5062c310494..011e84a0e42e 100644 --- a/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs +++ b/xcm/pallet-xcm-benchmarks/src/fungible/mod.rs @@ -18,6 +18,7 @@ pub use pallet::*; +#[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; #[cfg(test)] mod mock; @@ -33,7 +34,7 @@ pub mod pallet { type TransactAsset: frame_support::traits::fungible::Mutate; /// The account used to check assets being teleported. - type CheckedAccount: Get>; + type CheckedAccount: Get>; /// A trusted location which we allow teleports from, and the asset we allow to teleport. type TrustedTeleporter: Get>; diff --git a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index 05db22b287ac..cc83ab65c2e3 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -19,10 +19,9 @@ use crate::{new_executor, XcmCallOf}; use codec::Encode; use frame_benchmarking::{benchmarks, BenchmarkError}; use frame_support::dispatch::GetDispatchInfo; -use sp_io::hashing::blake2_256; use sp_std::vec; use xcm::{ - latest::{prelude::*, MaybeErrorCode, MultiAssets}, + latest::{prelude::*, MaybeErrorCode}, DoubleEncoded, }; use xcm_executor::{ExecutorError, FeesMode}; @@ -74,26 +73,6 @@ benchmarks! { } - // Worst case scenario for this benchmark is a large number of assets to - // filter through the reserve. - reserve_asset_deposited { - const MAX_ASSETS: u32 = 100; // TODO when executor has a built in limit, use it here. #4426 - let mut executor = new_executor::(Default::default()); - let assets = (0..MAX_ASSETS).map(|i| MultiAsset { - id: Abstract(i.using_encoded(blake2_256)), - fun: Fungible(i as u128), - - }).collect::>(); - let multiassets: MultiAssets = assets.into(); - - let instruction = Instruction::ReserveAssetDeposited(multiassets.clone()); - let xcm = Xcm(vec![instruction]); - }: { - executor.bench_process(xcm).map_err(|_| BenchmarkError::Skip)?; - } verify { - assert_eq!(executor.holding(), &multiassets.into()); - } - query_response { let mut executor = new_executor::(Default::default()); let (query_id, response) = T::worst_case_response(); @@ -113,14 +92,14 @@ benchmarks! { transact { let origin = T::transact_origin()?; let mut executor = new_executor::(origin); - let noop_call: ::Call = frame_system::Call::remark_with_event { + let noop_call: ::RuntimeCall = frame_system::Call::remark_with_event { remark: Default::default() }.into(); let double_encoded_noop_call: DoubleEncoded<_> = noop_call.encode().into(); let instruction = Instruction::Transact { origin_kind: OriginKind::SovereignAccount, - require_weight_at_most: noop_call.get_dispatch_info().weight, + require_weight_at_most: noop_call.get_dispatch_info().weight.ref_time(), call: double_encoded_noop_call, }; let xcm = Xcm(vec![instruction]); diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs index 26b69fc527aa..f9bc34844139 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mock.rs @@ -21,6 +21,7 @@ use codec::Decode; use frame_support::{ parameter_types, traits::{Everything, OriginTrait}, + weights::Weight, }; use sp_core::H256; use sp_runtime::{ @@ -54,7 +55,9 @@ frame_support::construct_runtime!( parameter_types! { pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); + frame_system::limits::BlockWeights::simple_max( + Weight::from_ref_time(1024).set_proof_size(u64::MAX), + ); } impl frame_system::Config for Test { @@ -62,16 +65,16 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -107,15 +110,15 @@ parameter_types! { pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { - type Call = Call; + type RuntimeCall = RuntimeCall; type XcmSender = DevNull; type AssetTransactor = NoAssetTransactor; - type OriginConverter = AlwaysSignedByDefault; + type OriginConverter = AlwaysSignedByDefault; type IsReserve = AllAssetLocationsPass; type IsTeleporter = (); type UniversalLocation = UniversalLocation; type Barrier = AllowUnpaidExecutionFrom; - type Weigher = xcm_builder::FixedWeightBounds; + type Weigher = xcm_builder::FixedWeightBounds; type Trader = xcm_builder::FixedRateOfFungible; type ResponseHandler = DevNull; type AssetTrap = TestAssetTrap; @@ -129,6 +132,7 @@ impl xcm_executor::Config for XcmConfig { // No bridges yet... type MessageExporter = (); type UniversalAliases = TestUniversalAliases; + type CallDispatcher = RuntimeCall; } impl crate::Config for Test { @@ -149,7 +153,7 @@ impl crate::Config for Test { } impl generic::Config for Test { - type Call = Call; + type RuntimeCall = RuntimeCall; fn worst_case_response() -> (u64, Response) { let assets: MultiAssets = (Concrete(Here.into()), 100).into(); @@ -190,18 +194,18 @@ pub fn new_test_ext() -> sp_io::TestExternalities { t.into() } -pub struct AlwaysSignedByDefault(core::marker::PhantomData); -impl ConvertOrigin for AlwaysSignedByDefault +pub struct AlwaysSignedByDefault(core::marker::PhantomData); +impl ConvertOrigin for AlwaysSignedByDefault where - Origin: OriginTrait, - ::AccountId: Decode, + RuntimeOrigin: OriginTrait, + ::AccountId: Decode, { fn convert_origin( _origin: impl Into, _kind: OriginKind, - ) -> Result { - Ok(Origin::signed( - ::AccountId::decode(&mut TrailingZeroInput::zeroes()) + ) -> Result { + Ok(RuntimeOrigin::signed( + ::AccountId::decode(&mut TrailingZeroInput::zeroes()) .expect("infinite length input; no invalid inputs for type; qed"), )) } diff --git a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs index cf5c03d2757c..cff8d626a347 100644 --- a/xcm/pallet-xcm-benchmarks/src/generic/mod.rs +++ b/xcm/pallet-xcm-benchmarks/src/generic/mod.rs @@ -1,5 +1,6 @@ pub use pallet::*; +#[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; #[cfg(test)] mod mock; @@ -7,12 +8,15 @@ mod mock; #[frame_support::pallet] pub mod pallet { use frame_benchmarking::BenchmarkError; - use frame_support::{dispatch::Dispatchable, pallet_prelude::Encode, weights::GetDispatchInfo}; + use frame_support::{ + dispatch::{Dispatchable, GetDispatchInfo}, + pallet_prelude::Encode, + }; use xcm::latest::{Junction, MultiAsset, MultiAssets, MultiLocation, Response}; #[pallet::config] pub trait Config: frame_system::Config + crate::Config { - type Call: Dispatchable + type RuntimeCall: Dispatchable + GetDispatchInfo + From> + Encode; @@ -31,7 +35,7 @@ pub mod pallet { /// A `Junction` that is one of the `UniversalAliases` configured by the XCM executor. /// - /// If set to `None`, benchmarks which rely on a universal alais will be skipped. + /// If set to `None`, benchmarks which rely on a universal alias will be skipped. fn universal_alias() -> Result; /// The `MultiLocation` used for successful transaction XCMs. diff --git a/xcm/pallet-xcm-benchmarks/src/lib.rs b/xcm/pallet-xcm-benchmarks/src/lib.rs index 4759199c7d63..c2bb093b1d1a 100644 --- a/xcm/pallet-xcm-benchmarks/src/lib.rs +++ b/xcm/pallet-xcm-benchmarks/src/lib.rs @@ -54,11 +54,11 @@ const SEED: u32 = 0; /// The XCM executor to use for doing stuff. pub type ExecutorOf = xcm_executor::XcmExecutor<::XcmConfig>; /// The overarching call type. -pub type OverArchingCallOf = ::Call; +pub type OverArchingCallOf = ::RuntimeCall; /// The asset transactor of our executor pub type AssetTransactorOf = <::XcmConfig as XcmConfig>::AssetTransactor; /// The call type of executor's config. Should eventually resolve to the same overarching call type. -pub type XcmCallOf = <::XcmConfig as XcmConfig>::Call; +pub type XcmCallOf = <::XcmConfig as XcmConfig>::RuntimeCall; pub fn mock_worst_case_holding(depositable_count: u32, max_assets: u32) -> MultiAssets { let fungibles_amount: u128 = 100; diff --git a/xcm/pallet-xcm-benchmarks/src/mock.rs b/xcm/pallet-xcm-benchmarks/src/mock.rs index 718f232f0779..61f8ea4e0926 100644 --- a/xcm/pallet-xcm-benchmarks/src/mock.rs +++ b/xcm/pallet-xcm-benchmarks/src/mock.rs @@ -15,7 +15,8 @@ // along with Polkadot. If not, see . use crate::*; -use frame_support::{parameter_types, traits::ContainsPair, weights::Weight}; +use frame_support::{parameter_types, traits::ContainsPair}; +use xcm::latest::Weight as XCMWeight; // An xcm sender/receiver akin to > /dev/null pub struct DevNull; @@ -38,9 +39,9 @@ impl xcm_executor::traits::OnResponse for DevNull { _: u64, _: Option<&MultiLocation>, _: Response, - _: Weight, + _: XCMWeight, _: &XcmContext, - ) -> Weight { + ) -> XCMWeight { 0 } } @@ -62,7 +63,7 @@ impl xcm_executor::traits::Convert for AccountIdConverter { parameter_types! { pub UniversalLocation: InteriorMultiLocation = Junction::Parachain(101).into(); - pub UnitWeightCost: Weight = 10; + pub UnitWeightCost: u64 = 10; pub WeightPrice: (AssetId, u128) = (Concrete(Here.into()), 1_000_000); } diff --git a/xcm/pallet-xcm-benchmarks/template.hbs b/xcm/pallet-xcm-benchmarks/template.hbs index 8a543316f89e..bd1c9241e64f 100644 --- a/xcm/pallet-xcm-benchmarks/template.hbs +++ b/xcm/pallet-xcm-benchmarks/template.hbs @@ -44,22 +44,22 @@ impl WeightInfo { {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - ({{underscore benchmark.base_weight}} as Weight) + Weight::from_ref_time({{underscore benchmark.base_weight}} as u64) {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + .saturating_add(Weight::from_ref_time({{underscore cw.slope}} as u64).saturating_mul({{cw.name}} as u64)) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight)) + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as u64)) {{/if}} {{#each benchmark.component_reads as |cr|}} - .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as u64).saturating_mul({{cr.name}} as u64))) {{/each}} {{#if (ne benchmark.base_writes "0")}} - .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as Weight)) + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}} as u64)) {{/if}} {{#each benchmark.component_writes as |cw|}} - .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as u64).saturating_mul({{cw.name}} as u64))) {{/each}} } {{/each}} diff --git a/xcm/pallet-xcm/Cargo.toml b/xcm/pallet-xcm/Cargo.toml index b7f7782e261a..ba562fbecafa 100644 --- a/xcm/pallet-xcm/Cargo.toml +++ b/xcm/pallet-xcm/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Parity Technologies "] edition = "2021" name = "pallet-xcm" -version = "0.9.28" +version = "0.9.31" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } @@ -10,20 +10,20 @@ scale-info = { version = "2.1.2", default-features = false, features = ["derive" serde = { version = "1.0.137", optional = true, features = ["derive"] } log = { version = "0.4.17", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.28" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.28" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.31" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.31" } xcm = { path = "..", default-features = false } xcm-executor = { path = "../xcm-executor", default-features = false } [dev-dependencies] -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } polkadot-runtime-parachains = { path = "../../runtime/parachains" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } xcm-builder = { path = "../xcm-builder" } polkadot-parachain = { path = "../../parachain" } @@ -35,6 +35,7 @@ std = [ "serde", "sp-std/std", "sp-core/std", + "sp-io/std", "sp-runtime/std", "frame-support/std", "frame-system/std", @@ -44,3 +45,4 @@ std = [ runtime-benchmarks = [ "frame-system/runtime-benchmarks" ] +try-runtime = ["frame-support/try-runtime"] diff --git a/xcm/pallet-xcm/src/lib.rs b/xcm/pallet-xcm/src/lib.rs index a07c248dc6eb..2913ff55dee9 100644 --- a/xcm/pallet-xcm/src/lib.rs +++ b/xcm/pallet-xcm/src/lib.rs @@ -29,11 +29,16 @@ use frame_support::traits::{ }; use scale_info::TypeInfo; use sp_runtime::{ - traits::{BadOrigin, Saturating, Zero}, + traits::{ + AccountIdConversion, BadOrigin, BlakeTwo256, BlockNumberProvider, Hash, Saturating, Zero, + }, RuntimeDebug, }; use sp_std::{boxed::Box, marker::PhantomData, prelude::*, result::Result, vec}; -use xcm::{latest::QueryResponseInfo, prelude::*}; +use xcm::{ + latest::{QueryResponseInfo, Weight as XcmWeight}, + prelude::*, +}; use xcm_executor::traits::{Convert, ConvertOrigin}; use frame_support::{ @@ -44,7 +49,6 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; pub use pallet::*; -use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, BlockNumberProvider, Hash}; use xcm_executor::{ traits::{ ClaimAssets, DropAssets, MatchesFungible, OnResponse, VersionChangeNotifier, WeightBounds, @@ -81,7 +85,7 @@ pub mod pallet { /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A lockable currency. // TODO: We should really use a trait which can handle multiple currencies. @@ -92,7 +96,10 @@ pub mod pallet { /// Required origin for sending XCM messages. If successful, it resolves to `MultiLocation` /// which exists as an interior location within this chain's XCM context. - type SendXcmOrigin: EnsureOrigin<::Origin, Success = MultiLocation>; + type SendXcmOrigin: EnsureOrigin< + ::RuntimeOrigin, + Success = MultiLocation, + >; /// The type used to actually dispatch an XCM to its destination. type XcmRouter: SendXcm; @@ -100,13 +107,16 @@ pub mod pallet { /// Required origin for executing XCM messages, including the teleport functionality. If successful, /// then it resolves to `MultiLocation` which exists as an interior location within this chain's XCM /// context. - type ExecuteXcmOrigin: EnsureOrigin<::Origin, Success = MultiLocation>; + type ExecuteXcmOrigin: EnsureOrigin< + ::RuntimeOrigin, + Success = MultiLocation, + >; /// Our XCM filter which messages to be executed using `XcmExecutor` must pass. - type XcmExecuteFilter: Contains<(MultiLocation, Xcm<::Call>)>; + type XcmExecuteFilter: Contains<(MultiLocation, Xcm<::RuntimeCall>)>; /// Something to execute an XCM message. - type XcmExecutor: ExecuteXcm<::Call>; + type XcmExecutor: ExecuteXcm<::RuntimeCall>; /// Our XCM filter which messages to be teleported using the dedicated extrinsic must pass. type XcmTeleportFilter: Contains<(MultiLocation, Vec)>; @@ -115,19 +125,22 @@ pub mod pallet { type XcmReserveTransferFilter: Contains<(MultiLocation, Vec)>; /// Means of measuring the weight consumed by an XCM message locally. - type Weigher: WeightBounds<::Call>; + type Weigher: WeightBounds<::RuntimeCall>; /// This chain's Universal Location. type UniversalLocation: Get; - /// The outer `Origin` type. - type Origin: From + From<::Origin>; + /// The runtime `Origin` type. + type RuntimeOrigin: From + From<::RuntimeOrigin>; - /// The outer `Call` type. - type Call: Parameter + /// The runtime `Call` type. + type RuntimeCall: Parameter + GetDispatchInfo - + IsType<::Call> - + Dispatchable::Origin, PostInfo = PostDispatchInfo>; + + IsType<::RuntimeCall> + + Dispatchable< + RuntimeOrigin = ::RuntimeOrigin, + PostInfo = PostDispatchInfo, + >; const VERSION_DISCOVERY_QUEUE_SIZE: u32; @@ -268,6 +281,10 @@ pub mod pallet { /// /// \[ paying location, fees \] FeesPaid(MultiLocation, MultiAssets), + /// Some assets have been claimed from an asset trap + /// + /// \[ hash, origin, assets \] + AssetsClaimed(H256, MultiLocation, VersionedMultiAssets), } #[pallet::origin] @@ -523,7 +540,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(_n: BlockNumberFor) -> Weight { - let mut weight_used = 0; + let mut weight_used = Weight::zero(); if let Some(migration) = CurrentMigration::::get() { // Consume 10% of block at most let max_weight = T::BlockWeights::get().max_block / 10; @@ -558,7 +575,7 @@ pub mod pallet { // Start a migration (this happens before on_initialize so it'll happen later in this // block, which should be good enough)... CurrentMigration::::put(VersionMigrationStage::default()); - T::DbWeight::get().write + T::DbWeight::get().writes(1) } } @@ -621,7 +638,7 @@ pub mod pallet { on_chain_storage_version, ); // calculate and return migration weights - T::DbWeight::get().reads_writes(count as Weight + 1, count as Weight + 1) + T::DbWeight::get().reads_writes(count as u64 + 1, count as u64 + 1) } else { log::warn!( target: "runtime::xcm", @@ -682,9 +699,9 @@ pub mod pallet { xcm: Xcm(vec![]), }, ]); - T::Weigher::weight(&mut message).map_or(Weight::max_value(), |w| 100_000_000.saturating_add(w)) + T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w))) }, - _ => Weight::max_value(), + _ => Weight::MAX, } })] pub fn teleport_assets( @@ -720,9 +737,9 @@ pub mod pallet { let mut message = Xcm(vec![ TransferReserveAsset { assets, dest, xcm: Xcm(vec![]) } ]); - T::Weigher::weight(&mut message).map_or(Weight::max_value(), |w| 100_000_000.saturating_add(w)) + T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w))) }, - _ => Weight::max_value(), + _ => Weight::MAX, } })] pub fn reserve_transfer_assets( @@ -753,11 +770,11 @@ pub mod pallet { /// /// NOTE: A successful return to this does *not* imply that the `msg` was executed successfully /// to completion; only that *some* of it was executed. - #[pallet::weight(max_weight.saturating_add(100_000_000u64))] + #[pallet::weight(Weight::from_ref_time(max_weight.saturating_add(100_000_000u64)))] pub fn execute( origin: OriginFor, - message: Box::Call>>, - max_weight: Weight, + message: Box::RuntimeCall>>, + max_weight: XcmWeight, ) -> DispatchResultWithPostInfo { let origin_location = T::ExecuteXcmOrigin::ensure_origin(origin)?; let hash = message.using_encoded(sp_io::hashing::blake2_256); @@ -769,8 +786,8 @@ pub mod pallet { origin_location, message, hash, - max_weight, - max_weight, + max_weight, //.ref_time(), + max_weight, //.ref_time(), ); let result = Ok(Some(outcome.weight_used().saturating_add(100_000_000)).into()); Self::deposit_event(Event::Attempted(outcome)); @@ -884,9 +901,9 @@ pub mod pallet { let mut message = Xcm(vec![ TransferReserveAsset { assets, dest, xcm: Xcm(vec![]) } ]); - T::Weigher::weight(&mut message).map_or(Weight::max_value(), |w| 100_000_000.saturating_add(w)) + T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w))) }, - _ => Weight::max_value(), + _ => Weight::MAX, } })] pub fn limited_reserve_transfer_assets( @@ -934,9 +951,9 @@ pub mod pallet { WithdrawAsset(assets), InitiateTeleport { assets: Wild(All), dest, xcm: Xcm(vec![]) }, ]); - T::Weigher::weight(&mut message).map_or(Weight::max_value(), |w| 100_000_000.saturating_add(w)) + T::Weigher::weight(&mut message).map_or(Weight::MAX, |w| Weight::from_ref_time(100_000_000.saturating_add(w))) }, - _ => Weight::max_value(), + _ => Weight::MAX, } })] pub fn limited_teleport_assets( @@ -1086,18 +1103,16 @@ impl Pallet { mut stage: VersionMigrationStage, weight_cutoff: Weight, ) -> (Weight, Option) { - let mut weight_used = 0; + let mut weight_used = Weight::zero(); // TODO: Correct weights for the components of this: - let todo_sv_migrate_weight: Weight = T::DbWeight::get().read + T::DbWeight::get().write; - let todo_vn_migrate_weight: Weight = T::DbWeight::get().read + T::DbWeight::get().write; - let todo_vnt_already_notified_weight: Weight = T::DbWeight::get().read; - let todo_vnt_notify_weight: Weight = T::DbWeight::get().read + T::DbWeight::get().write * 3; - let todo_vnt_migrate_weight: Weight = T::DbWeight::get().read + T::DbWeight::get().write; - let todo_vnt_migrate_fail_weight: Weight = - T::DbWeight::get().read + T::DbWeight::get().write; - let todo_vnt_notify_migrate_weight: Weight = - T::DbWeight::get().read + T::DbWeight::get().write * 3; + let todo_sv_migrate_weight: Weight = T::DbWeight::get().reads_writes(1, 1); + let todo_vn_migrate_weight: Weight = T::DbWeight::get().reads_writes(1, 1); + let todo_vnt_already_notified_weight: Weight = T::DbWeight::get().reads(1); + let todo_vnt_notify_weight: Weight = T::DbWeight::get().reads_writes(1, 3); + let todo_vnt_migrate_weight: Weight = T::DbWeight::get().reads_writes(1, 1); + let todo_vnt_migrate_fail_weight: Weight = T::DbWeight::get().reads_writes(1, 1); + let todo_vnt_notify_migrate_weight: Weight = T::DbWeight::get().reads_writes(1, 3); use VersionMigrationStage::*; @@ -1110,7 +1125,7 @@ impl Pallet { SupportedVersion::::insert(XCM_VERSION, new_key, value); } weight_used.saturating_accrue(todo_sv_migrate_weight); - if weight_used >= weight_cutoff { + if weight_used.any_gte(weight_cutoff) { return (weight_used, Some(stage)) } } @@ -1124,7 +1139,7 @@ impl Pallet { VersionNotifiers::::insert(XCM_VERSION, new_key, value); } weight_used.saturating_accrue(todo_vn_migrate_weight); - if weight_used >= weight_cutoff { + if weight_used.any_gte(weight_cutoff) { return (weight_used, Some(stage)) } } @@ -1166,7 +1181,7 @@ impl Pallet { }; Self::deposit_event(event); weight_used.saturating_accrue(todo_vnt_notify_weight); - if weight_used >= weight_cutoff { + if weight_used.any_gte(weight_cutoff) { let last = Some(iter.last_raw_key().into()); return (weight_used, Some(NotifyCurrentTargets(last))) } @@ -1182,7 +1197,7 @@ impl Pallet { Err(()) => { Self::deposit_event(Event::NotifyTargetMigrationFail(old_key, value.0)); weight_used.saturating_accrue(todo_vnt_migrate_fail_weight); - if weight_used >= weight_cutoff { + if weight_used.any_gte(weight_cutoff) { return (weight_used, Some(stage)) } continue @@ -1216,7 +1231,7 @@ impl Pallet { Self::deposit_event(event); weight_used.saturating_accrue(todo_vnt_notify_migrate_weight); } - if weight_used >= weight_cutoff { + if weight_used.any_gte(weight_cutoff) { return (weight_used, Some(stage)) } } @@ -1366,15 +1381,15 @@ impl Pallet { pub fn report_outcome_notify( message: &mut Xcm<()>, responder: impl Into, - notify: impl Into<::Call>, + notify: impl Into<::RuntimeCall>, timeout: T::BlockNumber, ) -> Result<(), XcmError> { let responder = responder.into(); let destination = T::UniversalLocation::get() .invert_target(&responder) .map_err(|()| XcmError::LocationNotInvertible)?; - let notify: ::Call = notify.into(); - let max_weight = notify.get_dispatch_info().weight; + let notify: ::RuntimeCall = notify.into(); + let max_weight = notify.get_dispatch_info().weight.ref_time(); let query_id = Self::new_notify_query(responder, notify, timeout, Here); let response_info = QueryResponseInfo { destination, query_id, max_weight }; let report_error = Xcm(vec![ReportError(response_info)]); @@ -1395,7 +1410,7 @@ impl Pallet { /// which will call a dispatchable when a response happens. pub fn new_notify_query( responder: impl Into, - notify: impl Into<::Call>, + notify: impl Into<::RuntimeCall>, timeout: T::BlockNumber, match_querier: impl Into, ) -> u64 { @@ -1471,7 +1486,7 @@ impl xcm_executor::traits::Enact for LockTicket { None => { locks .try_push((self.amount, self.unlocker.clone().into())) - .map_err(|()| UnexpectedState)?; + .map_err(|(_balance, _location)| UnexpectedState)?; }, } LockedFungibles::::insert(&self.sovereign_account, locks); @@ -1636,10 +1651,10 @@ impl xcm_executor::traits::AssetLock for Pallet { } impl WrapVersion for Pallet { - fn wrap_version( + fn wrap_version( dest: &MultiLocation, - xcm: impl Into>, - ) -> Result, ()> { + xcm: impl Into>, + ) -> Result, ()> { SupportedVersion::::get(XCM_VERSION, LatestVersionedMultiLocation(dest)) .or_else(|| { Self::note_unknown_version(dest); @@ -1702,7 +1717,7 @@ impl VersionChangeNotifier for Pallet { } impl DropAssets for Pallet { - fn drop_assets(origin: &MultiLocation, assets: Assets, _context: &XcmContext) -> Weight { + fn drop_assets(origin: &MultiLocation, assets: Assets, _context: &XcmContext) -> u64 { if assets.is_empty() { return 0 } @@ -1732,12 +1747,13 @@ impl ClaimAssets for Pallet { (0, Here) => (), _ => return false, }; - let hash = BlakeTwo256::hash_of(&(origin, versioned)); + let hash = BlakeTwo256::hash_of(&(origin, versioned.clone())); match AssetTraps::::get(hash) { 0 => return false, 1 => AssetTraps::::remove(hash), n => AssetTraps::::insert(hash, n - 1), } + Self::deposit_event(Event::AssetsClaimed(hash, origin.clone(), versioned)); return true } } @@ -1767,9 +1783,9 @@ impl OnResponse for Pallet { query_id: QueryId, querier: Option<&MultiLocation>, response: Response, - max_weight: Weight, + max_weight: u64, _context: &XcmContext, - ) -> Weight { + ) -> u64 { match (response, Queries::::get(query_id)) { ( Response::Version(v), @@ -1863,18 +1879,18 @@ impl OnResponse for Pallet { // be built by `(pallet_index: u8, call_index: u8, QueryId, Response)`. // So we just encode that and then re-encode to a real Call. let bare = (pallet_index, call_index, query_id, response); - if let Ok(call) = - bare.using_encoded(|mut bytes| ::Call::decode(&mut bytes)) - { + if let Ok(call) = bare.using_encoded(|mut bytes| { + ::RuntimeCall::decode(&mut bytes) + }) { Queries::::remove(query_id); let weight = call.get_dispatch_info().weight; - if weight > max_weight { + if weight.ref_time() > max_weight { let e = Event::NotifyOverweight( query_id, pallet_index, call_index, weight, - max_weight, + Weight::from_ref_time(max_weight), ); Self::deposit_event(e); return 0 @@ -1899,6 +1915,7 @@ impl OnResponse for Pallet { }, } .unwrap_or(weight) + .ref_time() } else { let e = Event::NotifyDecodeFailed(query_id, pallet_index, call_index); Self::deposit_event(e); @@ -1983,8 +2000,8 @@ where } #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> O { - O::from(Origin::Xcm(Here.into())) + fn try_successful_origin() -> Result { + Ok(O::from(Origin::Xcm(Here.into()))) } } @@ -2008,19 +2025,21 @@ where } #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> O { - O::from(Origin::Response(Here.into())) + fn try_successful_origin() -> Result { + Ok(O::from(Origin::Response(Here.into()))) } } /// A simple passthrough where we reuse the `MultiLocation`-typed XCM origin as the inner value of /// this crate's `Origin::Xcm` value. -pub struct XcmPassthrough(PhantomData); -impl> ConvertOrigin for XcmPassthrough { +pub struct XcmPassthrough(PhantomData); +impl> ConvertOrigin + for XcmPassthrough +{ fn convert_origin( origin: impl Into, kind: OriginKind, - ) -> Result { + ) -> Result { let origin = origin.into(); match kind { OriginKind::Xcm => Ok(crate::Origin::Xcm(origin).into()), diff --git a/xcm/pallet-xcm/src/mock.rs b/xcm/pallet-xcm/src/mock.rs index 2a6018ac35f1..6f11f5f6fcc3 100644 --- a/xcm/pallet-xcm/src/mock.rs +++ b/xcm/pallet-xcm/src/mock.rs @@ -18,7 +18,6 @@ use codec::Encode; use frame_support::{ construct_runtime, parameter_types, traits::{Everything, Nothing}, - weights::Weight, }; use polkadot_parachain::primitives::Id as ParaId; use polkadot_runtime_parachains::origin; @@ -56,10 +55,10 @@ pub mod pallet_test_notifier { #[pallet::config] pub trait Config: frame_system::Config + crate::Config { - type Event: IsType<::Event> + From>; - type Origin: IsType<::Origin> - + Into::Origin>>; - type Call: IsType<::Call> + From>; + type RuntimeEvent: IsType<::RuntimeEvent> + From>; + type RuntimeOrigin: IsType<::RuntimeOrigin> + + Into::RuntimeOrigin>>; + type RuntimeCall: IsType<::RuntimeCall> + From>; } #[pallet::event] @@ -106,7 +105,7 @@ pub mod pallet_test_notifier { Call::::notification_received { query_id: 0, response: Default::default() }; let qid = crate::Pallet::::new_notify_query( Junction::AccountId32 { network: None, id }, - ::Call::from(call), + ::RuntimeCall::from(call), 100u32.into(), querier, ); @@ -120,7 +119,7 @@ pub mod pallet_test_notifier { query_id: QueryId, response: Response, ) -> DispatchResult { - let responder = ensure_response(::Origin::from(origin))?; + let responder = ensure_response(::RuntimeOrigin::from(origin))?; Self::deposit_event(Event::::ResponseReceived(responder, query_id, response)); Ok(()) } @@ -198,8 +197,8 @@ parameter_types! { } impl frame_system::Config for Test { - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -207,7 +206,7 @@ impl frame_system::Config for Test { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); type BlockLength = (); @@ -233,7 +232,7 @@ parameter_types! { impl pallet_balances::Config for Test { type MaxLocks = MaxLocks; type Balance = Balance; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -246,7 +245,7 @@ parameter_types! { pub const RelayLocation: MultiLocation = Here.into_location(); pub const AnyNetwork: Option = None; pub UniversalLocation: InteriorMultiLocation = Here; - pub UnitWeightCost: Weight = 1_000; + pub UnitWeightCost: u64 = 1_000; } pub type SovereignAccountOf = @@ -256,14 +255,14 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter, SovereignAccountOf, AccountId, ()>; type LocalOriginConverter = ( - SovereignSignedViaLocation, - ChildParachainAsNative, - SignedAccountId32AsNative, - ChildSystemParachainAsSuperuser, + SovereignSignedViaLocation, + ChildParachainAsNative, + SignedAccountId32AsNative, + ChildSystemParachainAsSuperuser, ); parameter_types! { - pub const BaseXcmWeight: Weight = 1_000; + pub const BaseXcmWeight: u64 = 1_000; pub CurrencyPerSecond: (AssetId, u128) = (Concrete(RelayLocation::get()), 1); pub TrustedAssets: (MultiAssetFilter, MultiLocation) = (All.into(), Here.into()); pub const MaxInstructions: u32 = 100; @@ -279,7 +278,7 @@ pub type Barrier = ( pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { - type Call = Call; + type RuntimeCall = RuntimeCall; type XcmSender = TestSendXcm; type AssetTransactor = LocalAssetTransactor; type OriginConverter = LocalOriginConverter; @@ -287,7 +286,7 @@ impl xcm_executor::Config for XcmConfig { type IsTeleporter = Case; type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; @@ -300,27 +299,28 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; } -pub type LocalOriginToLocation = SignedToAccountId32; +pub type LocalOriginToLocation = SignedToAccountId32; parameter_types! { pub static AdvertisedXcmVersion: pallet_xcm::XcmVersion = 3; } impl pallet_xcm::Config for Test { - type Event = Event; - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + type RuntimeEvent = RuntimeEvent; + type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = (TestSendXcmErrX8, TestSendXcm); - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; + type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmExecuteFilter = Everything; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = AdvertisedXcmVersion; type TrustedLockers = (); @@ -333,16 +333,16 @@ impl pallet_xcm::Config for Test { impl origin::Config for Test {} impl pallet_test_notifier::Config for Test { - type Event = Event; - type Origin = Origin; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; } -pub(crate) fn last_event() -> Event { - System::events().pop().expect("Event expected").event +pub(crate) fn last_event() -> RuntimeEvent { + System::events().pop().expect("RuntimeEvent expected").event } -pub(crate) fn last_events(n: usize) -> Vec { +pub(crate) fn last_events(n: usize) -> Vec { System::events().into_iter().map(|e| e.event).rev().take(n).rev().collect() } diff --git a/xcm/pallet-xcm/src/tests.rs b/xcm/pallet-xcm/src/tests.rs index da60cfb15ab4..3d5216573adb 100644 --- a/xcm/pallet-xcm/src/tests.rs +++ b/xcm/pallet-xcm/src/tests.rs @@ -21,6 +21,7 @@ use crate::{ use frame_support::{ assert_noop, assert_ok, traits::{Currency, Hooks}, + weights::Weight, }; use polkadot_parachain::primitives::Id as ParaId; use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, Hash}; @@ -49,7 +50,7 @@ fn report_outcome_notify_works() { query_id: 0, response: Default::default(), }; - let notify = Call::TestNotifier(call); + let notify = RuntimeCall::TestNotifier(call); new_test_ext_with_balances(balances).execute_with(|| { XcmPallet::report_outcome_notify( &mut message, @@ -91,12 +92,12 @@ fn report_outcome_notify_works() { assert_eq!( last_events(2), vec![ - Event::TestNotifier(pallet_test_notifier::Event::ResponseReceived( + RuntimeEvent::TestNotifier(pallet_test_notifier::Event::ResponseReceived( Parachain(PARA_ID).into(), 0, Response::ExecutionResult(None), )), - Event::XcmPallet(crate::Event::Notified(0, 4, 2)), + RuntimeEvent::XcmPallet(crate::Event::Notified(0, 4, 2)), ] ); assert_eq!(crate::Queries::::iter().collect::>(), vec![]); @@ -148,7 +149,10 @@ fn report_outcome_works() { assert_eq!(r, Outcome::Complete(1_000)); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::ResponseReady(0, Response::ExecutionResult(None),)) + RuntimeEvent::XcmPallet(crate::Event::ResponseReady( + 0, + Response::ExecutionResult(None), + )) ); let response = Some((Response::ExecutionResult(None), 1)); @@ -166,7 +170,7 @@ fn custom_querier_works() { let querier: MultiLocation = (Parent, AccountId32 { network: None, id: ALICE.into() }).into(); - let r = TestNotifier::prepare_new_query(Origin::signed(ALICE), querier.clone()); + let r = TestNotifier::prepare_new_query(RuntimeOrigin::signed(ALICE), querier.clone()); assert_eq!(r, Ok(())); let status = QueryStatus::Pending { responder: MultiLocation::from(AccountId32 { network: None, id: ALICE.into() }).into(), @@ -194,7 +198,7 @@ fn custom_querier_works() { assert_eq!(r, Outcome::Complete(1_000)); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::InvalidQuerier( + RuntimeEvent::XcmPallet(crate::Event::InvalidQuerier( AccountId32 { network: None, id: ALICE.into() }.into(), 0, querier.clone(), @@ -220,7 +224,7 @@ fn custom_querier_works() { assert_eq!(r, Outcome::Complete(1_000)); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::InvalidQuerier( + RuntimeEvent::XcmPallet(crate::Event::InvalidQuerier( AccountId32 { network: None, id: ALICE.into() }.into(), 0, querier.clone(), @@ -245,7 +249,10 @@ fn custom_querier_works() { assert_eq!(r, Outcome::Complete(1_000)); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::ResponseReady(0, Response::ExecutionResult(None),)) + RuntimeEvent::XcmPallet(crate::Event::ResponseReady( + 0, + Response::ExecutionResult(None), + )) ); let response = Some((Response::ExecutionResult(None), 1)); @@ -272,7 +279,11 @@ fn send_works() { ]); let versioned_dest = Box::new(RelayLocation::get().into()); let versioned_message = Box::new(VersionedXcm::from(message.clone())); - assert_ok!(XcmPallet::send(Origin::signed(ALICE), versioned_dest, versioned_message)); + assert_ok!(XcmPallet::send( + RuntimeOrigin::signed(ALICE), + versioned_dest, + versioned_message + )); assert_eq!( sent_xcm(), vec![( @@ -285,7 +296,7 @@ fn send_works() { ); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::Sent(sender, RelayLocation::get(), message)) + RuntimeEvent::XcmPallet(crate::Event::Sent(sender, RelayLocation::get(), message)) ); }); } @@ -310,7 +321,7 @@ fn send_fails_when_xcm_router_blocks() { ]); assert_noop!( XcmPallet::send( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Box::new(MultiLocation::ancestor(8).into()), Box::new(VersionedXcm::from(message.clone())), ), @@ -334,7 +345,7 @@ fn teleport_assets_works() { assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::teleport_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Box::new(RelayLocation::get().into()), Box::new(dest.clone().into()), Box::new((Here, SEND_AMOUNT).into()), @@ -357,7 +368,7 @@ fn teleport_assets_works() { let _check_v2_ok: xcm::v2::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) + RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) ); }); } @@ -377,7 +388,7 @@ fn limmited_teleport_assets_works() { assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::limited_teleport_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Box::new(RelayLocation::get().into()), Box::new(dest.clone().into()), Box::new((Here, SEND_AMOUNT).into()), @@ -401,7 +412,7 @@ fn limmited_teleport_assets_works() { let _check_v2_ok: xcm::v2::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) + RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) ); }); } @@ -421,7 +432,7 @@ fn unlimmited_teleport_assets_works() { assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); let dest: MultiLocation = AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::limited_teleport_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Box::new(RelayLocation::get().into()), Box::new(dest.clone().into()), Box::new((Here, SEND_AMOUNT).into()), @@ -443,7 +454,7 @@ fn unlimmited_teleport_assets_works() { ); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) + RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) ); }); } @@ -463,7 +474,7 @@ fn reserve_transfer_assets_works() { let dest: MultiLocation = Junction::AccountId32 { network: None, id: ALICE.into() }.into(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_ok!(XcmPallet::reserve_transfer_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Box::new(Parachain(PARA_ID).into()), Box::new(dest.clone().into()), Box::new((Here, SEND_AMOUNT).into()), @@ -490,7 +501,7 @@ fn reserve_transfer_assets_works() { let _check_v2_ok: xcm::v2::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) + RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) ); }); } @@ -510,7 +521,7 @@ fn limited_reserve_transfer_assets_works() { let dest: MultiLocation = Junction::AccountId32 { network: None, id: ALICE.into() }.into(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_ok!(XcmPallet::limited_reserve_transfer_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Box::new(Parachain(PARA_ID).into()), Box::new(dest.clone().into()), Box::new((Here, SEND_AMOUNT).into()), @@ -538,7 +549,7 @@ fn limited_reserve_transfer_assets_works() { let _check_v2_ok: xcm::v2::Xcm<()> = versioned_sent.try_into().unwrap(); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) + RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) ); }); } @@ -558,7 +569,7 @@ fn unlimited_reserve_transfer_assets_works() { let dest: MultiLocation = Junction::AccountId32 { network: None, id: ALICE.into() }.into(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_ok!(XcmPallet::limited_reserve_transfer_assets( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Box::new(Parachain(PARA_ID).into()), Box::new(dest.clone().into()), Box::new((Here, SEND_AMOUNT).into()), @@ -584,7 +595,7 @@ fn unlimited_reserve_transfer_assets_works() { ); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) + RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) ); }); } @@ -604,7 +615,7 @@ fn execute_withdraw_to_deposit_works() { let dest: MultiLocation = Junction::AccountId32 { network: None, id: BOB.into() }.into(); assert_eq!(Balances::total_balance(&ALICE), INITIAL_BALANCE); assert_ok!(XcmPallet::execute( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Box::new(VersionedXcm::from(Xcm(vec![ WithdrawAsset((Here, SEND_AMOUNT).into()), buy_execution((Here, SEND_AMOUNT)), @@ -616,7 +627,7 @@ fn execute_withdraw_to_deposit_works() { assert_eq!(Balances::total_balance(&BOB), SEND_AMOUNT); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) + RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete(weight))) ); }); } @@ -630,7 +641,7 @@ fn trapped_assets_can_be_claimed() { let dest: MultiLocation = Junction::AccountId32 { network: None, id: BOB.into() }.into(); assert_ok!(XcmPallet::execute( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Box::new(VersionedXcm::from(Xcm(vec![ WithdrawAsset((Here, SEND_AMOUNT).into()), buy_execution((Here, SEND_AMOUNT)), @@ -651,8 +662,8 @@ fn trapped_assets_can_be_claimed() { assert_eq!( last_events(2), vec![ - Event::XcmPallet(crate::Event::AssetsTrapped(hash.clone(), source, vma)), - Event::XcmPallet(crate::Event::Attempted(Outcome::Complete( + RuntimeEvent::XcmPallet(crate::Event::AssetsTrapped(hash.clone(), source, vma)), + RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Complete( 5 * BaseXcmWeight::get() ))) ] @@ -665,7 +676,7 @@ fn trapped_assets_can_be_claimed() { let weight = 3 * BaseXcmWeight::get(); assert_ok!(XcmPallet::execute( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Box::new(VersionedXcm::from(Xcm(vec![ ClaimAsset { assets: (Here, SEND_AMOUNT).into(), ticket: Here.into() }, buy_execution((Here, SEND_AMOUNT)), @@ -680,7 +691,7 @@ fn trapped_assets_can_be_claimed() { let weight = 3 * BaseXcmWeight::get(); assert_ok!(XcmPallet::execute( - Origin::signed(ALICE), + RuntimeOrigin::signed(ALICE), Box::new(VersionedXcm::from(Xcm(vec![ ClaimAsset { assets: (Here, SEND_AMOUNT).into(), ticket: Here.into() }, buy_execution((Here, SEND_AMOUNT)), @@ -690,7 +701,7 @@ fn trapped_assets_can_be_claimed() { )); assert_eq!( last_event(), - Event::XcmPallet(crate::Event::Attempted(Outcome::Incomplete( + RuntimeEvent::XcmPallet(crate::Event::Attempted(Outcome::Incomplete( BaseXcmWeight::get(), XcmError::UnknownClaim ))) @@ -711,7 +722,7 @@ fn basic_subscription_works() { new_test_ext_with_balances(vec![]).execute_with(|| { let remote: MultiLocation = Parachain(1000).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( - Origin::root(), + RuntimeOrigin::root(), Box::new(remote.clone().into()), )); @@ -759,13 +770,13 @@ fn subscriptions_increment_id() { new_test_ext_with_balances(vec![]).execute_with(|| { let remote: MultiLocation = Parachain(1000).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( - Origin::root(), + RuntimeOrigin::root(), Box::new(remote.clone().into()), )); let remote2: MultiLocation = Parachain(1001).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( - Origin::root(), + RuntimeOrigin::root(), Box::new(remote2.clone().into()), )); @@ -790,12 +801,12 @@ fn double_subscription_fails() { new_test_ext_with_balances(vec![]).execute_with(|| { let remote: MultiLocation = Parachain(1000).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( - Origin::root(), + RuntimeOrigin::root(), Box::new(remote.clone().into()), )); assert_noop!( XcmPallet::force_subscribe_version_notify( - Origin::root(), + RuntimeOrigin::root(), Box::new(remote.clone().into()) ), Error::::AlreadySubscribed, @@ -808,16 +819,16 @@ fn unsubscribe_works() { new_test_ext_with_balances(vec![]).execute_with(|| { let remote: MultiLocation = Parachain(1000).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( - Origin::root(), + RuntimeOrigin::root(), Box::new(remote.clone().into()), )); assert_ok!(XcmPallet::force_unsubscribe_version_notify( - Origin::root(), + RuntimeOrigin::root(), Box::new(remote.clone().into()) )); assert_noop!( XcmPallet::force_unsubscribe_version_notify( - Origin::root(), + RuntimeOrigin::root(), Box::new(remote.clone().into()) ), Error::::NoSubscription, @@ -963,7 +974,7 @@ fn subscriber_side_subscription_works() { new_test_ext_with_balances(vec![]).execute_with(|| { let remote: MultiLocation = Parachain(1000).into(); assert_ok!(XcmPallet::force_subscribe_version_notify( - Origin::root(), + RuntimeOrigin::root(), Box::new(remote.clone().into()), )); take_sent_xcm(); @@ -1017,7 +1028,7 @@ fn auto_subscription_works() { let remote_v2: MultiLocation = Parachain(1000).into(); let remote_v3: MultiLocation = Parachain(1001).into(); - assert_ok!(XcmPallet::force_default_xcm_version(Origin::root(), Some(2))); + assert_ok!(XcmPallet::force_default_xcm_version(RuntimeOrigin::root(), Some(2))); // Wrapping a version for a destination we don't know elicits a subscription. let msg_v2 = xcm::v2::Xcm::<()>(vec![xcm::v2::Instruction::Trap(0)]); @@ -1132,7 +1143,7 @@ fn subscription_side_upgrades_work_with_multistage_notify() { let mut counter = 0; while let Some(migration) = maybe_migration.take() { counter += 1; - let (_, m) = XcmPallet::check_xcm_version_change(migration, 0); + let (_, m) = XcmPallet::check_xcm_version_change(migration, Weight::zero()); maybe_migration = m; } assert_eq!(counter, 4); diff --git a/xcm/procedural/Cargo.toml b/xcm/procedural/Cargo.toml index c779ab788a4a..14a7d068db68 100644 --- a/xcm/procedural/Cargo.toml +++ b/xcm/procedural/Cargo.toml @@ -1,14 +1,14 @@ [package] authors = ["Parity Technologies "] name = "xcm-procedural" -version = "0.9.28" +version = "0.9.31" edition = "2021" [lib] proc-macro = true [dependencies] -proc-macro2 = "1.0.40" +proc-macro2 = "1.0.43" quote = "1.0.20" syn = "1.0.95" Inflector = "0.11.4" diff --git a/xcm/src/lib.rs b/xcm/src/lib.rs index 5e3a0a6fe6dd..678a825b6608 100644 --- a/xcm/src/lib.rs +++ b/xcm/src/lib.rs @@ -353,12 +353,12 @@ versioned_type! { #[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] #[codec(encode_bound())] #[codec(decode_bound())] -#[scale_info(bounds(), skip_type_params(Call))] -pub enum VersionedXcm { - #[codec(index = 1)] - V2(v2::Xcm), +#[scale_info(bounds(), skip_type_params(RuntimeCall))] +pub enum VersionedXcm { #[codec(index = 2)] - V3(v3::Xcm), + V2(v2::Xcm), + #[codec(index = 3)] + V3(v3::Xcm), } impl IntoVersion for VersionedXcm { @@ -371,21 +371,21 @@ impl IntoVersion for VersionedXcm { } } -impl From> for VersionedXcm { - fn from(x: v2::Xcm) -> Self { +impl From> for VersionedXcm { + fn from(x: v2::Xcm) -> Self { VersionedXcm::V2(x) } } -impl From> for VersionedXcm { - fn from(x: v3::Xcm) -> Self { +impl From> for VersionedXcm { + fn from(x: v3::Xcm) -> Self { VersionedXcm::V3(x) } } -impl TryFrom> for v2::Xcm { +impl TryFrom> for v2::Xcm { type Error = (); - fn try_from(x: VersionedXcm) -> Result { + fn try_from(x: VersionedXcm) -> Result { use VersionedXcm::*; match x { V2(x) => Ok(x), @@ -407,18 +407,18 @@ impl TryFrom> for v3::Xcm { /// Convert an `Xcm` datum into a `VersionedXcm`, based on a destination `MultiLocation` which will interpret it. pub trait WrapVersion { - fn wrap_version( + fn wrap_version( dest: &latest::MultiLocation, - xcm: impl Into>, - ) -> Result, ()>; + xcm: impl Into>, + ) -> Result, ()>; } /// `()` implementation does nothing with the XCM, just sending with whatever version it was authored as. impl WrapVersion for () { - fn wrap_version( + fn wrap_version( _: &latest::MultiLocation, - xcm: impl Into>, - ) -> Result, ()> { + xcm: impl Into>, + ) -> Result, ()> { Ok(xcm.into()) } } @@ -426,11 +426,11 @@ impl WrapVersion for () { /// `WrapVersion` implementation which attempts to always convert the XCM to version 2 before wrapping it. pub struct AlwaysV2; impl WrapVersion for AlwaysV2 { - fn wrap_version( + fn wrap_version( _: &latest::MultiLocation, - xcm: impl Into>, - ) -> Result, ()> { - Ok(VersionedXcm::::V2(xcm.into().try_into()?)) + xcm: impl Into>, + ) -> Result, ()> { + Ok(VersionedXcm::::V2(xcm.into().try_into()?)) } } diff --git a/xcm/src/v2/junction.rs b/xcm/src/v2/junction.rs index c441981ec381..3a20e7b15c9d 100644 --- a/xcm/src/v2/junction.rs +++ b/xcm/src/v2/junction.rs @@ -18,14 +18,14 @@ use super::{BodyId, BodyPart, Junctions, MultiLocation, NetworkId}; use crate::v3::Junction as NewJunction; -use alloc::vec::Vec; -use parity_scale_codec::{self, Decode, Encode}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; +use sp_runtime::{traits::ConstU32, WeakBoundedVec}; /// A single item in a path to describe the relative location of a consensus system. /// /// Each item assumes a pre-existing location as its context and is defined in terms of it. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum Junction { /// An indexed parachain belonging to and operated by the context. @@ -66,7 +66,7 @@ pub enum Junction { /// Usage will vary widely owing to its generality. /// /// NOTE: Try to avoid using this and instead use a more specific item. - GeneralKey(Vec), + GeneralKey(WeakBoundedVec>), /// The unambiguous child. /// /// Not currently used except as a fallback when deriving ancestry. @@ -92,7 +92,12 @@ impl TryFrom for Junction { Self::AccountKey20 { network: network.try_into()?, key }, PalletInstance(index) => Self::PalletInstance(index), GeneralIndex(id) => Self::GeneralIndex(id), - GeneralKey(key) => Self::GeneralKey(key[..].to_vec()), + GeneralKey(key) => Self::GeneralKey( + key[..] + .to_vec() + .try_into() + .expect("array is of size 32 and so will never be out of bounds; qed"), + ), OnlyChild => Self::OnlyChild, Plurality { id, part } => Self::Plurality { id: id.into(), part: part.into() }, _ => return Err(()), diff --git a/xcm/src/v2/mod.rs b/xcm/src/v2/mod.rs index ba0a2dfc6b3d..d70a08185e28 100644 --- a/xcm/src/v2/mod.rs +++ b/xcm/src/v2/mod.rs @@ -60,8 +60,9 @@ use super::{ use alloc::{vec, vec::Vec}; use core::{fmt::Debug, result}; use derivative::Derivative; -use parity_scale_codec::{self, Decode, Encode}; +use parity_scale_codec::{self, Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; +use sp_runtime::{traits::ConstU32, WeakBoundedVec}; mod junction; mod multiasset; @@ -102,13 +103,13 @@ pub enum OriginKind { } /// A global identifier of an account-bearing consensus system. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum NetworkId { /// Unidentified/any. Any, /// Some named network. - Named(Vec), + Named(WeakBoundedVec>), /// The Polkadot Relay chain Polkadot, /// Kusama. @@ -129,13 +130,13 @@ impl TryInto for Option { } /// An identifier of a pluralistic body. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum BodyId { /// The only body in its context. Unit, /// A named body. - Named(Vec), + Named(WeakBoundedVec>), /// An indexed body. Index(#[codec(compact)] u32), /// The unambiguous executive body (for Polkadot, this would be the Polkadot council). @@ -155,7 +156,12 @@ impl From for BodyId { use NewBodyId::*; match n { Unit => Self::Unit, - Moniker(n) => Self::Named(n[..].to_vec()), + Moniker(n) => Self::Named( + n[..] + .to_vec() + .try_into() + .expect("array size is 4 and so will never be out of bounds; qed"), + ), Index(n) => Self::Index(n), Executive => Self::Executive, Technical => Self::Technical, @@ -166,7 +172,7 @@ impl From for BodyId { } /// A part of a pluralistic body. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum BodyPart { /// The body's declaration, under whatever means it decides. @@ -234,10 +240,10 @@ pub type QueryId = u64; #[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] #[codec(encode_bound())] #[codec(decode_bound())] -#[scale_info(bounds(), skip_type_params(Call))] -pub struct Xcm(pub Vec>); +#[scale_info(bounds(), skip_type_params(RuntimeCall))] +pub struct Xcm(pub Vec>); -impl Xcm { +impl Xcm { /// Create an empty instance. pub fn new() -> Self { Self(vec![]) @@ -264,17 +270,17 @@ impl Xcm { } /// Return the first instruction, if any. - pub fn first(&self) -> Option<&Instruction> { + pub fn first(&self) -> Option<&Instruction> { self.0.first() } /// Return the last instruction, if any. - pub fn last(&self) -> Option<&Instruction> { + pub fn last(&self) -> Option<&Instruction> { self.0.last() } /// Return the only instruction, contained in `Self`, iff only one exists (`None` otherwise). - pub fn only(&self) -> Option<&Instruction> { + pub fn only(&self) -> Option<&Instruction> { if self.0.len() == 1 { self.0.first() } else { @@ -284,7 +290,7 @@ impl Xcm { /// Return the only instruction, contained in `Self`, iff only one exists (returns `self` /// otherwise). - pub fn into_only(mut self) -> core::result::Result, Self> { + pub fn into_only(mut self) -> core::result::Result, Self> { if self.0.len() == 1 { self.0.pop().ok_or(self) } else { @@ -389,8 +395,8 @@ pub type Weight = u64; #[derivative(Clone(bound = ""), Eq(bound = ""), PartialEq(bound = ""), Debug(bound = ""))] #[codec(encode_bound())] #[codec(decode_bound())] -#[scale_info(bounds(), skip_type_params(Call))] -pub enum Instruction { +#[scale_info(bounds(), skip_type_params(RuntimeCall))] +pub enum Instruction { /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into the Holding /// Register. /// @@ -496,7 +502,7 @@ pub enum Instruction { origin_type: OriginKind, #[codec(compact)] require_weight_at_most: u64, - call: DoubleEncoded, + call: DoubleEncoded, }, /// A message to notify about a new incoming HRMP channel. This message is meant to be sent by the @@ -746,7 +752,7 @@ pub enum Instruction { /// Kind: *Instruction* /// /// Errors: None. - SetErrorHandler(Xcm), + SetErrorHandler(Xcm), /// Set the Appendix Register. This is code that should be called after code execution /// (including the error handler if any) is finished. This will be called regardless of whether @@ -762,7 +768,7 @@ pub enum Instruction { /// Kind: *Instruction* /// /// Errors: None. - SetAppendix(Xcm), + SetAppendix(Xcm), /// Clear the Error Register. /// @@ -818,16 +824,16 @@ pub enum Instruction { UnsubscribeVersion, } -impl Xcm { +impl Xcm { pub fn into(self) -> Xcm { Xcm::from(self) } pub fn from(xcm: Xcm) -> Self { - Self(xcm.0.into_iter().map(Instruction::::from).collect()) + Self(xcm.0.into_iter().map(Instruction::::from).collect()) } } -impl Instruction { +impl Instruction { pub fn into(self) -> Instruction { Instruction::from(self) } @@ -878,7 +884,7 @@ impl Instruction { } // TODO: Automate Generation -impl> GetWeight for Instruction { +impl> GetWeight for Instruction { fn weight(&self) -> Weight { use Instruction::*; match self { @@ -953,17 +959,17 @@ impl TryFrom for Response { } // Convert from a v3 XCM to a v2 XCM. -impl TryFrom> for Xcm { +impl TryFrom> for Xcm { type Error = (); - fn try_from(new_xcm: NewXcm) -> result::Result { + fn try_from(new_xcm: NewXcm) -> result::Result { Ok(Xcm(new_xcm.0.into_iter().map(TryInto::try_into).collect::>()?)) } } // Convert from a v3 instruction to a v2 instruction -impl TryFrom> for Instruction { +impl TryFrom> for Instruction { type Error = (); - fn try_from(instruction: NewInstruction) -> result::Result { + fn try_from(instruction: NewInstruction) -> result::Result { use NewInstruction::*; Ok(match instruction { WithdrawAsset(assets) => Self::WithdrawAsset(assets.try_into()?), diff --git a/xcm/src/v2/multilocation.rs b/xcm/src/v2/multilocation.rs index 95dbd636a93c..5cafd29c7061 100644 --- a/xcm/src/v2/multilocation.rs +++ b/xcm/src/v2/multilocation.rs @@ -19,7 +19,7 @@ use super::Junction; use crate::v3::MultiLocation as NewMultiLocation; use core::{mem, result}; -use parity_scale_codec::{Decode, Encode}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; /// A relative path between state-bearing consensus systems. @@ -48,7 +48,7 @@ use scale_info::TypeInfo; /// that a value is strictly an interior location, in those cases, `Junctions` may be used. /// /// The `MultiLocation` value of `Null` simply refers to the interpreting consensus system. -#[derive(Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo)] +#[derive(Clone, Decode, Encode, Eq, PartialEq, Ord, PartialOrd, Debug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct MultiLocation { /// The number of parent junctions at the beginning of this `MultiLocation`. @@ -467,7 +467,7 @@ const MAX_JUNCTIONS: usize = 8; /// /// Parent junctions cannot be constructed with this type. Refer to `MultiLocation` for /// instructions on constructing parent junctions. -#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo)] +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum Junctions { /// The interpreting consensus system. diff --git a/xcm/src/v2/traits.rs b/xcm/src/v2/traits.rs index 75aa94897993..77900e514c4b 100644 --- a/xcm/src/v2/traits.rs +++ b/xcm/src/v2/traits.rs @@ -193,13 +193,13 @@ impl Outcome { } /// Type of XCM message executor. -pub trait ExecuteXcm { +pub trait ExecuteXcm { /// Execute some XCM `message` from `origin` using no more than `weight_limit` weight. The weight limit is /// a basic hard-limit and the implementation may place further restrictions or requirements on weight and /// other aspects. fn execute_xcm( origin: impl Into, - message: Xcm, + message: Xcm, weight_limit: Weight, ) -> Outcome { let origin = origin.into(); @@ -219,7 +219,7 @@ pub trait ExecuteXcm { /// execution without associated payment. fn execute_xcm_in_credit( origin: impl Into, - message: Xcm, + message: Xcm, weight_limit: Weight, weight_credit: Weight, ) -> Outcome; diff --git a/xcm/src/v3/mod.rs b/xcm/src/v3/mod.rs index 6231a647086d..7369d4a9c20c 100644 --- a/xcm/src/v3/mod.rs +++ b/xcm/src/v3/mod.rs @@ -901,7 +901,7 @@ pub enum Instruction { /// This restriction may be removed by the `UnlockAsset` instruction being called with an /// Origin of `unlocker` and a `target` equal to the current `Origin`. /// - /// If the locking is successful, then a `NoteAssetLocked` instruction is sent to `unlocker`. + /// If the locking is successful, then a `NoteUnlockable` instruction is sent to `unlocker`. /// /// - `asset`: The asset(s) which should be locked. /// - `unlocker`: The value which the Origin must be for a corresponding `UnlockAsset` diff --git a/xcm/src/v3/traits.rs b/xcm/src/v3/traits.rs index 028d8365c1e3..5d657b3e65d5 100644 --- a/xcm/src/v3/traits.rs +++ b/xcm/src/v3/traits.rs @@ -531,7 +531,7 @@ pub fn send_xcm( dest: MultiLocation, msg: Xcm<()>, ) -> result::Result<(XcmHash, MultiAssets), SendError> { - let (ticket, price) = T::validate(&mut Some(dest), &mut Some(msg.clone()))?; + let (ticket, price) = T::validate(&mut Some(dest), &mut Some(msg))?; let hash = T::deliver(ticket)?; Ok((hash, price)) } diff --git a/xcm/xcm-builder/Cargo.toml b/xcm/xcm-builder/Cargo.toml index 3b1ed3de0c88..68b753d68454 100644 --- a/xcm/xcm-builder/Cargo.toml +++ b/xcm/xcm-builder/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Parity Technologies "] edition = "2021" name = "xcm-builder" description = "Tools & types for building with XCM and its executor." -version = "0.9.28" +version = "0.9.31" [dependencies] impl-trait-for-tuples = "0.2.2" @@ -11,21 +11,21 @@ parity-scale-codec = { version = "3.1.5", default-features = false, features = [ scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } xcm = { path = "..", default-features = false } xcm-executor = { path = "../xcm-executor", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } log = { version = "0.4.17", default-features = false } # Polkadot dependencies polkadot-parachain = { path = "../../parachain", default-features = false } [dev-dependencies] -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } pallet-xcm = { path = "../pallet-xcm" } polkadot-runtime-parachains = { path = "../../runtime/parachains" } [features] diff --git a/xcm/xcm-builder/src/barriers.rs b/xcm/xcm-builder/src/barriers.rs index 9542644803d7..7bb66917f1d9 100644 --- a/xcm/xcm-builder/src/barriers.rs +++ b/xcm/xcm-builder/src/barriers.rs @@ -19,7 +19,6 @@ use frame_support::{ ensure, traits::{Contains, Get}, - weights::Weight, }; use polkadot_parachain::primitives::IsSystem; use sp_std::{marker::PhantomData, result::Result}; @@ -27,7 +26,7 @@ use xcm::latest::{ Instruction::{self, *}, InteriorMultiLocation, Junction, Junctions, Junctions::X1, - MultiLocation, + MultiLocation, Weight, WeightLimit::*, }; use xcm_executor::traits::{OnResponse, ShouldExecute}; @@ -39,9 +38,9 @@ use xcm_executor::traits::{OnResponse, ShouldExecute}; /// out of the local chain to another one. pub struct TakeWeightCredit; impl ShouldExecute for TakeWeightCredit { - fn should_execute( + fn should_execute( _origin: &MultiLocation, - _instructions: &mut [Instruction], + _instructions: &mut [Instruction], max_weight: Weight, weight_credit: &mut Weight, ) -> Result<(), ()> { @@ -62,9 +61,9 @@ impl ShouldExecute for TakeWeightCredit { /// because they are the only ones that place assets in the Holding Register to pay for execution. pub struct AllowTopLevelPaidExecutionFrom(PhantomData); impl> ShouldExecute for AllowTopLevelPaidExecutionFrom { - fn should_execute( + fn should_execute( origin: &MultiLocation, - instructions: &mut [Instruction], + instructions: &mut [Instruction], max_weight: Weight, _weight_credit: &mut Weight, ) -> Result<(), ()> { @@ -206,9 +205,9 @@ impl< /// can be sent. pub struct AllowUnpaidExecutionFrom(PhantomData); impl> ShouldExecute for AllowUnpaidExecutionFrom { - fn should_execute( + fn should_execute( origin: &MultiLocation, - instructions: &mut [Instruction], + instructions: &mut [Instruction], _max_weight: Weight, _weight_credit: &mut Weight, ) -> Result<(), ()> { @@ -263,9 +262,9 @@ impl> Contains for IsChildSystemPara /// Allows only messages if the generic `ResponseHandler` expects them via `expecting_response`. pub struct AllowKnownQueryResponses(PhantomData); impl ShouldExecute for AllowKnownQueryResponses { - fn should_execute( + fn should_execute( origin: &MultiLocation, - instructions: &mut [Instruction], + instructions: &mut [Instruction], _max_weight: Weight, _weight_credit: &mut Weight, ) -> Result<(), ()> { @@ -288,9 +287,9 @@ impl ShouldExecute for AllowKnownQueryResponses(PhantomData); impl> ShouldExecute for AllowSubscriptionsFrom { - fn should_execute( + fn should_execute( origin: &MultiLocation, - instructions: &mut [Instruction], + instructions: &mut [Instruction], _max_weight: Weight, _weight_credit: &mut Weight, ) -> Result<(), ()> { diff --git a/xcm/xcm-builder/src/fungibles_adapter.rs b/xcm/xcm-builder/src/fungibles_adapter.rs index 556c1c0e5b9d..28a1fa172a12 100644 --- a/xcm/xcm-builder/src/fungibles_adapter.rs +++ b/xcm/xcm-builder/src/fungibles_adapter.rs @@ -69,6 +69,13 @@ pub trait AssetChecking { fn asset_checking(asset: &AssetId) -> Option; } +pub struct NoChecking; +impl AssetChecking for NoChecking { + fn asset_checking(_: &AssetId) -> Option { + None + } +} + pub struct LocalMint(sp_std::marker::PhantomData); impl> AssetChecking for LocalMint { fn asset_checking(asset: &AssetId) -> Option { @@ -125,7 +132,7 @@ impl< { fn can_accrue_checked(asset_id: Assets::AssetId, amount: Assets::Balance) -> XcmResult { let checking_account = CheckingAccount::get(); - Assets::can_deposit(asset_id, &checking_account, amount, false) + Assets::can_deposit(asset_id, &checking_account, amount, true) .into_result() .map_err(|_| XcmError::NotDepositable) } @@ -370,7 +377,7 @@ impl< context: &XcmContext, ) -> result::Result { FungiblesTransferAdapter::::transfer_asset( - what, from, to, context, + what, from, to, context ) } } diff --git a/xcm/xcm-builder/src/lib.rs b/xcm/xcm-builder/src/lib.rs index e0322e7e934c..1cb7fba9f5cc 100644 --- a/xcm/xcm-builder/src/lib.rs +++ b/xcm/xcm-builder/src/lib.rs @@ -58,7 +58,7 @@ pub use currency_adapter::CurrencyAdapter; mod fungibles_adapter; pub use fungibles_adapter::{ AssetChecking, DualMint, FungiblesAdapter, FungiblesMutateAdapter, FungiblesTransferAdapter, - LocalMint, MintLocation, NonLocalMint, + LocalMint, MintLocation, NoChecking, NonLocalMint, }; mod nonfungibles_adapter; @@ -79,6 +79,7 @@ pub use filter_asset_location::{Case, NativeAsset}; mod universal_exports; pub use universal_exports::{ - ExporterFor, LocalUnpaidExporter, NetworkExportTable, SovereignPaidRemoteExporter, + BridgeBlobDispatcher, BridgeMessage, DispatchBlob, DispatchBlobError, ExporterFor, HaulBlob, + HaulBlobExporter, LocalUnpaidExporter, NetworkExportTable, SovereignPaidRemoteExporter, UnpaidRemoteExporter, }; diff --git a/xcm/xcm-builder/src/nonfungibles_adapter.rs b/xcm/xcm-builder/src/nonfungibles_adapter.rs index 3beafb436d34..2735a03ab6f3 100644 --- a/xcm/xcm-builder/src/nonfungibles_adapter.rs +++ b/xcm/xcm-builder/src/nonfungibles_adapter.rs @@ -19,7 +19,7 @@ use crate::{AssetChecking, MintLocation}; use frame_support::{ ensure, - traits::{tokens::nonfungibles, Contains, Get}, + traits::{tokens::nonfungibles, Get}, }; use sp_std::{marker::PhantomData, prelude::*, result}; use xcm::latest::prelude::*; @@ -30,7 +30,7 @@ pub struct NonFungiblesTransferAdapter, - Matcher: MatchesNonFungibles, + Matcher: MatchesNonFungibles, AccountIdConverter: Convert, AccountId: Clone, // can't get away without it since Currency is generic over it. > TransactAsset for NonFungiblesTransferAdapter @@ -50,7 +50,7 @@ impl< let (class, instance) = Matcher::matches_nonfungibles(what)?; let destination = AccountIdConverter::convert_ref(to) .map_err(|()| MatchError::AccountIdConversionFailed)?; - Assets::transfer(&instance, &class, &destination) + Assets::transfer(&class, &instance, &destination) .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; Ok(what.clone().into()) } @@ -67,10 +67,10 @@ pub struct NonFungiblesMutateAdapter< impl< Assets: nonfungibles::Mutate, - Matcher: MatchesNonFungibles, + Matcher: MatchesNonFungibles, AccountIdConverter: Convert, AccountId: Clone + Eq, // can't get away without it since Currency is generic over it. - CheckAsset: AssetChecking, + CheckAsset: AssetChecking, CheckingAccount: Get>, > NonFungiblesMutateAdapter< @@ -82,37 +82,37 @@ impl< CheckingAccount, > { - fn can_accrue_checked(class: Assets::ItemId, instance: Assets::CollectionId) -> XcmResult { - ensure!(Assets::owner(&instance, &class).is_none(), XcmError::NotDepositable); + fn can_accrue_checked(class: Assets::CollectionId, instance: Assets::ItemId) -> XcmResult { + ensure!(Assets::owner(&class, &instance).is_none(), XcmError::NotDepositable); Ok(()) } - fn can_reduce_checked(class: Assets::ItemId, instance: Assets::CollectionId) -> XcmResult { + fn can_reduce_checked(class: Assets::CollectionId, instance: Assets::ItemId) -> XcmResult { if let Some(checking_account) = CheckingAccount::get() { // This is an asset whose teleports we track. - let owner = Assets::owner(&instance, &class); + let owner = Assets::owner(&class, &instance); ensure!(owner == Some(checking_account), XcmError::NotWithdrawable); - ensure!(Assets::can_transfer(&instance, &class), XcmError::NotWithdrawable); + ensure!(Assets::can_transfer(&class, &instance), XcmError::NotWithdrawable); } Ok(()) } - fn accrue_checked(class: Assets::ItemId, instance: Assets::CollectionId) { + fn accrue_checked(class: Assets::CollectionId, instance: Assets::ItemId) { if let Some(checking_account) = CheckingAccount::get() { - let ok = Assets::mint_into(&instance, &class, &checking_account).is_ok(); + let ok = Assets::mint_into(&class, &instance, &checking_account).is_ok(); debug_assert!(ok, "`mint_into` cannot generally fail; qed"); } } - fn reduce_checked(class: Assets::ItemId, instance: Assets::CollectionId) { - let ok = Assets::burn(&instance, &class, None).is_ok(); + fn reduce_checked(class: Assets::CollectionId, instance: Assets::ItemId) { + let ok = Assets::burn(&class, &instance, None).is_ok(); debug_assert!(ok, "`can_check_in` must have returned `true` immediately prior; qed"); } } impl< Assets: nonfungibles::Mutate, - Matcher: MatchesNonFungibles, + Matcher: MatchesNonFungibles, AccountIdConverter: Convert, AccountId: Clone + Eq, // can't get away without it since Currency is generic over it. - CheckAsset: Contains + AssetChecking, + CheckAsset: AssetChecking, CheckingAccount: Get>, > TransactAsset for NonFungiblesMutateAdapter< @@ -202,7 +202,7 @@ impl< let (class, instance) = Matcher::matches_nonfungibles(what)?; let who = AccountIdConverter::convert_ref(who) .map_err(|()| MatchError::AccountIdConversionFailed)?; - Assets::mint_into(&instance, &class, &who) + Assets::mint_into(&class, &instance, &who) .map_err(|e| XcmError::FailedToTransactAsset(e.into())) } @@ -220,7 +220,7 @@ impl< let who = AccountIdConverter::convert_ref(who) .map_err(|()| MatchError::AccountIdConversionFailed)?; let (class, instance) = Matcher::matches_nonfungibles(what)?; - Assets::burn(&instance, &class, Some(&who)) + Assets::burn(&class, &instance, Some(&who)) .map_err(|e| XcmError::FailedToTransactAsset(e.into()))?; Ok(what.clone().into()) } @@ -236,10 +236,10 @@ pub struct NonFungiblesAdapter< >(PhantomData<(Assets, Matcher, AccountIdConverter, AccountId, CheckAsset, CheckingAccount)>); impl< Assets: nonfungibles::Mutate + nonfungibles::Transfer, - Matcher: MatchesNonFungibles, + Matcher: MatchesNonFungibles, AccountIdConverter: Convert, AccountId: Clone + Eq, // can't get away without it since Currency is generic over it. - CheckAsset: Contains + AssetChecking, + CheckAsset: AssetChecking, CheckingAccount: Get>, > TransactAsset for NonFungiblesAdapter diff --git a/xcm/xcm-builder/src/origin_conversion.rs b/xcm/xcm-builder/src/origin_conversion.rs index e24c426e892f..19cb1261b200 100644 --- a/xcm/xcm-builder/src/origin_conversion.rs +++ b/xcm/xcm-builder/src/origin_conversion.rs @@ -24,18 +24,20 @@ use xcm::latest::{BodyId, BodyPart, Junction, Junctions::*, MultiLocation, Netwo use xcm_executor::traits::{Convert, ConvertOrigin}; /// Sovereign accounts use the system's `Signed` origin with an account ID derived from the `LocationConverter`. -pub struct SovereignSignedViaLocation( - PhantomData<(LocationConverter, Origin)>, +pub struct SovereignSignedViaLocation( + PhantomData<(LocationConverter, RuntimeOrigin)>, ); -impl, Origin: OriginTrait> - ConvertOrigin for SovereignSignedViaLocation +impl< + LocationConverter: Convert, + RuntimeOrigin: OriginTrait, + > ConvertOrigin for SovereignSignedViaLocation where - Origin::AccountId: Clone, + RuntimeOrigin::AccountId: Clone, { fn convert_origin( origin: impl Into, kind: OriginKind, - ) -> Result { + ) -> Result { let origin = origin.into(); log::trace!( target: "xcm::origin_conversion", @@ -44,57 +46,61 @@ where ); if let OriginKind::SovereignAccount = kind { let location = LocationConverter::convert(origin)?; - Ok(Origin::signed(location).into()) + Ok(RuntimeOrigin::signed(location).into()) } else { Err(origin) } } } -pub struct ParentAsSuperuser(PhantomData); -impl ConvertOrigin for ParentAsSuperuser { +pub struct ParentAsSuperuser(PhantomData); +impl ConvertOrigin for ParentAsSuperuser { fn convert_origin( origin: impl Into, kind: OriginKind, - ) -> Result { + ) -> Result { let origin = origin.into(); log::trace!(target: "xcm::origin_conversion", "ParentAsSuperuser origin: {:?}, kind: {:?}", origin, kind); if kind == OriginKind::Superuser && origin.contains_parents_only(1) { - Ok(Origin::root()) + Ok(RuntimeOrigin::root()) } else { Err(origin) } } } -pub struct ChildSystemParachainAsSuperuser(PhantomData<(ParaId, Origin)>); -impl, Origin: OriginTrait> ConvertOrigin - for ChildSystemParachainAsSuperuser +pub struct ChildSystemParachainAsSuperuser( + PhantomData<(ParaId, RuntimeOrigin)>, +); +impl, RuntimeOrigin: OriginTrait> ConvertOrigin + for ChildSystemParachainAsSuperuser { fn convert_origin( origin: impl Into, kind: OriginKind, - ) -> Result { + ) -> Result { let origin = origin.into(); log::trace!(target: "xcm::origin_conversion", "ChildSystemParachainAsSuperuser origin: {:?}, kind: {:?}", origin, kind); match (kind, origin) { ( OriginKind::Superuser, MultiLocation { parents: 0, interior: X1(Junction::Parachain(id)) }, - ) if ParaId::from(id).is_system() => Ok(Origin::root()), + ) if ParaId::from(id).is_system() => Ok(RuntimeOrigin::root()), (_, origin) => Err(origin), } } } -pub struct SiblingSystemParachainAsSuperuser(PhantomData<(ParaId, Origin)>); -impl, Origin: OriginTrait> ConvertOrigin - for SiblingSystemParachainAsSuperuser +pub struct SiblingSystemParachainAsSuperuser( + PhantomData<(ParaId, RuntimeOrigin)>, +); +impl, RuntimeOrigin: OriginTrait> ConvertOrigin + for SiblingSystemParachainAsSuperuser { fn convert_origin( origin: impl Into, kind: OriginKind, - ) -> Result { + ) -> Result { let origin = origin.into(); log::trace!( target: "xcm::origin_conversion", @@ -105,42 +111,44 @@ impl, Origin: OriginTrait> ConvertOrigin ( OriginKind::Superuser, MultiLocation { parents: 1, interior: X1(Junction::Parachain(id)) }, - ) if ParaId::from(id).is_system() => Ok(Origin::root()), + ) if ParaId::from(id).is_system() => Ok(RuntimeOrigin::root()), (_, origin) => Err(origin), } } } -pub struct ChildParachainAsNative(PhantomData<(ParachainOrigin, Origin)>); -impl, Origin: From> ConvertOrigin - for ChildParachainAsNative +pub struct ChildParachainAsNative( + PhantomData<(ParachainOrigin, RuntimeOrigin)>, +); +impl, RuntimeOrigin: From> ConvertOrigin + for ChildParachainAsNative { fn convert_origin( origin: impl Into, kind: OriginKind, - ) -> Result { + ) -> Result { let origin = origin.into(); log::trace!(target: "xcm::origin_conversion", "ChildParachainAsNative origin: {:?}, kind: {:?}", origin, kind); match (kind, origin) { ( OriginKind::Native, MultiLocation { parents: 0, interior: X1(Junction::Parachain(id)) }, - ) => Ok(Origin::from(ParachainOrigin::from(id))), + ) => Ok(RuntimeOrigin::from(ParachainOrigin::from(id))), (_, origin) => Err(origin), } } } -pub struct SiblingParachainAsNative( - PhantomData<(ParachainOrigin, Origin)>, +pub struct SiblingParachainAsNative( + PhantomData<(ParachainOrigin, RuntimeOrigin)>, ); -impl, Origin: From> ConvertOrigin - for SiblingParachainAsNative +impl, RuntimeOrigin: From> ConvertOrigin + for SiblingParachainAsNative { fn convert_origin( origin: impl Into, kind: OriginKind, - ) -> Result { + ) -> Result { let origin = origin.into(); log::trace!( target: "xcm::origin_conversion", @@ -151,21 +159,23 @@ impl, Origin: From> ConvertOrigin Ok(Origin::from(ParachainOrigin::from(id))), + ) => Ok(RuntimeOrigin::from(ParachainOrigin::from(id))), (_, origin) => Err(origin), } } } // Our Relay-chain has a native origin given by the `Get`ter. -pub struct RelayChainAsNative(PhantomData<(RelayOrigin, Origin)>); -impl, Origin> ConvertOrigin - for RelayChainAsNative +pub struct RelayChainAsNative( + PhantomData<(RelayOrigin, RuntimeOrigin)>, +); +impl, RuntimeOrigin> ConvertOrigin + for RelayChainAsNative { fn convert_origin( origin: impl Into, kind: OriginKind, - ) -> Result { + ) -> Result { let origin = origin.into(); log::trace!(target: "xcm::origin_conversion", "RelayChainAsNative origin: {:?}, kind: {:?}", origin, kind); if kind == OriginKind::Native && origin.contains_parents_only(1) { @@ -176,16 +186,16 @@ impl, Origin> ConvertOrigin } } -pub struct SignedAccountId32AsNative(PhantomData<(Network, Origin)>); -impl>, Origin: OriginTrait> ConvertOrigin - for SignedAccountId32AsNative +pub struct SignedAccountId32AsNative(PhantomData<(Network, RuntimeOrigin)>); +impl>, RuntimeOrigin: OriginTrait> ConvertOrigin + for SignedAccountId32AsNative where - Origin::AccountId: From<[u8; 32]>, + RuntimeOrigin::AccountId: From<[u8; 32]>, { fn convert_origin( origin: impl Into, kind: OriginKind, - ) -> Result { + ) -> Result { let origin = origin.into(); log::trace!( target: "xcm::origin_conversion", @@ -196,22 +206,25 @@ where ( OriginKind::Native, MultiLocation { parents: 0, interior: X1(Junction::AccountId32 { id, network }) }, - ) if matches!(network, None) || network == Network::get() => Ok(Origin::signed(id.into())), + ) if matches!(network, None) || network == Network::get() => + Ok(RuntimeOrigin::signed(id.into())), (_, origin) => Err(origin), } } } -pub struct SignedAccountKey20AsNative(PhantomData<(Network, Origin)>); -impl>, Origin: OriginTrait> ConvertOrigin - for SignedAccountKey20AsNative +pub struct SignedAccountKey20AsNative( + PhantomData<(Network, RuntimeOrigin)>, +); +impl>, RuntimeOrigin: OriginTrait> ConvertOrigin + for SignedAccountKey20AsNative where - Origin::AccountId: From<[u8; 20]>, + RuntimeOrigin::AccountId: From<[u8; 20]>, { fn convert_origin( origin: impl Into, kind: OriginKind, - ) -> Result { + ) -> Result { let origin = origin.into(); log::trace!( target: "xcm::origin_conversion", @@ -222,28 +235,29 @@ where ( OriginKind::Native, MultiLocation { parents: 0, interior: X1(Junction::AccountKey20 { key, network }) }, - ) if (matches!(network, None) || network == Network::get()) => Ok(Origin::signed(key.into())), + ) if (matches!(network, None) || network == Network::get()) => + Ok(RuntimeOrigin::signed(key.into())), (_, origin) => Err(origin), } } } /// `EnsureOrigin` barrier to convert from dispatch origin to XCM origin, if one exists. -pub struct EnsureXcmOrigin(PhantomData<(Origin, Conversion)>); -impl> EnsureOrigin - for EnsureXcmOrigin +pub struct EnsureXcmOrigin(PhantomData<(RuntimeOrigin, Conversion)>); +impl> + EnsureOrigin for EnsureXcmOrigin where - Origin::PalletsOrigin: PartialEq, + RuntimeOrigin::PalletsOrigin: PartialEq, { type Success = MultiLocation; - fn try_origin(o: Origin) -> Result { + fn try_origin(o: RuntimeOrigin) -> Result { let o = match Conversion::convert(o) { Ok(location) => return Ok(location), Err(o) => o, }; // We institute a root fallback so root can always represent the context. This // guarantees that `successful_origin` will work. - if o.caller() == Origin::root().caller() { + if o.caller() == RuntimeOrigin::root().caller() { Ok(Here.into()) } else { Err(o) @@ -251,8 +265,8 @@ where } #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> Origin { - Origin::root() + fn try_successful_origin() -> Result { + Ok(RuntimeOrigin::root()) } } @@ -260,16 +274,19 @@ where /// /// Typically used when configuring `pallet-xcm` for allowing normal accounts to dispatch an XCM from an `AccountId32` /// origin. -pub struct SignedToAccountId32( - PhantomData<(Origin, AccountId, Network)>, +pub struct SignedToAccountId32( + PhantomData<(RuntimeOrigin, AccountId, Network)>, ); -impl, Network: Get>> - Convert for SignedToAccountId32 +impl< + RuntimeOrigin: OriginTrait + Clone, + AccountId: Into<[u8; 32]>, + Network: Get>, + > Convert for SignedToAccountId32 where - Origin::PalletsOrigin: From> - + TryInto, Error = Origin::PalletsOrigin>, + RuntimeOrigin::PalletsOrigin: From> + + TryInto, Error = RuntimeOrigin::PalletsOrigin>, { - fn convert(o: Origin) -> Result { + fn convert(o: RuntimeOrigin) -> Result { o.try_with_caller(|caller| match caller.try_into() { Ok(SystemRawOrigin::Signed(who)) => Ok(Junction::AccountId32 { network: Network::get(), id: who.into() }.into()), @@ -284,13 +301,16 @@ where /// /// Typically used when configuring `pallet-xcm` for allowing a collective's Origin to dispatch an XCM from a /// `Plurality` origin. -pub struct BackingToPlurality(PhantomData<(Origin, COrigin, Body)>); -impl> - Convert for BackingToPlurality +pub struct BackingToPlurality( + PhantomData<(RuntimeOrigin, COrigin, Body)>, +); +impl> + Convert for BackingToPlurality where - Origin::PalletsOrigin: From + TryInto, + RuntimeOrigin::PalletsOrigin: + From + TryInto, { - fn convert(o: Origin) -> Result { + fn convert(o: RuntimeOrigin) -> Result { o.try_with_caller(|caller| match caller.try_into() { Ok(co) => match co.get_backing() { Some(backing) => Ok(Junction::Plurality { diff --git a/xcm/xcm-builder/src/test_utils.rs b/xcm/xcm-builder/src/test_utils.rs index da239cdea8dd..eabb46d62ffe 100644 --- a/xcm/xcm-builder/src/test_utils.rs +++ b/xcm/xcm-builder/src/test_utils.rs @@ -17,12 +17,11 @@ // Shared test utilities and implementations for the XCM Builder. use frame_support::{ - dispatch::Weight, parameter_types, traits::{Contains, CrateVersion, PalletInfoData, PalletsInfoAccess}, }; use sp_std::vec::Vec; -pub use xcm::latest::prelude::*; +pub use xcm::latest::{prelude::*, Weight}; use xcm_executor::traits::{ClaimAssets, DropAssets, VersionChangeNotifier}; pub use xcm_executor::{ traits::{ @@ -118,20 +117,20 @@ impl PalletsInfoAccess for TestPalletsInfo { 2 } fn infos() -> Vec { - let mut acc: Vec = vec![]; - acc.push(PalletInfoData { - index: 0, - name: "System", - module_name: "pallet_system", - crate_version: CrateVersion { major: 1, minor: 10, patch: 1 }, - }); - acc.push(PalletInfoData { - index: 1, - name: "Balances", - module_name: "pallet_balances", - crate_version: CrateVersion { major: 1, minor: 42, patch: 69 }, - }); - acc + vec![ + PalletInfoData { + index: 0, + name: "System", + module_name: "pallet_system", + crate_version: CrateVersion { major: 1, minor: 10, patch: 1 }, + }, + PalletInfoData { + index: 1, + name: "Balances", + module_name: "pallet_balances", + crate_version: CrateVersion { major: 1, minor: 42, patch: 69 }, + }, + ] } } diff --git a/xcm/xcm-builder/src/tests/mock.rs b/xcm/xcm-builder/src/tests/mock.rs index 8e402a10e4ad..46590b08f679 100644 --- a/xcm/xcm-builder/src/tests/mock.rs +++ b/xcm/xcm-builder/src/tests/mock.rs @@ -22,12 +22,12 @@ pub use crate::{ use frame_support::traits::ContainsPair; pub use frame_support::{ dispatch::{ - DispatchError, DispatchInfo, DispatchResultWithPostInfo, Dispatchable, Parameter, Weight, + DispatchError, DispatchInfo, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo, + Parameter, PostDispatchInfo, }, ensure, parameter_types, sp_runtime::DispatchErrorWithPostInfo, traits::{Contains, Get, IsInVec}, - weights::{GetDispatchInfo, PostDispatchInfo}, }; pub use parity_scale_codec::{Decode, Encode}; pub use sp_io::hashing::blake2_256; @@ -37,7 +37,7 @@ pub use sp_std::{ fmt::Debug, marker::PhantomData, }; -pub use xcm::prelude::*; +pub use xcm::latest::{prelude::*, Weight}; pub use xcm_executor::{ traits::{ AssetExchange, AssetLock, ConvertOrigin, Enact, ExportXcm, FeeManager, FeeReason, @@ -65,18 +65,20 @@ pub enum TestCall { Any(Weight, Option), } impl Dispatchable for TestCall { - type Origin = TestOrigin; + type RuntimeOrigin = TestOrigin; type Config = (); type Info = (); type PostInfo = PostDispatchInfo; - fn dispatch(self, origin: Self::Origin) -> DispatchResultWithPostInfo { + fn dispatch(self, origin: Self::RuntimeOrigin) -> DispatchResultWithPostInfo { let mut post_info = PostDispatchInfo::default(); - post_info.actual_weight = match self { + let maybe_actual = match self { TestCall::OnlyRoot(_, maybe_actual) | TestCall::OnlySigned(_, maybe_actual, _) | TestCall::OnlyParachain(_, maybe_actual, _) | TestCall::Any(_, maybe_actual) => maybe_actual, }; + post_info.actual_weight = + maybe_actual.map(|x| frame_support::weights::Weight::from_ref_time(x)); if match (&origin, &self) { (TestOrigin::Parachain(i), TestCall::OnlyParachain(_, _, Some(j))) => i == j, (TestOrigin::Signed(i), TestCall::OnlySigned(_, _, Some(j))) => i == j, @@ -101,7 +103,10 @@ impl GetDispatchInfo for TestCall { TestCall::OnlySigned(estimate, ..) | TestCall::Any(estimate, ..) => estimate, }; - DispatchInfo { weight, ..Default::default() } + DispatchInfo { + weight: frame_support::weights::Weight::from_ref_time(weight), + ..Default::default() + } } } @@ -403,7 +408,7 @@ pub fn response(query_id: u64) -> Option { parameter_types! { pub static ExecutorUniversalLocation: InteriorMultiLocation = (ByGenesis([0; 32]), Parachain(42)).into(); - pub UnitWeightCost: Weight = 10; + pub UnitWeightCost: u64 = 10; } parameter_types! { // Nothing is allowed to be paid/unpaid by default. @@ -619,7 +624,7 @@ impl AssetExchange for TestAssetExchange { pub struct TestConfig; impl Config for TestConfig { - type Call = TestCall; + type RuntimeCall = TestCall; type XcmSender = TestMessageSender; type AssetTransactor = TestAssetTransactor; type OriginConverter = TestOriginConverter; @@ -640,6 +645,7 @@ impl Config for TestConfig { type FeeManager = TestFeeManager; type UniversalAliases = TestUniversalAliases; type MessageExporter = TestMessageExporter; + type CallDispatcher = TestCall; } pub fn fungible_multi_asset(location: MultiLocation, amount: u128) -> MultiAsset { diff --git a/xcm/xcm-builder/src/tests/weight.rs b/xcm/xcm-builder/src/tests/weight.rs index c09c2420cda0..41a9a0c98ea3 100644 --- a/xcm/xcm-builder/src/tests/weight.rs +++ b/xcm/xcm-builder/src/tests/weight.rs @@ -101,8 +101,8 @@ fn weight_trader_tuple_should_work() { let para_2: MultiLocation = Parachain(2).into(); parameter_types! { - pub static HereWeightPrice: (AssetId, u128) = (Here.into(), WEIGHT_PER_SECOND.into()); - pub static Para1WeightPrice: (AssetId, u128) = (Parachain(1).into(), WEIGHT_PER_SECOND.into()); + pub static HereWeightPrice: (AssetId, u128) = (Here.into(), WEIGHT_PER_SECOND.ref_time().into()); + pub static Para1WeightPrice: (AssetId, u128) = (Parachain(1).into(), WEIGHT_PER_SECOND.ref_time().into()); } type Traders = ( diff --git a/xcm/xcm-builder/src/weight.rs b/xcm/xcm-builder/src/weight.rs index 54dc6e62914c..bad06674c543 100644 --- a/xcm/xcm-builder/src/weight.rs +++ b/xcm/xcm-builder/src/weight.rs @@ -15,13 +15,14 @@ // along with Polkadot. If not, see . use frame_support::{ + dispatch::GetDispatchInfo, traits::{tokens::currency::Currency as CurrencyT, Get, OnUnbalanced as OnUnbalancedT}, - weights::{constants::WEIGHT_PER_SECOND, GetDispatchInfo, Weight, WeightToFee as WeightToFeeT}, + weights::{constants::WEIGHT_PER_SECOND, WeightToFee as WeightToFeeT}, }; use parity_scale_codec::Decode; use sp_runtime::traits::{SaturatedConversion, Saturating, Zero}; use sp_std::{marker::PhantomData, result::Result}; -use xcm::latest::prelude::*; +use xcm::latest::{prelude::*, Weight}; use xcm_executor::{ traits::{WeightBounds, WeightTrader}, Assets, @@ -148,7 +149,7 @@ impl, R: TakeRevenue> WeightTrader for FixedRateOfFungib weight, payment, ); let (id, units_per_second) = T::get(); - let amount = units_per_second * (weight as u128) / (WEIGHT_PER_SECOND as u128); + let amount = units_per_second * (weight as u128) / (WEIGHT_PER_SECOND.ref_time() as u128); if amount == 0 { return Ok(payment) } @@ -163,7 +164,7 @@ impl, R: TakeRevenue> WeightTrader for FixedRateOfFungib log::trace!(target: "xcm::weight", "FixedRateOfFungible::refund_weight weight: {:?}", weight); let (id, units_per_second) = T::get(); let weight = weight.min(self.0); - let amount = units_per_second * (weight as u128) / (WEIGHT_PER_SECOND as u128); + let amount = units_per_second * (weight as u128) / (WEIGHT_PER_SECOND.ref_time() as u128); self.0 -= weight; self.1 = self.1.saturating_sub(amount); if amount > 0 { @@ -209,7 +210,8 @@ impl< fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result { log::trace!(target: "xcm::weight", "UsingComponents::buy_weight weight: {:?}, payment: {:?}", weight, payment); - let amount = WeightToFee::weight_to_fee(&weight); + let amount = + WeightToFee::weight_to_fee(&frame_support::weights::Weight::from_ref_time(weight)); let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?; let required = (Concrete(AssetId::get()), u128_amount).into(); let unused = payment.checked_sub(required).map_err(|_| XcmError::TooExpensive)?; @@ -221,7 +223,8 @@ impl< fn refund_weight(&mut self, weight: Weight) -> Option { log::trace!(target: "xcm::weight", "UsingComponents::refund_weight weight: {:?}", weight); let weight = weight.min(self.0); - let amount = WeightToFee::weight_to_fee(&weight); + let amount = + WeightToFee::weight_to_fee(&frame_support::weights::Weight::from_ref_time(weight)); self.0 -= weight; self.1 = self.1.saturating_sub(amount); let amount: u128 = amount.saturated_into(); diff --git a/xcm/xcm-builder/tests/mock/mod.rs b/xcm/xcm-builder/tests/mock/mod.rs index 4db82f6318df..12972b0eb61c 100644 --- a/xcm/xcm-builder/tests/mock/mod.rs +++ b/xcm/xcm-builder/tests/mock/mod.rs @@ -17,7 +17,6 @@ use frame_support::{ construct_runtime, parameter_types, traits::{Everything, Nothing}, - weights::Weight, }; use parity_scale_codec::Encode; use sp_core::H256; @@ -74,8 +73,8 @@ parameter_types! { } impl frame_system::Config for Runtime { - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -83,7 +82,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); type BlockLength = (); @@ -109,7 +108,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type MaxLocks = MaxLocks; type Balance = Balance; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -144,14 +143,14 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter< >; type LocalOriginConverter = ( - SovereignSignedViaLocation, - ChildParachainAsNative, - SignedAccountId32AsNative, - ChildSystemParachainAsSuperuser, + SovereignSignedViaLocation, + ChildParachainAsNative, + SignedAccountId32AsNative, + ChildSystemParachainAsSuperuser, ); parameter_types! { - pub const BaseXcmWeight: Weight = 1_000_000_000; + pub const BaseXcmWeight: u64 = 1_000_000_000; pub KsmPerSecond: (AssetId, u128) = (KsmLocation::get().into(), 1); } @@ -172,7 +171,7 @@ pub type TrustedTeleporters = (xcm_builder::Case,); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { - type Call = Call; + type RuntimeCall = RuntimeCall; type XcmSender = TestSendXcm; type AssetTransactor = LocalAssetTransactor; type OriginConverter = LocalOriginConverter; @@ -180,7 +179,7 @@ impl xcm_executor::Config for XcmConfig { type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; type ResponseHandler = XcmPallet; type AssetTrap = XcmPallet; @@ -193,24 +192,25 @@ impl xcm_executor::Config for XcmConfig { type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; } -pub type LocalOriginToLocation = SignedToAccountId32; +pub type LocalOriginToLocation = SignedToAccountId32; impl pallet_xcm::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type UniversalLocation = UniversalLocation; - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = TestSendXcm; // Anyone can execute XCM messages locally... - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; + type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmExecuteFilter = Nothing; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds; - type Call = Call; - type Origin = Origin; + type Weigher = FixedWeightBounds; + type RuntimeCall = RuntimeCall; + type RuntimeOrigin = RuntimeOrigin; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type TrustedLockers = (); diff --git a/xcm/xcm-executor/Cargo.toml b/xcm/xcm-executor/Cargo.toml index e3f18ea718d5..134d4f06947c 100644 --- a/xcm/xcm-executor/Cargo.toml +++ b/xcm/xcm-executor/Cargo.toml @@ -3,20 +3,20 @@ authors = ["Parity Technologies "] edition = "2021" name = "xcm-executor" description = "An abstract and configurable XCM message executor." -version = "0.9.28" +version = "0.9.31" [dependencies] impl-trait-for-tuples = "0.2.2" parity-scale-codec = { version = "3.1.5", default-features = false, features = ["derive"] } xcm = { path = "..", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-arithmetic = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } log = { version = "0.4.17", default-features = false } -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.28" } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.31" } [features] default = ["std"] diff --git a/xcm/xcm-executor/integration-tests/Cargo.toml b/xcm/xcm-executor/integration-tests/Cargo.toml index 12026d21936b..ddb38f41922e 100644 --- a/xcm/xcm-executor/integration-tests/Cargo.toml +++ b/xcm/xcm-executor/integration-tests/Cargo.toml @@ -3,23 +3,23 @@ authors = ["Parity Technologies "] edition = "2021" name = "xcm-executor-integration-tests" description = "Integration tests for the XCM Executor" -version = "0.9.28" +version = "0.9.31" [dependencies] -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } futures = "0.3.21" pallet-xcm = { path = "../../pallet-xcm" } polkadot-test-client = { path = "../../../node/test/client" } polkadot-test-runtime = { path = "../../../runtime/test-runtime" } polkadot-test-service = { path = "../../../node/test/service" } -sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.28" } -sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.31" } +sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } xcm = { path = "../..", default-features = false } xcm-executor = { path = ".." } -sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [features] default = ["std"] diff --git a/xcm/xcm-executor/integration-tests/src/lib.rs b/xcm/xcm-executor/integration-tests/src/lib.rs index 3da4867515a8..821987531aa0 100644 --- a/xcm/xcm-executor/integration-tests/src/lib.rs +++ b/xcm/xcm-executor/integration-tests/src/lib.rs @@ -23,7 +23,7 @@ use polkadot_test_client::{ }; use polkadot_test_runtime::pallet_test_notifier; use polkadot_test_service::construct_extrinsic; -use sp_runtime::{generic::BlockId, traits::Block}; +use sp_runtime::traits::Block; use sp_state_machine::InspectState; use xcm::{latest::prelude::*, VersionedResponse, VersionedXcm}; @@ -37,14 +37,14 @@ fn basic_buy_fees_message_executes() { let msg = Xcm(vec![ WithdrawAsset((Parent, 100).into()), BuyExecution { fees: (Parent, 1).into(), weight_limit: Unlimited }, - DepositAsset { assets: Wild(AllCounted(1)), beneficiary: Parent.into() }, + DepositAsset { assets: Wild(All), max_assets: 1, beneficiary: Parent.into() }, ]); let mut block_builder = client.init_polkadot_block_builder(); let execute = construct_extrinsic( &client, - polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute { + polkadot_test_runtime::RuntimeCall::Xcm(pallet_xcm::Call::execute { message: Box::new(VersionedXcm::from(msg)), max_weight: 1_000_000_000, }), @@ -60,24 +60,21 @@ fn basic_buy_fees_message_executes() { futures::executor::block_on(client.import(sp_consensus::BlockOrigin::Own, block)) .expect("imports the block"); - client - .state_at(&BlockId::Hash(block_hash)) - .expect("state should exist") - .inspect_state(|| { - assert!(polkadot_test_runtime::System::events().iter().any(|r| matches!( - r.event, - polkadot_test_runtime::Event::Xcm(pallet_xcm::Event::Attempted(Outcome::Complete( - _ - ))), - ))); - }); + client.state_at(&block_hash).expect("state should exist").inspect_state(|| { + assert!(polkadot_test_runtime::System::events().iter().any(|r| matches!( + r.event, + polkadot_test_runtime::RuntimeEvent::Xcm(pallet_xcm::Event::Attempted( + Outcome::Complete(_) + )), + ))); + }); } #[test] fn query_response_fires() { use pallet_test_notifier::Event::*; use pallet_xcm::QueryStatus; - use polkadot_test_runtime::Event::TestNotifier; + use polkadot_test_runtime::RuntimeEvent::TestNotifier; sp_tracing::try_init_simple(); let mut client = TestClientBuilder::new() @@ -88,7 +85,9 @@ fn query_response_fires() { let execute = construct_extrinsic( &client, - polkadot_test_runtime::Call::TestNotifier(pallet_test_notifier::Call::prepare_new_query {}), + polkadot_test_runtime::RuntimeCall::TestNotifier( + pallet_test_notifier::Call::prepare_new_query {}, + ), sp_keyring::Sr25519Keyring::Alice, 0, ); @@ -102,30 +101,26 @@ fn query_response_fires() { .expect("imports the block"); let mut query_id = None; - client - .state_at(&BlockId::Hash(block_hash)) - .expect("state should exist") - .inspect_state(|| { - for r in polkadot_test_runtime::System::events().iter() { - match r.event { - TestNotifier(QueryPrepared(q)) => query_id = Some(q), - _ => (), - } + client.state_at(&block_hash).expect("state should exist").inspect_state(|| { + for r in polkadot_test_runtime::System::events().iter() { + match r.event { + TestNotifier(QueryPrepared(q)) => query_id = Some(q), + _ => (), } - }); + } + }); let query_id = query_id.unwrap(); let mut block_builder = client.init_polkadot_block_builder(); let response = Response::ExecutionResult(None); let max_weight = 1_000_000; - let querier = Some(Here.into()); - let msg = Xcm(vec![QueryResponse { query_id, response, max_weight, querier }]); + let msg = Xcm(vec![QueryResponse { query_id, response, max_weight }]); let msg = Box::new(VersionedXcm::from(msg)); let execute = construct_extrinsic( &client, - polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute { + polkadot_test_runtime::RuntimeCall::Xcm(pallet_xcm::Call::execute { message: msg, max_weight: 1_000_000_000, }), @@ -141,31 +136,28 @@ fn query_response_fires() { futures::executor::block_on(client.import(sp_consensus::BlockOrigin::Own, block)) .expect("imports the block"); - client - .state_at(&BlockId::Hash(block_hash)) - .expect("state should exist") - .inspect_state(|| { - assert!(polkadot_test_runtime::System::events().iter().any(|r| matches!( - r.event, - polkadot_test_runtime::Event::Xcm(pallet_xcm::Event::ResponseReady( - q, - Response::ExecutionResult(None), - )) if q == query_id, - ))); - assert_eq!( - polkadot_test_runtime::Xcm::query(query_id), - Some(QueryStatus::Ready { - response: VersionedResponse::V3(Response::ExecutionResult(None)), - at: 2u32.into() - }), - ) - }); + client.state_at(&block_hash).expect("state should exist").inspect_state(|| { + assert!(polkadot_test_runtime::System::events().iter().any(|r| matches!( + r.event, + polkadot_test_runtime::RuntimeEvent::Xcm(pallet_xcm::Event::ResponseReady( + q, + Response::ExecutionResult(None), + )) if q == query_id, + ))); + assert_eq!( + polkadot_test_runtime::Xcm::query(query_id), + Some(QueryStatus::Ready { + response: VersionedResponse::V2(Response::ExecutionResult(None)), + at: 2u32.into() + }), + ) + }); } #[test] fn query_response_elicits_handler() { use pallet_test_notifier::Event::*; - use polkadot_test_runtime::Event::TestNotifier; + use polkadot_test_runtime::RuntimeEvent::TestNotifier; sp_tracing::try_init_simple(); let mut client = TestClientBuilder::new() @@ -176,7 +168,7 @@ fn query_response_elicits_handler() { let execute = construct_extrinsic( &client, - polkadot_test_runtime::Call::TestNotifier( + polkadot_test_runtime::RuntimeCall::TestNotifier( pallet_test_notifier::Call::prepare_new_notify_query {}, ), sp_keyring::Sr25519Keyring::Alice, @@ -192,29 +184,25 @@ fn query_response_elicits_handler() { .expect("imports the block"); let mut query_id = None; - client - .state_at(&BlockId::Hash(block_hash)) - .expect("state should exist") - .inspect_state(|| { - for r in polkadot_test_runtime::System::events().iter() { - match r.event { - TestNotifier(NotifyQueryPrepared(q)) => query_id = Some(q), - _ => (), - } + client.state_at(&block_hash).expect("state should exist").inspect_state(|| { + for r in polkadot_test_runtime::System::events().iter() { + match r.event { + TestNotifier(NotifyQueryPrepared(q)) => query_id = Some(q), + _ => (), } - }); + } + }); let query_id = query_id.unwrap(); let mut block_builder = client.init_polkadot_block_builder(); let response = Response::ExecutionResult(None); let max_weight = 1_000_000; - let querier = Some(Here.into()); - let msg = Xcm(vec![QueryResponse { query_id, response, max_weight, querier }]); + let msg = Xcm(vec![QueryResponse { query_id, response, max_weight }]); let execute = construct_extrinsic( &client, - polkadot_test_runtime::Call::Xcm(pallet_xcm::Call::execute { + polkadot_test_runtime::RuntimeCall::Xcm(pallet_xcm::Call::execute { message: Box::new(VersionedXcm::from(msg)), max_weight: 1_000_000_000, }), @@ -230,17 +218,14 @@ fn query_response_elicits_handler() { futures::executor::block_on(client.import(sp_consensus::BlockOrigin::Own, block)) .expect("imports the block"); - client - .state_at(&BlockId::Hash(block_hash)) - .expect("state should exist") - .inspect_state(|| { - assert!(polkadot_test_runtime::System::events().iter().any(|r| matches!( - r.event, - TestNotifier(ResponseReceived( - MultiLocation { parents: 0, interior: X1(Junction::AccountId32 { .. }) }, - q, - Response::ExecutionResult(None), - )) if q == query_id, - ))); - }); + client.state_at(&block_hash).expect("state should exist").inspect_state(|| { + assert!(polkadot_test_runtime::System::events().iter().any(|r| matches!( + r.event, + TestNotifier(ResponseReceived( + MultiLocation { parents: 0, interior: X1(Junction::AccountId32 { .. }) }, + q, + Response::ExecutionResult(None), + )) if q == query_id, + ))); + }); } diff --git a/xcm/xcm-executor/src/config.rs b/xcm/xcm-executor/src/config.rs index 1184f77c6712..bd8143adcb7b 100644 --- a/xcm/xcm-executor/src/config.rs +++ b/xcm/xcm-executor/src/config.rs @@ -15,20 +15,20 @@ // along with Polkadot. If not, see . use crate::traits::{ - AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, - OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, + AssetExchange, AssetLock, CallDispatcher, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, + FeeManager, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, + WeightTrader, }; use frame_support::{ - dispatch::{Dispatchable, Parameter}, + dispatch::{Dispatchable, GetDispatchInfo, Parameter, PostDispatchInfo}, traits::{Contains, ContainsPair, Get, PalletsInfoAccess}, - weights::{GetDispatchInfo, PostDispatchInfo}, }; use xcm::prelude::*; /// The trait to parameterize the `XcmExecutor`. pub trait Config { /// The outer call dispatch type. - type Call: Parameter + Dispatchable + GetDispatchInfo; + type RuntimeCall: Parameter + Dispatchable + GetDispatchInfo; /// How to send an onward XCM message. type XcmSender: SendXcm; @@ -37,7 +37,7 @@ pub trait Config { type AssetTransactor: TransactAsset; /// How to get a call origin from a `OriginKind` value. - type OriginConverter: ConvertOrigin<::Origin>; + type OriginConverter: ConvertOrigin<::RuntimeOrigin>; /// Combinations of (Asset, Location) pairs which we trust as reserves. type IsReserve: ContainsPair; @@ -52,7 +52,7 @@ pub trait Config { type Barrier: ShouldExecute; /// The means of determining an XCM message's weight. - type Weigher: WeightBounds; + type Weigher: WeightBounds; /// The means of purchasing weight credit for XCM execution. type Trader: WeightTrader; @@ -94,4 +94,10 @@ pub trait Config { /// The origin locations and specific universal junctions to which they are allowed to elevate /// themselves. type UniversalAliases: Contains<(MultiLocation, Junction)>; + + /// The call dispatcher used by XCM. + /// + /// XCM will use this to dispatch any calls. When no special call dispatcher is required, + /// this can be set to the same type as `Self::Call`. + type CallDispatcher: CallDispatcher; } diff --git a/xcm/xcm-executor/src/lib.rs b/xcm/xcm-executor/src/lib.rs index b9d0f61a63b2..c170c8c05d8f 100644 --- a/xcm/xcm-executor/src/lib.rs +++ b/xcm/xcm-executor/src/lib.rs @@ -17,10 +17,9 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{ - dispatch::{Dispatchable, Weight}, + dispatch::GetDispatchInfo, ensure, traits::{Contains, ContainsPair, Get, PalletsInfoAccess}, - weights::GetDispatchInfo, }; use parity_scale_codec::{Decode, Encode}; use sp_io::hashing::blake2_128; @@ -30,8 +29,8 @@ use xcm::latest::prelude::*; pub mod traits; use traits::{ - validate_export, AssetExchange, AssetLock, ClaimAssets, ConvertOrigin, DropAssets, Enact, - ExportXcm, FeeManager, FeeReason, OnResponse, ShouldExecute, TransactAsset, + validate_export, AssetExchange, AssetLock, CallDispatcher, ClaimAssets, ConvertOrigin, + DropAssets, Enact, ExportXcm, FeeManager, FeeReason, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, }; @@ -61,9 +60,9 @@ pub struct XcmExecutor { /// the weight of dynamically determined instructions such as `Transact`). total_surplus: u64, total_refunded: u64, - error_handler: Xcm, + error_handler: Xcm, error_handler_weight: u64, - appendix: Xcm, + appendix: Xcm, appendix_weight: u64, transact_status: MaybeErrorCode, fees_mode: FeesMode, @@ -121,10 +120,10 @@ impl XcmExecutor { pub fn set_total_refunded(&mut self, v: u64) { self.total_refunded = v } - pub fn error_handler(&self) -> &Xcm { + pub fn error_handler(&self) -> &Xcm { &self.error_handler } - pub fn set_error_handler(&mut self, v: Xcm) { + pub fn set_error_handler(&mut self, v: Xcm) { self.error_handler = v } pub fn error_handler_weight(&self) -> &u64 { @@ -133,10 +132,10 @@ impl XcmExecutor { pub fn set_error_handler_weight(&mut self, v: u64) { self.error_handler_weight = v } - pub fn appendix(&self) -> &Xcm { + pub fn appendix(&self) -> &Xcm { &self.appendix } - pub fn set_appendix(&mut self, v: Xcm) { + pub fn set_appendix(&mut self, v: Xcm) { self.appendix = v } pub fn appendix_weight(&self) -> &u64 { @@ -165,16 +164,18 @@ impl XcmExecutor { } } -pub struct WeighedMessage(Weight, Xcm); +pub struct WeighedMessage(u64, Xcm); impl PreparedMessage for WeighedMessage { - fn weight_of(&self) -> Weight { + fn weight_of(&self) -> u64 { self.0 } } -impl ExecuteXcm for XcmExecutor { - type Prepared = WeighedMessage; - fn prepare(mut message: Xcm) -> Result> { +impl ExecuteXcm for XcmExecutor { + type Prepared = WeighedMessage; + fn prepare( + mut message: Xcm, + ) -> Result> { match Config::Weigher::weight(&mut message) { Ok(weight) => Ok(WeighedMessage(weight, message)), Err(_) => Err(message), @@ -182,9 +183,9 @@ impl ExecuteXcm for XcmExecutor { } fn execute( origin: impl Into, - WeighedMessage(xcm_weight, mut message): WeighedMessage, + WeighedMessage(xcm_weight, mut message): WeighedMessage, message_hash: XcmHash, - mut weight_credit: Weight, + mut weight_credit: u64, ) -> Outcome { let origin = origin.into(); log::trace!( @@ -285,11 +286,11 @@ impl XcmExecutor { } #[cfg(feature = "runtime-benchmarks")] - pub fn bench_process(&mut self, xcm: Xcm) -> Result<(), ExecutorError> { + pub fn bench_process(&mut self, xcm: Xcm) -> Result<(), ExecutorError> { self.process(xcm) } - fn process(&mut self, xcm: Xcm) -> Result<(), ExecutorError> { + fn process(&mut self, xcm: Xcm) -> Result<(), ExecutorError> { log::trace!( target: "xcm::process", "origin: {:?}, total_surplus/refunded: {:?}/{:?}, error_handler_weight: {:?}", @@ -317,7 +318,7 @@ impl XcmExecutor { /// Execute any final operations after having executed the XCM message. /// This includes refunding surplus weight, trapping extra holding funds, and returning any errors during execution. - pub fn post_process(mut self, xcm_weight: Weight) -> Outcome { + pub fn post_process(mut self, xcm_weight: u64) -> Outcome { // We silently drop any error from our attempt to refund the surplus as it's a charitable // thing so best-effort is all we will do. let _ = self.refund_surplus(); @@ -372,8 +373,8 @@ impl XcmExecutor { } /// Remove the registered error handler and return it. Do not refund its weight. - fn take_error_handler(&mut self) -> Xcm { - let mut r = Xcm::(vec![]); + fn take_error_handler(&mut self) -> Xcm { + let mut r = Xcm::(vec![]); sp_std::mem::swap(&mut self.error_handler, &mut r); self.error_handler_weight = 0; r @@ -381,14 +382,14 @@ impl XcmExecutor { /// Drop the registered error handler and refund its weight. fn drop_error_handler(&mut self) { - self.error_handler = Xcm::(vec![]); + self.error_handler = Xcm::(vec![]); self.total_surplus.saturating_accrue(self.error_handler_weight); self.error_handler_weight = 0; } /// Remove the registered appendix and return it. - fn take_appendix(&mut self) -> Xcm { - let mut r = Xcm::(vec![]); + fn take_appendix(&mut self) -> Xcm { + let mut r = Xcm::(vec![]); sp_std::mem::swap(&mut self.appendix, &mut r); self.appendix_weight = 0; r @@ -425,7 +426,10 @@ impl XcmExecutor { } /// Process a single XCM instruction, mutating the state of the XCM virtual machine. - fn process_instruction(&mut self, instr: Instruction) -> Result<(), XcmError> { + fn process_instruction( + &mut self, + instr: Instruction, + ) -> Result<(), XcmError> { log::trace!( target: "xcm::process_instruction", "=== {:?}", @@ -510,17 +514,18 @@ impl XcmExecutor { let dispatch_origin = Config::OriginConverter::convert_origin(origin, origin_kind) .map_err(|_| XcmError::BadOrigin)?; let weight = message_call.get_dispatch_info().weight; - ensure!(weight <= require_weight_at_most, XcmError::MaxWeightInvalid); - let maybe_actual_weight = match message_call.dispatch(dispatch_origin) { - Ok(post_info) => { - self.transact_status = MaybeErrorCode::Success; - post_info.actual_weight - }, - Err(error_and_info) => { - self.transact_status = error_and_info.error.encode().into(); - error_and_info.post_info.actual_weight - }, - }; + ensure!(weight.ref_time() <= require_weight_at_most, XcmError::MaxWeightInvalid); + let maybe_actual_weight = + match Config::CallDispatcher::dispatch(message_call, dispatch_origin) { + Ok(post_info) => { + self.transact_status = MaybeErrorCode::Success; + post_info.actual_weight + }, + Err(error_and_info) => { + self.transact_status = error_and_info.error.encode().into(); + error_and_info.post_info.actual_weight + }, + }; let actual_weight = maybe_actual_weight.unwrap_or(weight); let surplus = weight.saturating_sub(actual_weight); // We assume that the `Config::Weigher` will counts the `require_weight_at_most` @@ -531,7 +536,7 @@ impl XcmExecutor { // reported back to the caller and this ensures that they account for the total // weight consumed correctly (potentially allowing them to do more operations in a // block than they otherwise would). - self.total_surplus.saturating_accrue(surplus); + self.total_surplus.saturating_accrue(surplus.ref_time()); Ok(()) }, QueryResponse { query_id, response, max_weight, querier } => { diff --git a/xcm/xcm-executor/src/traits/conversion.rs b/xcm/xcm-executor/src/traits/conversion.rs index ee5c84f2c78b..7b5ce42a7aa1 100644 --- a/xcm/xcm-executor/src/traits/conversion.rs +++ b/xcm/xcm-executor/src/traits/conversion.rs @@ -15,6 +15,7 @@ // along with Polkadot. If not, see . use parity_scale_codec::{Decode, Encode}; +use sp_runtime::{traits::Dispatchable, DispatchErrorWithPostInfo}; use sp_std::{borrow::Borrow, prelude::*, result::Result}; use xcm::latest::prelude::*; @@ -203,3 +204,24 @@ impl ConvertOrigin for Tuple { Err(origin) } } + +/// Defines how a call is dispatched with given origin. +/// Allows to customize call dispatch, such as adapting the origin based on the call +/// or modifying the call. +pub trait CallDispatcher { + fn dispatch( + call: Call, + origin: Call::RuntimeOrigin, + ) -> Result>; +} + +// We implement it for every calls so they can dispatch themselves +// (without any change). +impl CallDispatcher for Call { + fn dispatch( + call: Call, + origin: Call::RuntimeOrigin, + ) -> Result> { + call.dispatch(origin) + } +} diff --git a/xcm/xcm-executor/src/traits/drop_assets.rs b/xcm/xcm-executor/src/traits/drop_assets.rs index 45eefc9fba4e..f5e59ba50db4 100644 --- a/xcm/xcm-executor/src/traits/drop_assets.rs +++ b/xcm/xcm-executor/src/traits/drop_assets.rs @@ -16,8 +16,9 @@ use crate::Assets; use core::marker::PhantomData; -use frame_support::{traits::Contains, weights::Weight}; -use xcm::latest::{MultiAssets, MultiLocation, XcmContext}; +use frame_support::traits::Contains; +use sp_runtime::traits::Zero; +use xcm::latest::{MultiAssets, MultiLocation, Weight, XcmContext}; /// Define a handler for when some non-empty `Assets` value should be dropped. pub trait DropAssets { @@ -26,7 +27,7 @@ pub trait DropAssets { } impl DropAssets for () { fn drop_assets(_origin: &MultiLocation, _assets: Assets, _context: &XcmContext) -> Weight { - 0 + Weight::zero() } } @@ -39,7 +40,7 @@ impl> DropAssets for FilterAssets { if A::contains(&assets) { D::drop_assets(origin, assets, context) } else { - 0 + Weight::zero() } } } @@ -54,7 +55,7 @@ impl> DropAssets for FilterOrigin( channel, &mut Some(universal_source), &mut Some(dest), - &mut Some(msg.clone()), + &mut Some(msg), )?; let hash = T::deliver(ticket)?; Ok((hash, price)) diff --git a/xcm/xcm-executor/src/traits/mod.rs b/xcm/xcm-executor/src/traits/mod.rs index ead19f79eea5..989c9d4e0006 100644 --- a/xcm/xcm-executor/src/traits/mod.rs +++ b/xcm/xcm-executor/src/traits/mod.rs @@ -17,7 +17,7 @@ //! Various traits used in configuring the executor. mod conversion; -pub use conversion::{Convert, ConvertOrigin, Decoded, Encoded, Identity, JustTry}; +pub use conversion::{CallDispatcher, Convert, ConvertOrigin, Decoded, Encoded, Identity, JustTry}; mod drop_assets; pub use drop_assets::{ClaimAssets, DropAssets}; mod asset_lock; diff --git a/xcm/xcm-executor/src/traits/on_response.rs b/xcm/xcm-executor/src/traits/on_response.rs index 2720dfd6ce5a..59d6d47962b1 100644 --- a/xcm/xcm-executor/src/traits/on_response.rs +++ b/xcm/xcm-executor/src/traits/on_response.rs @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use frame_support::weights::Weight; +use sp_runtime::traits::Zero; use xcm::latest::{ - Error as XcmError, MultiLocation, QueryId, Response, Result as XcmResult, XcmContext, + Error as XcmError, MultiLocation, QueryId, Response, Result as XcmResult, Weight, XcmContext, }; /// Define what needs to be done upon receiving a query response. @@ -55,7 +55,7 @@ impl OnResponse for () { _max_weight: Weight, _context: &XcmContext, ) -> Weight { - 0 + Weight::zero() } } diff --git a/xcm/xcm-executor/src/traits/should_execute.rs b/xcm/xcm-executor/src/traits/should_execute.rs index 2bf781cee559..7db8fbe4a09e 100644 --- a/xcm/xcm-executor/src/traits/should_execute.rs +++ b/xcm/xcm-executor/src/traits/should_execute.rs @@ -14,9 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -use frame_support::weights::Weight; use sp_std::result::Result; -use xcm::latest::{Instruction, MultiLocation}; +use xcm::latest::{Instruction, MultiLocation, Weight}; /// Trait to determine whether the execution engine should actually execute a given XCM. /// @@ -31,9 +30,9 @@ pub trait ShouldExecute { /// - `weight_credit`: The pre-established amount of weight that the system has determined this /// message may utilize in its execution. Typically non-zero only because of prior fee /// payment, but could in principle be due to other factors. - fn should_execute( + fn should_execute( origin: &MultiLocation, - instructions: &mut [Instruction], + instructions: &mut [Instruction], max_weight: Weight, weight_credit: &mut Weight, ) -> Result<(), ()>; @@ -41,9 +40,9 @@ pub trait ShouldExecute { #[impl_trait_for_tuples::impl_for_tuples(30)] impl ShouldExecute for Tuple { - fn should_execute( + fn should_execute( origin: &MultiLocation, - instructions: &mut [Instruction], + instructions: &mut [Instruction], max_weight: Weight, weight_credit: &mut Weight, ) -> Result<(), ()> { diff --git a/xcm/xcm-executor/src/traits/weight.rs b/xcm/xcm-executor/src/traits/weight.rs index a3c7d2a2f645..76f411e5c1f5 100644 --- a/xcm/xcm-executor/src/traits/weight.rs +++ b/xcm/xcm-executor/src/traits/weight.rs @@ -15,19 +15,18 @@ // along with Polkadot. If not, see . use crate::Assets; -use frame_support::weights::Weight; use sp_std::result::Result; -use xcm::latest::prelude::*; +use xcm::latest::{prelude::*, Weight}; /// Determine the weight of an XCM message. -pub trait WeightBounds { +pub trait WeightBounds { /// Return the maximum amount of weight that an attempted execution of this message could /// consume. - fn weight(message: &mut Xcm) -> Result; + fn weight(message: &mut Xcm) -> Result; /// Return the maximum amount of weight that an attempted execution of this instruction could /// consume. - fn instr_weight(instruction: &Instruction) -> Result; + fn instr_weight(instruction: &Instruction) -> Result; } /// A means of getting approximate weight consumption for a given destination message executor and a diff --git a/xcm/xcm-simulator/Cargo.toml b/xcm/xcm-simulator/Cargo.toml index 60bc28735189..569d301ece94 100644 --- a/xcm/xcm-simulator/Cargo.toml +++ b/xcm/xcm-simulator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xcm-simulator" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Test kit to simulate cross-chain message passing and XCM execution" edition = "2021" @@ -9,9 +9,9 @@ edition = "2021" codec = { package = "parity-scale-codec", version = "3.0.0" } paste = "1.0.7" -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } xcm = { path = "../" } xcm-executor = { path = "../xcm-executor" } diff --git a/xcm/xcm-simulator/example/Cargo.toml b/xcm/xcm-simulator/example/Cargo.toml index 88f3b58f2dc9..69fafd06bec1 100644 --- a/xcm/xcm-simulator/example/Cargo.toml +++ b/xcm/xcm-simulator/example/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xcm-simulator-example" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Examples of xcm-simulator usage." edition = "2021" @@ -8,14 +8,17 @@ edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0" } scale-info = { version = "2.1.2", features = ["derive"] } +log = { version = "0.4.14", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-uniques = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } xcm = { path = "../../" } xcm-simulator = { path = "../" } @@ -25,3 +28,18 @@ pallet-xcm = { path = "../../pallet-xcm" } polkadot-core-primitives = { path = "../../../core-primitives" } polkadot-runtime-parachains = { path = "../../../runtime/parachains" } polkadot-parachain = { path = "../../../parachain" } + +[features] +default = [] +runtime-benchmarks = [ + "frame-system/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-uniques/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", + "xcm-executor/runtime-benchmarks", + "xcm/runtime-benchmarks", + "polkadot-runtime-parachains/runtime-benchmarks", + "polkadot-parachain/runtime-benchmarks", +] diff --git a/xcm/xcm-simulator/example/src/lib.rs b/xcm/xcm-simulator/example/src/lib.rs index d9c08a5f369f..299007a307e3 100644 --- a/xcm/xcm-simulator/example/src/lib.rs +++ b/xcm/xcm-simulator/example/src/lib.rs @@ -107,7 +107,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { } pub fn relay_ext() -> sp_io::TestExternalities { - use relay_chain::{Origin, Runtime, System, Uniques}; + use relay_chain::{Runtime, RuntimeOrigin, System, Uniques}; let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); @@ -124,8 +124,8 @@ pub fn relay_ext() -> sp_io::TestExternalities { let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| { System::set_block_number(1); - assert_eq!(Uniques::force_create(Origin::root(), 1, ALICE, true), Ok(())); - assert_eq!(Uniques::mint(Origin::signed(ALICE), 1, 42, child_account_id(1)), Ok(())); + assert_eq!(Uniques::force_create(RuntimeOrigin::root(), 1, ALICE, true), Ok(())); + assert_eq!(Uniques::mint(RuntimeOrigin::signed(ALICE), 1, 42, child_account_id(1)), Ok(())); }); ext } @@ -158,10 +158,9 @@ mod tests { fn dmp() { MockNet::reset(); - let remark = - parachain::Call::System(frame_system::Call::::remark_with_event { - remark: vec![1, 2, 3], - }); + let remark = parachain::RuntimeCall::System( + frame_system::Call::::remark_with_event { remark: vec![1, 2, 3] }, + ); Relay::execute_with(|| { assert_ok!(RelayChainPalletXcm::send_xcm( Here, @@ -175,10 +174,11 @@ mod tests { }); ParaA::execute_with(|| { - use parachain::{Event, System}; - assert!(System::events() - .iter() - .any(|r| matches!(r.event, Event::System(frame_system::Event::Remarked { .. })))); + use parachain::{RuntimeEvent, System}; + assert!(System::events().iter().any(|r| matches!( + r.event, + RuntimeEvent::System(frame_system::Event::Remarked { .. }) + ))); }); } @@ -186,7 +186,7 @@ mod tests { fn ump() { MockNet::reset(); - let remark = relay_chain::Call::System( + let remark = relay_chain::RuntimeCall::System( frame_system::Call::::remark_with_event { remark: vec![1, 2, 3] }, ); ParaA::execute_with(|| { @@ -202,10 +202,11 @@ mod tests { }); Relay::execute_with(|| { - use relay_chain::{Event, System}; - assert!(System::events() - .iter() - .any(|r| matches!(r.event, Event::System(frame_system::Event::Remarked { .. })))); + use relay_chain::{RuntimeEvent, System}; + assert!(System::events().iter().any(|r| matches!( + r.event, + RuntimeEvent::System(frame_system::Event::Remarked { .. }) + ))); }); } @@ -213,10 +214,9 @@ mod tests { fn xcmp() { MockNet::reset(); - let remark = - parachain::Call::System(frame_system::Call::::remark_with_event { - remark: vec![1, 2, 3], - }); + let remark = parachain::RuntimeCall::System( + frame_system::Call::::remark_with_event { remark: vec![1, 2, 3] }, + ); ParaA::execute_with(|| { assert_ok!(ParachainPalletXcm::send_xcm( Here, @@ -230,10 +230,11 @@ mod tests { }); ParaB::execute_with(|| { - use parachain::{Event, System}; - assert!(System::events() - .iter() - .any(|r| matches!(r.event, Event::System(frame_system::Event::Remarked { .. })))); + use parachain::{RuntimeEvent, System}; + assert!(System::events().iter().any(|r| matches!( + r.event, + RuntimeEvent::System(frame_system::Event::Remarked { .. }) + ))); }); } @@ -245,7 +246,7 @@ mod tests { Relay::execute_with(|| { assert_ok!(RelayChainPalletXcm::reserve_transfer_assets( - relay_chain::Origin::signed(ALICE), + relay_chain::RuntimeOrigin::signed(ALICE), Box::new(Parachain(1).into()), Box::new(AccountId32 { network: None, id: ALICE.into() }.into()), Box::new((Here, withdraw_amount).into()), @@ -340,7 +341,7 @@ mod tests { Relay::execute_with(|| { // Mint the NFT (1, 69) and give it to our "parachain#1 alias". assert_ok!(relay_chain::Uniques::mint( - relay_chain::Origin::signed(ALICE), + relay_chain::RuntimeOrigin::signed(ALICE), 1, 69, child_account_account_id(1, ALICE), @@ -354,7 +355,7 @@ mod tests { }); ParaA::execute_with(|| { assert_ok!(parachain::ForeignUniques::force_create( - parachain::Origin::root(), + parachain::RuntimeOrigin::root(), (Parent, GeneralIndex(1)).into(), ALICE, false, @@ -406,13 +407,13 @@ mod tests { Relay::execute_with(|| { assert_ok!(relay_chain::Uniques::force_create( - relay_chain::Origin::root(), + relay_chain::RuntimeOrigin::root(), 2, ALICE, false )); assert_ok!(relay_chain::Uniques::mint( - relay_chain::Origin::signed(ALICE), + relay_chain::RuntimeOrigin::signed(ALICE), 2, 69, child_account_account_id(1, ALICE) @@ -424,7 +425,7 @@ mod tests { }); ParaA::execute_with(|| { assert_ok!(parachain::ForeignUniques::force_create( - parachain::Origin::root(), + parachain::RuntimeOrigin::root(), (Parent, GeneralIndex(2)).into(), ALICE, false, @@ -475,13 +476,13 @@ mod tests { Relay::execute_with(|| { assert_ok!(relay_chain::Uniques::force_create( - relay_chain::Origin::root(), + relay_chain::RuntimeOrigin::root(), 2, ALICE, false )); assert_ok!(relay_chain::Uniques::mint( - relay_chain::Origin::signed(ALICE), + relay_chain::RuntimeOrigin::signed(ALICE), 2, 69, child_account_account_id(1, ALICE) @@ -494,10 +495,12 @@ mod tests { let message = Xcm(vec![Transact { origin_kind: OriginKind::Xcm, require_weight_at_most: 1_000_000_000, - call: parachain::Call::from(pallet_uniques::Call::::create { - class: (Parent, 2u64).into(), - admin: parent_account_id(), - }) + call: parachain::RuntimeCall::from( + pallet_uniques::Call::::create { + collection: (Parent, 2u64).into(), + admin: parent_account_id(), + }, + ) .encode() .into(), }]); @@ -523,7 +526,7 @@ mod tests { ParaA::execute_with(|| { assert_eq!(parachain::Balances::reserved_balance(&parent_account_id()), 1000); assert_eq!( - parachain::ForeignUniques::class_owner((Parent, 2u64).into()), + parachain::ForeignUniques::collection_owner((Parent, 2u64).into()), Some(parent_account_id()) ); }); diff --git a/xcm/xcm-simulator/example/src/parachain.rs b/xcm/xcm-simulator/example/src/parachain.rs index 77dfa962bf37..6101b78bd9df 100644 --- a/xcm/xcm-simulator/example/src/parachain.rs +++ b/xcm/xcm-simulator/example/src/parachain.rs @@ -39,8 +39,9 @@ use xcm::{latest::prelude::*, VersionedXcm}; use xcm_builder::{ Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, - IsConcrete, NativeAsset, NonFungiblesAdapter, ParentIsPreset, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, + IsConcrete, NativeAsset, NoChecking, NonFungiblesAdapter, ParentIsPreset, + SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, }; use xcm_executor::{ traits::{Convert, JustTry}, @@ -61,8 +62,8 @@ parameter_types! { } impl frame_system::Config for Runtime { - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -70,7 +71,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); type BlockLength = (); @@ -96,7 +97,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type MaxLocks = MaxLocks; type Balance = Balance; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -109,29 +110,30 @@ impl pallet_balances::Config for Runtime { pub struct UniquesHelper; #[cfg(feature = "runtime-benchmarks")] impl pallet_uniques::BenchmarkHelper for UniquesHelper { - fn class(i: u16) -> MultiLocation { + fn collection(i: u16) -> MultiLocation { GeneralIndex(i as u128).into() } - fn instance(i: u16) -> AssetInstance { + fn item(i: u16) -> AssetInstance { AssetInstance::Index(i as u128) } } impl pallet_uniques::Config for Runtime { - type Event = Event; - type ClassId = MultiLocation; - type InstanceId = AssetInstance; + type RuntimeEvent = RuntimeEvent; + type CollectionId = MultiLocation; + type ItemId = AssetInstance; type Currency = Balances; type CreateOrigin = ForeignCreators; type ForceOrigin = frame_system::EnsureRoot; - type ClassDeposit = frame_support::traits::ConstU128<1_000>; - type InstanceDeposit = frame_support::traits::ConstU128<1_000>; + type CollectionDeposit = frame_support::traits::ConstU128<1_000>; + type ItemDeposit = frame_support::traits::ConstU128<1_000>; type MetadataDepositBase = frame_support::traits::ConstU128<1_000>; type AttributeDepositBase = frame_support::traits::ConstU128<1_000>; type DepositPerByte = frame_support::traits::ConstU128<1>; type StringLimit = frame_support::traits::ConstU32<64>; type KeyLimit = frame_support::traits::ConstU32<64>; type ValueLimit = frame_support::traits::ConstU32<128>; + type Locker = (); type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] type Helper = UniquesHelper; @@ -140,10 +142,13 @@ impl pallet_uniques::Config for Runtime { // `EnsureOriginWithArg` impl for `CreateOrigin` which allows only XCM origins // which are locations containing the class location. pub struct ForeignCreators; -impl EnsureOriginWithArg for ForeignCreators { +impl EnsureOriginWithArg for ForeignCreators { type Success = AccountId; - fn try_origin(o: Origin, a: &MultiLocation) -> sp_std::result::Result { + fn try_origin( + o: RuntimeOrigin, + a: &MultiLocation, + ) -> sp_std::result::Result { let origin_location = pallet_xcm::EnsureXcm::::try_origin(o.clone())?; if !a.starts_with(&origin_location) { return Err(o) @@ -152,14 +157,14 @@ impl EnsureOriginWithArg for ForeignCreators { } #[cfg(feature = "runtime-benchmarks")] - fn successful_origin(a: &MultiLocation) -> Origin { + fn successful_origin(a: &MultiLocation) -> RuntimeOrigin { pallet_xcm::Origin::Xcm(a.clone()).into() } } parameter_types! { - pub const ReservedXcmpWeight: Weight = WEIGHT_PER_SECOND / 4; - pub const ReservedDmpWeight: Weight = WEIGHT_PER_SECOND / 4; + pub const ReservedXcmpWeight: Weight = WEIGHT_PER_SECOND.saturating_div(4); + pub const ReservedDmpWeight: Weight = WEIGHT_PER_SECOND.saturating_div(4); } parameter_types! { @@ -176,13 +181,13 @@ pub type LocationToAccountId = ( ); pub type XcmOriginToCallOrigin = ( - SovereignSignedViaLocation, - SignedAccountId32AsNative, - XcmPassthrough, + SovereignSignedViaLocation, + SignedAccountId32AsNative, + XcmPassthrough, ); parameter_types! { - pub const UnitWeightCost: Weight = 1; + pub const UnitWeightCost: u64 = 1; pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; @@ -196,7 +201,7 @@ pub type LocalAssetTransactor = ( ConvertedConcreteId, SovereignAccountOf, AccountId, - Nothing, + NoChecking, (), >, ); @@ -215,7 +220,7 @@ pub type TrustedReserves = EverythingBut; + type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); @@ -236,6 +241,7 @@ impl Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; } #[frame_support::pallet] @@ -245,8 +251,8 @@ pub mod mock_msg_queue { #[pallet::config] pub trait Config: frame_system::Config { - type Event: From> + IsType<::Event>; - type XcmExecutor: ExecuteXcm; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type XcmExecutor: ExecuteXcm; } #[pallet::call] @@ -264,7 +270,7 @@ pub mod mock_msg_queue { #[pallet::storage] #[pallet::getter(fn received_dmp)] /// A queue of received DMP messages - pub(super) type ReceivedDmp = StorageValue<_, Vec>, ValueQuery>; + pub(super) type ReceivedDmp = StorageValue<_, Vec>, ValueQuery>; impl Get for Pallet { fn get() -> ParaId { @@ -304,20 +310,27 @@ pub mod mock_msg_queue { fn handle_xcmp_message( sender: ParaId, _sent_at: RelayBlockNumber, - xcm: VersionedXcm, + xcm: VersionedXcm, max_weight: Weight, ) -> Result { let hash = Encode::using_encoded(&xcm, T::Hashing::hash); let message_hash = Encode::using_encoded(&xcm, sp_io::hashing::blake2_256); - let (result, event) = match Xcm::::try_from(xcm) { + let (result, event) = match Xcm::::try_from(xcm) { Ok(xcm) => { let location = (Parent, Parachain(sender.into())); - match T::XcmExecutor::execute_xcm(location, xcm, message_hash, max_weight) { + match T::XcmExecutor::execute_xcm( + location, + xcm, + message_hash, + max_weight.ref_time(), + ) { Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)), - Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))), + Outcome::Complete(w) => + (Ok(Weight::from_ref_time(w)), Event::Success(Some(hash))), // As far as the caller is concerned, this was dispatched without error, so // we just report the weight used. - Outcome::Incomplete(w, e) => (Ok(w), Event::Fail(Some(hash), e)), + Outcome::Incomplete(w, e) => + (Ok(Weight::from_ref_time(w)), Event::Fail(Some(hash), e)), } }, Err(()) => (Err(XcmError::UnhandledXcmVersion), Event::BadVersion(Some(hash))), @@ -339,7 +352,9 @@ pub mod mock_msg_queue { let mut remaining_fragments = &data_ref[..]; while !remaining_fragments.is_empty() { - if let Ok(xcm) = VersionedXcm::::decode(&mut remaining_fragments) { + if let Ok(xcm) = + VersionedXcm::::decode(&mut remaining_fragments) + { let _ = Self::handle_xcmp_message(sender, sent_at, xcm, max_weight); } else { debug_assert!(false, "Invalid incoming XCMP message data"); @@ -357,7 +372,7 @@ pub mod mock_msg_queue { ) -> Weight { for (_i, (_sent_at, data)) in iter.enumerate() { let id = sp_io::hashing::blake2_256(&data[..]); - let maybe_versioned = VersionedXcm::::decode(&mut &data[..]); + let maybe_versioned = VersionedXcm::::decode(&mut &data[..]); match maybe_versioned { Err(_) => { Self::deposit_event(Event::InvalidFormat(id)); @@ -365,7 +380,12 @@ pub mod mock_msg_queue { Ok(versioned) => match Xcm::try_from(versioned) { Err(()) => Self::deposit_event(Event::UnsupportedVersion(id)), Ok(x) => { - let outcome = T::XcmExecutor::execute_xcm(Parent, x.clone(), id, limit); + let outcome = T::XcmExecutor::execute_xcm( + Parent, + x.clone(), + id, + limit.ref_time(), + ); >::append(x); Self::deposit_event(Event::ExecutedDownward(id, outcome)); }, @@ -378,25 +398,25 @@ pub mod mock_msg_queue { } impl mock_msg_queue::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type XcmExecutor = XcmExecutor; } -pub type LocalOriginToLocation = SignedToAccountId32; +pub type LocalOriginToLocation = SignedToAccountId32; impl pallet_xcm::Config for Runtime { - type Event = Event; - type SendXcmOrigin = EnsureXcmOrigin; + type RuntimeEvent = RuntimeEvent; + type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; - type ExecuteXcmOrigin = EnsureXcmOrigin; + type ExecuteXcmOrigin = EnsureXcmOrigin; type XcmExecuteFilter = Everything; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type Currency = Balances; diff --git a/xcm/xcm-simulator/example/src/relay_chain.rs b/xcm/xcm-simulator/example/src/relay_chain.rs index b7a7a13f0bf6..f743b84ab280 100644 --- a/xcm/xcm-simulator/example/src/relay_chain.rs +++ b/xcm/xcm-simulator/example/src/relay_chain.rs @@ -19,7 +19,6 @@ use frame_support::{ construct_runtime, parameter_types, traits::{AsEnsureOriginWithArg, Everything, Nothing}, - weights::Weight, }; use sp_core::H256; use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; @@ -31,7 +30,7 @@ use xcm_builder::{ Account32Hash, AccountId32Aliases, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, ConvertedConcreteId, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, - FixedWeightBounds, IsConcrete, NonFungiblesAdapter, SignedAccountId32AsNative, + FixedWeightBounds, IsConcrete, NoChecking, NonFungiblesAdapter, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, }; use xcm_executor::{traits::JustTry, Config, XcmExecutor}; @@ -44,8 +43,8 @@ parameter_types! { } impl frame_system::Config for Runtime { - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -53,7 +52,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); type BlockLength = (); @@ -79,7 +78,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type MaxLocks = MaxLocks; type Balance = Balance; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -89,20 +88,21 @@ impl pallet_balances::Config for Runtime { } impl pallet_uniques::Config for Runtime { - type Event = Event; - type ClassId = u32; - type InstanceId = u32; + type RuntimeEvent = RuntimeEvent; + type CollectionId = u32; + type ItemId = u32; type Currency = Balances; type CreateOrigin = AsEnsureOriginWithArg>; type ForceOrigin = frame_system::EnsureRoot; - type ClassDeposit = frame_support::traits::ConstU128<1_000>; - type InstanceDeposit = frame_support::traits::ConstU128<1_000>; + type CollectionDeposit = frame_support::traits::ConstU128<1_000>; + type ItemDeposit = frame_support::traits::ConstU128<1_000>; type MetadataDepositBase = frame_support::traits::ConstU128<1_000>; type AttributeDepositBase = frame_support::traits::ConstU128<1_000>; type DepositPerByte = frame_support::traits::ConstU128<1>; type StringLimit = frame_support::traits::ConstU32<64>; type KeyLimit = frame_support::traits::ConstU32<64>; type ValueLimit = frame_support::traits::ConstU32<128>; + type Locker = (); type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] type Helper = (); @@ -119,7 +119,7 @@ parameter_types! { pub RelayNetwork: NetworkId = ByGenesis([0; 32]); pub const AnyNetwork: Option = None; pub UniversalLocation: InteriorMultiLocation = Here; - pub UnitWeightCost: Weight = 1_000; + pub UnitWeightCost: u64 = 1_000; } pub type LocationToAccountId = ( @@ -135,20 +135,20 @@ pub type LocalAssetTransactor = ( ConvertedConcreteId, JustTry>, LocationToAccountId, AccountId, - Nothing, + NoChecking, (), >, ); type LocalOriginConverter = ( - SovereignSignedViaLocation, - ChildParachainAsNative, - SignedAccountId32AsNative, - ChildSystemParachainAsSuperuser, + SovereignSignedViaLocation, + ChildParachainAsNative, + SignedAccountId32AsNative, + ChildSystemParachainAsSuperuser, ); parameter_types! { - pub const BaseXcmWeight: Weight = 1_000; + pub const BaseXcmWeight: u64 = 1_000; pub TokensPerSecond: (AssetId, u128) = (Concrete(TokenLocation::get()), 1_000_000_000_000); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; @@ -159,7 +159,7 @@ pub type Barrier = AllowUnpaidExecutionFrom; pub struct XcmConfig; impl Config for XcmConfig { - type Call = Call; + type RuntimeCall = RuntimeCall; type XcmSender = XcmRouter; type AssetTransactor = LocalAssetTransactor; type OriginConverter = LocalOriginConverter; @@ -167,7 +167,7 @@ impl Config for XcmConfig { type IsTeleporter = (); type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); @@ -180,24 +180,25 @@ impl Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; } -pub type LocalOriginToLocation = SignedToAccountId32; +pub type LocalOriginToLocation = SignedToAccountId32; impl pallet_xcm::Config for Runtime { - type Event = Event; - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + type RuntimeEvent = RuntimeEvent; + type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = XcmRouter; // Anyone can execute XCM messages locally... - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; + type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmExecuteFilter = Nothing; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type Currency = Balances; @@ -212,7 +213,7 @@ parameter_types! { } impl ump::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type UmpSink = ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = frame_system::EnsureRoot; diff --git a/xcm/xcm-simulator/fuzzer/Cargo.toml b/xcm/xcm-simulator/fuzzer/Cargo.toml index 0c85466b4de3..3137db72ff0b 100644 --- a/xcm/xcm-simulator/fuzzer/Cargo.toml +++ b/xcm/xcm-simulator/fuzzer/Cargo.toml @@ -1,22 +1,22 @@ [package] name = "xcm-simulator-fuzzer" -version = "0.9.28" +version = "0.9.31" authors = ["Parity Technologies "] description = "Examples of xcm-simulator usage." edition = "2021" [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0" } -honggfuzz = "0.5.54" +honggfuzz = "0.5.55" scale-info = { version = "2.1.2", features = ["derive"] } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.28" } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } xcm = { path = "../../" } xcm-simulator = { path = "../" } diff --git a/xcm/xcm-simulator/fuzzer/src/fuzz.rs b/xcm/xcm-simulator/fuzzer/src/fuzz.rs index 691fba10cc10..70ad3c1e2cc6 100644 --- a/xcm/xcm-simulator/fuzzer/src/fuzz.rs +++ b/xcm/xcm-simulator/fuzzer/src/fuzz.rs @@ -122,7 +122,7 @@ fn main() { #[cfg(fuzzing)] { loop { - fuzz!(|data: &[u8]| { + honggfuzz::fuzz!(|data: &[u8]| { run_one_input(data); }); } diff --git a/xcm/xcm-simulator/fuzzer/src/parachain.rs b/xcm/xcm-simulator/fuzzer/src/parachain.rs index 11eacc7f5963..1785e1178bf6 100644 --- a/xcm/xcm-simulator/fuzzer/src/parachain.rs +++ b/xcm/xcm-simulator/fuzzer/src/parachain.rs @@ -52,8 +52,8 @@ parameter_types! { } impl frame_system::Config for Runtime { - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -61,7 +61,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); type BlockLength = (); @@ -87,7 +87,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type MaxLocks = MaxLocks; type Balance = Balance; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -97,8 +97,8 @@ impl pallet_balances::Config for Runtime { } parameter_types! { - pub const ReservedXcmpWeight: Weight = WEIGHT_PER_SECOND / 4; - pub const ReservedDmpWeight: Weight = WEIGHT_PER_SECOND / 4; + pub const ReservedXcmpWeight: Weight = WEIGHT_PER_SECOND.saturating_div(4); + pub const ReservedDmpWeight: Weight = WEIGHT_PER_SECOND.saturating_div(4); } parameter_types! { @@ -114,13 +114,13 @@ pub type LocationToAccountId = ( ); pub type XcmOriginToCallOrigin = ( - SovereignSignedViaLocation, - SignedAccountId32AsNative, - XcmPassthrough, + SovereignSignedViaLocation, + SignedAccountId32AsNative, + XcmPassthrough, ); parameter_types! { - pub const UnitWeightCost: Weight = 1; + pub const UnitWeightCost: u64 = 1; pub KsmPerSecond: (AssetId, u128) = (Concrete(Parent.into()), 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; @@ -134,7 +134,7 @@ pub type Barrier = AllowUnpaidExecutionFrom; pub struct XcmConfig; impl Config for XcmConfig { - type Call = Call; + type RuntimeCall = RuntimeCall; type XcmSender = XcmRouter; type AssetTransactor = LocalAssetTransactor; type OriginConverter = XcmOriginToCallOrigin; @@ -142,7 +142,7 @@ impl Config for XcmConfig { type IsTeleporter = (); type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); @@ -155,6 +155,7 @@ impl Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; } #[frame_support::pallet] @@ -164,8 +165,8 @@ pub mod mock_msg_queue { #[pallet::config] pub trait Config: frame_system::Config { - type Event: From> + IsType<::Event>; - type XcmExecutor: ExecuteXcm; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type XcmExecutor: ExecuteXcm; } #[pallet::call] @@ -183,7 +184,7 @@ pub mod mock_msg_queue { #[pallet::storage] #[pallet::getter(fn received_dmp)] /// A queue of received DMP messages - pub(super) type ReceivedDmp = StorageValue<_, Vec>, ValueQuery>; + pub(super) type ReceivedDmp = StorageValue<_, Vec>, ValueQuery>; impl Get for Pallet { fn get() -> ParaId { @@ -223,20 +224,27 @@ pub mod mock_msg_queue { fn handle_xcmp_message( sender: ParaId, _sent_at: RelayBlockNumber, - xcm: VersionedXcm, + xcm: VersionedXcm, max_weight: Weight, ) -> Result { let hash = Encode::using_encoded(&xcm, T::Hashing::hash); let message_hash = xcm.using_encoded(sp_io::hashing::blake2_256); - let (result, event) = match Xcm::::try_from(xcm) { + let (result, event) = match Xcm::::try_from(xcm) { Ok(xcm) => { let location = MultiLocation::new(1, X1(Parachain(sender.into()))); - match T::XcmExecutor::execute_xcm(location, xcm, message_hash, max_weight) { + match T::XcmExecutor::execute_xcm( + location, + xcm, + message_hash, + max_weight.ref_time(), + ) { Outcome::Error(e) => (Err(e.clone()), Event::Fail(Some(hash), e)), - Outcome::Complete(w) => (Ok(w), Event::Success(Some(hash))), + Outcome::Complete(w) => + (Ok(Weight::from_ref_time(w)), Event::Success(Some(hash))), // As far as the caller is concerned, this was dispatched without error, so // we just report the weight used. - Outcome::Incomplete(w, e) => (Ok(w), Event::Fail(Some(hash), e)), + Outcome::Incomplete(w, e) => + (Ok(Weight::from_ref_time(w)), Event::Fail(Some(hash), e)), } }, Err(()) => (Err(XcmError::UnhandledXcmVersion), Event::BadVersion(Some(hash))), @@ -258,7 +266,9 @@ pub mod mock_msg_queue { let mut remaining_fragments = &data_ref[..]; while !remaining_fragments.is_empty() { - if let Ok(xcm) = VersionedXcm::::decode(&mut remaining_fragments) { + if let Ok(xcm) = + VersionedXcm::::decode(&mut remaining_fragments) + { let _ = Self::handle_xcmp_message(sender, sent_at, xcm, max_weight); } else { debug_assert!(false, "Invalid incoming XCMP message data"); @@ -276,8 +286,8 @@ pub mod mock_msg_queue { ) -> Weight { for (_i, (_sent_at, data)) in iter.enumerate() { let id = sp_io::hashing::blake2_256(&data[..]); - let maybe_msg = - VersionedXcm::::decode(&mut &data[..]).map(Xcm::::try_from); + let maybe_msg = VersionedXcm::::decode(&mut &data[..]) + .map(Xcm::::try_from); match maybe_msg { Err(_) => { Self::deposit_event(Event::InvalidFormat(id)); @@ -286,7 +296,8 @@ pub mod mock_msg_queue { Self::deposit_event(Event::UnsupportedVersion(id)); }, Ok(Ok(x)) => { - let outcome = T::XcmExecutor::execute_xcm(Parent, x.clone(), id, limit); + let outcome = + T::XcmExecutor::execute_xcm(Parent, x.clone(), id, limit.ref_time()); >::append(x); Self::deposit_event(Event::ExecutedDownward(id, outcome)); }, @@ -298,25 +309,25 @@ pub mod mock_msg_queue { } impl mock_msg_queue::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type XcmExecutor = XcmExecutor; } -pub type LocalOriginToLocation = SignedToAccountId32; +pub type LocalOriginToLocation = SignedToAccountId32; impl pallet_xcm::Config for Runtime { - type Event = Event; - type SendXcmOrigin = EnsureXcmOrigin; + type RuntimeEvent = RuntimeEvent; + type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; - type ExecuteXcmOrigin = EnsureXcmOrigin; + type ExecuteXcmOrigin = EnsureXcmOrigin; type XcmExecuteFilter = Everything; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Nothing; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type Currency = Balances; diff --git a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs index 4a0267214a8a..aa6d4fd99583 100644 --- a/xcm/xcm-simulator/fuzzer/src/relay_chain.rs +++ b/xcm/xcm-simulator/fuzzer/src/relay_chain.rs @@ -19,7 +19,6 @@ use frame_support::{ construct_runtime, parameter_types, traits::{Everything, Nothing}, - weights::Weight, }; use sp_core::H256; use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32}; @@ -43,8 +42,8 @@ parameter_types! { } impl frame_system::Config for Runtime { - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -52,7 +51,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type BlockWeights = (); type BlockLength = (); @@ -78,7 +77,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type MaxLocks = MaxLocks; type Balance = Balance; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -98,7 +97,7 @@ parameter_types! { pub const ThisNetwork: NetworkId = NetworkId::ByGenesis([0; 32]); pub const AnyNetwork: Option = None; pub const UniversalLocation: InteriorMultiLocation = Here; - pub const UnitWeightCost: Weight = 1_000; + pub const UnitWeightCost: u64 = 1_000; } pub type SovereignAccountOf = @@ -108,14 +107,14 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter, SovereignAccountOf, AccountId, ()>; type LocalOriginConverter = ( - SovereignSignedViaLocation, - ChildParachainAsNative, - SignedAccountId32AsNative, - ChildSystemParachainAsSuperuser, + SovereignSignedViaLocation, + ChildParachainAsNative, + SignedAccountId32AsNative, + ChildSystemParachainAsSuperuser, ); parameter_types! { - pub const BaseXcmWeight: Weight = 1_000; + pub const BaseXcmWeight: u64 = 1_000; pub KsmPerSecond: (AssetId, u128) = (Concrete(TokenLocation::get()), 1); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; @@ -126,7 +125,7 @@ pub type Barrier = AllowUnpaidExecutionFrom; pub struct XcmConfig; impl Config for XcmConfig { - type Call = Call; + type RuntimeCall = RuntimeCall; type XcmSender = XcmRouter; type AssetTransactor = LocalAssetTransactor; type OriginConverter = LocalOriginConverter; @@ -134,7 +133,7 @@ impl Config for XcmConfig { type IsTeleporter = (); type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; type ResponseHandler = (); type AssetTrap = (); @@ -147,24 +146,25 @@ impl Config for XcmConfig { type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; } -pub type LocalOriginToLocation = SignedToAccountId32; +pub type LocalOriginToLocation = SignedToAccountId32; impl pallet_xcm::Config for Runtime { - type Event = Event; - type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; + type RuntimeEvent = RuntimeEvent; + type SendXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmRouter = XcmRouter; // Anyone can execute XCM messages locally... - type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; + type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin; type XcmExecuteFilter = Nothing; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds; + type Weigher = FixedWeightBounds; type UniversalLocation = UniversalLocation; - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; type Currency = Balances; @@ -179,7 +179,7 @@ parameter_types! { } impl ump::Config for Runtime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type UmpSink = ump::XcmSink, Runtime>; type FirstMessageFactorPercent = FirstMessageFactorPercent; type ExecuteOverweightOrigin = frame_system::EnsureRoot; diff --git a/xcm/xcm-simulator/src/lib.rs b/xcm/xcm-simulator/src/lib.rs index 6a60eecb71d4..ca126504ccae 100644 --- a/xcm/xcm-simulator/src/lib.rs +++ b/xcm/xcm-simulator/src/lib.rs @@ -248,10 +248,10 @@ macro_rules! decl_test_network { let encoded = $crate::encode_xcm(message, $crate::MessageKind::Ump); let r = <$relay_chain>::process_upward_message( para_id, &encoded[..], - $crate::Weight::max_value(), + $crate::Weight::MAX, ); if let Err((id, required)) = r { - return Err($crate::XcmError::WeightLimitReached(required)); + return Err($crate::XcmError::WeightLimitReached(required.ref_time())); } }, $( @@ -260,7 +260,7 @@ macro_rules! decl_test_network { let messages = vec![(para_id, 1, &encoded[..])]; let _weight = <$parachain>::handle_xcmp_messages( messages.into_iter(), - $crate::Weight::max_value(), + $crate::Weight::MAX, ); }, )* @@ -286,7 +286,7 @@ macro_rules! decl_test_network { // NOTE: RelayChainBlockNumber is hard-coded to 1 let messages = vec![(1, encoded)]; let _weight = <$parachain>::handle_dmp_messages( - messages.into_iter(), $crate::Weight::max_value(), + messages.into_iter(), $crate::Weight::MAX, ); }, )* diff --git a/zombienet_tests/README.md b/zombienet_tests/README.md index 2c732a6801d9..5760e203d958 100644 --- a/zombienet_tests/README.md +++ b/zombienet_tests/README.md @@ -7,10 +7,11 @@ _The content of this directory is meant to be used by Parity's private CI/CD inf `parachains` At the moment this directory only have one test related to parachains: `/parachains-smoke-test`, that check the parachain registration and the block height. -## Resources (private) +## Resources * [zombienet repo](https://github.com/paritytech/zombienet) +* [zombienet book](https://paritytech.github.io/zombienet/) ## Questions / permissions -Ping in element [Javier](@javier:matrix.parity.io) to ask questions or grant permission to run the test from your local setup. +Ping in element Javier (@javier:matrix.parity.io) to ask questions or grant permission to run the test from your local setup. diff --git a/zombienet_tests/functional/0001-parachains-pvf.feature b/zombienet_tests/functional/0001-parachains-pvf.zndsl similarity index 92% rename from zombienet_tests/functional/0001-parachains-pvf.feature rename to zombienet_tests/functional/0001-parachains-pvf.zndsl index 07bc356464fe..1f187498d78f 100644 --- a/zombienet_tests/functional/0001-parachains-pvf.feature +++ b/zombienet_tests/functional/0001-parachains-pvf.zndsl @@ -64,14 +64,14 @@ one: reports histogram polkadot_pvf_preparation_time has at least 1 samples in b two: reports histogram polkadot_pvf_preparation_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2", "3", "10"] within 10 seconds # Check all buckets >= 20. -alice: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "+Inf"] within 10 seconds -bob: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "+Inf"] within 10 seconds -charlie: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "+Inf"] within 10 seconds -dave: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "+Inf"] within 10 seconds -ferdie: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "+Inf"] within 10 seconds -eve: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "+Inf"] within 10 seconds -one: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "+Inf"] within 10 seconds -two: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "+Inf"] within 10 seconds +alice: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "180", "+Inf"] within 10 seconds +bob: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "180", "+Inf"] within 10 seconds +charlie: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "180", "+Inf"] within 10 seconds +dave: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "180", "+Inf"] within 10 seconds +ferdie: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "180", "+Inf"] within 10 seconds +eve: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "180", "+Inf"] within 10 seconds +one: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "180", "+Inf"] within 10 seconds +two: reports histogram polkadot_pvf_preparation_time has 0 samples in buckets ["20", "30", "60", "180", "+Inf"] within 10 seconds # Check execution time. # There are two different timeout conditions: BACKING_EXECUTION_TIMEOUT(2s) and diff --git a/zombienet_tests/functional/0002-parachains-disputes.toml b/zombienet_tests/functional/0002-parachains-disputes.toml index dc909726bdae..a0a87d60d4e3 100644 --- a/zombienet_tests/functional/0002-parachains-disputes.toml +++ b/zombienet_tests/functional/0002-parachains-disputes.toml @@ -26,12 +26,10 @@ requests = { memory = "2G", cpu = "1" } name = "bob" command = "malus dispute-ancestor --fake-validation approval-invalid" args = [ "--bob", "-lparachain=debug,MALUS=trace"] - + [[relaychain.nodes]] - image = "{{MALUS_IMAGE}}" name = "charlie" - command = "malus dispute-ancestor --fake-validation approval-invalid" - args = [ "--charlie", "-lparachain=debug,MALUS=trace" ] + args = [ "--charlie", "-lparachain=debug" ] [[relaychain.nodes]] name = "dave" diff --git a/zombienet_tests/functional/0002-parachains-disputes.feature b/zombienet_tests/functional/0002-parachains-disputes.zndsl similarity index 96% rename from zombienet_tests/functional/0002-parachains-disputes.feature rename to zombienet_tests/functional/0002-parachains-disputes.zndsl index b56cd9b06c89..9386e07e209a 100644 --- a/zombienet_tests/functional/0002-parachains-disputes.feature +++ b/zombienet_tests/functional/0002-parachains-disputes.zndsl @@ -48,6 +48,9 @@ eve: reports parachain_candidate_disputes_total is at least 10 within 15 seconds eve: reports parachain_candidate_dispute_concluded{validity="valid"} is at least 10 within 15 seconds eve: reports parachain_candidate_dispute_concluded{validity="invalid"} is 0 within 15 seconds +# Check there is an offence report +alice: system event contains "There is an offence reported" within 60 seconds + # Check lag - approval alice: reports polkadot_parachain_approval_checking_finality_lag is 0 bob: reports polkadot_parachain_approval_checking_finality_lag is 0 diff --git a/zombienet_tests/functional/0003-beefy-and-mmr.toml b/zombienet_tests/functional/0003-beefy-and-mmr.toml index 6ac2ec0af7ff..1608976abdf2 100644 --- a/zombienet_tests/functional/0003-beefy-and-mmr.toml +++ b/zombienet_tests/functional/0003-beefy-and-mmr.toml @@ -8,5 +8,5 @@ command = "polkadot" [[relaychain.node_groups]] name = "validator" -count = 3 +count = 4 args = ["--log=beefy=debug", "--beefy", "--enable-offchain-indexing=true"] diff --git a/zombienet_tests/functional/0003-beefy-and-mmr.feature b/zombienet_tests/functional/0003-beefy-and-mmr.zndsl similarity index 74% rename from zombienet_tests/functional/0003-beefy-and-mmr.feature rename to zombienet_tests/functional/0003-beefy-and-mmr.zndsl index 2736cb60cc35..fad890bec9e4 100644 --- a/zombienet_tests/functional/0003-beefy-and-mmr.feature +++ b/zombienet_tests/functional/0003-beefy-and-mmr.zndsl @@ -6,21 +6,28 @@ Creds: config validator-0: is up validator-1: is up validator-2: is up +validator-3: is up # Check authority status. validator-0: reports node_roles is 4 validator-1: reports node_roles is 4 validator-2: reports node_roles is 4 +validator-3: reports node_roles is 4 # BEEFY sanity checks. validator-0: reports substrate_beefy_validator_set_id is 0 validator-1: reports substrate_beefy_validator_set_id is 0 validator-2: reports substrate_beefy_validator_set_id is 0 +validator-3: reports substrate_beefy_validator_set_id is 0 # Verify voting happens and 1st mandatory block is finalized within 1st session. validator-0: reports substrate_beefy_best_block is at least 1 within 60 seconds validator-1: reports substrate_beefy_best_block is at least 1 within 60 seconds validator-2: reports substrate_beefy_best_block is at least 1 within 60 seconds +validator-3: reports substrate_beefy_best_block is at least 1 within 60 seconds + +# Pause validator-3 and test chain is making progress without it. +validator-3: pause # Verify validator sets get changed on new sessions. validator-0: reports substrate_beefy_validator_set_id is at least 1 within 70 seconds @@ -37,8 +44,10 @@ validator-0: reports substrate_beefy_best_block is at least 21 within 130 second validator-1: reports substrate_beefy_best_block is at least 21 within 130 seconds validator-2: reports substrate_beefy_best_block is at least 21 within 130 seconds -# TODO 1: Custom JS to test BEEFY RPCs - -# TODO 2: Custom JS to test MMR RPCs +# TODO (issue #11972): Custom JS to test BEEFY RPCs +# TODO (issue #11972): Custom JS to test MMR RPCs -# TODO 3: once zombienet/#227 is implemented: pause+resume nodes to test Justifications Import +# Resume validator-3 and verify it imports all BEEFY justification and catches up. +validator-3: resume +validator-3: reports substrate_beefy_validator_set_id is at least 2 within 30 seconds +validator-3: reports substrate_beefy_best_block is at least 21 within 30 seconds diff --git a/zombienet_tests/functional/0003-parachains-garbage-candidate.feature b/zombienet_tests/functional/0003-parachains-garbage-candidate.zndsl similarity index 100% rename from zombienet_tests/functional/0003-parachains-garbage-candidate.feature rename to zombienet_tests/functional/0003-parachains-garbage-candidate.zndsl diff --git a/zombienet_tests/misc/0001-paritydb.feature b/zombienet_tests/misc/0001-paritydb.zndsl similarity index 98% rename from zombienet_tests/misc/0001-paritydb.feature rename to zombienet_tests/misc/0001-paritydb.zndsl index 2ed448321f78..7340fffb477e 100644 --- a/zombienet_tests/misc/0001-paritydb.feature +++ b/zombienet_tests/misc/0001-paritydb.zndsl @@ -30,7 +30,7 @@ validator-8: reports node_roles is 4 validator-9: reports node_roles is 4 # Ensure parachains are registered. -validator-0: parachain 2000 is registered +validator-0: parachain 2000 is registered within 20 seconds validator-0: parachain 2001 is registered validator-0: parachain 2002 is registered validator-0: parachain 2003 is registered diff --git a/zombienet_tests/misc/0002-download-polkadot-from-pr.sh b/zombienet_tests/misc/0002-download-polkadot-from-pr.sh new file mode 100644 index 000000000000..7ff323d9c41f --- /dev/null +++ b/zombienet_tests/misc/0002-download-polkadot-from-pr.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -euxo pipefail + +echo $@ + +CFG_DIR=/cfg + +# add CFG_DIR as first `looking dir` to allow to overrides commands. +mkdir -p $CFG_DIR +export PATH=$CFG_DIR:$PATH + +cd $CFG_DIR +# see 0002-upgrade-node.zndsl to view the args. +curl -L -O $1 +chmod +x $CFG_DIR/polkadot +echo $(polkadot --version) diff --git a/zombienet_tests/misc/0002-upgrade-node.toml b/zombienet_tests/misc/0002-upgrade-node.toml new file mode 100644 index 000000000000..ef3fa54dc200 --- /dev/null +++ b/zombienet_tests/misc/0002-upgrade-node.toml @@ -0,0 +1,49 @@ +[settings] +timeout = 1000 + +[relaychain] +default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" +chain = "rococo-local" + + + [[relaychain.nodes]] + name = "alice" + args = [ "-lparachain=debug,runtime=debug", "--db paritydb" ] + + [[relaychain.nodes]] + name = "bob" + args = [ "-lparachain=debug,runtime=debug", "--db rocksdb" ] + + [[relaychain.nodes]] + name = "charlie" + args = [ "-lparachain=debug,runtime=debug", "--db paritydb" ] + + [[relaychain.nodes]] + name = "dave" + args = [ "-lparachain=debug,runtime=debug", "--db rocksdb" ] + + +[[parachains]] +id = 2000 +addToGenesis = true + + [parachains.collator] + name = "collator01" + image = "{{COL_IMAGE}}" + command = "undying-collator" + args = ["-lparachain=debug"] + +[[parachains]] +id = 2001 +addToGenesis = true + + [parachains.collator] + name = "collator02" + image = "{{COL_IMAGE}}" + command = "undying-collator" + args = ["-lparachain=debug"] + +[types.Header] +number = "u64" +parent_hash = "Hash" +post_state = "Hash" \ No newline at end of file diff --git a/zombienet_tests/misc/0002-upgrade-node.zndsl b/zombienet_tests/misc/0002-upgrade-node.zndsl new file mode 100644 index 000000000000..6d0bd643c4f9 --- /dev/null +++ b/zombienet_tests/misc/0002-upgrade-node.zndsl @@ -0,0 +1,33 @@ +Description: Smoke / Upgrade Node +Network: ./0002-upgrade-node.toml +Creds: config + +alice: is up +bob: is up +charlie: is up +dave: is up + +alice: parachain 2000 block height is at least 10 within 200 seconds +bob: parachain 2001 block height is at least 10 within 200 seconds + +# upgrade both nodes +# For testing using native provider you should set this env var +# POLKADOT_PR_BIN_URL=https://gitlab.parity.io/parity/mirrors/polkadot/-/jobs/1842869/artifacts/raw/artifacts/polkadot +# with the version of polkadot you want to download. + +# avg 30s in our infra +alice: run ./0002-download-polkadot-from-pr.sh with "{{POLKADOT_PR_BIN_URL}}" within 40 seconds +bob: run ./0002-download-polkadot-from-pr.sh with "{{POLKADOT_PR_BIN_URL}}" within 40 seconds +alice: restart after 5 seconds +bob: restart after 5 seconds + +# process bootstrap +sleep 30 seconds + +alice: is up within 10 seconds +bob: is up within 10 seconds + + +alice: parachain 2000 block height is at least 30 within 300 seconds +bob: parachain 2001 block height is at least 30 within 120 seconds + diff --git a/zombienet_tests/smoke/0001-parachains-smoke-test.feature b/zombienet_tests/smoke/0001-parachains-smoke-test.zndsl similarity index 100% rename from zombienet_tests/smoke/0001-parachains-smoke-test.feature rename to zombienet_tests/smoke/0001-parachains-smoke-test.zndsl diff --git a/zombienet_tests/smoke/0002-parachains-upgrade-smoke-test.feature b/zombienet_tests/smoke/0002-parachains-upgrade-smoke-test.zndsl similarity index 100% rename from zombienet_tests/smoke/0002-parachains-upgrade-smoke-test.feature rename to zombienet_tests/smoke/0002-parachains-upgrade-smoke-test.zndsl diff --git a/zombienet_tests/smoke/0003-deregister-register-validator-smoke.feature b/zombienet_tests/smoke/0003-deregister-register-validator-smoke.zndsl similarity index 89% rename from zombienet_tests/smoke/0003-deregister-register-validator-smoke.feature rename to zombienet_tests/smoke/0003-deregister-register-validator-smoke.zndsl index 90fa4ef9d711..6a79c4cb071d 100644 --- a/zombienet_tests/smoke/0003-deregister-register-validator-smoke.feature +++ b/zombienet_tests/smoke/0003-deregister-register-validator-smoke.zndsl @@ -2,10 +2,10 @@ Description: Deregister / Register Validator Smoke Network: ./0003-deregister-register-validator-smoke.toml Creds: config -alice: is up -bob: is up -charlie: is up -dave: is up +alice: is up within 30 seconds +bob: is up within 30 seconds +charlie: is up within 30 seconds +dave: is up within 30 seconds # ensure is in the validator set dave: reports polkadot_node_is_parachain_validator is 1 within 240 secs