Merge remote-tracking branch 'origin/master' into gav-xcm-v3

This commit is contained in:
Branislav Kontur
2022-11-07 11:38:53 +01:00
119 changed files with 4558 additions and 2716 deletions
+12 -6
View File
@@ -6,6 +6,10 @@ title: Release Checklist for Runtime {{ env.VERSION }}
# Release Checklist - Runtimes # Release Checklist - Runtimes
**All** following checks must be completed before publishing a new release.
The release process is owned and led by @paritytech/release-engineering team.
The checks marked with :crab: are meant to be checked by [a runtime engineer](https://github.com/paritytech/cumulus/issues/1761).
## Runtimes Release ## Runtimes Release
### Codebase ### Codebase
@@ -13,19 +17,17 @@ These checks should be performed on the codebase.
- [ ] the [`spec_version`](https://github.com/paritytech/cumulus/blob/master/docs/release.md#spec-version) has been incremented since the - [ ] the [`spec_version`](https://github.com/paritytech/cumulus/blob/master/docs/release.md#spec-version) has been incremented since the
last release for any native runtimes from any existing use on public (non-private/test) networks last release for any native runtimes from any existing use on public (non-private/test) networks
- [ ] previously [completed migrations](https://github.com/paritytech/cumulus/blob/master/docs/release.md#old-migrations-removed) are - [ ] :crab: previously [completed migrations](https://github.com/paritytech/cumulus/blob/master/docs/release.md#old-migrations-removed) are removed for any public (non-private/test) networks
removed for any public (non-private/test) networks
- [ ] No migrations added in the last release that would need to be removed
- [ ] pallet and [extrinsic ordering](https://github.com/paritytech/cumulus/blob/master/docs/release.md#extrinsic-ordering--storage) as well as `SignedExtension`s have stayed - [ ] pallet and [extrinsic ordering](https://github.com/paritytech/cumulus/blob/master/docs/release.md#extrinsic-ordering--storage) as well as `SignedExtension`s have stayed
the same. Bump `transaction_version` otherwise the same. Bump `transaction_version` otherwise
- [ ] the [benchmarks](https://github.com/paritytech/ci_cd/wiki/Benchmarks:-cumulus) ran - [ ] the [benchmarks](https://github.com/paritytech/ci_cd/wiki/Benchmarks:-cumulus) ran
- [ ] the weights have been updated for any modified runtime logic - [ ] the weights have been updated for any modified runtime logic
- [ ] the various pieces of XCM config are sane - [ ] :crab: the new weights are sane, there are no significant (>50%) drops or rises with no reason
- [ ] :crab: XCM config is compatible with the configurations and versions of relevant interlocutors, like the Relay Chain.
### On the release branch ### On the release branch
The following checks can be performed after we have forked off to the release- The following checks can be performed after we have forked off to the release-candidate branch or started an additional release candidate branch (rc-2, rc-3, etc)
candidate branch or started an additional release candidate branch (rc-2, rc-3, etc)
- [ ] Verify [new migrations](https://github.com/paritytech/cumulus/blob/master/docs/release.md#new-migrations) complete successfully, and the - [ ] Verify [new migrations](https://github.com/paritytech/cumulus/blob/master/docs/release.md#new-migrations) complete successfully, and the
runtime state is correctly updated for any public (non-private/test) runtime state is correctly updated for any public (non-private/test)
@@ -41,6 +43,10 @@ candidate branch or started an additional release candidate branch (rc-2, rc-3,
- [ ] Check that [build artifacts](https://github.com/paritytech/cumulus/blob/master/docs/release.md#build-artifacts) have been added to the - [ ] Check that [build artifacts](https://github.com/paritytech/cumulus/blob/master/docs/release.md#build-artifacts) have been added to the
draft-release. draft-release.
# Post release
- [ ] :crab: all commits (runtime version bumps, fixes) on this release branch have been merged back to master.
--- ---
Read more about the [release documentation](https://github.com/paritytech/cumulus/blob/master/docs/release.md). Read more about the [release documentation](https://github.com/paritytech/cumulus/blob/master/docs/release.md).
+1
View File
@@ -29,6 +29,7 @@ rules:
check_type: changed_files check_type: changed_files
condition: condition:
include: ^\.gitlab-ci\.yml|^scripts/ci/.*|^\.github/.* include: ^\.gitlab-ci\.yml|^scripts/ci/.*|^\.github/.*
exclude: ^scripts/ci/gitlab/pipeline/zombienet.yml$
min_approvals: 2 min_approvals: 2
teams: teams:
- ci - ci
+1 -1
View File
@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v3 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with: with:
fetch-depth: 0 fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }} ref: ${{ github.event.pull_request.head.ref }}
+6 -1
View File
@@ -11,8 +11,13 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Install tooling
run: |
sudo apt-get install -y protobuf-compiler
protoc --version
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- name: Rust versions - name: Rust versions
run: rustup show run: rustup show
+40
View File
@@ -0,0 +1,40 @@
name: Rustfmt check
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
quick_check:
strategy:
matrix:
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: Install Rust nightly toolchain
uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.7
with:
profile: minimal
toolchain: nightly
override: true
components: clippy, rustfmt
- name: Cache Dependencies & Build Outputs
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
- name: Cargo fmt
uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # v1.0.3
with:
command: fmt
args: --all -- --check
@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v3 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with: with:
fetch-depth: 0 fetch-depth: 0
@@ -9,9 +9,15 @@ on:
jobs: jobs:
tag_rc: tag_rc:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
channel:
- name: 'Cumulus Release Coordination'
room: '!ZrLPsivsytpkdJfVaa:matrix.parity.io'
pre-releases: true
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v3 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with: with:
fetch-depth: 0 fetch-depth: 0
- id: compute_tag - id: compute_tag
@@ -67,11 +73,11 @@ jobs:
assignees: release-engineering assignees: release-engineering
filename: .github/ISSUE_TEMPLATE/release-runtime.md filename: .github/ISSUE_TEMPLATE/release-runtime.md
- name: Send Matrix message - name: Matrix notification to ${{ matrix.channel.name }}
uses: s3krit/matrix-message-action@70ad3fb812ee0e45ff8999d6af11cafad11a6ecf # v0.0.3 uses: s3krit/matrix-message-action@70ad3fb812ee0e45ff8999d6af11cafad11a6ecf # v0.0.3
if: steps.create-issue-checklist-client.outputs.url != '' && steps.create-issue-checklist-runtime.outputs.url != '' if: steps.create-issue-checklist-client.outputs.url != '' && steps.create-issue-checklist-runtime.outputs.url != ''
with: with:
room_id: ${{ secrets.INTERNAL_CUMULUS_MATRIX_ROOM_ID }} room_id: ${{ matrix.channel.room }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
server: "matrix.parity.io" server: "matrix.parity.io"
message: | message: |
@@ -79,7 +79,7 @@ jobs:
continue-on-error: true continue-on-error: true
- name: Save output as artifact - name: Save output as artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with: with:
name: ${{ env.CHAIN }} name: ${{ env.CHAIN }}
path: | path: |
@@ -108,7 +108,7 @@ jobs:
cat output.txt cat output.txt
- name: Save output as artifact - name: Save output as artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with: with:
name: ${{ matrix.runtime }} name: ${{ matrix.runtime }}
path: | path: |
+22 -16
View File
@@ -62,13 +62,13 @@ jobs:
runtime: rococo-parachain runtime: rococo-parachain
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v3 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with: with:
ref: ${{ github.event.inputs.ref2 }} ref: ${{ github.event.inputs.ref2 }}
- name: Cache target dir - name: Cache target dir
if: ${{ github.event.inputs.release_type != 'client' }} if: ${{ github.event.inputs.release_type != 'client' }}
uses: actions/cache@v3 uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with: with:
path: "${{ github.workspace }}/runtime/${{ matrix.runtime }}/target" path: "${{ github.workspace }}/runtime/${{ matrix.runtime }}/target"
key: srtool-target-${{ matrix.runtime }}-${{ github.sha }} key: srtool-target-${{ matrix.runtime }}-${{ github.sha }}
@@ -79,7 +79,7 @@ jobs:
- name: Build ${{ matrix.runtime }} runtime - name: Build ${{ matrix.runtime }} runtime
if: ${{ github.event.inputs.release_type != 'client' }} if: ${{ github.event.inputs.release_type != 'client' }}
id: srtool_build id: srtool_build
uses: chevdor/srtool-actions@v0.5.0 uses: chevdor/srtool-actions@v0.6.0
with: with:
image: paritytech/srtool image: paritytech/srtool
chain: ${{ matrix.runtime }} chain: ${{ matrix.runtime }}
@@ -93,14 +93,14 @@ jobs:
- name: Upload ${{ matrix.runtime }} srtool json - name: Upload ${{ matrix.runtime }} srtool json
if: ${{ github.event.inputs.release_type != 'client' }} if: ${{ github.event.inputs.release_type != 'client' }}
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with: with:
name: ${{ matrix.runtime }}-srtool-json name: ${{ matrix.runtime }}-srtool-json
path: ${{ matrix.runtime }}-srtool-digest.json path: ${{ matrix.runtime }}-srtool-digest.json
- name: Upload ${{ matrix.runtime }} runtime - name: Upload ${{ matrix.runtime }} runtime
if: ${{ github.event.inputs.release_type != 'client' }} if: ${{ github.event.inputs.release_type != 'client' }}
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with: with:
name: ${{ matrix.runtime }}-runtime name: ${{ matrix.runtime }}-runtime
path: | path: |
@@ -114,18 +114,18 @@ jobs:
asset_upload_url: ${{ steps.create-release.outputs.upload_url }} asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v3 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with: with:
fetch-depth: 0 fetch-depth: 0
path: cumulus path: cumulus
ref: ${{ github.event.inputs.ref2 }} ref: ${{ github.event.inputs.ref2 }}
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 # v1.118.0
with: with:
ruby-version: 3.0.0 ruby-version: 3.0.0
- name: Download srtool json output - name: Download srtool json output
uses: actions/download-artifact@v3 uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v3.0.0
- name: Prepare tooling - name: Prepare tooling
run: | run: |
@@ -177,14 +177,14 @@ jobs:
- name: Archive srtool json - name: Archive srtool json
if: ${{ github.event.inputs.release_type != 'client' }} if: ${{ github.event.inputs.release_type != 'client' }}
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with: with:
name: srtool-json name: srtool-json
path: | path: |
**/*-srtool-digest.json **/*-srtool-digest.json
- name: Archive context artifact - name: Archive context artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with: with:
name: release-notes-context name: release-notes-context
path: | path: |
@@ -228,14 +228,14 @@ jobs:
runtime: rococo-parachain runtime: rococo-parachain
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v3 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with: with:
ref: ${{ github.event.inputs.ref2 }} ref: ${{ github.event.inputs.ref2 }}
- name: Download artifacts - name: Download artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v3.0.0
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 # v1.118.0
with: with:
ruby-version: 3.0.0 ruby-version: 3.0.0
@@ -271,11 +271,17 @@ jobs:
if: ${{ github.event.inputs.notification == 'true' }} if: ${{ github.event.inputs.notification == 'true' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: publish-draft-release needs: publish-draft-release
strategy:
matrix:
channel:
- name: 'Cumulus Release Coordination'
room: '!ZrLPsivsytpkdJfVaa:matrix.parity.io'
pre-releases: true
steps: steps:
- name: Internal polkadot channel - name: Matrix notification to ${{ matrix.channel.name }}
uses: s3krit/matrix-message-action@v0.0.3 uses: s3krit/matrix-message-action@70ad3fb812ee0e45ff8999d6af11cafad11a6ecf # v0.0.3
with: with:
room_id: ${{ secrets.INTERNAL_CUMULUS_MATRIX_ROOM_ID }} room_id: ${{ matrix.channel.room }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: | message: |
**New draft for ${{ github.repository }}**: ${{ github.event.inputs.ref2 }}<br/> **New draft for ${{ github.repository }}**: ${{ github.event.inputs.ref2 }}<br/>
@@ -25,7 +25,7 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v3 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with: with:
ref: ${{ github.event.release.tag_name }} ref: ${{ github.event.release.tag_name }}
@@ -91,7 +91,7 @@ jobs:
./docker/scripts/build-injected-image.sh ./docker/scripts/build-injected-image.sh
- name: Login to Dockerhub - name: Login to Dockerhub
uses: docker/login-action@v2 uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
+2 -2
View File
@@ -20,7 +20,7 @@ jobs:
steps: steps:
- name: Checkout sources - name: Checkout sources
uses: actions/checkout@v3 uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with: with:
ref: ${{ github.event.release.tag_name }} ref: ${{ github.event.release.tag_name }}
@@ -90,7 +90,7 @@ jobs:
./docker/scripts/build-injected-image.sh ./docker/scripts/build-injected-image.sh
- name: Login to Dockerhub - name: Login to Dockerhub
uses: docker/login-action@v2 uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
@@ -18,8 +18,8 @@ jobs:
pre-release: true pre-release: true
steps: steps:
- name: send message - name: Matrix notification to ${{ matrix.channel.name }}
uses: s3krit/matrix-message-action@v0.0.3 uses: s3krit/matrix-message-action@70ad3fb812ee0e45ff8999d6af11cafad11a6ecf # v0.0.3
with: with:
room_id: ${{ matrix.channel.room }} room_id: ${{ matrix.channel.room }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
+4 -4
View File
@@ -48,13 +48,13 @@ jobs:
- category: testing - category: testing
runtime: rococo-parachain runtime: rococo-parachain
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Srtool build - name: Srtool build
id: srtool_build id: srtool_build
uses: chevdor/srtool-actions@v0.5.0 uses: chevdor/srtool-actions@v0.6.0
with: with:
chain: ${{ matrix.runtime }} chain: ${{ matrix.runtime }}
runtime_dir: parachains/runtimes/${{ matrix.category }}/${{ matrix.runtime }} runtime_dir: parachains/runtimes/${{ matrix.category }}/${{ matrix.runtime }}
@@ -68,7 +68,7 @@ jobs:
# it takes a while to build the runtime, so let's save the artifact as soon as we have it # it takes a while to build the runtime, so let's save the artifact as soon as we have it
- name: Archive Artifacts for ${{ matrix.runtime }} - name: Archive Artifacts for ${{ matrix.runtime }}
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with: with:
name: ${{ matrix.runtime }}-runtime name: ${{ matrix.runtime }}-runtime
path: | path: |
@@ -106,7 +106,7 @@ jobs:
tee ${{ matrix.runtime }}-diff.txt tee ${{ matrix.runtime }}-diff.txt
- name: Archive Subwasm results - name: Archive Subwasm results
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with: with:
name: ${{ matrix.runtime }}-runtime name: ${{ matrix.runtime }}-runtime
path: | path: |
+43 -540
View File
@@ -11,7 +11,8 @@ stages:
- benchmarks-build - benchmarks-build
- benchmarks-run - benchmarks-run
- publish - publish
- integration-test - integration-tests
- zombienet
default: default:
interruptible: true interruptible: true
@@ -29,9 +30,9 @@ variables:
CI_IMAGE: "paritytech/ci-linux:production" CI_IMAGE: "paritytech/ci-linux:production"
DOCKER_OS: "debian:stretch" DOCKER_OS: "debian:stretch"
ARCH: "x86_64" ARCH: "x86_64"
ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.2.59" ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.2.82"
.collect-artifacts: &collect-artifacts .collect-artifacts:
artifacts: artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}" name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: on_success when: on_success
@@ -39,27 +40,21 @@ variables:
paths: paths:
- ./artifacts/ - ./artifacts/
.rust-info-script: &rust-info-script
- rustup show
- cargo --version
- rustup +nightly show
- cargo +nightly --version
- bash --version
# collecting vars for pipeline stopper # collecting vars for pipeline stopper
# they will be used if the job fails # 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_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 "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 - echo "PR_NUM=${CI_COMMIT_REF_NAME}" >> pipeline-stopper.env
.pipeline-stopper-artifacts: &pipeline-stopper-artifacts .pipeline-stopper-artifacts:
artifacts: artifacts:
reports: reports:
dotenv: pipeline-stopper.env dotenv: pipeline-stopper.env
.common-refs: &common-refs .common-refs:
# these jobs run always* # these jobs run always*
rules: rules:
- if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_PIPELINE_SOURCE == "schedule"
@@ -69,29 +64,29 @@ variables:
- if: $CI_COMMIT_REF_NAME =~ /^release-parachains-v[0-9].*$/ # i.e. release-parachains-v1.0, release-parachains-v2.1rc1, release-parachains-v3000 - if: $CI_COMMIT_REF_NAME =~ /^release-parachains-v[0-9].*$/ # i.e. release-parachains-v1.0, release-parachains-v2.1rc1, release-parachains-v3000
- if: $CI_COMMIT_REF_NAME =~ /^polkadot-v[0-9]+\.[0-9]+.*$/ # i.e. polkadot-v1.0.99, polkadot-v2.1rc1 - if: $CI_COMMIT_REF_NAME =~ /^polkadot-v[0-9]+\.[0-9]+.*$/ # i.e. polkadot-v1.0.99, polkadot-v2.1rc1
.pr-refs: &pr-refs .pr-refs:
# these jobs run always* # these jobs run always*
rules: rules:
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
.publish-refs: &publish-refs .publish-refs:
rules: rules:
- if: $CI_COMMIT_REF_NAME == "master" - if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 - if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
# run benchmarks manually only on release-parachains-v* branch # run benchmarks manually only on release-parachains-v* branch
.benchmarks-manual-refs: &benchmarks-manual-refs .benchmarks-manual-refs:
rules: rules:
- if: $CI_COMMIT_REF_NAME =~ /^release-parachains-v[0-9].*$/ # i.e. release-parachains-v1.0, release-parachains-v2.1rc1, release-parachains-v3000 - if: $CI_COMMIT_REF_NAME =~ /^release-parachains-v[0-9].*$/ # i.e. release-parachains-v1.0, release-parachains-v2.1rc1, release-parachains-v3000
when: manual when: manual
# run benchmarks only on release-parachains-v* branch # run benchmarks only on release-parachains-v* branch
.benchmarks-refs: &benchmarks-refs .benchmarks-refs:
rules: rules:
- if: $CI_COMMIT_REF_NAME =~ /^release-parachains-v[0-9].*$/ # i.e. release-parachains-v1.0, release-parachains-v2.1rc1, release-parachains-v3000 - if: $CI_COMMIT_REF_NAME =~ /^release-parachains-v[0-9].*$/ # i.e. release-parachains-v1.0, release-parachains-v2.1rc1, release-parachains-v3000
.zombienet-refs: &zombienet-refs .zombienet-refs:
rules: rules:
- if: $CI_PIPELINE_SOURCE == "pipeline" - if: $CI_PIPELINE_SOURCE == "pipeline"
when: never when: never
@@ -100,547 +95,55 @@ variables:
- if: $CI_COMMIT_REF_NAME == "master" - if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
.docker-env: &docker-env .docker-env:
image: "${CI_IMAGE}" image: "${CI_IMAGE}"
before_script: before_script:
- *rust-info-script - rustup show
- cargo --version
- rustup +nightly show
- cargo +nightly --version
- bash --version
tags: tags:
- linux-docker - linux-docker
.kubernetes-env: &kubernetes-env .kubernetes-env:
image: "${CI_IMAGE}" image: "${CI_IMAGE}"
tags: tags:
- kubernetes-parity-build - kubernetes-parity-build
#### stage: test .git-commit-push:
test-linux-stable:
stage: test
<<: *docker-env
<<: *common-refs
<<: *pipeline-stopper-artifacts
before_script:
- *rust-info-script
- *pipeline-stopper-vars
variables:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
script: script:
- time cargo nextest run --all --release --locked --run-ignored all
test-doc:
stage: test
<<: *docker-env
<<: *common-refs
variables:
# 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 --doc
check-runtime-benchmarks:
stage: test
<<: *docker-env
<<: *common-refs
script:
# Check that the node will compile with `runtime-benchmarks` feature flag.
- time cargo check --all --features runtime-benchmarks
# Check that parachain-template will compile with `runtime-benchmarks` feature flag.
- time cargo check -p parachain-template-node --features runtime-benchmarks
cargo-check-try-runtime:
stage: test
<<: *docker-env
<<: *common-refs
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: check-runtime-benchmarks
artifacts: false
script:
# Check that the node will compile with `try-runtime` feature flag.
- time cargo check --all --features try-runtime
# Check that parachain-template will compile with `try-runtime` feature flag.
- time cargo check -p parachain-template-node --features try-runtime
check-rustdoc:
stage: test
<<: *docker-env
<<: *common-refs
variables:
SKIP_WASM_BUILD: 1
RUSTDOCFLAGS: "-Dwarnings"
script:
- time cargo +nightly doc --workspace --all-features --verbose --no-deps
cargo-check-benches:
stage: test
<<: *docker-env
<<: *common-refs
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: check-rustdoc
artifacts: false
script:
- time cargo check --all --benches
#### stage: build
build-linux-stable:
stage: build
<<: *docker-env
<<: *collect-artifacts
<<: *common-refs
variables:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: check-rustdoc
artifacts: false
script:
- echo "___Building a binary, please refrain from using it in production since it goes with the debug assertions.___"
- time cargo build --release --locked --bin polkadot-parachain
- echo "___Packing the artifacts___"
- mkdir -p ./artifacts
- mv ./target/release/polkadot-parachain ./artifacts/.
- echo "___The VERSION is either a tag name or the curent branch if triggered not by a tag___"
- echo ${CI_COMMIT_REF_NAME} | tee ./artifacts/VERSION
build-test-parachain:
stage: build
<<: *docker-env
<<: *collect-artifacts
<<: *common-refs
variables:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: check-rustdoc
artifacts: false
script:
- echo "___Building a binary, please refrain from using it in production since it goes with the debug assertions.___"
- time cargo +nightly build --release --locked --bin test-parachain
- echo "___Packing the artifacts___"
- mkdir -p ./artifacts
- mv ./target/release/test-parachain ./artifacts/.
- mkdir -p ./artifacts/zombienet
- mv ./target/release/wbuild/cumulus-test-runtime/wasm_binary_spec_version_incremented.rs.compact.compressed.wasm ./artifacts/zombienet/.
# build runtime only if files in $RUNTIME_PATH/$RUNTIME_NAME were changed
.build-runtime-template: &build-runtime-template
stage: build
<<: *docker-env
<<: *pr-refs
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: check-rustdoc
artifacts: false
variables:
RUNTIME_PATH: "parachains/runtimes/assets"
script:
- cd ${RUNTIME_PATH}
- for directory in $(echo */); do
echo "_____Running cargo check for ${directory} ______";
cd ${directory};
pwd;
SKIP_WASM_BUILD=1 cargo check;
cd ..;
done
# DAG: build-runtime-assets -> build-runtime-collectives -> build-runtime-contracts
# DAG: build-runtime-assets ->build-runtime-starters -> build-runtime-testing
build-runtime-assets:
<<: *build-runtime-template
variables:
RUNTIME_PATH: "parachains/runtimes/assets"
build-runtime-collectives:
<<: *build-runtime-template
variables:
RUNTIME_PATH: "parachains/runtimes/collectives"
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: build-runtime-assets
artifacts: false
build-runtime-contracts:
<<: *build-runtime-template
variables:
RUNTIME_PATH: "parachains/runtimes/contracts"
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: build-runtime-collectives
artifacts: false
build-runtime-starters:
<<: *build-runtime-template
variables:
RUNTIME_PATH: "parachains/runtimes/starters"
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: build-runtime-assets
artifacts: false
build-runtime-testing:
<<: *build-runtime-template
variables:
RUNTIME_PATH: "parachains/runtimes/testing"
# this is an artificial job dependency, for pipeline optimization using GitLab's DAGs
needs:
- job: build-runtime-starters
artifacts: false
#### stage: publish
.build-push-image: &build-push-image
image: quay.io/buildah/stable
variables:
DOCKERFILE: "" # docker/path-to.Dockerfile
IMAGE_NAME: "" # docker.io/paritypr/image_name
VERSION: "${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
script:
- test "$PARITYPR_USER" -a "$PARITYPR_PASS" ||
( echo "no docker credentials provided"; exit 1 )
- buildah bud
--format=docker
--build-arg VCS_REF="${CI_COMMIT_SHA}"
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
--build-arg IMAGE_NAME="${IMAGE_NAME}"
--tag "$IMAGE_NAME:$VERSION"
--file ${DOCKERFILE} .
- echo "$PARITYPR_PASS" |
buildah login --username "$PARITYPR_USER" --password-stdin docker.io
- buildah info
- buildah push --format=v2s2 "$IMAGE_NAME:$VERSION"
after_script:
- buildah logout --all
build-push-image-polkadot-parachain-debug:
stage: publish
<<: *kubernetes-env
<<: *common-refs
<<: *build-push-image
needs:
- job: build-linux-stable
artifacts: true
variables:
DOCKERFILE: "docker/polkadot-parachain-debug_unsigned_injected.Dockerfile"
IMAGE_NAME: "docker.io/paritypr/polkadot-parachain-debug"
VERSION: "${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
build-push-image-test-parachain:
stage: publish
<<: *kubernetes-env
<<: *common-refs
<<: *build-push-image
needs:
- job: build-test-parachain
artifacts: true
variables:
DOCKERFILE: "docker/test-parachain_injected.Dockerfile"
IMAGE_NAME: "docker.io/paritypr/test-parachain"
VERSION: "${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
publish-s3:
stage: publish
<<: *kubernetes-env
image: paritytech/awscli:latest
<<: *publish-refs
needs:
- job: build-linux-stable
artifacts: true
variables:
GIT_STRATEGY: none
BUCKET: "releases.parity.io"
PREFIX: "cumulus/${ARCH}-${DOCKER_OS}"
script:
- echo "___Publishing a binary with debug assertions!___"
- echo "___VERSION = $(cat ./artifacts/VERSION) ___"
- aws s3 sync ./artifacts/ s3://${BUCKET}/${PREFIX}/$(cat ./artifacts/VERSION)/
- echo "___Updating objects in latest path___"
- aws s3 sync s3://${BUCKET}/${PREFIX}/$(cat ./artifacts/VERSION)/ s3://${BUCKET}/${PREFIX}/latest/
after_script:
- aws s3 ls s3://${BUCKET}/${PREFIX}/latest/
--recursive --human-readable --summarize
#### stage: benchmarks
# Work only on release-parachains-v* branches
benchmarks-build:
stage: benchmarks-build
<<: *docker-env
<<: *collect-artifacts
<<: *benchmarks-manual-refs
script:
- time cargo build --profile production --locked --features runtime-benchmarks
- mkdir -p artifacts
- cp target/production/polkadot-parachain ./artifacts/
.git-commit-push: &git-commit-push
- git status
# Set git config
- rm -rf .git/config
- git config --global user.email "${GITHUB_EMAIL}"
- git config --global user.name "${GITHUB_USER}"
- git config remote.origin.url "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/paritytech/${CI_PROJECT_NAME}.git"
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
# push results to github
- git checkout -b $BRANCHNAME
- git add parachains/*
- git commit -m "[benchmarks] pr with weights"
- git push origin $BRANCHNAME
benchmarks-assets:
stage: benchmarks-run
before_script:
- *rust-info-script
<<: *collect-artifacts
<<: *benchmarks-refs
timeout: 1d
script:
- ./scripts/benchmarks-ci.sh assets statemine ./artifacts
- ./scripts/benchmarks-ci.sh assets statemint ./artifacts
- ./scripts/benchmarks-ci.sh assets westmint ./artifacts
- export CURRENT_TIME=$(date '+%s')
- export BRANCHNAME="weights-statemint-${CI_COMMIT_BRANCH}-${CURRENT_TIME}"
- *git-commit-push
# create PR to release-parachains-v* branch
- curl -u ${GITHUB_USER}:${GITHUB_TOKEN}
-d '{"title":"[benchmarks] Update weights for statemine/t","body":"This PR is generated automatically by CI. (Once merged please backport to master and node release branch.)","head":"'${BRANCHNAME}'","base":"'${CI_COMMIT_BRANCH}'"}'
-X POST https://api.github.com/repos/paritytech/${CI_PROJECT_NAME}/pulls
after_script:
- rm -rf .git/config
tags:
- weights
benchmarks-collectives:
stage: benchmarks-run
before_script:
- *rust-info-script
<<: *collect-artifacts
<<: *benchmarks-refs
script:
- ./scripts/benchmarks-ci.sh collectives collectives-polkadot ./artifacts
- git status - git status
- export CURRENT_TIME=$(date '+%s') # Set git config
- export BRANCHNAME="weights-collectives-${CI_COMMIT_BRANCH}-${CURRENT_TIME}"
- *git-commit-push
# create PR
- curl -u ${GITHUB_USER}:${GITHUB_TOKEN}
-d '{"title":"[benchmarks] Update weights for collectives","body":"This PR is generated automatically by CI.","head":"'$BRANCHNAME'","base":"'${CI_COMMIT_BRANCH}'"}'
-X POST https://api.github.com/repos/paritytech/${CI_PROJECT_NAME}/pulls
after_script:
- rm -rf .git/config - rm -rf .git/config
tags: - git config --global user.email "${GITHUB_EMAIL}"
- weights - git config --global user.name "${GITHUB_USER}"
- git config remote.origin.url "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/paritytech/${CI_PROJECT_NAME}.git"
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
# push results to github
- git checkout -b $BRANCHNAME
- git add parachains/*
- git commit -m "[benchmarks] pr with weights"
- git push origin $BRANCHNAME
publish-benchmarks-assets-s3: &publish-benchmarks include:
stage: publish # test jobs
<<: *kubernetes-env - scripts/ci/gitlab/pipeline/test.yml
image: paritytech/awscli:latest # # build jobs
<<: *benchmarks-refs - scripts/ci/gitlab/pipeline/build.yml
needs: # # benchmarks jobs
- job: benchmarks-assets - scripts/ci/gitlab/pipeline/benchmarks.yml
artifacts: true # # publish jobs
variables: - scripts/ci/gitlab/pipeline/publish.yml
GIT_STRATEGY: none # zombienet jobs
BUCKET: "releases.parity.io" - scripts/ci/gitlab/pipeline/zombienet.yml
PREFIX: "cumulus/$CI_COMMIT_REF_NAME/benchmarks"
script:
- echo "___Removing binary from artifacts___"
- rm -f ./artifacts/polkadot-parachain
- echo "___Publishing benchmark results___"
- aws s3 sync ./artifacts/ s3://${BUCKET}/${PREFIX}/
after_script:
- aws s3 ls s3://${BUCKET}/${PREFIX}/ --recursive --human-readable --summarize
publish-benchmarks-collectives-s3:
<<: *publish-benchmarks
needs:
- job: benchmarks-collectives
artifacts: true
# Ref: https://github.com/paritytech/opstooling/issues/111
update-parachain-template:
stage: publish
extends: .kubernetes-env
rules:
- if: $CI_COMMIT_REF_NAME =~ /^polkadot-v[0-9]+\.[0-9]+.*$/ # i.e. polkadot-v1.0.99, polkadot-v2.1rc1
script:
- git clone --depth=1 --branch="$PIPELINE_SCRIPTS_TAG" https://github.com/paritytech/pipeline-scripts
- ./pipeline-scripts/update_substrate_template.sh
--repo-name "substrate-parachain-template"
--template-path "parachain-template"
--github-api-token "$GITHUB_TOKEN"
--polkadot-branch "$CI_COMMIT_REF_NAME"
#### stage: integration-test
zombienet-0001-sync_blocks_from_tip_without_connected_collator:
stage: integration-test
image: "${ZOMBIENET_IMAGE}"
<<: *zombienet-refs
needs:
- job: build-push-image-test-parachain
variables:
POLKADOT_IMAGE: "docker.io/paritypr/polkadot-debug:master"
GH_DIR: "https://github.com/paritytech/cumulus/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests"
COL_IMAGE: "docker.io/paritypr/test-parachain:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
before_script:
- echo "Zombie-net Tests Config"
- echo "${ZOMBIENET_IMAGE}"
- echo "${RELAY_IMAGE}"
- echo "${COL_IMAGE}"
- echo "${GH_DIR}"
- export DEBUG=zombie
- export RELAY_IMAGE=${POLKADOT_IMAGE}
- export COL_IMAGE=${COL_IMAGE}
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh
--github-remote-dir="${GH_DIR}"
--concurrency=1
--test="0001-sync_blocks_from_tip_without_connected_collator.feature"
allow_failure: true
retry: 2
tags:
- zombienet-polkadot-integration-test
zombienet-0002-pov_recovery:
stage: integration-test
image: "${ZOMBIENET_IMAGE}"
<<: *zombienet-refs
needs:
- job: build-push-image-test-parachain
variables:
POLKADOT_IMAGE: "docker.io/paritypr/polkadot-debug:master"
GH_DIR: "https://github.com/paritytech/cumulus/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests"
COL_IMAGE: "docker.io/paritypr/test-parachain:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
before_script:
- echo "Zombie-net Tests Config"
- echo "${ZOMBIENET_IMAGE}"
- echo "${RELAY_IMAGE}"
- echo "${COL_IMAGE}"
- echo "${GH_DIR}"
- export DEBUG=zombie
- export RELAY_IMAGE=${POLKADOT_IMAGE}
- export COL_IMAGE=${COL_IMAGE}
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh
--github-remote-dir="${GH_DIR}"
--concurrency=1
--test="0002-pov_recovery.feature"
allow_failure: true
retry: 2
tags:
- zombienet-polkadot-integration-test
zombienet-0003-full_node_catching_up:
stage: integration-test
image: "${ZOMBIENET_IMAGE}"
<<: *zombienet-refs
needs:
- job: build-push-image-test-parachain
variables:
POLKADOT_IMAGE: "docker.io/paritypr/polkadot-debug:master"
GH_DIR: "https://github.com/paritytech/cumulus/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests"
COL_IMAGE: "docker.io/paritypr/test-parachain:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
before_script:
- echo "Zombie-net Tests Config"
- echo "${ZOMBIENET_IMAGE}"
- echo "${RELAY_IMAGE}"
- echo "${COL_IMAGE}"
- echo "${GH_DIR}"
- export DEBUG=zombie
- export RELAY_IMAGE=${POLKADOT_IMAGE}
- export COL_IMAGE=${COL_IMAGE}
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh
--github-remote-dir="${GH_DIR}"
--concurrency=1
--test="0003-full_node_catching_up.feature"
allow_failure: true
retry: 2
tags:
- zombienet-polkadot-integration-test
zombienet-0004-runtime_upgrade:
stage: integration-test
image: "${ZOMBIENET_IMAGE}"
<<: *zombienet-refs
needs:
- job: build-push-image-test-parachain
- job: build-test-parachain
artifacts: true
variables:
POLKADOT_IMAGE: "docker.io/paritypr/polkadot-debug:master"
GH_DIR: "https://github.com/paritytech/cumulus/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests"
COL_IMAGE: "docker.io/paritypr/test-parachain:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
before_script:
- ls -ltr *
- cp ./artifacts/zombienet/wasm_binary_spec_version_incremented.rs.compact.compressed.wasm /tmp/
- ls /tmp
- echo "Zombie-net Tests Config"
- echo "${ZOMBIENET_IMAGE}"
- echo "${RELAY_IMAGE}"
- echo "${COL_IMAGE}"
- echo "${GH_DIR}"
- export DEBUG=zombie
- export RELAY_IMAGE=${POLKADOT_IMAGE}
- export COL_IMAGE=${COL_IMAGE}
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh
--github-remote-dir="${GH_DIR}"
--concurrency=1
--test="0004-runtime_upgrade.feature"
allow_failure: true
retry: 2
tags:
- zombienet-polkadot-integration-test
zombienet-0005-migrate_solo_to_para:
stage: integration-test
image: "${ZOMBIENET_IMAGE}"
<<: *zombienet-refs
needs:
- job: build-push-image-test-parachain
- job: build-test-parachain
artifacts: true
variables:
POLKADOT_IMAGE: "docker.io/paritypr/polkadot-debug:master"
GH_DIR: "https://github.com/paritytech/cumulus/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests"
COL_IMAGE: "docker.io/paritypr/test-parachain:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
before_script:
- ls -ltr *
- echo "Zombie-net Tests Config"
- echo "${ZOMBIENET_IMAGE}"
- echo "${RELAY_IMAGE}"
- echo "${COL_IMAGE}"
- echo "${GH_DIR}"
- export DEBUG=zombie
- export RELAY_IMAGE=${POLKADOT_IMAGE}
- export COL_IMAGE=${COL_IMAGE}
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh
--github-remote-dir="${GH_DIR}"
--concurrency=1
--test="0005-migrate_solo_to_para.feature"
allow_failure: true
retry: 2
tags:
- zombienet-polkadot-integration-test
#### stage: .post #### stage: .post
# This job cancels the whole pipeline if any of provided jobs fail. # 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 # 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. # to fail the pipeline as soon as possible to shorten the feedback loop.
.cancel-pipeline: cancel-pipeline:
stage: .post stage: .post
needs: needs:
- job: test-linux-stable - job: test-linux-stable
Generated
+881 -883
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -10,6 +10,7 @@ members = [
"client/relay-chain-interface", "client/relay-chain-interface",
"client/relay-chain-inprocess-interface", "client/relay-chain-inprocess-interface",
"client/relay-chain-rpc-interface", "client/relay-chain-rpc-interface",
"client/relay-chain-minimal-node",
"pallets/aura-ext", "pallets/aura-ext",
"pallets/collator-selection", "pallets/collator-selection",
"pallets/dmp-queue", "pallets/dmp-queue",
+1 -1
View File
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021" edition = "2021"
[dependencies] [dependencies]
clap = { version = "3.2.22", features = ["derive", "deprecated"] } clap = { version = "4.0.17", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0.0" } codec = { package = "parity-scale-codec", version = "3.0.0" }
url = "2.3.1" url = "2.3.1"
+18 -16
View File
@@ -40,17 +40,18 @@ use url::Url;
/// The `purge-chain` command used to remove the whole chain: the parachain and the relay chain. /// The `purge-chain` command used to remove the whole chain: the parachain and the relay chain.
#[derive(Debug, clap::Parser)] #[derive(Debug, clap::Parser)]
#[group(skip)]
pub struct PurgeChainCmd { pub struct PurgeChainCmd {
/// The base struct of the purge-chain command. /// The base struct of the purge-chain command.
#[clap(flatten)] #[command(flatten)]
pub base: sc_cli::PurgeChainCmd, pub base: sc_cli::PurgeChainCmd,
/// Only delete the para chain database /// Only delete the para chain database
#[clap(long, aliases = &["para"])] #[arg(long, aliases = &["para"])]
pub parachain: bool, pub parachain: bool,
/// Only delete the relay chain database /// Only delete the relay chain database
#[clap(long, aliases = &["relay"])] #[arg(long, aliases = &["relay"])]
pub relaychain: bool, pub relaychain: bool,
} }
@@ -131,15 +132,15 @@ impl sc_cli::CliConfiguration for PurgeChainCmd {
#[derive(Debug, clap::Parser)] #[derive(Debug, clap::Parser)]
pub struct ExportGenesisStateCommand { pub struct ExportGenesisStateCommand {
/// Output file name or stdout if unspecified. /// Output file name or stdout if unspecified.
#[clap(action)] #[arg()]
pub output: Option<PathBuf>, pub output: Option<PathBuf>,
/// Write output in binary. Default is to write in hex. /// Write output in binary. Default is to write in hex.
#[clap(short, long)] #[arg(short, long)]
pub raw: bool, pub raw: bool,
#[allow(missing_docs)] #[allow(missing_docs)]
#[clap(flatten)] #[command(flatten)]
pub shared_params: sc_cli::SharedParams, pub shared_params: sc_cli::SharedParams,
} }
@@ -214,15 +215,15 @@ impl sc_cli::CliConfiguration for ExportGenesisStateCommand {
#[derive(Debug, clap::Parser)] #[derive(Debug, clap::Parser)]
pub struct ExportGenesisWasmCommand { pub struct ExportGenesisWasmCommand {
/// Output file name or stdout if unspecified. /// Output file name or stdout if unspecified.
#[clap(action)] #[arg()]
pub output: Option<PathBuf>, pub output: Option<PathBuf>,
/// Write output in binary. Default is to write in hex. /// Write output in binary. Default is to write in hex.
#[clap(short, long)] #[arg(short, long)]
pub raw: bool, pub raw: bool,
#[allow(missing_docs)] #[allow(missing_docs)]
#[clap(flatten)] #[command(flatten)]
pub shared_params: sc_cli::SharedParams, pub shared_params: sc_cli::SharedParams,
} }
@@ -264,7 +265,8 @@ impl sc_cli::CliConfiguration for ExportGenesisWasmCommand {
fn validate_relay_chain_url(arg: &str) -> Result<Url, String> { fn validate_relay_chain_url(arg: &str) -> Result<Url, String> {
let url = Url::parse(arg).map_err(|e| e.to_string())?; let url = Url::parse(arg).map_err(|e| e.to_string())?;
if url.scheme() == "ws" { let scheme = url.scheme();
if scheme == "ws" || scheme == "wss" {
Ok(url) Ok(url)
} else { } else {
Err(format!( Err(format!(
@@ -276,23 +278,23 @@ fn validate_relay_chain_url(arg: &str) -> Result<Url, String> {
/// The `run` command used to run a node. /// The `run` command used to run a node.
#[derive(Debug, clap::Parser)] #[derive(Debug, clap::Parser)]
#[group(skip)]
pub struct RunCmd { pub struct RunCmd {
/// The cumulus RunCmd inherents from sc_cli's /// The cumulus RunCmd inherents from sc_cli's
#[clap(flatten)] #[command(flatten)]
pub base: sc_cli::RunCmd, pub base: sc_cli::RunCmd,
/// Run node as collator. /// Run node as collator.
/// ///
/// Note that this is the same as running with `--validator`. /// Note that this is the same as running with `--validator`.
#[clap(long, conflicts_with = "validator")] #[arg(long, conflicts_with = "validator")]
pub collator: bool, pub collator: bool,
/// EXPERIMENTAL: Specify an URL to a relay chain full node to communicate with. /// EXPERIMENTAL: Specify an URL to a relay chain full node to communicate with.
#[clap( #[arg(
long, long,
value_parser = validate_relay_chain_url, value_parser = validate_relay_chain_url
conflicts_with_all = &["alice", "bob", "charlie", "dave", "eve", "ferdie", "one", "two"] ) )]
]
pub relay_chain_rpc_url: Option<Url>, pub relay_chain_rpc_url: Option<Url>,
} }
+2 -2
View File
@@ -6,10 +6,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021" edition = "2021"
[dependencies] [dependencies]
async-trait = "0.1.57" async-trait = "0.1.58"
codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ] } codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ] }
futures = "0.3.24" futures = "0.3.24"
tracing = "0.1.36" tracing = "0.1.37"
# Substrate # Substrate
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
+9 -6
View File
@@ -17,9 +17,10 @@
//! Parachain specific wrapper for the AuRa import queue. //! Parachain specific wrapper for the AuRa import queue.
use codec::Codec; use codec::Codec;
use cumulus_client_consensus_common::ParachainBlockImport;
use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider}; use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider};
use sc_consensus::{import_queue::DefaultImportQueue, BlockImport}; use sc_consensus::{import_queue::DefaultImportQueue, BlockImport};
use sc_consensus_aura::AuraVerifier; use sc_consensus_aura::{AuraVerifier, CompatibilityMode};
use sc_consensus_slots::InherentDataProviderExt; use sc_consensus_slots::InherentDataProviderExt;
use sc_telemetry::TelemetryHandle; use sc_telemetry::TelemetryHandle;
use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_api::{ApiExt, ProvideRuntimeApi};
@@ -33,10 +34,10 @@ use sp_runtime::traits::Block as BlockT;
use std::{fmt::Debug, hash::Hash, sync::Arc}; use std::{fmt::Debug, hash::Hash, sync::Arc};
use substrate_prometheus_endpoint::Registry; use substrate_prometheus_endpoint::Registry;
/// Parameters of [`import_queue`]. /// Parameters for [`import_queue`].
pub struct ImportQueueParams<'a, I, C, CIDP, S> { pub struct ImportQueueParams<'a, I, C, CIDP, S> {
/// The block import to use. /// The block import to use.
pub block_import: I, pub block_import: ParachainBlockImport<I>,
/// The client to interact with the chain. /// The client to interact with the chain.
pub client: Arc<C>, pub client: Arc<C>,
/// The inherent data providers, to create the inherent data. /// The inherent data providers, to create the inherent data.
@@ -83,7 +84,7 @@ where
CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync, CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync,
{ {
sc_consensus_aura::import_queue::<P, _, _, _, _, _>(sc_consensus_aura::ImportQueueParams { sc_consensus_aura::import_queue::<P, _, _, _, _, _>(sc_consensus_aura::ImportQueueParams {
block_import: cumulus_client_consensus_common::ParachainBlockImport::new(block_import), block_import,
justification_import: None, justification_import: None,
client, client,
create_inherent_data_providers, create_inherent_data_providers,
@@ -91,6 +92,7 @@ where
registry, registry,
check_for_equivocation: sc_consensus_aura::CheckForEquivocation::No, check_for_equivocation: sc_consensus_aura::CheckForEquivocation::No,
telemetry, telemetry,
compatibility_mode: CompatibilityMode::None,
}) })
} }
@@ -105,16 +107,17 @@ pub struct BuildVerifierParams<C, CIDP> {
} }
/// Build the [`AuraVerifier`]. /// Build the [`AuraVerifier`].
pub fn build_verifier<P, C, CIDP>( pub fn build_verifier<P, C, CIDP, N>(
BuildVerifierParams { client, create_inherent_data_providers, telemetry }: BuildVerifierParams< BuildVerifierParams { client, create_inherent_data_providers, telemetry }: BuildVerifierParams<
C, C,
CIDP, CIDP,
>, >,
) -> AuraVerifier<C, P, CIDP> { ) -> AuraVerifier<C, P, CIDP, N> {
sc_consensus_aura::build_verifier(sc_consensus_aura::BuildVerifierParams { sc_consensus_aura::build_verifier(sc_consensus_aura::BuildVerifierParams {
client, client,
create_inherent_data_providers, create_inherent_data_providers,
telemetry, telemetry,
check_for_equivocation: sc_consensus_aura::CheckForEquivocation::No, check_for_equivocation: sc_consensus_aura::CheckForEquivocation::No,
compatibility_mode: CompatibilityMode::None,
}) })
} }
+18 -17
View File
@@ -71,6 +71,22 @@ impl<B, CIDP, W> Clone for AuraConsensus<B, CIDP, W> {
} }
} }
/// Parameters of [`AuraConsensus::build`].
pub struct BuildAuraConsensusParams<PF, BI, CIDP, Client, BS, SO> {
pub proposer_factory: PF,
pub create_inherent_data_providers: CIDP,
pub block_import: ParachainBlockImport<BI>,
pub para_client: Arc<Client>,
pub backoff_authoring_blocks: Option<BS>,
pub sync_oracle: SO,
pub keystore: SyncCryptoStorePtr,
pub force_authoring: bool,
pub slot_duration: SlotDuration,
pub telemetry: Option<TelemetryHandle>,
pub block_proposal_slot_portion: SlotProportion,
pub max_block_proposal_slot_portion: Option<SlotProportion>,
}
impl<B, CIDP> AuraConsensus<B, CIDP, ()> impl<B, CIDP> AuraConsensus<B, CIDP, ()>
where where
B: BlockT, B: BlockT,
@@ -117,7 +133,7 @@ where
let worker = sc_consensus_aura::build_aura_worker::<P, _, _, _, _, _, _, _, _>( let worker = sc_consensus_aura::build_aura_worker::<P, _, _, _, _, _, _, _, _>(
BuildAuraWorkerParams { BuildAuraWorkerParams {
client: para_client, client: para_client,
block_import: ParachainBlockImport::new(block_import), block_import,
justification_sync_link: (), justification_sync_link: (),
proposer_factory, proposer_factory,
sync_oracle, sync_oracle,
@@ -127,6 +143,7 @@ where
telemetry, telemetry,
block_proposal_slot_portion, block_proposal_slot_portion,
max_block_proposal_slot_portion, max_block_proposal_slot_portion,
compatibility_mode: sc_consensus_aura::CompatibilityMode::None,
}, },
); );
@@ -216,19 +233,3 @@ where
Some(ParachainCandidate { block: res.block, proof: res.storage_proof }) Some(ParachainCandidate { block: res.block, proof: res.storage_proof })
} }
} }
/// Parameters of [`AuraConsensus::build`].
pub struct BuildAuraConsensusParams<PF, BI, CIDP, Client, BS, SO> {
pub proposer_factory: PF,
pub create_inherent_data_providers: CIDP,
pub block_import: BI,
pub para_client: Arc<Client>,
pub backoff_authoring_blocks: Option<BS>,
pub sync_oracle: SO,
pub keystore: SyncCryptoStorePtr,
pub force_authoring: bool,
pub slot_duration: SlotDuration,
pub telemetry: Option<TelemetryHandle>,
pub block_proposal_slot_portion: SlotProportion,
pub max_block_proposal_slot_portion: Option<SlotProportion>,
}
+2 -2
View File
@@ -6,11 +6,11 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021" edition = "2021"
[dependencies] [dependencies]
async-trait = "0.1.57" async-trait = "0.1.58"
codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ] } codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ] }
dyn-clone = "1.0.9" dyn-clone = "1.0.9"
futures = "0.3.24" futures = "0.3.24"
tracing = "0.1.36" tracing = "0.1.37"
# Substrate # Substrate
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
+6
View File
@@ -83,6 +83,12 @@ impl<I> ParachainBlockImport<I> {
} }
} }
impl<I: Clone> Clone for ParachainBlockImport<I> {
fn clone(&self) -> Self {
ParachainBlockImport(self.0.clone())
}
}
#[async_trait::async_trait] #[async_trait::async_trait]
impl<Block, I> BlockImport<Block> for ParachainBlockImport<I> impl<Block, I> BlockImport<Block> for ParachainBlockImport<I>
where where
@@ -102,7 +102,7 @@ where
// don't finalize the same block multiple times. // don't finalize the same block multiple times.
if parachain.usage_info().chain.finalized_hash != hash { if parachain.usage_info().chain.finalized_hash != hash {
if let Err(e) = parachain.finalize_block(BlockId::hash(hash), None, true) { if let Err(e) = parachain.finalize_block(&hash, None, true) {
match e { match e {
ClientError::UnknownBlock(_) => tracing::debug!( ClientError::UnknownBlock(_) => tracing::debug!(
target: "cumulus-consensus", target: "cumulus-consensus",
+2 -2
View File
@@ -6,10 +6,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021" edition = "2021"
[dependencies] [dependencies]
async-trait = "0.1.57" async-trait = "0.1.58"
futures = "0.3.24" futures = "0.3.24"
parking_lot = "0.12.1" parking_lot = "0.12.1"
tracing = "0.1.36" tracing = "0.1.37"
# Substrate # Substrate
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -16,6 +16,8 @@
use std::{marker::PhantomData, sync::Arc}; use std::{marker::PhantomData, sync::Arc};
use cumulus_client_consensus_common::ParachainBlockImport;
use sc_consensus::{ use sc_consensus::{
import_queue::{BasicQueue, Verifier as VerifierT}, import_queue::{BasicQueue, Verifier as VerifierT},
BlockImport, BlockImportParams, BlockImport, BlockImportParams,
@@ -103,7 +105,7 @@ where
/// Start an import queue for a Cumulus collator that does not uses any special authoring logic. /// Start an import queue for a Cumulus collator that does not uses any special authoring logic.
pub fn import_queue<Client, Block: BlockT, I, CIDP>( pub fn import_queue<Client, Block: BlockT, I, CIDP>(
client: Arc<Client>, client: Arc<Client>,
block_import: I, block_import: ParachainBlockImport<I>,
create_inherent_data_providers: CIDP, create_inherent_data_providers: CIDP,
spawner: &impl sp_core::traits::SpawnEssentialNamed, spawner: &impl sp_core::traits::SpawnEssentialNamed,
registry: Option<&substrate_prometheus_endpoint::Registry>, registry: Option<&substrate_prometheus_endpoint::Registry>,
@@ -117,11 +119,5 @@ where
{ {
let verifier = Verifier::new(client, create_inherent_data_providers); let verifier = Verifier::new(client, create_inherent_data_providers);
Ok(BasicQueue::new( Ok(BasicQueue::new(verifier, Box::new(block_import), None, spawner, registry))
verifier,
Box::new(cumulus_client_consensus_common::ParachainBlockImport::new(block_import)),
None,
spawner,
registry,
))
} }
+3 -5
View File
@@ -90,16 +90,14 @@ where
para_id: ParaId, para_id: ParaId,
proposer_factory: PF, proposer_factory: PF,
create_inherent_data_providers: CIDP, create_inherent_data_providers: CIDP,
block_import: BI, block_import: ParachainBlockImport<BI>,
relay_chain_interface: RCInterface, relay_chain_interface: RCInterface,
) -> Self { ) -> Self {
Self { Self {
para_id, para_id,
proposer_factory: Arc::new(Mutex::new(proposer_factory)), proposer_factory: Arc::new(Mutex::new(proposer_factory)),
create_inherent_data_providers: Arc::new(create_inherent_data_providers), create_inherent_data_providers: Arc::new(create_inherent_data_providers),
block_import: Arc::new(futures::lock::Mutex::new(ParachainBlockImport::new( block_import: Arc::new(futures::lock::Mutex::new(block_import)),
block_import,
))),
relay_chain_interface, relay_chain_interface,
_phantom: PhantomData, _phantom: PhantomData,
} }
@@ -222,7 +220,7 @@ pub struct BuildRelayChainConsensusParams<PF, BI, CIDP, RCInterface> {
pub para_id: ParaId, pub para_id: ParaId,
pub proposer_factory: PF, pub proposer_factory: PF,
pub create_inherent_data_providers: CIDP, pub create_inherent_data_providers: CIDP,
pub block_import: BI, pub block_import: ParachainBlockImport<BI>,
pub relay_chain_interface: RCInterface, pub relay_chain_interface: RCInterface,
} }
+3 -3
View File
@@ -6,12 +6,12 @@ description = "Cumulus-specific networking protocol"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
async-trait = "0.1.57" async-trait = "0.1.58"
codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ] } codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ] }
futures = "0.3.24" futures = "0.3.24"
futures-timer = "3.0.2" futures-timer = "3.0.2"
parking_lot = "0.12.1" parking_lot = "0.12.1"
tracing = "0.1.36" tracing = "0.1.37"
# Substrate # Substrate
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -31,7 +31,7 @@ cumulus-relay-chain-interface = { path = "../relay-chain-interface" }
[dev-dependencies] [dev-dependencies]
portpicker = "0.1.1" portpicker = "0.1.1"
tokio = { version = "1.21.1", features = ["macros"] } tokio = { version = "1.21.2", features = ["macros"] }
url = "2.3.1" url = "2.3.1"
# Substrate # Substrate
+1 -1
View File
@@ -174,7 +174,7 @@ impl RelayChainInterface for DummyRelayChainInterface {
Ok(false) Ok(false)
} }
fn overseer_handle(&self) -> RelayChainResult<Option<Handle>> { fn overseer_handle(&self) -> RelayChainResult<Handle> {
unimplemented!("Not needed for test") unimplemented!("Not needed for test")
} }
+3 -2
View File
@@ -10,7 +10,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "deriv
futures = "0.3.24" futures = "0.3.24"
futures-timer = "3.0.2" futures-timer = "3.0.2"
rand = "0.8.5" rand = "0.8.5"
tracing = "0.1.36" tracing = "0.1.37"
# Substrate # Substrate
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -30,7 +30,8 @@ cumulus-primitives-core = { path = "../../primitives/core" }
cumulus-relay-chain-interface = {path = "../relay-chain-interface"} cumulus-relay-chain-interface = {path = "../relay-chain-interface"}
[dev-dependencies] [dev-dependencies]
tokio = { version = "1.21.1", features = ["macros"] } tokio = { version = "1.21.2", features = ["macros"] }
portpicker = "0.1.1"
# Cumulus # Cumulus
cumulus-test-service = { path = "../../test/service" } cumulus-test-service = { path = "../../test/service" }
+8 -4
View File
@@ -181,7 +181,7 @@ where
Ok(_) => return, Ok(_) => return,
Err(e) => { Err(e) => {
tracing::debug!( tracing::debug!(
target: "cumulus-consensus", target: LOG_TARGET,
error = ?e, error = ?e,
block_hash = ?hash, block_hash = ?hash,
"Failed to get block status", "Failed to get block status",
@@ -190,6 +190,7 @@ where
}, },
} }
tracing::debug!(target: LOG_TARGET, ?hash, "Adding pending candidate");
if self if self
.pending_candidates .pending_candidates
.insert( .insert(
@@ -233,6 +234,7 @@ where
None => return, None => return,
}; };
tracing::debug!(target: LOG_TARGET, ?block_hash, "Issuing recovery request");
self.active_candidate_recovery self.active_candidate_recovery
.recover_candidate(block_hash, pending_candidate) .recover_candidate(block_hash, pending_candidate)
.await; .await;
@@ -301,7 +303,7 @@ where
Ok(BlockStatus::Unknown) => { Ok(BlockStatus::Unknown) => {
if self.active_candidate_recovery.is_being_recovered(&parent) { if self.active_candidate_recovery.is_being_recovered(&parent) {
tracing::debug!( tracing::debug!(
target: "cumulus-consensus", target: LOG_TARGET,
?block_hash, ?block_hash,
parent_hash = ?parent, parent_hash = ?parent,
"Parent is still being recovered, waiting.", "Parent is still being recovered, waiting.",
@@ -311,7 +313,7 @@ where
return return
} else { } else {
tracing::debug!( tracing::debug!(
target: "cumulus-consensus", target: LOG_TARGET,
?block_hash, ?block_hash,
parent_hash = ?parent, parent_hash = ?parent,
"Parent not found while trying to import recovered block.", "Parent not found while trying to import recovered block.",
@@ -324,7 +326,7 @@ where
}, },
Err(error) => { Err(error) => {
tracing::debug!( tracing::debug!(
target: "cumulus-consensus", target: LOG_TARGET,
block_hash = ?parent, block_hash = ?parent,
?error, ?error,
"Error while checking block status", "Error while checking block status",
@@ -346,6 +348,8 @@ where
/// This will also recursivley drain `waiting_for_parent` and import them as well. /// This will also recursivley drain `waiting_for_parent` and import them as well.
async fn import_block(&mut self, block: Block) { async fn import_block(&mut self, block: Block) {
let mut blocks = VecDeque::new(); let mut blocks = VecDeque::new();
tracing::debug!(target: LOG_TARGET, hash = ?block.hash(), "Importing block retrieved using pov_recovery");
blocks.push_back(block); blocks.push_back(block);
let mut incoming_blocks = Vec::new(); let mut incoming_blocks = Vec::new();
+38 -3
View File
@@ -16,6 +16,7 @@
use cumulus_primitives_core::ParaId; use cumulus_primitives_core::ParaId;
use cumulus_test_service::{initial_head_data, Keyring::*}; use cumulus_test_service::{initial_head_data, Keyring::*};
use futures::join;
use std::sync::Arc; use std::sync::Arc;
/// Tests the PoV recovery. /// Tests the PoV recovery.
@@ -34,12 +35,13 @@ async fn pov_recovery() {
let tokio_handle = tokio::runtime::Handle::current(); let tokio_handle = tokio::runtime::Handle::current();
// Start alice // Start alice
let ws_port = portpicker::pick_unused_port().expect("No free ports");
let alice = cumulus_test_service::run_relay_chain_validator_node( let alice = cumulus_test_service::run_relay_chain_validator_node(
tokio_handle.clone(), tokio_handle.clone(),
Alice, Alice,
|| {}, || {},
Vec::new(), Vec::new(),
None, Some(ws_port),
); );
// Start bob // Start bob
@@ -90,7 +92,7 @@ async fn pov_recovery() {
.build() .build()
.await; .await;
let eve = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle, Eve) let eve = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle.clone(), Eve)
.use_null_consensus() .use_null_consensus()
.connect_to_parachain_node(&charlie) .connect_to_parachain_node(&charlie)
.connect_to_relay_chain_nodes(vec![&alice, &bob]) .connect_to_relay_chain_nodes(vec![&alice, &bob])
@@ -101,5 +103,38 @@ async fn pov_recovery() {
.build() .build()
.await; .await;
futures::future::join(dave.wait_for_blocks(7), eve.wait_for_blocks(7)).await; // Run ferdie as parachain RPC collator and one as parachain RPC full node
//
// They will need to recover the pov blocks through availability recovery.
let ferdie = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle.clone(), Ferdie)
.use_null_consensus()
.connect_to_parachain_node(&charlie)
.connect_to_relay_chain_nodes(vec![&alice, &bob])
.use_external_relay_chain_node_at_port(ws_port)
.wrap_announce_block(|_| {
// Never announce any block
Arc::new(|_, _| {})
})
.build()
.await;
let one = cumulus_test_service::TestNodeBuilder::new(para_id, tokio_handle, One)
.enable_collator()
.use_null_consensus()
.connect_to_parachain_node(&charlie)
.connect_to_relay_chain_nodes(vec![&alice, &bob])
.use_external_relay_chain_node_at_port(ws_port)
.wrap_announce_block(|_| {
// Never announce any block
Arc::new(|_, _| {})
})
.build()
.await;
join!(
dave.wait_for_blocks(7),
eve.wait_for_blocks(7),
ferdie.wait_for_blocks(7),
one.wait_for_blocks(7)
);
} }
@@ -5,7 +5,7 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
async-trait = "0.1.57" async-trait = "0.1.58"
futures = "0.3.24" futures = "0.3.24"
futures-timer = "3.0.2" futures-timer = "3.0.2"
@@ -38,3 +38,7 @@ sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master
# Polkadot # Polkadot
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-test-client = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-test-client = { git = "https://github.com/paritytech/polkadot", branch = "master" }
metered = { package = "prioritized-metered-channel", version = "0.2.0" }
# Cumulus
cumulus-test-service = { path = "../../test/service" }
@@ -50,7 +50,7 @@ pub struct RelayChainInProcessInterface<Client> {
full_client: Arc<Client>, full_client: Arc<Client>,
backend: Arc<FullBackend>, backend: Arc<FullBackend>,
sync_oracle: Arc<dyn SyncOracle + Send + Sync>, sync_oracle: Arc<dyn SyncOracle + Send + Sync>,
overseer_handle: Option<Handle>, overseer_handle: Handle,
} }
impl<Client> RelayChainInProcessInterface<Client> { impl<Client> RelayChainInProcessInterface<Client> {
@@ -59,7 +59,7 @@ impl<Client> RelayChainInProcessInterface<Client> {
full_client: Arc<Client>, full_client: Arc<Client>,
backend: Arc<FullBackend>, backend: Arc<FullBackend>,
sync_oracle: Arc<dyn SyncOracle + Send + Sync>, sync_oracle: Arc<dyn SyncOracle + Send + Sync>,
overseer_handle: Option<Handle>, overseer_handle: Handle,
) -> Self { ) -> Self {
Self { full_client, backend, sync_oracle, overseer_handle } Self { full_client, backend, sync_oracle, overseer_handle }
} }
@@ -171,7 +171,7 @@ where
Ok(self.sync_oracle.is_major_syncing()) Ok(self.sync_oracle.is_major_syncing())
} }
fn overseer_handle(&self) -> RelayChainResult<Option<Handle>> { fn overseer_handle(&self) -> RelayChainResult<Handle> {
Ok(self.overseer_handle.clone()) Ok(self.overseer_handle.clone())
} }
@@ -180,8 +180,7 @@ where
relay_parent: PHash, relay_parent: PHash,
key: &[u8], key: &[u8],
) -> RelayChainResult<Option<StorageValue>> { ) -> RelayChainResult<Option<StorageValue>> {
let block_id = BlockId::Hash(relay_parent); let state = self.backend.state_at(&relay_parent)?;
let state = self.backend.state_at(block_id)?;
state.storage(key).map_err(RelayChainError::GenericError) state.storage(key).map_err(RelayChainError::GenericError)
} }
@@ -190,8 +189,7 @@ where
relay_parent: PHash, relay_parent: PHash,
relevant_keys: &Vec<Vec<u8>>, relevant_keys: &Vec<Vec<u8>>,
) -> RelayChainResult<StorageProof> { ) -> RelayChainResult<StorageProof> {
let block_id = BlockId::Hash(relay_parent); let state_backend = self.backend.state_at(&relay_parent)?;
let state_backend = self.backend.state_at(block_id)?;
sp_state_machine::prove_read(state_backend, relevant_keys) sp_state_machine::prove_read(state_backend, relevant_keys)
.map_err(RelayChainError::StateMachineError) .map_err(RelayChainError::StateMachineError)
@@ -288,7 +286,7 @@ struct RelayChainInProcessInterfaceBuilder {
polkadot_client: polkadot_client::Client, polkadot_client: polkadot_client::Client,
backend: Arc<FullBackend>, backend: Arc<FullBackend>,
sync_oracle: Arc<dyn SyncOracle + Send + Sync>, sync_oracle: Arc<dyn SyncOracle + Send + Sync>,
overseer_handle: Option<Handle>, overseer_handle: Handle,
} }
impl RelayChainInProcessInterfaceBuilder { impl RelayChainInProcessInterfaceBuilder {
@@ -378,7 +376,9 @@ pub fn build_inprocess_relay_chain(
polkadot_client: full_node.client.clone(), polkadot_client: full_node.client.clone(),
backend: full_node.backend.clone(), backend: full_node.backend.clone(),
sync_oracle, sync_oracle,
overseer_handle: full_node.overseer_handle.clone(), overseer_handle: full_node.overseer_handle.clone().ok_or(RelayChainError::GenericError(
"Overseer not running in full node.".to_string(),
))?,
}; };
task_manager.add_child(full_node.task_manager); task_manager.add_child(full_node.task_manager);
@@ -425,10 +425,12 @@ mod tests {
let block = block_builder.build().expect("Finalizes the block").block; let block = block_builder.build().expect("Finalizes the block").block;
let dummy_network: Arc<dyn SyncOracle + Sync + Send> = Arc::new(DummyNetwork {}); let dummy_network: Arc<dyn SyncOracle + Sync + Send> = Arc::new(DummyNetwork {});
let (tx, _rx) = metered::channel(30);
let mock_handle = Handle::new(tx);
( (
client.clone(), client.clone(),
block, block,
RelayChainInProcessInterface::new(client, backend.clone(), dummy_network, None), RelayChainInProcessInterface::new(client, backend.clone(), dummy_network, mock_handle),
) )
} }
+2 -2
View File
@@ -16,7 +16,7 @@ sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
futures = "0.3.24" futures = "0.3.24"
async-trait = "0.1.57" async-trait = "0.1.58"
thiserror = "1.0.35" thiserror = "1.0.37"
jsonrpsee-core = "0.15.1" jsonrpsee-core = "0.15.1"
parity-scale-codec = "3.2.1" parity-scale-codec = "3.2.1"
+21 -4
View File
@@ -23,7 +23,8 @@ use cumulus_primitives_core::{
}, },
InboundDownwardMessage, ParaId, PersistedValidationData, InboundDownwardMessage, ParaId, PersistedValidationData,
}; };
use polkadot_overseer::Handle as OverseerHandle; use polkadot_overseer::{prometheus::PrometheusError, Handle as OverseerHandle};
use polkadot_service::SubstrateServiceError;
use sc_client_api::StorageProof; use sc_client_api::StorageProof;
use futures::Stream; use futures::Stream;
@@ -58,18 +59,34 @@ pub enum RelayChainError {
WorkerCommunicationError(String), WorkerCommunicationError(String),
#[error("Scale codec deserialization error: {0}")] #[error("Scale codec deserialization error: {0}")]
DeserializationError(CodecError), DeserializationError(CodecError),
#[error("Scale codec deserialization error: {0}")] #[error("Polkadot service error: {0}")]
ServiceError(#[from] polkadot_service::Error), ServiceError(#[from] polkadot_service::Error),
#[error("Substrate service error: {0}")]
SubServiceError(#[from] SubstrateServiceError),
#[error("Prometheus error: {0}")]
PrometheusError(#[from] PrometheusError),
#[error("Unspecified error occured: {0}")] #[error("Unspecified error occured: {0}")]
GenericError(String), GenericError(String),
} }
impl From<RelayChainError> for ApiError {
fn from(r: RelayChainError) -> Self {
sp_api::ApiError::Application(Box::new(r))
}
}
impl From<CodecError> for RelayChainError { impl From<CodecError> for RelayChainError {
fn from(e: CodecError) -> Self { fn from(e: CodecError) -> Self {
RelayChainError::DeserializationError(e) RelayChainError::DeserializationError(e)
} }
} }
impl From<RelayChainError> for sp_blockchain::Error {
fn from(r: RelayChainError) -> Self {
sp_blockchain::Error::Application(Box::new(r))
}
}
/// Trait that provides all necessary methods for interaction between collator and relay chain. /// Trait that provides all necessary methods for interaction between collator and relay chain.
#[async_trait] #[async_trait]
pub trait RelayChainInterface: Send + Sync { pub trait RelayChainInterface: Send + Sync {
@@ -155,7 +172,7 @@ pub trait RelayChainInterface: Send + Sync {
async fn is_major_syncing(&self) -> RelayChainResult<bool>; async fn is_major_syncing(&self) -> RelayChainResult<bool>;
/// Get a handle to the overseer. /// Get a handle to the overseer.
fn overseer_handle(&self) -> RelayChainResult<Option<OverseerHandle>>; fn overseer_handle(&self) -> RelayChainResult<OverseerHandle>;
/// Generate a storage read proof. /// Generate a storage read proof.
async fn prove_read( async fn prove_read(
@@ -233,7 +250,7 @@ where
(**self).is_major_syncing().await (**self).is_major_syncing().await
} }
fn overseer_handle(&self) -> RelayChainResult<Option<OverseerHandle>> { fn overseer_handle(&self) -> RelayChainResult<OverseerHandle> {
(**self).overseer_handle() (**self).overseer_handle()
} }
@@ -0,0 +1,50 @@
[package]
authors = ["Parity Technologies <admin@parity.io>"]
name = "cumulus-relay-chain-minimal-node"
version = "0.1.0"
edition = "2021"
[dependencies]
# polkadot deps
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-overseer = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-subsystem-util = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-network-protocol = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-network-bridge = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-node-core-av-store = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-availability-distribution = { git = "https://github.com/paritytech/polkadot", branch = "master" }
# substrate deps
sc-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network-sync = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network-light = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
# cumulus deps
cumulus-relay-chain-interface = { path = "../relay-chain-interface" }
cumulus-relay-chain-rpc-interface = { path = "../relay-chain-rpc-interface" }
cumulus-primitives-core = { path = "../../primitives/core" }
array-bytes = "4.1"
lru = "0.8"
tracing = "0.1.37"
async-trait = "0.1.58"
futures = "0.3.24"
url = "2.2.2"
tokio = { version = "1.21.2", features = ["macros"] }
@@ -0,0 +1,463 @@
// Copyright 2022 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use std::{pin::Pin, str::FromStr};
use cumulus_relay_chain_interface::{RelayChainError, RelayChainResult};
use cumulus_relay_chain_rpc_interface::RelayChainRpcClient;
use futures::{Future, Stream, StreamExt};
use polkadot_core_primitives::{Block, BlockId, Hash, Header};
use polkadot_overseer::RuntimeApiSubsystemClient;
use polkadot_service::{AuxStore, HeaderBackend};
use sc_authority_discovery::AuthorityDiscovery;
use sc_network_common::config::MultiaddrWithPeerId;
use sp_api::{ApiError, RuntimeApiInfo};
use sp_blockchain::Info;
const LOG_TARGET: &str = "blockchain-rpc-client";
#[derive(Clone)]
pub struct BlockChainRpcClient {
rpc_client: RelayChainRpcClient,
}
impl BlockChainRpcClient {
pub fn new(rpc_client: RelayChainRpcClient) -> Self {
Self { rpc_client }
}
pub async fn chain_get_header(
&self,
hash: Option<Hash>,
) -> Result<Option<Header>, RelayChainError> {
self.rpc_client.chain_get_header(hash).await
}
pub async fn block_get_hash(
&self,
number: Option<polkadot_service::BlockNumber>,
) -> Result<Option<Hash>, RelayChainError> {
self.rpc_client.chain_get_block_hash(number).await
}
}
// Implementation required by Availability-Distribution subsystem
// but never called in our case.
impl AuxStore for BlockChainRpcClient {
fn insert_aux<
'a,
'b: 'a,
'c: 'a,
I: IntoIterator<Item = &'a (&'c [u8], &'c [u8])>,
D: IntoIterator<Item = &'a &'b [u8]>,
>(
&self,
_insert: I,
_delete: D,
) -> sp_blockchain::Result<()> {
unimplemented!("Not supported on the RPC collator")
}
fn get_aux(&self, _key: &[u8]) -> sp_blockchain::Result<Option<Vec<u8>>> {
unimplemented!("Not supported on the RPC collator")
}
}
#[async_trait::async_trait]
impl RuntimeApiSubsystemClient for BlockChainRpcClient {
async fn validators(
&self,
at: Hash,
) -> Result<Vec<polkadot_primitives::v2::ValidatorId>, sp_api::ApiError> {
Ok(self.rpc_client.parachain_host_validators(at).await?)
}
async fn validator_groups(
&self,
at: Hash,
) -> Result<
(
Vec<Vec<polkadot_primitives::v2::ValidatorIndex>>,
polkadot_primitives::v2::GroupRotationInfo<polkadot_core_primitives::BlockNumber>,
),
sp_api::ApiError,
> {
Ok(self.rpc_client.parachain_host_validator_groups(at).await?)
}
async fn availability_cores(
&self,
at: Hash,
) -> Result<
Vec<polkadot_primitives::v2::CoreState<Hash, polkadot_core_primitives::BlockNumber>>,
sp_api::ApiError,
> {
Ok(self.rpc_client.parachain_host_availability_cores(at).await?)
}
async fn persisted_validation_data(
&self,
at: Hash,
para_id: cumulus_primitives_core::ParaId,
assumption: polkadot_primitives::v2::OccupiedCoreAssumption,
) -> Result<
Option<
cumulus_primitives_core::PersistedValidationData<
Hash,
polkadot_core_primitives::BlockNumber,
>,
>,
sp_api::ApiError,
> {
Ok(self
.rpc_client
.parachain_host_persisted_validation_data(at, para_id, assumption)
.await?)
}
async fn assumed_validation_data(
&self,
at: Hash,
para_id: cumulus_primitives_core::ParaId,
expected_persisted_validation_data_hash: Hash,
) -> Result<
Option<(
cumulus_primitives_core::PersistedValidationData<
Hash,
polkadot_core_primitives::BlockNumber,
>,
polkadot_primitives::v2::ValidationCodeHash,
)>,
sp_api::ApiError,
> {
Ok(self
.rpc_client
.parachain_host_assumed_validation_data(
at,
para_id,
expected_persisted_validation_data_hash,
)
.await?)
}
async fn check_validation_outputs(
&self,
at: Hash,
para_id: cumulus_primitives_core::ParaId,
outputs: polkadot_primitives::v2::CandidateCommitments,
) -> Result<bool, sp_api::ApiError> {
Ok(self
.rpc_client
.parachain_host_check_validation_outputs(at, para_id, outputs)
.await?)
}
async fn session_index_for_child(
&self,
at: Hash,
) -> Result<polkadot_primitives::v2::SessionIndex, sp_api::ApiError> {
Ok(self.rpc_client.parachain_host_session_index_for_child(at).await?)
}
async fn validation_code(
&self,
at: Hash,
para_id: cumulus_primitives_core::ParaId,
assumption: polkadot_primitives::v2::OccupiedCoreAssumption,
) -> Result<Option<polkadot_primitives::v2::ValidationCode>, sp_api::ApiError> {
Ok(self.rpc_client.parachain_host_validation_code(at, para_id, assumption).await?)
}
async fn candidate_pending_availability(
&self,
at: Hash,
para_id: cumulus_primitives_core::ParaId,
) -> Result<Option<polkadot_primitives::v2::CommittedCandidateReceipt<Hash>>, sp_api::ApiError>
{
Ok(self
.rpc_client
.parachain_host_candidate_pending_availability(at, para_id)
.await?)
}
async fn candidate_events(
&self,
at: Hash,
) -> Result<Vec<polkadot_primitives::v2::CandidateEvent<Hash>>, sp_api::ApiError> {
Ok(self.rpc_client.parachain_host_candidate_events(at).await?)
}
async fn dmq_contents(
&self,
at: Hash,
recipient: cumulus_primitives_core::ParaId,
) -> Result<
Vec<cumulus_primitives_core::InboundDownwardMessage<polkadot_core_primitives::BlockNumber>>,
sp_api::ApiError,
> {
Ok(self.rpc_client.parachain_host_dmq_contents(recipient, at).await?)
}
async fn inbound_hrmp_channels_contents(
&self,
at: Hash,
recipient: cumulus_primitives_core::ParaId,
) -> Result<
std::collections::BTreeMap<
cumulus_primitives_core::ParaId,
Vec<
polkadot_core_primitives::InboundHrmpMessage<polkadot_core_primitives::BlockNumber>,
>,
>,
sp_api::ApiError,
> {
Ok(self
.rpc_client
.parachain_host_inbound_hrmp_channels_contents(recipient, at)
.await?)
}
async fn validation_code_by_hash(
&self,
at: Hash,
validation_code_hash: polkadot_primitives::v2::ValidationCodeHash,
) -> Result<Option<polkadot_primitives::v2::ValidationCode>, sp_api::ApiError> {
Ok(self
.rpc_client
.parachain_host_validation_code_by_hash(at, validation_code_hash)
.await?)
}
async fn on_chain_votes(
&self,
at: Hash,
) -> Result<Option<polkadot_primitives::v2::ScrapedOnChainVotes<Hash>>, sp_api::ApiError> {
Ok(self.rpc_client.parachain_host_on_chain_votes(at).await?)
}
async fn session_info(
&self,
at: Hash,
index: polkadot_primitives::v2::SessionIndex,
) -> Result<Option<polkadot_primitives::v2::SessionInfo>, sp_api::ApiError> {
Ok(self.rpc_client.parachain_host_session_info(at, index).await?)
}
async fn session_info_before_version_2(
&self,
at: Hash,
index: polkadot_primitives::v2::SessionIndex,
) -> Result<Option<polkadot_primitives::v2::OldV1SessionInfo>, sp_api::ApiError> {
Ok(self.rpc_client.parachain_host_session_info_before_version_2(at, index).await?)
}
async fn submit_pvf_check_statement(
&self,
at: Hash,
stmt: polkadot_primitives::v2::PvfCheckStatement,
signature: polkadot_primitives::v2::ValidatorSignature,
) -> Result<(), sp_api::ApiError> {
Ok(self
.rpc_client
.parachain_host_submit_pvf_check_statement(at, stmt, signature)
.await?)
}
async fn pvfs_require_precheck(
&self,
at: Hash,
) -> Result<Vec<polkadot_primitives::v2::ValidationCodeHash>, sp_api::ApiError> {
Ok(self.rpc_client.parachain_host_pvfs_require_precheck(at).await?)
}
async fn validation_code_hash(
&self,
at: Hash,
para_id: cumulus_primitives_core::ParaId,
assumption: polkadot_primitives::v2::OccupiedCoreAssumption,
) -> Result<Option<polkadot_primitives::v2::ValidationCodeHash>, sp_api::ApiError> {
Ok(self
.rpc_client
.parachain_host_validation_code_hash(at, para_id, assumption)
.await?)
}
async fn current_epoch(&self, at: Hash) -> Result<sp_consensus_babe::Epoch, sp_api::ApiError> {
Ok(self.rpc_client.babe_api_current_epoch(at).await?)
}
async fn authorities(
&self,
at: Hash,
) -> std::result::Result<Vec<polkadot_primitives::v2::AuthorityDiscoveryId>, sp_api::ApiError> {
Ok(self.rpc_client.authority_discovery_authorities(at).await?)
}
async fn api_version_parachain_host(&self, at: Hash) -> Result<Option<u32>, sp_api::ApiError> {
let api_id = <dyn polkadot_primitives::runtime_api::ParachainHost<Block>>::ID;
Ok(self.rpc_client.runtime_version(at).await.map(|v| v.api_version(&api_id))?)
}
async fn disputes(
&self,
at: Hash,
) -> Result<
Vec<(
polkadot_primitives::v2::SessionIndex,
polkadot_primitives::v2::CandidateHash,
polkadot_primitives::v2::DisputeState<polkadot_primitives::v2::BlockNumber>,
)>,
ApiError,
> {
Ok(self.rpc_client.parachain_host_staging_get_disputes(at).await?)
}
}
#[async_trait::async_trait]
impl AuthorityDiscovery<Block> for BlockChainRpcClient {
async fn authorities(
&self,
at: Hash,
) -> std::result::Result<Vec<polkadot_primitives::v2::AuthorityDiscoveryId>, sp_api::ApiError> {
let result = self.rpc_client.authority_discovery_authorities(at).await?;
Ok(result)
}
}
impl BlockChainRpcClient {
pub async fn local_listen_addresses(
&self,
) -> Result<Vec<MultiaddrWithPeerId>, RelayChainError> {
let addresses = self.rpc_client.system_local_listen_addresses().await?;
tracing::debug!(target: LOG_TARGET, ?addresses, "Fetched listen address from RPC node.");
let mut result_vec = Vec::new();
for address in addresses {
match MultiaddrWithPeerId::from_str(&address) {
Ok(addr) => result_vec.push(addr),
Err(err) =>
return Err(RelayChainError::GenericError(format!(
"Failed to parse a local listen addresses from the RPC node: {}",
err
))),
}
}
Ok(result_vec)
}
pub async fn import_notification_stream(
&self,
) -> RelayChainResult<Pin<Box<dyn Stream<Item = Header> + Send>>> {
Ok(self.rpc_client.get_imported_heads_stream().await?.boxed())
}
pub async fn finality_notification_stream(
&self,
) -> RelayChainResult<Pin<Box<dyn Stream<Item = Header> + Send>>> {
Ok(self.rpc_client.get_finalized_heads_stream().await?.boxed())
}
}
fn block_local<T>(fut: impl Future<Output = T>) -> T {
let tokio_handle = tokio::runtime::Handle::current();
tokio::task::block_in_place(|| tokio_handle.block_on(fut))
}
impl HeaderBackend<Block> for BlockChainRpcClient {
fn header(
&self,
id: BlockId,
) -> sp_blockchain::Result<Option<<Block as polkadot_service::BlockT>::Header>> {
let fetch_header = |hash| block_local(self.rpc_client.chain_get_header(Some(hash)));
match id {
BlockId::Hash(hash) => Ok(fetch_header(hash)?),
BlockId::Number(number) => {
if let Some(hash) = HeaderBackend::<Block>::hash(self, number)? {
Ok(fetch_header(hash)?)
} else {
Ok(None)
}
},
}
}
fn info(&self) -> Info<Block> {
let best_header = block_local(self.rpc_client.chain_get_header(None))
.expect("Unable to get header from relay chain.")
.unwrap();
let genesis_hash = block_local(self.rpc_client.chain_get_head(Some(0)))
.expect("Unable to get header from relay chain.");
let finalized_head = block_local(self.rpc_client.chain_get_finalized_head())
.expect("Unable to get finalized head from relay chain.");
let finalized_header = block_local(self.rpc_client.chain_get_header(Some(finalized_head)))
.expect("Unable to get finalized header from relay chain.")
.unwrap();
Info {
best_hash: best_header.hash(),
best_number: best_header.number,
genesis_hash,
finalized_hash: finalized_head,
finalized_number: finalized_header.number,
finalized_state: None,
number_leaves: 1,
block_gap: None,
}
}
fn status(
&self,
id: sp_api::BlockId<Block>,
) -> sp_blockchain::Result<sp_blockchain::BlockStatus> {
let exists = match id {
BlockId::Hash(_) => self.header(id)?.is_some(),
BlockId::Number(n) => {
let best_header = block_local(self.rpc_client.chain_get_header(None))?;
if let Some(best) = best_header {
n < best.number
} else {
false
}
},
};
if exists {
Ok(sc_client_api::blockchain::BlockStatus::InChain)
} else {
Ok(sc_client_api::blockchain::BlockStatus::Unknown)
}
}
fn number(
&self,
hash: <Block as polkadot_service::BlockT>::Hash,
) -> sp_blockchain::Result<
Option<<<Block as polkadot_service::BlockT>::Header as polkadot_service::HeaderT>::Number>,
> {
let result = block_local(self.rpc_client.chain_get_header(Some(hash)))?
.map(|maybe_header| maybe_header.number);
Ok(result)
}
fn hash(
&self,
number: polkadot_service::NumberFor<Block>,
) -> sp_blockchain::Result<Option<<Block as polkadot_service::BlockT>::Hash>> {
Ok(block_local(self.rpc_client.chain_get_block_hash(number.into()))?)
}
}
@@ -0,0 +1,274 @@
// 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 <http://www.gnu.org/licenses/>.
use cumulus_relay_chain_interface::RelayChainError;
use lru::LruCache;
use polkadot_availability_distribution::{
AvailabilityDistributionSubsystem, IncomingRequestReceivers,
};
use polkadot_node_core_av_store::Config;
use polkadot_node_network_protocol::{
peer_set::PeerSetProtocolNames,
request_response::{
v1::{
AvailableDataFetchingRequest, ChunkFetchingRequest, CollationFetchingRequest,
PoVFetchingRequest,
},
IncomingRequestReceiver, ReqProtocolNames,
},
};
use polkadot_node_subsystem_util::metrics::{prometheus::Registry, Metrics};
use polkadot_overseer::{
BlockInfo, DummySubsystem, MetricsTrait, Overseer, OverseerHandle, OverseerMetrics, SpawnGlue,
KNOWN_LEAVES_CACHE_SIZE,
};
use polkadot_primitives::v2::CollatorPair;
use polkadot_service::{
overseer::{
AvailabilityRecoverySubsystem, AvailabilityStoreSubsystem, ChainApiSubsystem,
CollationGenerationSubsystem, CollatorProtocolSubsystem, NetworkBridgeMetrics,
NetworkBridgeRxSubsystem, NetworkBridgeTxSubsystem, ProtocolSide, RuntimeApiSubsystem,
},
Error, OverseerConnector,
};
use sc_authority_discovery::Service as AuthorityDiscoveryService;
use sc_keystore::LocalKeystore;
use sc_network::NetworkStateInfo;
use std::sync::Arc;
use cumulus_primitives_core::relay_chain::{Block, Hash as PHash};
use polkadot_service::{Handle, TaskManager};
use crate::BlockChainRpcClient;
use futures::{select, StreamExt};
use sp_runtime::traits::Block as BlockT;
/// Arguments passed for overseer construction.
pub(crate) struct CollatorOverseerGenArgs<'a> {
/// Runtime client generic, providing the `ProvieRuntimeApi` trait besides others.
pub runtime_client: Arc<BlockChainRpcClient>,
/// Underlying network service implementation.
pub network_service: Arc<sc_network::NetworkService<Block, PHash>>,
/// Underlying authority discovery service.
pub authority_discovery_service: AuthorityDiscoveryService,
// Receiver for collation request protocol
pub collation_req_receiver: IncomingRequestReceiver<CollationFetchingRequest>,
// Receiver for PoV request protocol
pub pov_req_receiver: IncomingRequestReceiver<PoVFetchingRequest>,
// Receiver for chunk request protocol
pub chunk_req_receiver: IncomingRequestReceiver<ChunkFetchingRequest>,
// Receiver for availability request protocol
pub available_data_req_receiver: IncomingRequestReceiver<AvailableDataFetchingRequest>,
/// Prometheus registry, commonly used for production systems, less so for test.
pub registry: Option<&'a Registry>,
/// Task spawner to be used throughout the overseer and the APIs it provides.
pub spawner: sc_service::SpawnTaskHandle,
/// Determines the behavior of the collator.
pub collator_pair: CollatorPair,
/// Request response protocols
pub req_protocol_names: ReqProtocolNames,
/// Peerset protocols name mapping
pub peer_set_protocol_names: PeerSetProtocolNames,
/// Config for the availability store
pub availability_config: Config,
/// The underlying key value store for the parachains.
pub parachains_db: Arc<dyn polkadot_node_subsystem_util::database::Database>,
}
fn build_overseer<'a>(
connector: OverseerConnector,
CollatorOverseerGenArgs {
runtime_client,
network_service,
authority_discovery_service,
collation_req_receiver,
available_data_req_receiver,
availability_config,
registry,
spawner,
collator_pair,
req_protocol_names,
peer_set_protocol_names,
parachains_db,
pov_req_receiver,
chunk_req_receiver,
}: CollatorOverseerGenArgs<'a>,
) -> Result<
(Overseer<SpawnGlue<sc_service::SpawnTaskHandle>, Arc<BlockChainRpcClient>>, OverseerHandle),
Error,
> {
let leaves = Vec::new();
let metrics = <OverseerMetrics as MetricsTrait>::register(registry)?;
let keystore = Arc::new(LocalKeystore::in_memory());
let spawner = SpawnGlue(spawner);
let network_bridge_metrics: NetworkBridgeMetrics = Metrics::register(registry)?;
let builder = Overseer::builder()
.availability_distribution(AvailabilityDistributionSubsystem::new(
keystore.clone(),
IncomingRequestReceivers { pov_req_receiver, chunk_req_receiver },
Metrics::register(registry)?,
))
.availability_recovery(AvailabilityRecoverySubsystem::with_chunks_only(
available_data_req_receiver,
Metrics::register(registry)?,
))
.availability_store(AvailabilityStoreSubsystem::new(
parachains_db.clone(),
availability_config,
Metrics::register(registry)?,
))
.bitfield_distribution(DummySubsystem)
.bitfield_signing(DummySubsystem)
.candidate_backing(DummySubsystem)
.candidate_validation(DummySubsystem)
.pvf_checker(DummySubsystem)
.chain_api(ChainApiSubsystem::new(runtime_client.clone(), Metrics::register(registry)?))
.collation_generation(CollationGenerationSubsystem::new(Metrics::register(registry)?))
.collator_protocol({
let side = ProtocolSide::Collator(
network_service.local_peer_id().clone(),
collator_pair,
collation_req_receiver,
Metrics::register(registry)?,
);
CollatorProtocolSubsystem::new(side)
})
.network_bridge_rx(NetworkBridgeRxSubsystem::new(
network_service.clone(),
authority_discovery_service.clone(),
Box::new(network_service.clone()),
network_bridge_metrics.clone(),
peer_set_protocol_names.clone(),
))
.network_bridge_tx(NetworkBridgeTxSubsystem::new(
network_service.clone(),
authority_discovery_service.clone(),
network_bridge_metrics,
req_protocol_names,
peer_set_protocol_names,
))
.provisioner(DummySubsystem)
.runtime_api(RuntimeApiSubsystem::new(
runtime_client.clone(),
Metrics::register(registry)?,
spawner.clone(),
))
.statement_distribution(DummySubsystem)
.approval_distribution(DummySubsystem)
.approval_voting(DummySubsystem)
.gossip_support(DummySubsystem)
.dispute_coordinator(DummySubsystem)
.dispute_distribution(DummySubsystem)
.chain_selection(DummySubsystem)
.leaves(Vec::from_iter(
leaves
.into_iter()
.map(|BlockInfo { hash, parent_hash: _, number }| (hash, number)),
))
.activation_external_listeners(Default::default())
.span_per_active_leaf(Default::default())
.active_leaves(Default::default())
.supports_parachains(runtime_client)
.known_leaves(LruCache::new(KNOWN_LEAVES_CACHE_SIZE))
.metrics(metrics)
.spawner(spawner);
builder.build_with_connector(connector).map_err(|e| e.into())
}
pub(crate) fn spawn_overseer(
overseer_args: CollatorOverseerGenArgs,
task_manager: &TaskManager,
relay_chain_rpc_client: Arc<BlockChainRpcClient>,
) -> Result<polkadot_overseer::Handle, polkadot_service::Error> {
let (overseer, overseer_handle) = build_overseer(OverseerConnector::default(), overseer_args)
.map_err(|e| {
tracing::error!("Failed to initialize overseer: {}", e);
e
})?;
let overseer_handle = Handle::new(overseer_handle.clone());
{
let handle = overseer_handle.clone();
task_manager.spawn_essential_handle().spawn_blocking(
"overseer",
None,
Box::pin(async move {
use futures::{pin_mut, FutureExt};
let forward = forward_collator_events(relay_chain_rpc_client, handle).fuse();
let overseer_fut = overseer.run().fuse();
pin_mut!(overseer_fut);
pin_mut!(forward);
select! {
_ = forward => (),
_ = overseer_fut => (),
}
}),
);
}
Ok(overseer_handle)
}
/// Minimal relay chain node representation
pub struct NewMinimalNode {
/// Task manager running all tasks for the minimal node
pub task_manager: TaskManager,
/// Overseer handle to interact with subsystems
pub overseer_handle: Handle,
/// Network service
pub network: Arc<sc_network::NetworkService<Block, <Block as BlockT>::Hash>>,
}
/// Glues together the [`Overseer`] and `BlockchainEvents` by forwarding
/// import and finality notifications into the [`OverseerHandle`].
async fn forward_collator_events(
client: Arc<BlockChainRpcClient>,
mut handle: Handle,
) -> Result<(), RelayChainError> {
let mut finality = client.finality_notification_stream().await?.fuse();
let mut imports = client.import_notification_stream().await?.fuse();
loop {
select! {
f = finality.next() => {
match f {
Some(header) => {
tracing::info!(target: "minimal-polkadot-node", "Received finalized block via RPC: #{} ({})", header.number, header.hash());
let block_info = BlockInfo { hash: header.hash(), parent_hash: header.parent_hash, number: header.number };
handle.block_finalized(block_info).await;
}
None => return Err(RelayChainError::GenericError("Relay chain finality stream ended.".to_string())),
}
},
i = imports.next() => {
match i {
Some(header) => {
tracing::info!(target: "minimal-polkadot-node", "Received imported block via RPC: #{} ({})", header.number, header.hash());
let block_info = BlockInfo { hash: header.hash(), parent_hash: header.parent_hash, number: header.number };
handle.block_imported(block_info).await;
}
None => return Err(RelayChainError::GenericError("Relay chain import stream ended.".to_string())),
}
}
}
}
}
+223
View File
@@ -0,0 +1,223 @@
// 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 <http://www.gnu.org/licenses/>.
use collator_overseer::{CollatorOverseerGenArgs, NewMinimalNode};
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};
use cumulus_relay_chain_rpc_interface::{RelayChainRpcInterface, Url};
use polkadot_network_bridge::{peer_sets_info, IsAuthority};
use polkadot_node_network_protocol::{
peer_set::PeerSetProtocolNames,
request_response::{self, IncomingRequest, ReqProtocolNames},
};
use polkadot_node_subsystem_util::metrics::prometheus::Registry;
use polkadot_primitives::v2::CollatorPair;
use sc_authority_discovery::Service as AuthorityDiscoveryService;
use sc_network::{Event, NetworkService};
use sc_network_common::service::NetworkEventStream;
use std::sync::Arc;
use polkadot_service::{open_database, Configuration, TaskManager};
use futures::StreamExt;
use sp_runtime::{app_crypto::Pair, traits::Block as BlockT};
mod collator_overseer;
mod network;
mod blockchain_rpc_client;
pub use blockchain_rpc_client::BlockChainRpcClient;
fn build_authority_discovery_service<Block: BlockT>(
task_manager: &TaskManager,
client: Arc<BlockChainRpcClient>,
config: &Configuration,
network: Arc<NetworkService<Block, <Block as BlockT>::Hash>>,
prometheus_registry: Option<Registry>,
) -> AuthorityDiscoveryService {
let auth_disc_publish_non_global_ips = config.network.allow_non_globals_in_dht;
let authority_discovery_role = sc_authority_discovery::Role::Discover;
let dht_event_stream = network.event_stream("authority-discovery").filter_map(|e| async move {
match e {
Event::Dht(e) => Some(e),
_ => None,
}
});
let (worker, service) = sc_authority_discovery::new_worker_and_service_with_config(
sc_authority_discovery::WorkerConfig {
publish_non_global_ips: auth_disc_publish_non_global_ips,
// Require that authority discovery records are signed.
strict_record_validation: true,
..Default::default()
},
client,
network.clone(),
Box::pin(dht_event_stream),
authority_discovery_role,
prometheus_registry.clone(),
);
task_manager.spawn_handle().spawn(
"authority-discovery-worker",
Some("authority-discovery"),
worker.run(),
);
service
}
pub async fn build_minimal_relay_chain_node(
polkadot_config: Configuration,
task_manager: &mut TaskManager,
relay_chain_url: Url,
) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> {
let client = cumulus_relay_chain_rpc_interface::create_client_and_start_worker(
relay_chain_url,
task_manager,
)
.await?;
let collator_pair = CollatorPair::generate().0;
let collator_node = new_minimal_relay_chain(
polkadot_config,
collator_pair.clone(),
Arc::new(BlockChainRpcClient::new(client.clone())),
)
.await?;
task_manager.add_child(collator_node.task_manager);
Ok((
Arc::new(RelayChainRpcInterface::new(client, collator_node.overseer_handle)),
Some(collator_pair),
))
}
/// Builds a minimal relay chain node. Chain data is fetched
/// via [`BlockChainRpcClient`] and fed into the overseer and its subsystems.
///
/// Instead of spawning all subsystems, this minimal node will only spawn subsystems
/// required to collate:
/// - AvailabilityRecovery
/// - CollationGeneration
/// - CollatorProtocol
/// - NetworkBridgeRx
/// - NetworkBridgeTx
/// - RuntimeApi
/// - ChainApi
/// - AvailabilityDistribution
#[sc_tracing::logging::prefix_logs_with("Relaychain")]
async fn new_minimal_relay_chain(
mut config: Configuration,
collator_pair: CollatorPair,
relay_chain_rpc_client: Arc<BlockChainRpcClient>,
) -> Result<NewMinimalNode, RelayChainError> {
let role = config.role.clone();
// Use the given RPC node as bootnode, since we do not have a chain spec with valid boot nodes
let mut boot_node_address = relay_chain_rpc_client.local_listen_addresses().await?;
config.network.boot_nodes.append(&mut boot_node_address);
let task_manager = {
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
TaskManager::new(config.tokio_handle.clone(), registry)?
};
let prometheus_registry = config.prometheus_registry().cloned();
let genesis_hash = relay_chain_rpc_client
.block_get_hash(Some(0))
.await
.expect("Genesis block hash is always available; qed")
.unwrap_or_default();
let peer_set_protocol_names =
PeerSetProtocolNames::new(genesis_hash, config.chain_spec.fork_id());
let is_authority = if role.is_authority() { IsAuthority::Yes } else { IsAuthority::No };
config
.network
.extra_sets
.extend(peer_sets_info(is_authority, &peer_set_protocol_names));
let request_protocol_names = ReqProtocolNames::new(genesis_hash, config.chain_spec.fork_id());
let (collation_req_receiver, available_data_req_receiver, pov_req_receiver, chunk_req_receiver) =
build_request_response_protocol_receivers(&request_protocol_names, &mut config);
let (network, network_starter) =
network::build_collator_network(network::BuildCollatorNetworkParams {
config: &config,
client: relay_chain_rpc_client.clone(),
spawn_handle: task_manager.spawn_handle(),
genesis_hash,
})?;
let authority_discovery_service = build_authority_discovery_service(
&task_manager,
relay_chain_rpc_client.clone(),
&config,
network.clone(),
prometheus_registry.clone(),
);
let parachains_db = open_database(&config.database)?;
let overseer_args = CollatorOverseerGenArgs {
runtime_client: relay_chain_rpc_client.clone(),
network_service: network.clone(),
authority_discovery_service,
collation_req_receiver,
available_data_req_receiver,
registry: prometheus_registry.as_ref(),
spawner: task_manager.spawn_handle(),
collator_pair,
req_protocol_names: request_protocol_names,
peer_set_protocol_names,
parachains_db,
availability_config: polkadot_service::AVAILABILITY_CONFIG,
pov_req_receiver,
chunk_req_receiver,
};
let overseer_handle = collator_overseer::spawn_overseer(
overseer_args,
&task_manager,
relay_chain_rpc_client.clone(),
)?;
network_starter.start_network();
Ok(NewMinimalNode { task_manager, overseer_handle, network })
}
fn build_request_response_protocol_receivers(
request_protocol_names: &ReqProtocolNames,
config: &mut Configuration,
) -> (
request_response::IncomingRequestReceiver<request_response::v1::CollationFetchingRequest>,
request_response::IncomingRequestReceiver<request_response::v1::AvailableDataFetchingRequest>,
request_response::IncomingRequestReceiver<request_response::v1::PoVFetchingRequest>,
request_response::IncomingRequestReceiver<request_response::v1::ChunkFetchingRequest>,
) {
let (collation_req_receiver, cfg) =
IncomingRequest::get_config_receiver(request_protocol_names);
config.network.request_response_protocols.push(cfg);
let (available_data_req_receiver, cfg) =
IncomingRequest::get_config_receiver(request_protocol_names);
config.network.request_response_protocols.push(cfg);
let (pov_req_receiver, cfg) = IncomingRequest::get_config_receiver(request_protocol_names);
config.network.request_response_protocols.push(cfg);
let (chunk_req_receiver, cfg) = IncomingRequest::get_config_receiver(request_protocol_names);
config.network.request_response_protocols.push(cfg);
(collation_req_receiver, available_data_req_receiver, pov_req_receiver, chunk_req_receiver)
}
@@ -0,0 +1,466 @@
// Copyright 2022 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use polkadot_core_primitives::{Block, Hash};
use polkadot_service::{BlockT, NumberFor};
use polkadot_node_network_protocol::PeerId;
use sc_network::{NetworkService, SyncState};
use sc_client_api::HeaderBackend;
use sc_network_common::{
config::{
NonDefaultSetConfig, NonReservedPeerMode, NotificationHandshake, ProtocolId, SetConfig,
},
protocol::role::Roles,
service::NetworkSyncForkRequest,
sync::{message::BlockAnnouncesHandshake, Metrics, SyncStatus},
};
use sc_network_light::light_client_requests;
use sc_network_sync::{block_request_handler, state_request_handler};
use sc_service::{error::Error, Configuration, NetworkStarter, SpawnTaskHandle};
use sp_consensus::BlockOrigin;
use sp_runtime::Justifications;
use std::{iter, sync::Arc};
use crate::BlockChainRpcClient;
pub(crate) struct BuildCollatorNetworkParams<'a> {
/// The service configuration.
pub config: &'a Configuration,
/// A shared client returned by `new_full_parts`.
pub client: Arc<BlockChainRpcClient>,
/// A handle for spawning tasks.
pub spawn_handle: SpawnTaskHandle,
/// Genesis hash
pub genesis_hash: Hash,
}
/// Build the network service, the network status sinks and an RPC sender.
pub(crate) fn build_collator_network(
params: BuildCollatorNetworkParams,
) -> Result<(Arc<NetworkService<Block, Hash>>, NetworkStarter), Error> {
let BuildCollatorNetworkParams { config, client, spawn_handle, genesis_hash } = params;
let protocol_id = config.protocol_id();
let block_request_protocol_config =
block_request_handler::generate_protocol_config(&protocol_id, genesis_hash, None);
let state_request_protocol_config =
state_request_handler::generate_protocol_config(&protocol_id, genesis_hash, None);
let light_client_request_protocol_config =
light_client_requests::generate_protocol_config(&protocol_id, genesis_hash, None);
let chain_sync = DummyChainSync;
let block_announce_config = chain_sync.get_block_announce_proto_config::<Block>(
protocol_id.clone(),
&None,
Roles::from(&config.role),
client.info().best_number,
client.info().best_hash,
genesis_hash,
);
let network_params = sc_network::config::Params {
role: config.role.clone(),
executor: {
let spawn_handle = Clone::clone(&spawn_handle);
Some(Box::new(move |fut| {
spawn_handle.spawn("libp2p-node", Some("networking"), fut);
}))
},
fork_id: None,
chain_sync: Box::new(chain_sync),
network_config: config.network.clone(),
chain: client.clone(),
import_queue: Box::new(DummyImportQueue),
protocol_id,
metrics_registry: config.prometheus_config.as_ref().map(|config| config.registry.clone()),
block_announce_config,
chain_sync_service: Box::new(DummyChainSyncService::<Block>(Default::default())),
block_request_protocol_config,
state_request_protocol_config,
warp_sync_protocol_config: None,
light_client_request_protocol_config,
request_response_protocol_configs: Vec::new(),
};
let network_worker = sc_network::NetworkWorker::new(network_params)?;
let network_service = network_worker.service().clone();
let (network_start_tx, network_start_rx) = futures::channel::oneshot::channel();
// The network worker is responsible for gathering all network messages and processing
// them. This is quite a heavy task, and at the time of the writing of this comment it
// frequently happens that this future takes several seconds or in some situations
// even more than a minute until it has processed its entire queue. This is clearly an
// issue, and ideally we would like to fix the network future to take as little time as
// possible, but we also take the extra harm-prevention measure to execute the networking
// future using `spawn_blocking`.
spawn_handle.spawn_blocking("network-worker", Some("networking"), async move {
if network_start_rx.await.is_err() {
tracing::warn!(
"The NetworkStart returned as part of `build_network` has been silently dropped"
);
// This `return` might seem unnecessary, but we don't want to make it look like
// everything is working as normal even though the user is clearly misusing the API.
return
}
network_worker.await
});
let network_starter = NetworkStarter::new(network_start_tx);
Ok((network_service, network_starter))
}
/// Empty ChainSync shell. Syncing code is not necessary for
/// the minimal node, but network currently requires it. So
/// we provide a noop implementation.
struct DummyChainSync;
impl DummyChainSync {
pub fn get_block_announce_proto_config<B: BlockT>(
&self,
protocol_id: ProtocolId,
fork_id: &Option<String>,
roles: Roles,
best_number: NumberFor<B>,
best_hash: B::Hash,
genesis_hash: B::Hash,
) -> NonDefaultSetConfig {
let block_announces_protocol = {
let genesis_hash = genesis_hash.as_ref();
if let Some(ref fork_id) = fork_id {
format!(
"/{}/{}/block-announces/1",
array_bytes::bytes2hex("", genesis_hash),
fork_id
)
} else {
format!("/{}/block-announces/1", array_bytes::bytes2hex("", genesis_hash))
}
};
NonDefaultSetConfig {
notifications_protocol: block_announces_protocol.into(),
fallback_names: iter::once(
format!("/{}/block-announces/1", protocol_id.as_ref()).into(),
)
.collect(),
max_notification_size: 1024 * 1024,
handshake: Some(NotificationHandshake::new(BlockAnnouncesHandshake::<B>::build(
roles,
best_number,
best_hash,
genesis_hash,
))),
// NOTE: `set_config` will be ignored by `protocol.rs` as the block announcement
// protocol is still hardcoded into the peerset.
set_config: SetConfig {
in_peers: 0,
out_peers: 0,
reserved_nodes: Vec::new(),
non_reserved_mode: NonReservedPeerMode::Deny,
},
}
}
}
impl<B: BlockT> sc_network_common::sync::ChainSync<B> for DummyChainSync {
fn peer_info(&self, _who: &PeerId) -> Option<sc_network_common::sync::PeerInfo<B>> {
None
}
fn status(&self) -> sc_network_common::sync::SyncStatus<B> {
SyncStatus {
state: SyncState::Idle,
best_seen_block: None,
num_peers: 0,
queued_blocks: 0,
state_sync: None,
warp_sync: None,
}
}
fn num_sync_requests(&self) -> usize {
0
}
fn num_downloaded_blocks(&self) -> usize {
0
}
fn num_peers(&self) -> usize {
0
}
fn new_peer(
&mut self,
_who: PeerId,
_best_hash: <B as BlockT>::Hash,
_best_number: polkadot_service::NumberFor<B>,
) -> Result<
Option<sc_network_common::sync::message::BlockRequest<B>>,
sc_network_common::sync::BadPeer,
> {
Ok(None)
}
fn update_chain_info(
&mut self,
_best_hash: &<B as BlockT>::Hash,
_best_number: polkadot_service::NumberFor<B>,
) {
}
fn request_justification(
&mut self,
_hash: &<B as BlockT>::Hash,
_number: polkadot_service::NumberFor<B>,
) {
}
fn clear_justification_requests(&mut self) {}
fn set_sync_fork_request(
&mut self,
_peers: Vec<PeerId>,
_hash: &<B as BlockT>::Hash,
_number: polkadot_service::NumberFor<B>,
) {
}
fn justification_requests(
&mut self,
) -> Box<dyn Iterator<Item = (PeerId, sc_network_common::sync::message::BlockRequest<B>)> + '_>
{
Box::new(std::iter::empty())
}
fn block_requests(
&mut self,
) -> Box<dyn Iterator<Item = (PeerId, sc_network_common::sync::message::BlockRequest<B>)> + '_>
{
Box::new(std::iter::empty())
}
fn state_request(&mut self) -> Option<(PeerId, sc_network_common::sync::OpaqueStateRequest)> {
None
}
fn warp_sync_request(
&mut self,
) -> Option<(PeerId, sc_network_common::sync::warp::WarpProofRequest<B>)> {
None
}
fn on_block_data(
&mut self,
_who: &PeerId,
_request: Option<sc_network_common::sync::message::BlockRequest<B>>,
_response: sc_network_common::sync::message::BlockResponse<B>,
) -> Result<sc_network_common::sync::OnBlockData<B>, sc_network_common::sync::BadPeer> {
unimplemented!("Not supported on the RPC collator")
}
fn on_state_data(
&mut self,
_who: &PeerId,
_response: sc_network_common::sync::OpaqueStateResponse,
) -> Result<sc_network_common::sync::OnStateData<B>, sc_network_common::sync::BadPeer> {
unimplemented!("Not supported on the RPC collator")
}
fn on_warp_sync_data(
&mut self,
_who: &PeerId,
_response: sc_network_common::sync::warp::EncodedProof,
) -> Result<(), sc_network_common::sync::BadPeer> {
unimplemented!("Not supported on the RPC collator")
}
fn on_block_justification(
&mut self,
_who: PeerId,
_response: sc_network_common::sync::message::BlockResponse<B>,
) -> Result<sc_network_common::sync::OnBlockJustification<B>, sc_network_common::sync::BadPeer>
{
unimplemented!("Not supported on the RPC collator")
}
fn on_blocks_processed(
&mut self,
_imported: usize,
_count: usize,
_results: Vec<(
Result<
sc_consensus::BlockImportStatus<polkadot_service::NumberFor<B>>,
sc_consensus::BlockImportError,
>,
<B as BlockT>::Hash,
)>,
) -> Box<
dyn Iterator<
Item = Result<
(PeerId, sc_network_common::sync::message::BlockRequest<B>),
sc_network_common::sync::BadPeer,
>,
>,
> {
Box::new(std::iter::empty())
}
fn on_justification_import(
&mut self,
_hash: <B as BlockT>::Hash,
_number: polkadot_service::NumberFor<B>,
_success: bool,
) {
}
fn on_block_finalized(
&mut self,
_hash: &<B as BlockT>::Hash,
_number: polkadot_service::NumberFor<B>,
) {
}
fn push_block_announce_validation(
&mut self,
_who: PeerId,
_hash: <B as BlockT>::Hash,
_announce: sc_network_common::sync::message::BlockAnnounce<<B as BlockT>::Header>,
_is_best: bool,
) {
}
fn poll_block_announce_validation(
&mut self,
_cx: &mut std::task::Context,
) -> std::task::Poll<sc_network_common::sync::PollBlockAnnounceValidation<<B as BlockT>::Header>>
{
std::task::Poll::Pending
}
fn peer_disconnected(
&mut self,
_who: &PeerId,
) -> Option<sc_network_common::sync::OnBlockData<B>> {
None
}
fn metrics(&self) -> sc_network_common::sync::Metrics {
Metrics {
queued_blocks: 0,
fork_targets: 0,
justifications: sc_network_common::sync::metrics::Metrics {
pending_requests: 0,
active_requests: 0,
importing_requests: 0,
failed_requests: 0,
},
}
}
fn create_opaque_block_request(
&self,
_request: &sc_network_common::sync::message::BlockRequest<B>,
) -> sc_network_common::sync::OpaqueBlockRequest {
unimplemented!("Not supported on the RPC collator")
}
fn encode_block_request(
&self,
_request: &sc_network_common::sync::OpaqueBlockRequest,
) -> Result<Vec<u8>, String> {
unimplemented!("Not supported on the RPC collator")
}
fn decode_block_response(
&self,
_response: &[u8],
) -> Result<sc_network_common::sync::OpaqueBlockResponse, String> {
unimplemented!("Not supported on the RPC collator")
}
fn block_response_into_blocks(
&self,
_request: &sc_network_common::sync::message::BlockRequest<B>,
_response: sc_network_common::sync::OpaqueBlockResponse,
) -> Result<Vec<sc_network_common::sync::message::BlockData<B>>, String> {
unimplemented!("Not supported on the RPC collator")
}
fn encode_state_request(
&self,
_request: &sc_network_common::sync::OpaqueStateRequest,
) -> Result<Vec<u8>, String> {
unimplemented!("Not supported on the RPC collator")
}
fn decode_state_response(
&self,
_response: &[u8],
) -> Result<sc_network_common::sync::OpaqueStateResponse, String> {
unimplemented!("Not supported on the RPC collator")
}
fn poll(
&mut self,
_cx: &mut std::task::Context,
) -> std::task::Poll<sc_network_common::sync::PollBlockAnnounceValidation<<B as BlockT>::Header>>
{
std::task::Poll::Pending
}
}
struct DummyImportQueue;
impl sc_service::ImportQueue<Block> for DummyImportQueue {
fn import_blocks(
&mut self,
_origin: BlockOrigin,
_blocks: Vec<sc_consensus::IncomingBlock<Block>>,
) {
}
fn import_justifications(
&mut self,
_who: PeerId,
_hash: Hash,
_number: NumberFor<Block>,
_justifications: Justifications,
) {
}
fn poll_actions(
&mut self,
_cx: &mut futures::task::Context,
_link: &mut dyn sc_consensus::import_queue::Link<Block>,
) {
}
}
struct DummyChainSyncService<B>(std::marker::PhantomData<B>);
impl<B: BlockT> NetworkSyncForkRequest<B::Hash, NumberFor<B>> for DummyChainSyncService<B> {
fn set_sync_fork_request(&self, _peers: Vec<PeerId>, _hash: B::Hash, _number: NumberFor<B>) {}
}
+6 -3
View File
@@ -11,19 +11,22 @@ polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "m
cumulus-primitives-core = { path = "../../primitives/core" } cumulus-primitives-core = { path = "../../primitives/core" }
cumulus-relay-chain-interface = { path = "../relay-chain-interface" } cumulus-relay-chain-interface = { path = "../relay-chain-interface" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-storage = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-storage = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-rpc-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
tokio = { version = "1.21.1", features = ["sync"] } tokio = { version = "1.21.2", features = ["sync"] }
futures = "0.3.24" futures = "0.3.24"
futures-timer = "3.0.2" futures-timer = "3.0.2"
parity-scale-codec = "3.2.1" parity-scale-codec = "3.2.1"
jsonrpsee = { version = "0.15.1", features = ["ws-client"] } jsonrpsee = { version = "0.15.1", features = ["ws-client"] }
tracing = "0.1.36" tracing = "0.1.37"
async-trait = "0.1.57" async-trait = "0.1.58"
url = "2.3.1" url = "2.3.1"
backoff = { version = "0.4.0", features = ["tokio"] } backoff = { version = "0.4.0", features = ["tokio"] }
+6 -5
View File
@@ -44,11 +44,12 @@ const TIMEOUT_IN_SECONDS: u64 = 6;
#[derive(Clone)] #[derive(Clone)]
pub struct RelayChainRpcInterface { pub struct RelayChainRpcInterface {
rpc_client: RelayChainRpcClient, rpc_client: RelayChainRpcClient,
overseer_handle: Handle,
} }
impl RelayChainRpcInterface { impl RelayChainRpcInterface {
pub fn new(rpc_client: RelayChainRpcClient) -> Self { pub fn new(rpc_client: RelayChainRpcClient, overseer_handle: Handle) -> Self {
Self { rpc_client } Self { rpc_client, overseer_handle }
} }
} }
@@ -118,15 +119,15 @@ impl RelayChainInterface for RelayChainRpcInterface {
} }
async fn best_block_hash(&self) -> RelayChainResult<PHash> { async fn best_block_hash(&self) -> RelayChainResult<PHash> {
self.rpc_client.chain_get_head().await self.rpc_client.chain_get_head(None).await
} }
async fn is_major_syncing(&self) -> RelayChainResult<bool> { async fn is_major_syncing(&self) -> RelayChainResult<bool> {
self.rpc_client.system_health().await.map(|h| h.is_syncing) self.rpc_client.system_health().await.map(|h| h.is_syncing)
} }
fn overseer_handle(&self) -> RelayChainResult<Option<Handle>> { fn overseer_handle(&self) -> RelayChainResult<Handle> {
unimplemented!("Overseer handle is not available on relay-chain-rpc-interface"); Ok(self.overseer_handle.clone())
} }
async fn get_storage_by_key( async fn get_storage_by_key(
@@ -17,8 +17,13 @@
use backoff::{future::retry_notify, ExponentialBackoff}; use backoff::{future::retry_notify, ExponentialBackoff};
use cumulus_primitives_core::{ use cumulus_primitives_core::{
relay_chain::{ relay_chain::{
v2::{CommittedCandidateReceipt, OccupiedCoreAssumption, SessionIndex, ValidatorId}, v2::{
Hash as PHash, Header as PHeader, InboundHrmpMessage, CandidateCommitments, CandidateEvent, CommittedCandidateReceipt, CoreState,
DisputeState, GroupRotationInfo, OccupiedCoreAssumption, OldV1SessionInfo,
PvfCheckStatement, ScrapedOnChainVotes, SessionIndex, SessionInfo, ValidationCode,
ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature,
},
CandidateHash, Hash as PHash, Header as PHeader, InboundHrmpMessage,
}, },
InboundDownwardMessage, ParaId, PersistedValidationData, InboundDownwardMessage, ParaId, PersistedValidationData,
}; };
@@ -37,9 +42,11 @@ use jsonrpsee::{
ws_client::WsClientBuilder, ws_client::WsClientBuilder,
}; };
use parity_scale_codec::{Decode, Encode}; use parity_scale_codec::{Decode, Encode};
use polkadot_service::TaskManager; use polkadot_service::{BlockNumber, TaskManager};
use sc_client_api::StorageData; use sc_client_api::StorageData;
use sc_rpc_api::{state::ReadProof, system::Health}; use sc_rpc_api::{state::ReadProof, system::Health};
use sp_api::RuntimeVersion;
use sp_consensus_babe::Epoch;
use sp_core::sp_std::collections::btree_map::BTreeMap; use sp_core::sp_std::collections::btree_map::BTreeMap;
use sp_runtime::DeserializeOwned; use sp_runtime::DeserializeOwned;
use sp_storage::StorageKey; use sp_storage::StorageKey;
@@ -253,8 +260,6 @@ impl RelayChainRpcClient {
Decode::decode(&mut &*res.0).map_err(Into::into) Decode::decode(&mut &*res.0).map_err(Into::into)
} }
/// Subscribe to a notification stream via RPC
/// Perform RPC request /// Perform RPC request
async fn request<'a, R>( async fn request<'a, R>(
&self, &self,
@@ -300,10 +305,69 @@ impl RelayChainRpcClient {
RelayChainError::RpcCallError(method.to_string(), err)}) RelayChainError::RpcCallError(method.to_string(), err)})
} }
/// Returns information regarding the current epoch.
pub async fn babe_api_current_epoch(&self, at: PHash) -> Result<Epoch, RelayChainError> {
self.call_remote_runtime_function("BabeApi_current_epoch", at, None::<()>).await
}
/// Old method to fetch v1 session info.
pub async fn parachain_host_session_info_before_version_2(
&self,
at: PHash,
index: SessionIndex,
) -> Result<Option<OldV1SessionInfo>, RelayChainError> {
self.call_remote_runtime_function(
"ParachainHost_session_info_before_version_2",
at,
Some(index),
)
.await
}
/// Scrape dispute relevant from on-chain, backing votes and resolved disputes.
pub async fn parachain_host_on_chain_votes(
&self,
at: PHash,
) -> Result<Option<ScrapedOnChainVotes<PHash>>, RelayChainError> {
self.call_remote_runtime_function("ParachainHost_on_chain_votes", at, None::<()>)
.await
}
/// Returns code hashes of PVFs that require pre-checking by validators in the active set.
pub async fn parachain_host_pvfs_require_precheck(
&self,
at: PHash,
) -> Result<Vec<ValidationCodeHash>, RelayChainError> {
self.call_remote_runtime_function("ParachainHost_pvfs_require_precheck", at, None::<()>)
.await
}
/// Submits a PVF pre-checking statement into the transaction pool.
pub async fn parachain_host_submit_pvf_check_statement(
&self,
at: PHash,
stmt: PvfCheckStatement,
signature: ValidatorSignature,
) -> Result<(), RelayChainError> {
self.call_remote_runtime_function(
"ParachainHost_submit_pvf_check_statement",
at,
Some((stmt, signature)),
)
.await
}
/// Get local listen address of the node
pub async fn system_local_listen_addresses(&self) -> Result<Vec<String>, RelayChainError> {
self.request("system_localListenAddresses", None).await
}
/// Get system health information
pub async fn system_health(&self) -> Result<Health, RelayChainError> { pub async fn system_health(&self) -> Result<Health, RelayChainError> {
self.request("system_health", None).await self.request("system_health", None).await
} }
/// Get read proof for `storage_keys`
pub async fn state_get_read_proof( pub async fn state_get_read_proof(
&self, &self,
storage_keys: Vec<StorageKey>, storage_keys: Vec<StorageKey>,
@@ -313,6 +377,7 @@ impl RelayChainRpcClient {
self.request("state_getReadProof", params).await self.request("state_getReadProof", params).await
} }
/// Retrieve storage item at `storage_key`
pub async fn state_get_storage( pub async fn state_get_storage(
&self, &self,
storage_key: StorageKey, storage_key: StorageKey,
@@ -322,47 +387,85 @@ impl RelayChainRpcClient {
self.request("state_getStorage", params).await self.request("state_getStorage", params).await
} }
pub async fn chain_get_head(&self) -> Result<PHash, RelayChainError> { /// Get hash of the n-th block in the canon chain.
self.request("chain_getHead", None).await ///
/// By default returns latest block hash.
pub async fn chain_get_head(&self, at: Option<u64>) -> Result<PHash, RelayChainError> {
let params = rpc_params!(at);
self.request("chain_getHead", params).await
} }
pub async fn chain_get_header( /// Returns the validator groups and rotation info localized based on the hypothetical child
/// of a block whose state this is invoked on. Note that `now` in the `GroupRotationInfo`
/// should be the successor of the number of the block.
pub async fn parachain_host_validator_groups(
&self, &self,
hash: Option<PHash>, at: PHash,
) -> Result<Option<PHeader>, RelayChainError> { ) -> Result<(Vec<Vec<ValidatorIndex>>, GroupRotationInfo), RelayChainError> {
let params = rpc_params!(hash); self.call_remote_runtime_function("ParachainHost_validator_groups", at, None::<()>)
self.request("chain_getHeader", params).await .await
} }
pub async fn parachain_host_candidate_pending_availability( /// Get a vector of events concerning candidates that occurred within a block.
pub async fn parachain_host_candidate_events(
&self,
at: PHash,
) -> Result<Vec<CandidateEvent>, RelayChainError> {
self.call_remote_runtime_function("ParachainHost_candidate_events", at, None::<()>)
.await
}
/// Checks if the given validation outputs pass the acceptance criteria.
pub async fn parachain_host_check_validation_outputs(
&self, &self,
at: PHash, at: PHash,
para_id: ParaId, para_id: ParaId,
) -> Result<Option<CommittedCandidateReceipt>, RelayChainError> { outputs: CandidateCommitments,
) -> Result<bool, RelayChainError> {
self.call_remote_runtime_function( self.call_remote_runtime_function(
"ParachainHost_candidate_pending_availability", "ParachainHost_check_validation_outputs",
at, at,
Some(para_id), Some((para_id, outputs)),
) )
.await .await
} }
pub async fn parachain_host_session_index_for_child( /// Returns the persisted validation data for the given `ParaId` along with the corresponding
/// validation code hash. Instead of accepting assumption about the para, matches the validation
/// data hash against an expected one and yields `None` if they're not equal.
pub async fn parachain_host_assumed_validation_data(
&self, &self,
at: PHash, at: PHash,
) -> Result<SessionIndex, RelayChainError> { para_id: ParaId,
self.call_remote_runtime_function("ParachainHost_session_index_for_child", at, None::<()>) expected_hash: PHash,
.await ) -> Result<Option<(PersistedValidationData, ValidationCodeHash)>, RelayChainError> {
self.call_remote_runtime_function(
"ParachainHost_persisted_assumed_validation_data",
at,
Some((para_id, expected_hash)),
)
.await
} }
pub async fn parachain_host_validators( /// Get hash of last finalized block.
pub async fn chain_get_finalized_head(&self) -> Result<PHash, RelayChainError> {
self.request("chain_getFinalizedHead", None).await
}
/// Get hash of n-th block.
pub async fn chain_get_block_hash(
&self, &self,
at: PHash, block_number: Option<polkadot_service::BlockNumber>,
) -> Result<Vec<ValidatorId>, RelayChainError> { ) -> Result<Option<PHash>, RelayChainError> {
self.call_remote_runtime_function("ParachainHost_validators", at, None::<()>) let params = rpc_params!(block_number);
.await self.request("chain_getBlockHash", params).await
} }
/// Yields the persisted validation data for the given `ParaId` along with an assumption that
/// should be used if the para currently occupies a core.
///
/// Returns `None` if either the para is not registered or the assumption is `Freed`
/// and the para already occupies a core.
pub async fn parachain_host_persisted_validation_data( pub async fn parachain_host_persisted_validation_data(
&self, &self,
at: PHash, at: PHash,
@@ -377,6 +480,143 @@ impl RelayChainRpcClient {
.await .await
} }
/// Get the validation code from its hash.
pub async fn parachain_host_validation_code_by_hash(
&self,
at: PHash,
validation_code_hash: ValidationCodeHash,
) -> Result<Option<ValidationCode>, RelayChainError> {
self.call_remote_runtime_function(
"ParachainHost_validation_code_by_hash",
at,
Some(validation_code_hash),
)
.await
}
/// Yields information on all availability cores as relevant to the child block.
/// Cores are either free or occupied. Free cores can have paras assigned to them.
pub async fn parachain_host_availability_cores(
&self,
at: PHash,
) -> Result<Vec<CoreState<PHash, BlockNumber>>, RelayChainError> {
self.call_remote_runtime_function("ParachainHost_availability_cores", at, None::<()>)
.await
}
/// Get runtime version
pub async fn runtime_version(&self, at: PHash) -> Result<RuntimeVersion, RelayChainError> {
let params = rpc_params!(at);
self.request("state_getRuntimeVersion", params).await
}
/// Returns all onchain disputes.
/// This is a staging method! Do not use on production runtimes!
pub async fn parachain_host_staging_get_disputes(
&self,
at: PHash,
) -> Result<Vec<(SessionIndex, CandidateHash, DisputeState<BlockNumber>)>, RelayChainError> {
self.call_remote_runtime_function("ParachainHost_staging_get_disputes", at, None::<()>)
.await
}
pub async fn authority_discovery_authorities(
&self,
at: PHash,
) -> Result<Vec<sp_authority_discovery::AuthorityId>, RelayChainError> {
self.call_remote_runtime_function("AuthorityDiscoveryApi_authorities", at, None::<()>)
.await
}
/// Fetch the validation code used by a para, making the given `OccupiedCoreAssumption`.
///
/// Returns `None` if either the para is not registered or the assumption is `Freed`
/// and the para already occupies a core.
pub async fn parachain_host_validation_code(
&self,
at: PHash,
para_id: ParaId,
occupied_core_assumption: OccupiedCoreAssumption,
) -> Result<Option<ValidationCode>, RelayChainError> {
self.call_remote_runtime_function(
"ParachainHost_validation_code",
at,
Some((para_id, occupied_core_assumption)),
)
.await
}
/// Fetch the hash of the validation code used by a para, making the given `OccupiedCoreAssumption`.
pub async fn parachain_host_validation_code_hash(
&self,
at: PHash,
para_id: ParaId,
occupied_core_assumption: OccupiedCoreAssumption,
) -> Result<Option<ValidationCodeHash>, RelayChainError> {
self.call_remote_runtime_function(
"ParachainHost_validation_code_hash",
at,
Some((para_id, occupied_core_assumption)),
)
.await
}
/// Get the session info for the given session, if stored.
pub async fn parachain_host_session_info(
&self,
at: PHash,
index: SessionIndex,
) -> Result<Option<SessionInfo>, RelayChainError> {
self.call_remote_runtime_function("ParachainHost_session_info", at, Some(index))
.await
}
/// Get header at specified hash
pub async fn chain_get_header(
&self,
hash: Option<PHash>,
) -> Result<Option<PHeader>, RelayChainError> {
let params = rpc_params!(hash);
self.request("chain_getHeader", params).await
}
/// Get the receipt of a candidate pending availability. This returns `Some` for any paras
/// assigned to occupied cores in `availability_cores` and `None` otherwise.
pub async fn parachain_host_candidate_pending_availability(
&self,
at: PHash,
para_id: ParaId,
) -> Result<Option<CommittedCandidateReceipt>, RelayChainError> {
self.call_remote_runtime_function(
"ParachainHost_candidate_pending_availability",
at,
Some(para_id),
)
.await
}
/// Returns the session index expected at a child of the block.
///
/// This can be used to instantiate a `SigningContext`.
pub async fn parachain_host_session_index_for_child(
&self,
at: PHash,
) -> Result<SessionIndex, RelayChainError> {
self.call_remote_runtime_function("ParachainHost_session_index_for_child", at, None::<()>)
.await
}
/// Get the current validators.
pub async fn parachain_host_validators(
&self,
at: PHash,
) -> Result<Vec<ValidatorId>, RelayChainError> {
self.call_remote_runtime_function("ParachainHost_validators", at, None::<()>)
.await
}
/// Get the contents of all channels addressed to the given recipient. Channels that have no
/// messages in them are also included.
pub async fn parachain_host_inbound_hrmp_channels_contents( pub async fn parachain_host_inbound_hrmp_channels_contents(
&self, &self,
para_id: ParaId, para_id: ParaId,
@@ -390,6 +630,7 @@ impl RelayChainRpcClient {
.await .await
} }
/// Get all the pending inbound messages in the downward message queue for a para.
pub async fn parachain_host_dmq_contents( pub async fn parachain_host_dmq_contents(
&self, &self,
para_id: ParaId, para_id: ParaId,
@@ -399,15 +640,7 @@ impl RelayChainRpcClient {
.await .await
} }
fn send_register_message_to_worker( /// Get a stream of all imported relay chain headers
&self,
message: NotificationRegisterMessage,
) -> Result<(), RelayChainError> {
self.to_worker_channel
.try_send(message)
.map_err(|e| RelayChainError::WorkerCommunicationError(e.to_string()))
}
pub async fn get_imported_heads_stream(&self) -> Result<Receiver<PHeader>, RelayChainError> { pub async fn get_imported_heads_stream(&self) -> Result<Receiver<PHeader>, RelayChainError> {
let (tx, rx) = futures::channel::mpsc::channel::<PHeader>(NOTIFICATION_CHANNEL_SIZE_LIMIT); let (tx, rx) = futures::channel::mpsc::channel::<PHeader>(NOTIFICATION_CHANNEL_SIZE_LIMIT);
self.send_register_message_to_worker(NotificationRegisterMessage::RegisterImportListener( self.send_register_message_to_worker(NotificationRegisterMessage::RegisterImportListener(
@@ -416,6 +649,7 @@ impl RelayChainRpcClient {
Ok(rx) Ok(rx)
} }
/// Get a stream of new best relay chain headers
pub async fn get_best_heads_stream(&self) -> Result<Receiver<PHeader>, RelayChainError> { pub async fn get_best_heads_stream(&self) -> Result<Receiver<PHeader>, RelayChainError> {
let (tx, rx) = futures::channel::mpsc::channel::<PHeader>(NOTIFICATION_CHANNEL_SIZE_LIMIT); let (tx, rx) = futures::channel::mpsc::channel::<PHeader>(NOTIFICATION_CHANNEL_SIZE_LIMIT);
self.send_register_message_to_worker( self.send_register_message_to_worker(
@@ -424,6 +658,7 @@ impl RelayChainRpcClient {
Ok(rx) Ok(rx)
} }
/// Get a stream of finalized relay chain headers
pub async fn get_finalized_heads_stream(&self) -> Result<Receiver<PHeader>, RelayChainError> { pub async fn get_finalized_heads_stream(&self) -> Result<Receiver<PHeader>, RelayChainError> {
let (tx, rx) = futures::channel::mpsc::channel::<PHeader>(NOTIFICATION_CHANNEL_SIZE_LIMIT); let (tx, rx) = futures::channel::mpsc::channel::<PHeader>(NOTIFICATION_CHANNEL_SIZE_LIMIT);
self.send_register_message_to_worker( self.send_register_message_to_worker(
@@ -432,6 +667,15 @@ impl RelayChainRpcClient {
Ok(rx) Ok(rx)
} }
fn send_register_message_to_worker(
&self,
message: NotificationRegisterMessage,
) -> Result<(), RelayChainError> {
self.to_worker_channel
.try_send(message)
.map_err(|e| RelayChainError::WorkerCommunicationError(e.to_string()))
}
async fn subscribe_imported_heads( async fn subscribe_imported_heads(
ws_client: &JsonRpcClient, ws_client: &JsonRpcClient,
) -> Result<Subscription<PHeader>, RelayChainError> { ) -> Result<Subscription<PHeader>, RelayChainError> {
+2 -15
View File
@@ -18,7 +18,6 @@
//! //!
//! Provides functions for starting a collator node or a normal full node. //! Provides functions for starting a collator node or a normal full node.
use cumulus_client_cli::CollatorOptions;
use cumulus_client_consensus_common::ParachainConsensus; use cumulus_client_consensus_common::ParachainConsensus;
use cumulus_primitives_core::{CollectCollationInfo, ParaId}; use cumulus_primitives_core::{CollectCollationInfo, ParaId};
use cumulus_relay_chain_interface::RelayChainInterface; use cumulus_relay_chain_interface::RelayChainInterface;
@@ -108,8 +107,7 @@ where
let overseer_handle = relay_chain_interface let overseer_handle = relay_chain_interface
.overseer_handle() .overseer_handle()
.map_err(|e| sc_service::Error::Application(Box::new(e)))? .map_err(|e| sc_service::Error::Application(Box::new(e)))?;
.ok_or_else(|| "Polkadot full node did not provide an `OverseerHandle`!")?;
let pov_recovery = cumulus_client_pov_recovery::PoVRecovery::new( let pov_recovery = cumulus_client_pov_recovery::PoVRecovery::new(
overseer_handle.clone(), overseer_handle.clone(),
@@ -149,7 +147,6 @@ pub struct StartFullNodeParams<'a, Block: BlockT, Client, RCInterface, IQ> {
pub announce_block: Arc<dyn Fn(Block::Hash, Option<Vec<u8>>) + Send + Sync>, pub announce_block: Arc<dyn Fn(Block::Hash, Option<Vec<u8>>) + Send + Sync>,
pub relay_chain_slot_duration: Duration, pub relay_chain_slot_duration: Duration,
pub import_queue: IQ, pub import_queue: IQ,
pub collator_options: CollatorOptions,
} }
/// Start a full node for a parachain. /// Start a full node for a parachain.
@@ -165,7 +162,6 @@ pub fn start_full_node<Block, Client, Backend, RCInterface, IQ>(
para_id, para_id,
relay_chain_slot_duration, relay_chain_slot_duration,
import_queue, import_queue,
collator_options,
}: StartFullNodeParams<Block, Client, RCInterface, IQ>, }: StartFullNodeParams<Block, Client, RCInterface, IQ>,
) -> sc_service::error::Result<()> ) -> sc_service::error::Result<()>
where where
@@ -193,18 +189,9 @@ where
.spawn_essential_handle() .spawn_essential_handle()
.spawn("cumulus-consensus", None, consensus); .spawn("cumulus-consensus", None, consensus);
// PoV Recovery is currently not supported when we connect to the
// relay chain via RPC, so we return early. The node will work, but not be able to recover PoVs from the
// relay chain if blocks are not announced on parachain. This will be enabled again once
// https://github.com/paritytech/cumulus/issues/545 is finished.
if collator_options.relay_chain_rpc_url.is_some() {
return Ok(())
}
let overseer_handle = relay_chain_interface let overseer_handle = relay_chain_interface
.overseer_handle() .overseer_handle()
.map_err(|e| sc_service::Error::Application(Box::new(e)))? .map_err(|e| sc_service::Error::Application(Box::new(e)))?;
.ok_or_else(|| "Polkadot full node did not provide an `OverseerHandle`!")?;
let pov_recovery = cumulus_client_pov_recovery::PoVRecovery::new( let pov_recovery = cumulus_client_pov_recovery::PoVRecovery::new(
overseer_handle, overseer_handle,
+1 -1
View File
@@ -7,7 +7,7 @@ description = "AURA consensus extension pallet for parachains"
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
# Substrate # Substrate
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
+1 -1
View File
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
codec = { default-features = false, features = ["derive"], package = "parity-scale-codec", version = "3.0.0" } codec = { default-features = false, features = ["derive"], package = "parity-scale-codec", version = "3.0.0" }
rand = { version = "0.8.5", features = ["std_rng"], default-features = false } rand = { version = "0.8.5", features = ["std_rng"], default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" } sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
+3 -1
View File
@@ -6,7 +6,8 @@ edition = "2021"
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ], default-features = false } codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ], default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
# Substrate # Substrate
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -32,6 +33,7 @@ std = [
"scale-info/std", "scale-info/std",
"frame-support/std", "frame-support/std",
"frame-system/std", "frame-system/std",
"log/std",
"sp-io/std", "sp-io/std",
"sp-runtime/std", "sp-runtime/std",
"sp-std/std", "sp-std/std",
+30 -32
View File
@@ -21,6 +21,8 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
pub mod migration;
use codec::{Decode, DecodeLimit, Encode}; use codec::{Decode, DecodeLimit, Encode};
use cumulus_primitives_core::{relay_chain::BlockNumber as RelayBlockNumber, DmpMessageHandler}; use cumulus_primitives_core::{relay_chain::BlockNumber as RelayBlockNumber, DmpMessageHandler};
use frame_support::{ use frame_support::{
@@ -31,7 +33,12 @@ pub use pallet::*;
use scale_info::TypeInfo; use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug; use sp_runtime::RuntimeDebug;
use sp_std::{convert::TryFrom, prelude::*}; use sp_std::{convert::TryFrom, prelude::*};
use xcm::{latest::prelude::*, VersionedXcm, MAX_XCM_DECODE_DEPTH}; use xcm::{
latest::{prelude::*, Weight as XcmWeight},
VersionedXcm, MAX_XCM_DECODE_DEPTH,
};
const DEFAULT_POV_SIZE: u64 = 64 * 1024; // 64 KB
#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] #[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct ConfigData { pub struct ConfigData {
@@ -44,7 +51,10 @@ pub struct ConfigData {
impl Default for ConfigData { impl Default for ConfigData {
fn default() -> Self { fn default() -> Self {
Self { Self {
max_individual: 10u64 * WEIGHT_PER_MILLIS, // 10 ms of execution time maximum by default max_individual: Weight::from_parts(
10u64 * WEIGHT_PER_MILLIS.ref_time(), // 10 ms of execution time maximum by default
DEFAULT_POV_SIZE, // 64 KB of proof size by default
),
} }
} }
} }
@@ -78,6 +88,7 @@ pub mod pallet {
#[pallet::pallet] #[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)] #[pallet::generate_store(pub(super) trait Store)]
#[pallet::storage_version(migration::STORAGE_VERSION)]
#[pallet::without_storage_info] #[pallet::without_storage_info]
pub struct Pallet<T>(_); pub struct Pallet<T>(_);
@@ -121,6 +132,10 @@ pub mod pallet {
#[pallet::hooks] #[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_runtime_upgrade() -> Weight {
migration::migrate_to_latest::<T>()
}
fn on_idle(_now: T::BlockNumber, max_weight: Weight) -> Weight { fn on_idle(_now: T::BlockNumber, max_weight: Weight) -> Weight {
// on_idle processes additional messages with any remaining block weight. // on_idle processes additional messages with any remaining block weight.
Self::service_queue(max_weight) Self::service_queue(max_weight)
@@ -141,17 +156,18 @@ pub mod pallet {
/// ///
/// Events: /// Events:
/// - `OverweightServiced`: On success. /// - `OverweightServiced`: On success.
#[pallet::weight(weight_limit.saturating_add(Weight::from_ref_time(1_000_000)))] #[pallet::weight(Weight::from_ref_time(weight_limit.saturating_add(1_000_000)))]
pub fn service_overweight( pub fn service_overweight(
origin: OriginFor<T>, origin: OriginFor<T>,
index: OverweightIndex, index: OverweightIndex,
weight_limit: Weight, weight_limit: XcmWeight,
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
T::ExecuteOverweightOrigin::ensure_origin(origin)?; T::ExecuteOverweightOrigin::ensure_origin(origin)?;
let (sent_at, data) = Overweight::<T>::get(index).ok_or(Error::<T>::Unknown)?; let (sent_at, data) = Overweight::<T>::get(index).ok_or(Error::<T>::Unknown)?;
let weight_used = Self::try_service_message(weight_limit, sent_at, &data[..]) let weight_used =
.map_err(|_| Error::<T>::OverLimit)?; Self::try_service_message(Weight::from_ref_time(weight_limit), sent_at, &data[..])
.map_err(|_| Error::<T>::OverLimit)?;
Overweight::<T>::remove(index); Overweight::<T>::remove(index);
Self::deposit_event(Event::OverweightServiced { overweight_index: index, weight_used }); Self::deposit_event(Event::OverweightServiced { overweight_index: index, weight_used });
Ok(Some(weight_used.saturating_add(Weight::from_ref_time(1_000_000))).into()) Ok(Some(weight_used.saturating_add(Weight::from_ref_time(1_000_000))).into())
@@ -750,49 +766,31 @@ mod tests {
assert_eq!(overweights(), vec![0]); assert_eq!(overweights(), vec![0]);
assert_noop!( assert_noop!(
DmpQueue::service_overweight( DmpQueue::service_overweight(RuntimeOrigin::signed(1), 0, 20000),
RuntimeOrigin::signed(1),
0,
Weight::from_ref_time(20000)
),
BadOrigin BadOrigin
); );
assert_noop!( assert_noop!(
DmpQueue::service_overweight( DmpQueue::service_overweight(RuntimeOrigin::root(), 1, 20000),
RuntimeOrigin::root(),
1,
Weight::from_ref_time(20000)
),
Error::<Test>::Unknown Error::<Test>::Unknown
); );
assert_noop!( assert_noop!(
DmpQueue::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(9999)), DmpQueue::service_overweight(RuntimeOrigin::root(), 0, 9999),
Error::<Test>::OverLimit Error::<Test>::OverLimit
); );
assert_eq!(take_trace(), vec![msg_limit_reached(10000)]); assert_eq!(take_trace(), vec![msg_limit_reached(10000)]);
let base_weight = let base_weight = super::Call::<Test>::service_overweight { index: 0, weight_limit: 0 }
super::Call::<Test>::service_overweight { index: 0, weight_limit: Weight::zero() } .get_dispatch_info()
.get_dispatch_info() .weight;
.weight;
use frame_support::dispatch::GetDispatchInfo; use frame_support::dispatch::GetDispatchInfo;
let info = DmpQueue::service_overweight( let info = DmpQueue::service_overweight(RuntimeOrigin::root(), 0, 20000).unwrap();
RuntimeOrigin::root(),
0,
Weight::from_ref_time(20000),
)
.unwrap();
let actual_weight = info.actual_weight.unwrap(); let actual_weight = info.actual_weight.unwrap();
assert_eq!(actual_weight, base_weight + Weight::from_ref_time(10000)); assert_eq!(actual_weight, base_weight + Weight::from_ref_time(10000));
assert_eq!(take_trace(), vec![msg_complete(10000)]); assert_eq!(take_trace(), vec![msg_complete(10000)]);
assert!(overweights().is_empty()); assert!(overweights().is_empty());
assert_noop!( assert_noop!(
DmpQueue::service_overweight( DmpQueue::service_overweight(RuntimeOrigin::root(), 0, 20000),
RuntimeOrigin::root(),
0,
Weight::from_ref_time(20000)
),
Error::<Test>::Unknown Error::<Test>::Unknown
); );
}); });
+104
View File
@@ -0,0 +1,104 @@
// 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 <http://www.gnu.org/licenses/>.
//! A module that is responsible for migration of storage.
use crate::{Config, Pallet, Store, DEFAULT_POV_SIZE};
use frame_support::{
pallet_prelude::*,
traits::StorageVersion,
weights::{constants::WEIGHT_PER_MILLIS, Weight},
};
use xcm::latest::Weight as XcmWeight;
/// The current storage version.
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
/// Migrates the pallet storage to the most recent version, checking and setting the
/// `StorageVersion`.
pub fn migrate_to_latest<T: Config>() -> Weight {
let mut weight = T::DbWeight::get().reads(1);
if StorageVersion::get::<Pallet<T>>() == 0 {
weight += migrate_to_v1::<T>();
StorageVersion::new(1).put::<Pallet<T>>();
}
weight
}
mod v0 {
use super::*;
use codec::{Decode, Encode};
#[derive(Decode, Encode, Debug)]
pub struct ConfigData {
pub max_individual: XcmWeight,
}
impl Default for ConfigData {
fn default() -> Self {
ConfigData { max_individual: 10u64 * WEIGHT_PER_MILLIS.ref_time() }
}
}
}
/// Migrates `QueueConfigData` from v1 (using only reference time weights) to v2 (with
/// 2D weights).
///
/// NOTE: Only use this function if you know what you're doing. Default to using
/// `migrate_to_latest`.
pub fn migrate_to_v1<T: Config>() -> Weight {
let translate = |pre: v0::ConfigData| -> super::ConfigData {
super::ConfigData {
max_individual: Weight::from_parts(pre.max_individual, DEFAULT_POV_SIZE),
}
};
if let Err(_) = <Pallet<T> as Store>::Configuration::translate(|pre| pre.map(translate)) {
log::error!(
target: "dmp_queue",
"unexpected error when performing translation of the QueueConfig type during storage upgrade to v2"
);
}
T::DbWeight::get().reads_writes(1, 1)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tests::{new_test_ext, Test};
#[test]
fn test_migration_to_v1() {
let v0 = v0::ConfigData { max_individual: 30_000_000_000 };
new_test_ext().execute_with(|| {
frame_support::storage::unhashed::put_raw(
&crate::Configuration::<Test>::hashed_key(),
&v0.encode(),
);
migrate_to_v1::<Test>();
let v1 = crate::Configuration::<Test>::get();
assert_eq!(v0.max_individual, v1.max_individual.ref_time());
assert_eq!(v1.max_individual.proof_size(), DEFAULT_POV_SIZE);
});
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
environmental = { version = "1.1.2", default-features = false } environmental = { version = "1.1.2", default-features = false }
impl-trait-for-tuples = "0.2.1" impl-trait-for-tuples = "0.2.1"
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
# Substrate # Substrate
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -9,8 +9,8 @@ description = "Proc macros provided by the parachain-system pallet"
proc-macro = true proc-macro = true
[dependencies] [dependencies]
syn = "1.0.101" syn = "1.0.103"
proc-macro2 = "1.0.46" proc-macro2 = "1.0.47"
quote = "1.0.21" quote = "1.0.21"
proc-macro-crate = "1.2.1" proc-macro-crate = "1.2.1"
+1
View File
@@ -141,6 +141,7 @@ pub mod pallet {
#[pallet::pallet] #[pallet::pallet]
#[pallet::storage_version(migration::STORAGE_VERSION)] #[pallet::storage_version(migration::STORAGE_VERSION)]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::without_storage_info] #[pallet::without_storage_info]
pub struct Pallet<T>(_); pub struct Pallet<T>(_);
+40 -3
View File
@@ -14,18 +14,18 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::{Config, Pallet}; use crate::{Config, Pallet, Store};
use frame_support::{ use frame_support::{
traits::{Get, StorageVersion}, traits::{Get, StorageVersion},
weights::Weight, weights::Weight,
}; };
/// The current storage version. /// The current storage version.
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
/// Call this during the next runtime upgrade for this module. /// Call this during the next runtime upgrade for this module.
pub fn on_runtime_upgrade<T: Config>() -> Weight { pub fn on_runtime_upgrade<T: Config>() -> Weight {
let mut weight: Weight = Weight::zero(); let mut weight: Weight = T::DbWeight::get().reads(2);
if StorageVersion::get::<Pallet<T>>() == 0 { if StorageVersion::get::<Pallet<T>>() == 0 {
weight = weight weight = weight
@@ -34,9 +34,46 @@ pub fn on_runtime_upgrade<T: Config>() -> Weight {
StorageVersion::new(1).put::<Pallet<T>>(); StorageVersion::new(1).put::<Pallet<T>>();
} }
if StorageVersion::get::<Pallet<T>>() == 1 {
weight = weight
.saturating_add(v2::migrate::<T>())
.saturating_add(T::DbWeight::get().writes(1));
STORAGE_VERSION.put::<Pallet<T>>();
}
weight weight
} }
/// V2: Migrate to 2D weights for ReservedXcmpWeightOverride and ReservedDmpWeightOverride.
mod v2 {
use super::*;
const DEFAULT_POV_SIZE: u64 = 64 * 1024; // 64 KB
pub fn migrate<T: Config>() -> Weight {
let translate = |pre: u64| -> Weight { Weight::from_parts(pre, DEFAULT_POV_SIZE) };
if <Pallet<T> as Store>::ReservedXcmpWeightOverride::translate(|pre| pre.map(translate))
.is_err()
{
log::error!(
target: "parachain_system",
"unexpected error when performing translation of the ReservedXcmpWeightOverride type during storage upgrade to v2"
);
}
if <Pallet<T> as Store>::ReservedDmpWeightOverride::translate(|pre| pre.map(translate))
.is_err()
{
log::error!(
target: "parachain_system",
"unexpected error when performing translation of the ReservedDmpWeightOverride type during storage upgrade to v2"
);
}
T::DbWeight::get().reads_writes(2, 2)
}
}
/// V1: `LastUpgrade` block number is removed from the storage since the upgrade /// V1: `LastUpgrade` block number is removed from the storage since the upgrade
/// mechanism now uses signals instead of block offsets. /// mechanism now uses signals instead of block offsets.
mod v1 { mod v1 {
+1 -1
View File
@@ -6,7 +6,7 @@ version = "0.1.0"
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
+1 -1
View File
@@ -8,7 +8,7 @@ edition = "2021"
codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ], default-features = false } codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ], default-features = false }
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
rand_chacha = { version = "0.3.0", default-features = false } rand_chacha = { version = "0.3.0", default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
# Substrate # Substrate
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
+1 -1
View File
@@ -22,7 +22,7 @@ use frame_system::RawOrigin;
benchmarks! { benchmarks! {
set_config_with_u32 {}: update_resume_threshold(RawOrigin::Root, 100) set_config_with_u32 {}: update_resume_threshold(RawOrigin::Root, 100)
set_config_with_weight {}: update_weight_restrict_decay(RawOrigin::Root, Weight::from_ref_time(3_000_000)) set_config_with_weight {}: update_weight_restrict_decay(RawOrigin::Root, 3_000_000)
} }
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test); impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
+27 -12
View File
@@ -55,7 +55,10 @@ use rand_chacha::{
use scale_info::TypeInfo; use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug; use sp_runtime::RuntimeDebug;
use sp_std::{convert::TryFrom, prelude::*}; use sp_std::{convert::TryFrom, prelude::*};
use xcm::{latest::prelude::*, VersionedXcm, WrapVersion, MAX_XCM_DECODE_DEPTH}; use xcm::{
latest::{prelude::*, Weight as XcmWeight},
VersionedXcm, WrapVersion, MAX_XCM_DECODE_DEPTH,
};
use xcm_executor::traits::ConvertOrigin; use xcm_executor::traits::ConvertOrigin;
pub use pallet::*; pub use pallet::*;
@@ -64,6 +67,7 @@ pub use pallet::*;
pub type OverweightIndex = u64; pub type OverweightIndex = u64;
const LOG_TARGET: &str = "xcmp_queue"; const LOG_TARGET: &str = "xcmp_queue";
const DEFAULT_POV_SIZE: u64 = 64 * 1024; // 64 KB
#[frame_support::pallet] #[frame_support::pallet]
pub mod pallet { pub mod pallet {
@@ -134,11 +138,11 @@ pub mod pallet {
/// ///
/// Events: /// Events:
/// - `OverweightServiced`: On success. /// - `OverweightServiced`: On success.
#[pallet::weight((weight_limit.saturating_add(Weight::from_ref_time(1_000_000)), DispatchClass::Operational,))] #[pallet::weight((Weight::from_ref_time(weight_limit.saturating_add(1_000_000)), DispatchClass::Operational,))]
pub fn service_overweight( pub fn service_overweight(
origin: OriginFor<T>, origin: OriginFor<T>,
index: OverweightIndex, index: OverweightIndex,
weight_limit: Weight, weight_limit: XcmWeight,
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
T::ExecuteOverweightOrigin::ensure_origin(origin)?; T::ExecuteOverweightOrigin::ensure_origin(origin)?;
@@ -149,8 +153,9 @@ pub mod pallet {
&mut data.as_slice(), &mut data.as_slice(),
) )
.map_err(|_| Error::<T>::BadXcm)?; .map_err(|_| Error::<T>::BadXcm)?;
let used = Self::handle_xcm_message(sender, sent_at, xcm, weight_limit) let used =
.map_err(|_| Error::<T>::WeightOverLimit)?; Self::handle_xcm_message(sender, sent_at, xcm, Weight::from_ref_time(weight_limit))
.map_err(|_| Error::<T>::WeightOverLimit)?;
Overweight::<T>::remove(index); Overweight::<T>::remove(index);
Self::deposit_event(Event::OverweightServiced { index, used }); Self::deposit_event(Event::OverweightServiced { index, used });
Ok(Some(used.saturating_add(Weight::from_ref_time(1_000_000))).into()) Ok(Some(used.saturating_add(Weight::from_ref_time(1_000_000))).into())
@@ -226,9 +231,9 @@ pub mod pallet {
/// - `origin`: Must pass `Root`. /// - `origin`: Must pass `Root`.
/// - `new`: Desired value for `QueueConfigData.threshold_weight` /// - `new`: Desired value for `QueueConfigData.threshold_weight`
#[pallet::weight((T::WeightInfo::set_config_with_weight(), DispatchClass::Operational,))] #[pallet::weight((T::WeightInfo::set_config_with_weight(), DispatchClass::Operational,))]
pub fn update_threshold_weight(origin: OriginFor<T>, new: Weight) -> DispatchResult { pub fn update_threshold_weight(origin: OriginFor<T>, new: XcmWeight) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
QueueConfig::<T>::mutate(|data| data.threshold_weight = new); QueueConfig::<T>::mutate(|data| data.threshold_weight = Weight::from_ref_time(new));
Ok(()) Ok(())
} }
@@ -239,9 +244,14 @@ pub mod pallet {
/// - `origin`: Must pass `Root`. /// - `origin`: Must pass `Root`.
/// - `new`: Desired value for `QueueConfigData.weight_restrict_decay`. /// - `new`: Desired value for `QueueConfigData.weight_restrict_decay`.
#[pallet::weight((T::WeightInfo::set_config_with_weight(), DispatchClass::Operational,))] #[pallet::weight((T::WeightInfo::set_config_with_weight(), DispatchClass::Operational,))]
pub fn update_weight_restrict_decay(origin: OriginFor<T>, new: Weight) -> DispatchResult { pub fn update_weight_restrict_decay(
origin: OriginFor<T>,
new: XcmWeight,
) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
QueueConfig::<T>::mutate(|data| data.weight_restrict_decay = new); QueueConfig::<T>::mutate(|data| {
data.weight_restrict_decay = Weight::from_ref_time(new)
});
Ok(()) Ok(())
} }
@@ -254,10 +264,12 @@ pub mod pallet {
#[pallet::weight((T::WeightInfo::set_config_with_weight(), DispatchClass::Operational,))] #[pallet::weight((T::WeightInfo::set_config_with_weight(), DispatchClass::Operational,))]
pub fn update_xcmp_max_individual_weight( pub fn update_xcmp_max_individual_weight(
origin: OriginFor<T>, origin: OriginFor<T>,
new: Weight, new: XcmWeight,
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
QueueConfig::<T>::mutate(|data| data.xcmp_max_individual_weight = new); QueueConfig::<T>::mutate(|data| {
data.xcmp_max_individual_weight = Weight::from_ref_time(new)
});
Ok(()) Ok(())
} }
@@ -455,7 +467,10 @@ impl Default for QueueConfigData {
resume_threshold: 1, resume_threshold: 1,
threshold_weight: Weight::from_ref_time(100_000), threshold_weight: Weight::from_ref_time(100_000),
weight_restrict_decay: Weight::from_ref_time(2), weight_restrict_decay: Weight::from_ref_time(2),
xcmp_max_individual_weight: 20u64 * WEIGHT_PER_MILLIS, xcmp_max_individual_weight: Weight::from_parts(
20u64 * WEIGHT_PER_MILLIS.ref_time(),
DEFAULT_POV_SIZE,
),
} }
} }
} }
+44 -37
View File
@@ -16,26 +16,31 @@
//! A module that is responsible for migration of storage. //! A module that is responsible for migration of storage.
use crate::{Config, Pallet, Store}; use crate::{Config, Pallet, Store, DEFAULT_POV_SIZE};
use frame_support::{pallet_prelude::*, traits::StorageVersion, weights::Weight}; use frame_support::{
pallet_prelude::*,
traits::StorageVersion,
weights::{constants::WEIGHT_PER_MILLIS, Weight},
};
use xcm::latest::Weight as XcmWeight;
/// The current storage version. /// The current storage version.
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
/// Migrates the pallet storage to the most recent version, checking and setting the /// Migrates the pallet storage to the most recent version, checking and setting the
/// `StorageVersion`. /// `StorageVersion`.
pub fn migrate_to_latest<T: Config>() -> Weight { pub fn migrate_to_latest<T: Config>() -> Weight {
let mut weight = Weight::zero(); let mut weight = T::DbWeight::get().reads(1);
if StorageVersion::get::<Pallet<T>>() == 0 { if StorageVersion::get::<Pallet<T>>() == 1 {
weight += migrate_to_v1::<T>(); weight += migrate_to_v2::<T>();
StorageVersion::new(1).put::<Pallet<T>>(); StorageVersion::new(2).put::<Pallet<T>>();
} }
weight weight
} }
mod v0 { mod v1 {
use super::*; use super::*;
use codec::{Decode, Encode}; use codec::{Decode, Encode};
@@ -44,8 +49,9 @@ mod v0 {
pub suspend_threshold: u32, pub suspend_threshold: u32,
pub drop_threshold: u32, pub drop_threshold: u32,
pub resume_threshold: u32, pub resume_threshold: u32,
pub threshold_weight: Weight, pub threshold_weight: XcmWeight,
pub weight_restrict_decay: Weight, pub weight_restrict_decay: XcmWeight,
pub xcmp_max_individual_weight: XcmWeight,
} }
impl Default for QueueConfigData { impl Default for QueueConfigData {
@@ -54,37 +60,38 @@ mod v0 {
suspend_threshold: 2, suspend_threshold: 2,
drop_threshold: 5, drop_threshold: 5,
resume_threshold: 1, resume_threshold: 1,
threshold_weight: Weight::from_ref_time(100_000), threshold_weight: 100_000,
weight_restrict_decay: Weight::from_ref_time(2), weight_restrict_decay: 2,
xcmp_max_individual_weight: 20u64 * WEIGHT_PER_MILLIS.ref_time(),
} }
} }
} }
} }
/// Migrates `QueueConfigData` from v0 (without the `xcmp_max_individual_weight` field) to v1 (with /// Migrates `QueueConfigData` from v1 (using only reference time weights) to v2 (with
/// max individual weight). /// 2D weights).
/// Uses the `Default` implementation of `QueueConfigData` to choose a value for
/// `xcmp_max_individual_weight`.
/// ///
/// NOTE: Only use this function if you know what you're doing. Default to using /// NOTE: Only use this function if you know what you're doing. Default to using
/// `migrate_to_latest`. /// `migrate_to_latest`.
pub fn migrate_to_v1<T: Config>() -> Weight { pub fn migrate_to_v2<T: Config>() -> Weight {
let translate = |pre: v0::QueueConfigData| -> super::QueueConfigData { let translate = |pre: v1::QueueConfigData| -> super::QueueConfigData {
super::QueueConfigData { super::QueueConfigData {
suspend_threshold: pre.suspend_threshold, suspend_threshold: pre.suspend_threshold,
drop_threshold: pre.drop_threshold, drop_threshold: pre.drop_threshold,
resume_threshold: pre.resume_threshold, resume_threshold: pre.resume_threshold,
threshold_weight: pre.threshold_weight, threshold_weight: Weight::from_ref_time(pre.threshold_weight),
weight_restrict_decay: pre.weight_restrict_decay, weight_restrict_decay: Weight::from_ref_time(pre.weight_restrict_decay),
xcmp_max_individual_weight: super::QueueConfigData::default() xcmp_max_individual_weight: Weight::from_parts(
.xcmp_max_individual_weight, pre.xcmp_max_individual_weight,
DEFAULT_POV_SIZE,
),
} }
}; };
if let Err(_) = <Pallet<T> as Store>::QueueConfig::translate(|pre| pre.map(translate)) { if let Err(_) = <Pallet<T> as Store>::QueueConfig::translate(|pre| pre.map(translate)) {
log::error!( log::error!(
target: super::LOG_TARGET, target: super::LOG_TARGET,
"unexpected error when performing translation of the QueueConfig type during storage upgrade to v1" "unexpected error when performing translation of the QueueConfig type during storage upgrade to v2"
); );
} }
@@ -97,32 +104,32 @@ mod tests {
use crate::mock::{new_test_ext, Test}; use crate::mock::{new_test_ext, Test};
#[test] #[test]
fn test_migration_to_v1() { fn test_migration_to_v2() {
let v0 = v0::QueueConfigData { let v1 = v1::QueueConfigData {
suspend_threshold: 5, suspend_threshold: 5,
drop_threshold: 12, drop_threshold: 12,
resume_threshold: 3, resume_threshold: 3,
threshold_weight: Weight::from_ref_time(333_333), threshold_weight: 333_333,
weight_restrict_decay: Weight::from_ref_time(1), weight_restrict_decay: 1,
xcmp_max_individual_weight: 10_000_000_000,
}; };
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Put the v0 version in the state
frame_support::storage::unhashed::put_raw( frame_support::storage::unhashed::put_raw(
&crate::QueueConfig::<Test>::hashed_key(), &crate::QueueConfig::<Test>::hashed_key(),
&v0.encode(), &v1.encode(),
); );
migrate_to_v1::<Test>(); migrate_to_v2::<Test>();
let v1 = crate::QueueConfig::<Test>::get(); let v2 = crate::QueueConfig::<Test>::get();
assert_eq!(v0.suspend_threshold, v1.suspend_threshold); assert_eq!(v1.suspend_threshold, v2.suspend_threshold);
assert_eq!(v0.drop_threshold, v1.drop_threshold); assert_eq!(v1.drop_threshold, v2.drop_threshold);
assert_eq!(v0.resume_threshold, v1.resume_threshold); assert_eq!(v1.resume_threshold, v2.resume_threshold);
assert_eq!(v0.threshold_weight, v1.threshold_weight); assert_eq!(v1.threshold_weight, v2.threshold_weight.ref_time());
assert_eq!(v0.weight_restrict_decay, v1.weight_restrict_decay); assert_eq!(v1.weight_restrict_decay, v2.weight_restrict_decay.ref_time());
assert_eq!(v1.xcmp_max_individual_weight, Weight::from_ref_time(20_000_000_000)); assert_eq!(v1.xcmp_max_individual_weight, v2.xcmp_max_individual_weight.ref_time());
}); });
} }
} }
+12 -21
View File
@@ -96,7 +96,7 @@ fn handle_invalid_data() {
fn service_overweight_unknown() { fn service_overweight_unknown() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_noop!( assert_noop!(
XcmpQueue::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(1000)), XcmpQueue::service_overweight(RuntimeOrigin::root(), 0, 1000),
Error::<Test>::BadOverweightIndex, Error::<Test>::BadOverweightIndex,
); );
}); });
@@ -109,7 +109,7 @@ fn service_overweight_bad_xcm_format() {
Overweight::<Test>::insert(0, (ParaId::from(1000), 0, bad_xcm)); Overweight::<Test>::insert(0, (ParaId::from(1000), 0, bad_xcm));
assert_noop!( assert_noop!(
XcmpQueue::service_overweight(RuntimeOrigin::root(), 0, Weight::from_ref_time(1000)), XcmpQueue::service_overweight(RuntimeOrigin::root(), 0, 1000),
Error::<Test>::BadXcm Error::<Test>::BadXcm
); );
}); });
@@ -187,15 +187,9 @@ fn update_threshold_weight_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let data: QueueConfigData = <QueueConfig<Test>>::get(); let data: QueueConfigData = <QueueConfig<Test>>::get();
assert_eq!(data.threshold_weight, Weight::from_ref_time(100_000)); assert_eq!(data.threshold_weight, Weight::from_ref_time(100_000));
assert_ok!(XcmpQueue::update_threshold_weight( assert_ok!(XcmpQueue::update_threshold_weight(RuntimeOrigin::root(), 10_000));
RuntimeOrigin::root(),
Weight::from_ref_time(10_000)
));
assert_noop!( assert_noop!(
XcmpQueue::update_threshold_weight( XcmpQueue::update_threshold_weight(RuntimeOrigin::signed(5), 10_000_000),
RuntimeOrigin::signed(5),
Weight::from_ref_time(10_000_000)
),
BadOrigin BadOrigin
); );
let data: QueueConfigData = <QueueConfig<Test>>::get(); let data: QueueConfigData = <QueueConfig<Test>>::get();
@@ -209,15 +203,9 @@ fn update_weight_restrict_decay_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let data: QueueConfigData = <QueueConfig<Test>>::get(); let data: QueueConfigData = <QueueConfig<Test>>::get();
assert_eq!(data.weight_restrict_decay, Weight::from_ref_time(2)); assert_eq!(data.weight_restrict_decay, Weight::from_ref_time(2));
assert_ok!(XcmpQueue::update_weight_restrict_decay( assert_ok!(XcmpQueue::update_weight_restrict_decay(RuntimeOrigin::root(), 5));
RuntimeOrigin::root(),
Weight::from_ref_time(5)
));
assert_noop!( assert_noop!(
XcmpQueue::update_weight_restrict_decay( XcmpQueue::update_weight_restrict_decay(RuntimeOrigin::signed(6), 4),
RuntimeOrigin::signed(6),
Weight::from_ref_time(4)
),
BadOrigin BadOrigin
); );
let data: QueueConfigData = <QueueConfig<Test>>::get(); let data: QueueConfigData = <QueueConfig<Test>>::get();
@@ -230,15 +218,18 @@ fn update_weight_restrict_decay_works() {
fn update_xcmp_max_individual_weight() { fn update_xcmp_max_individual_weight() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let data: QueueConfigData = <QueueConfig<Test>>::get(); let data: QueueConfigData = <QueueConfig<Test>>::get();
assert_eq!(data.xcmp_max_individual_weight, 20u64 * WEIGHT_PER_MILLIS); assert_eq!(
data.xcmp_max_individual_weight,
Weight::from_parts(20u64 * WEIGHT_PER_MILLIS.ref_time(), DEFAULT_POV_SIZE),
);
assert_ok!(XcmpQueue::update_xcmp_max_individual_weight( assert_ok!(XcmpQueue::update_xcmp_max_individual_weight(
RuntimeOrigin::root(), RuntimeOrigin::root(),
30u64 * WEIGHT_PER_MILLIS 30u64 * WEIGHT_PER_MILLIS.ref_time()
)); ));
assert_noop!( assert_noop!(
XcmpQueue::update_xcmp_max_individual_weight( XcmpQueue::update_xcmp_max_individual_weight(
RuntimeOrigin::signed(3), RuntimeOrigin::signed(3),
10u64 * WEIGHT_PER_MILLIS 10u64 * WEIGHT_PER_MILLIS.ref_time()
), ),
BadOrigin BadOrigin
); );
+8 -3
View File
@@ -10,7 +10,7 @@ edition = "2021"
build = "build.rs" build = "build.rs"
[dependencies] [dependencies]
clap = { version = "3.2.22", features = ["derive"] } clap = { version = "4.0.17", features = ["derive"] }
log = "0.4.17" log = "0.4.17"
codec = { package = "parity-scale-codec", version = "3.0.0" } codec = { package = "parity-scale-codec", version = "3.0.0" }
serde = { version = "1.0.145", features = ["derive"] } serde = { version = "1.0.145", features = ["derive"] }
@@ -51,7 +51,7 @@ sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "mast
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master" } try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
# Polkadot # Polkadot
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" } polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master" }
@@ -70,6 +70,7 @@ cumulus-primitives-parachain-inherent = { path = "../../primitives/parachain-inh
cumulus-relay-chain-inprocess-interface = { path = "../../client/relay-chain-inprocess-interface" } cumulus-relay-chain-inprocess-interface = { path = "../../client/relay-chain-inprocess-interface" }
cumulus-relay-chain-interface = { path = "../../client/relay-chain-interface" } cumulus-relay-chain-interface = { path = "../../client/relay-chain-interface" }
cumulus-relay-chain-rpc-interface = { path = "../../client/relay-chain-rpc-interface" } cumulus-relay-chain-rpc-interface = { path = "../../client/relay-chain-rpc-interface" }
cumulus-relay-chain-minimal-node = { path = "../../client/relay-chain-minimal-node" }
[build-dependencies] [build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -77,7 +78,11 @@ substrate-build-script-utils = { git = "https://github.com/paritytech/substrate"
[features] [features]
default = [] default = []
runtime-benchmarks = [ runtime-benchmarks = [
"try-runtime-cli/try-runtime",
"parachain-template-runtime/runtime-benchmarks", "parachain-template-runtime/runtime-benchmarks",
"polkadot-cli/runtime-benchmarks", "polkadot-cli/runtime-benchmarks",
] ]
try-runtime = ["parachain-template-runtime/try-runtime"] try-runtime = [
"try-runtime-cli/try-runtime",
"parachain-template-runtime/try-runtime"
]
+11 -6
View File
@@ -32,24 +32,29 @@ pub enum Subcommand {
/// Sub-commands concerned with benchmarking. /// Sub-commands concerned with benchmarking.
/// The pallet benchmarking moved to the `pallet` sub-command. /// The pallet benchmarking moved to the `pallet` sub-command.
#[clap(subcommand)] #[command(subcommand)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd), Benchmark(frame_benchmarking_cli::BenchmarkCmd),
/// Try some testing command against a specified runtime state. /// Try some testing command against a specified runtime state.
#[cfg(feature = "try-runtime")]
TryRuntime(try_runtime_cli::TryRuntimeCmd), TryRuntime(try_runtime_cli::TryRuntimeCmd),
/// Errors since the binary was not build with `--features try-runtime`.
#[cfg(not(feature = "try-runtime"))]
TryRuntime,
} }
#[derive(Debug, clap::Parser)] #[derive(Debug, clap::Parser)]
#[clap( #[command(
propagate_version = true, propagate_version = true,
args_conflicts_with_subcommands = true, args_conflicts_with_subcommands = true,
subcommand_negates_reqs = true subcommand_negates_reqs = true
)] )]
pub struct Cli { pub struct Cli {
#[clap(subcommand)] #[command(subcommand)]
pub subcommand: Option<Subcommand>, pub subcommand: Option<Subcommand>,
#[clap(flatten)] #[command(flatten)]
pub run: cumulus_client_cli::RunCmd, pub run: cumulus_client_cli::RunCmd,
/// Disable automatic hardware benchmarks. /// Disable automatic hardware benchmarks.
@@ -59,11 +64,11 @@ pub struct Cli {
/// ///
/// The results are then printed out in the logs, and also sent as part of /// The results are then printed out in the logs, and also sent as part of
/// telemetry, if telemetry is enabled. /// telemetry, if telemetry is enabled.
#[clap(long)] #[arg(long)]
pub no_hardware_benchmarks: bool, pub no_hardware_benchmarks: bool,
/// Relay chain arguments /// Relay chain arguments
#[clap(raw = true)] #[arg(raw = true)]
pub relay_chain_args: Vec<String>, pub relay_chain_args: Vec<String>,
} }
+26 -38
View File
@@ -4,23 +4,20 @@ use codec::Encode;
use cumulus_client_cli::generate_genesis_block; use cumulus_client_cli::generate_genesis_block;
use cumulus_primitives_core::ParaId; use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use log::info; use log::{info, warn};
use parachain_template_runtime::{Block, RuntimeApi}; use parachain_template_runtime::Block;
use sc_cli::{ use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
}; };
use sc_service::{ use sc_service::config::{BasePath, PrometheusConfig};
config::{BasePath, PrometheusConfig},
TaskManager,
};
use sp_core::hexdisplay::HexDisplay; use sp_core::hexdisplay::HexDisplay;
use sp_runtime::traits::{AccountIdConversion, Block as BlockT}; use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
use crate::{ use crate::{
chain_spec, chain_spec,
cli::{Cli, RelayChainCli, Subcommand}, cli::{Cli, RelayChainCli, Subcommand},
service::{new_partial, TemplateRuntimeExecutor}, service::{new_partial, ParachainNativeExecutor},
}; };
fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> { fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
@@ -116,14 +113,7 @@ macro_rules! construct_async_run {
(|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{ (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{
let runner = $cli.create_runner($cmd)?; let runner = $cli.create_runner($cmd)?;
runner.async_run(|$config| { runner.async_run(|$config| {
let $components = new_partial::< let $components = new_partial(&$config)?;
RuntimeApi,
TemplateRuntimeExecutor,
_
>(
&$config,
crate::service::parachain_build_import_queue,
)?;
let task_manager = $components.task_manager; let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager)) { $( $code )* }.map(|v| (v, task_manager))
}) })
@@ -204,17 +194,14 @@ pub fn run() -> Result<()> {
match cmd { match cmd {
BenchmarkCmd::Pallet(cmd) => BenchmarkCmd::Pallet(cmd) =>
if cfg!(feature = "runtime-benchmarks") { if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| cmd.run::<Block, TemplateRuntimeExecutor>(config)) runner.sync_run(|config| cmd.run::<Block, ParachainNativeExecutor>(config))
} else { } else {
Err("Benchmarking wasn't enabled when building the node. \ Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`." You can enable it with `--features runtime-benchmarks`."
.into()) .into())
}, },
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
let partials = new_partial::<RuntimeApi, TemplateRuntimeExecutor, _>( let partials = new_partial(&config)?;
&config,
crate::service::parachain_build_import_queue,
)?;
cmd.run(partials.client) cmd.run(partials.client)
}), }),
#[cfg(not(feature = "runtime-benchmarks"))] #[cfg(not(feature = "runtime-benchmarks"))]
@@ -227,13 +214,9 @@ pub fn run() -> Result<()> {
.into()), .into()),
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
let partials = new_partial::<RuntimeApi, TemplateRuntimeExecutor, _>( let partials = new_partial(&config)?;
&config,
crate::service::parachain_build_import_queue,
)?;
let db = partials.backend.expose_db(); let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage(); let storage = partials.backend.expose_storage();
cmd.run(config, partials.client.clone(), db, storage) cmd.run(config, partials.client.clone(), db, storage)
}), }),
BenchmarkCmd::Machine(cmd) => BenchmarkCmd::Machine(cmd) =>
@@ -244,23 +227,24 @@ pub fn run() -> Result<()> {
_ => Err("Benchmarking sub-command unsupported".into()), _ => Err("Benchmarking sub-command unsupported".into()),
} }
}, },
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => { Some(Subcommand::TryRuntime(cmd)) => {
if cfg!(feature = "try-runtime") { let runner = cli.create_runner(cmd)?;
let runner = cli.create_runner(cmd)?;
// grab the task manager. // grab the task manager.
let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry); let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry);
let task_manager = let task_manager =
TaskManager::new(runner.config().tokio_handle.clone(), *registry) sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry)
.map_err(|e| format!("Error: {:?}", e))?; .map_err(|e| format!("Error: {:?}", e))?;
runner.async_run(|config| { runner.async_run(|config| {
Ok((cmd.run::<Block, TemplateRuntimeExecutor>(config), task_manager)) Ok((cmd.run::<Block, ParachainNativeExecutor>(config), task_manager))
}) })
} else {
Err("Try-runtime must be enabled by `--features try-runtime`.".into())
}
}, },
#[cfg(not(feature = "try-runtime"))]
Some(Subcommand::TryRuntime) => Err("Try-runtime was not enabled when building the node. \
You can enable it with `--features try-runtime`."
.into()),
None => { None => {
let runner = cli.create_runner(&cli.run.normalize())?; let runner = cli.create_runner(&cli.run.normalize())?;
let collator_options = cli.run.collator_options(); let collator_options = cli.run.collator_options();
@@ -304,6 +288,10 @@ pub fn run() -> Result<()> {
info!("Parachain genesis state: {}", genesis_state); info!("Parachain genesis state: {}", genesis_state);
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
if collator_options.relay_chain_rpc_url.is_some() && cli.relay_chain_args.len() > 0 {
warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options.");
}
crate::service::start_parachain_node( crate::service::start_parachain_node(
config, config,
polkadot_config, polkadot_config,
+115 -219
View File
@@ -3,18 +3,15 @@
// std // std
use std::{sync::Arc, time::Duration}; use std::{sync::Arc, time::Duration};
// rpc
use jsonrpsee::RpcModule;
use cumulus_client_cli::CollatorOptions; use cumulus_client_cli::CollatorOptions;
// Local Runtime Types // Local Runtime Types
use parachain_template_runtime::{ use parachain_template_runtime::{opaque::Block, Hash, RuntimeApi};
opaque::Block, AccountId, Balance, Hash, Index as Nonce, RuntimeApi,
};
// Cumulus Imports // Cumulus Imports
use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion}; use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};
use cumulus_client_consensus_common::ParachainConsensus; use cumulus_client_consensus_common::{
ParachainBlockImport as TParachainBlockImport, ParachainConsensus,
};
use cumulus_client_network::BlockAnnounceValidator; use cumulus_client_network::BlockAnnounceValidator;
use cumulus_client_service::{ use cumulus_client_service::{
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams, prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
@@ -22,7 +19,7 @@ use cumulus_client_service::{
use cumulus_primitives_core::ParaId; use cumulus_primitives_core::ParaId;
use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain; use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult}; use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};
use cumulus_relay_chain_rpc_interface::{create_client_and_start_worker, RelayChainRpcInterface}; use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node;
// Substrate Imports // Substrate Imports
use sc_executor::NativeElseWasmExecutor; use sc_executor::NativeElseWasmExecutor;
@@ -30,17 +27,15 @@ use sc_network::NetworkService;
use sc_network_common::service::NetworkBlock; use sc_network_common::service::NetworkBlock;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sp_api::ConstructRuntimeApi;
use sp_keystore::SyncCryptoStorePtr; use sp_keystore::SyncCryptoStorePtr;
use sp_runtime::traits::BlakeTwo256;
use substrate_prometheus_endpoint::Registry; use substrate_prometheus_endpoint::Registry;
use polkadot_service::CollatorPair; use polkadot_service::CollatorPair;
/// Native executor instance. /// Native executor type.
pub struct TemplateRuntimeExecutor; pub struct ParachainNativeExecutor;
impl sc_executor::NativeExecutionDispatch for TemplateRuntimeExecutor { impl sc_executor::NativeExecutionDispatch for ParachainNativeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> { fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
@@ -52,59 +47,31 @@ impl sc_executor::NativeExecutionDispatch for TemplateRuntimeExecutor {
} }
} }
type ParachainExecutor = NativeElseWasmExecutor<ParachainNativeExecutor>;
type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;
type ParachainBackend = TFullBackend<Block>;
type ParachainBlockImport = TParachainBlockImport<Arc<ParachainClient>>;
/// Starts a `ServiceBuilder` for a full service. /// Starts a `ServiceBuilder` for a full service.
/// ///
/// Use this macro if you don't actually need the full service, but just the builder in order to /// Use this macro if you don't actually need the full service, but just the builder in order to
/// be able to perform chain operations. /// be able to perform chain operations.
#[allow(clippy::type_complexity)] pub fn new_partial(
pub fn new_partial<RuntimeApi, Executor, BIQ>(
config: &Configuration, config: &Configuration,
build_import_queue: BIQ,
) -> Result< ) -> Result<
PartialComponents< PartialComponents<
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, ParachainClient,
TFullBackend<Block>, ParachainBackend,
(), (),
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<Block, ParachainClient>,
Block, sc_transaction_pool::FullPool<Block, ParachainClient>,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>, (ParachainBlockImport, Option<Telemetry>, Option<TelemetryWorkerHandle>),
>,
sc_transaction_pool::FullPool<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
(Option<Telemetry>, Option<TelemetryWorkerHandle>),
>, >,
sc_service::Error, sc_service::Error,
> > {
where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block>
+ sp_api::ApiExt<
Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>,
> + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
&Configuration,
Option<TelemetryHandle>,
&TaskManager,
) -> Result<
sc_consensus::DefaultImportQueue<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
sc_service::Error,
>,
{
let telemetry = config let telemetry = config
.telemetry_endpoints .telemetry_endpoints
.clone() .clone()
@@ -116,7 +83,7 @@ where
}) })
.transpose()?; .transpose()?;
let executor = sc_executor::NativeElseWasmExecutor::<Executor>::new( let executor = ParachainExecutor::new(
config.wasm_method, config.wasm_method,
config.default_heap_pages, config.default_heap_pages,
config.max_runtime_instances, config.max_runtime_instances,
@@ -146,14 +113,17 @@ where
client.clone(), client.clone(),
); );
let block_import = ParachainBlockImport::new(client.clone());
let import_queue = build_import_queue( let import_queue = build_import_queue(
client.clone(), client.clone(),
block_import.clone(),
config, config,
telemetry.as_ref().map(|telemetry| telemetry.handle()), telemetry.as_ref().map(|telemetry| telemetry.handle()),
&task_manager, &task_manager,
)?; )?;
let params = PartialComponents { Ok(PartialComponents {
backend, backend,
client, client,
import_queue, import_queue,
@@ -161,10 +131,8 @@ where
task_manager, task_manager,
transaction_pool, transaction_pool,
select_chain: (), select_chain: (),
other: (telemetry, telemetry_worker_handle), other: (block_import, telemetry, telemetry_worker_handle),
}; })
Ok(params)
} }
async fn build_relay_chain_interface( async fn build_relay_chain_interface(
@@ -176,10 +144,8 @@ async fn build_relay_chain_interface(
hwbench: Option<sc_sysinfo::HwBench>, hwbench: Option<sc_sysinfo::HwBench>,
) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> { ) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> {
match collator_options.relay_chain_rpc_url { match collator_options.relay_chain_rpc_url {
Some(relay_chain_url) => { Some(relay_chain_url) =>
let client = create_client_and_start_worker(relay_chain_url, task_manager).await?; build_minimal_relay_chain_node(polkadot_config, task_manager, relay_chain_url).await,
Ok((Arc::new(RelayChainRpcInterface::new(client)) as Arc<_>, None))
},
None => build_inprocess_relay_chain( None => build_inprocess_relay_chain(
polkadot_config, polkadot_config,
parachain_config, parachain_config,
@@ -194,75 +160,17 @@ async fn build_relay_chain_interface(
/// ///
/// This is the actual implementation that is abstract over the executor and the runtime api. /// This is the actual implementation that is abstract over the executor and the runtime api.
#[sc_tracing::logging::prefix_logs_with("Parachain")] #[sc_tracing::logging::prefix_logs_with("Parachain")]
async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>( async fn start_node_impl(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
id: ParaId, id: ParaId,
_rpc_ext_builder: RB,
build_import_queue: BIQ,
build_consensus: BIC,
hwbench: Option<sc_sysinfo::HwBench>, hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient>)> {
TaskManager,
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
)>
where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block>
+ sp_api::ApiExt<
Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>,
> + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
RB: Fn(
Arc<TFullClient<Block, RuntimeApi, Executor>>,
) -> Result<RpcModule<()>, sc_service::Error>
+ Send
+ 'static,
BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
&Configuration,
Option<TelemetryHandle>,
&TaskManager,
) -> Result<
sc_consensus::DefaultImportQueue<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
sc_service::Error,
> + 'static,
BIC: FnOnce(
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
Option<&Registry>,
Option<TelemetryHandle>,
&TaskManager,
Arc<dyn RelayChainInterface>,
Arc<
sc_transaction_pool::FullPool<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
>,
Arc<NetworkService<Block, Hash>>,
SyncCryptoStorePtr,
bool,
) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,
{
let parachain_config = prepare_node_config(parachain_config); let parachain_config = prepare_node_config(parachain_config);
let params = new_partial::<RuntimeApi, Executor, BIQ>(&parachain_config, build_import_queue)?; let params = new_partial(&parachain_config)?;
let (mut telemetry, telemetry_worker_handle) = params.other; let (block_import, mut telemetry, telemetry_worker_handle) = params.other;
let client = params.client.clone(); let client = params.client.clone();
let backend = params.backend.clone(); let backend = params.backend.clone();
@@ -354,6 +262,7 @@ where
if validator { if validator {
let parachain_consensus = build_consensus( let parachain_consensus = build_consensus(
client.clone(), client.clone(),
block_import,
prometheus_registry.as_ref(), prometheus_registry.as_ref(),
telemetry.as_ref().map(|t| t.handle()), telemetry.as_ref().map(|t| t.handle()),
&task_manager, &task_manager,
@@ -362,10 +271,10 @@ where
network, network,
params.keystore_container.sync_keystore(), params.keystore_container.sync_keystore(),
force_authoring, force_authoring,
id,
)?; )?;
let spawner = task_manager.spawn_handle(); let spawner = task_manager.spawn_handle();
let params = StartCollatorParams { let params = StartCollatorParams {
para_id: id, para_id: id,
block_status: client.clone(), block_status: client.clone(),
@@ -390,7 +299,6 @@ where
relay_chain_interface, relay_chain_interface,
relay_chain_slot_duration, relay_chain_slot_duration,
import_queue, import_queue,
collator_options,
}; };
start_full_node(params)?; start_full_node(params)?;
@@ -402,19 +310,13 @@ where
} }
/// Build the import queue for the parachain runtime. /// Build the import queue for the parachain runtime.
#[allow(clippy::type_complexity)] fn build_import_queue(
pub fn parachain_build_import_queue( client: Arc<ParachainClient>,
client: Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<TemplateRuntimeExecutor>>>, block_import: ParachainBlockImport,
config: &Configuration, config: &Configuration,
telemetry: Option<TelemetryHandle>, telemetry: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<sc_consensus::DefaultImportQueue<Block, ParachainClient>, sc_service::Error> {
sc_consensus::DefaultImportQueue<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<TemplateRuntimeExecutor>>,
>,
sc_service::Error,
> {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
cumulus_client_consensus_aura::import_queue::< cumulus_client_consensus_aura::import_queue::<
@@ -425,8 +327,8 @@ pub fn parachain_build_import_queue(
_, _,
_, _,
>(cumulus_client_consensus_aura::ImportQueueParams { >(cumulus_client_consensus_aura::ImportQueueParams {
block_import: client.clone(), block_import,
client: client.clone(), client,
create_inherent_data_providers: move |_, _| async move { create_inherent_data_providers: move |_, _| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
@@ -445,6 +347,75 @@ pub fn parachain_build_import_queue(
.map_err(Into::into) .map_err(Into::into)
} }
fn build_consensus(
client: Arc<ParachainClient>,
block_import: ParachainBlockImport,
prometheus_registry: Option<&Registry>,
telemetry: Option<TelemetryHandle>,
task_manager: &TaskManager,
relay_chain_interface: Arc<dyn RelayChainInterface>,
transaction_pool: Arc<sc_transaction_pool::FullPool<Block, ParachainClient>>,
sync_oracle: Arc<NetworkService<Block, Hash>>,
keystore: SyncCryptoStorePtr,
force_authoring: bool,
id: ParaId,
) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error> {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
task_manager.spawn_handle(),
client.clone(),
transaction_pool,
prometheus_registry,
telemetry.clone(),
);
let params = BuildAuraConsensusParams {
proposer_factory,
create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
let relay_chain_interface = relay_chain_interface.clone();
async move {
let parachain_inherent =
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(
relay_parent,
&relay_chain_interface,
&validation_data,
id,
)
.await;
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
let parachain_inherent = parachain_inherent.ok_or_else(|| {
Box::<dyn std::error::Error + Send + Sync>::from(
"Failed to create parachain inherent",
)
})?;
Ok((slot, timestamp, parachain_inherent))
}
},
block_import,
para_client: client,
backoff_authoring_blocks: Option::<()>::None,
sync_oracle,
keystore,
force_authoring,
slot_duration,
// We got around 500ms for proposing
block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),
// And a maximum of 750ms if slots are skipped
max_block_proposal_slot_portion: Some(SlotProportion::new(1f32 / 16f32)),
telemetry,
};
Ok(AuraConsensus::build::<sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _>(params))
}
/// Start a parachain node. /// Start a parachain node.
pub async fn start_parachain_node( pub async fn start_parachain_node(
parachain_config: Configuration, parachain_config: Configuration,
@@ -452,81 +423,6 @@ pub async fn start_parachain_node(
collator_options: CollatorOptions, collator_options: CollatorOptions,
id: ParaId, id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>, hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient>)> {
TaskManager, start_node_impl(parachain_config, polkadot_config, collator_options, id, hwbench).await
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<TemplateRuntimeExecutor>>>,
)> {
start_node_impl::<RuntimeApi, TemplateRuntimeExecutor, _, _, _>(
parachain_config,
polkadot_config,
collator_options,
id,
|_| Ok(RpcModule::new(())),
parachain_build_import_queue,
|client,
prometheus_registry,
telemetry,
task_manager,
relay_chain_interface,
transaction_pool,
sync_oracle,
keystore,
force_authoring| {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
task_manager.spawn_handle(),
client.clone(),
transaction_pool,
prometheus_registry,
telemetry.clone(),
);
Ok(AuraConsensus::build::<sp_consensus_aura::sr25519::AuthorityPair, _, _, _, _, _, _>(
BuildAuraConsensusParams {
proposer_factory,
create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
let relay_chain_interface = relay_chain_interface.clone();
async move {
let parachain_inherent =
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(
relay_parent,
&relay_chain_interface,
&validation_data,
id,
).await;
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp,
slot_duration,
);
let parachain_inherent = parachain_inherent.ok_or_else(|| {
Box::<dyn std::error::Error + Send + Sync>::from(
"Failed to create parachain inherent",
)
})?;
Ok((slot, timestamp, parachain_inherent))
}
},
block_import: client.clone(),
para_client: client,
backoff_authoring_blocks: Option::<()>::None,
sync_oracle,
keystore,
force_authoring,
slot_duration,
// We got around 500ms for proposing
block_proposal_slot_portion: SlotProportion::new(1f32 / 24f32),
// And a maximum of 750ms if slots are skipped
max_block_proposal_slot_portion: Some(SlotProportion::new(1f32 / 16f32)),
telemetry,
},
))
},
hwbench,
)
.await
} }
+2 -2
View File
@@ -18,7 +18,7 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
hex-literal = { version = "0.3.4", optional = true } hex-literal = { version = "0.3.4", optional = true }
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
smallvec = "1.10.0" smallvec = "1.10.0"
# Local # Local
@@ -148,7 +148,7 @@ try-runtime = [
"cumulus-pallet-xcmp-queue/try-runtime", "cumulus-pallet-xcmp-queue/try-runtime",
"frame-executive/try-runtime", "frame-executive/try-runtime",
"frame-system/try-runtime", "frame-system/try-runtime",
"frame-try-runtime", "frame-try-runtime/try-runtime",
"pallet-aura/try-runtime", "pallet-aura/try-runtime",
"pallet-authorship/try-runtime", "pallet-authorship/try-runtime",
"pallet-balances/try-runtime", "pallet-balances/try-runtime",
+2 -1
View File
@@ -217,7 +217,8 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// We allow for 0.5 of a second of compute with a 12 second average block time. /// We allow for 0.5 of a second of compute with a 12 second average block time.
const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.saturating_div(2) const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND
.saturating_div(2)
.set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64); .set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64);
/// The version information used to identify this runtime when compiled natively. /// The version information used to identify this runtime when compiled natively.
+1 -1
View File
@@ -10,7 +10,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false } codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
# Substrate # Substrate
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
+2 -1
View File
@@ -92,7 +92,8 @@ mod constants {
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// We allow for 0.5 seconds of compute with a 6 second average block time. /// We allow for 0.5 seconds of compute with a 6 second average block time.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.saturating_div(2) pub const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND
.saturating_div(2)
.set_proof_size(polkadot_primitives::v2::MAX_POV_SIZE as u64); .set_proof_size(polkadot_primitives::v2::MAX_POV_SIZE as u64);
} }
+1 -1
View File
@@ -6,7 +6,7 @@ version = "0.1.0"
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
+1 -1
View File
@@ -6,7 +6,7 @@ version = "0.1.0"
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -9,7 +9,7 @@ description = "Kusama variant of Statemint parachain runtime"
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] }
hex-literal = { version = "0.3.4", optional = true } hex-literal = { version = "0.3.4", optional = true }
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
smallvec = "1.10.0" smallvec = "1.10.0"
# Substrate # Substrate
@@ -109,7 +109,7 @@ try-runtime = [
"cumulus-pallet-xcmp-queue/try-runtime", "cumulus-pallet-xcmp-queue/try-runtime",
"frame-executive/try-runtime", "frame-executive/try-runtime",
"frame-system/try-runtime", "frame-system/try-runtime",
"frame-try-runtime", "frame-try-runtime/try-runtime",
"pallet-asset-tx-payment/try-runtime", "pallet-asset-tx-payment/try-runtime",
"pallet-assets/try-runtime", "pallet-assets/try-runtime",
"pallet-aura/try-runtime", "pallet-aura/try-runtime",
@@ -250,7 +250,7 @@ parameter_types! {
pub const DepositBase: Balance = deposit(1, 88); pub const DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes. // Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = deposit(0, 32); pub const DepositFactor: Balance = deposit(0, 32);
pub const MaxSignatories: u16 = 100; pub const MaxSignatories: u32 = 100;
} }
impl pallet_multisig::Config for Runtime { impl pallet_multisig::Config for Runtime {
@@ -17,22 +17,21 @@
//! Autogenerated weights for `pallet_multisig` //! Autogenerated weights for `pallet_multisig`
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-09-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! DATE: 2022-10-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024 //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024
// Executed Command: // Executed Command:
// ./artifacts/polkadot-parachain // ./target/production/polkadot-parachain
// benchmark // benchmark
// pallet // pallet
// --chain=statemine-dev // --chain=statemine-dev
// --execution=wasm // --execution=wasm
// --wasm-execution=compiled // --wasm-execution=compiled
// --pallet=pallet_multisig // --pallet=pallet_multisig
// --extrinsic=* // --extrinsic=
// --steps=50 // --steps=50
// --repeat=20 // --repeat=20
// --json
// --header=./file_header.txt // --header=./file_header.txt
// --output=./parachains/runtimes/assets/statemine/src/weights/pallet_multisig.rs // --output=./parachains/runtimes/assets/statemine/src/weights/pallet_multisig.rs
@@ -40,7 +39,7 @@
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
use frame_support::{traits::Get, weights::{Weight}}; use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData; use sp_std::marker::PhantomData;
/// Weight functions for `pallet_multisig`. /// Weight functions for `pallet_multisig`.
@@ -48,115 +47,81 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_threshold_1(z: u32, ) -> Weight { fn as_multi_threshold_1(z: u32, ) -> Weight {
Weight::from_ref_time(21_168_000 as u64) // Minimum execution time: 21_063 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(21_862_078 as u64)
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z as u64)) // Standard Error: 7
.saturating_add(Weight::from_ref_time(343 as u64).saturating_mul(z as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Multisigs (r:1 w:1)
// Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_create(s: u32, z: u32, ) -> Weight { fn as_multi_create(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(40_339_000 as u64) // Minimum execution time: 48_498 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(39_020_484 as u64)
.saturating_add(Weight::from_ref_time(100_000 as u64).saturating_mul(s as u64)) // Standard Error: 917
// Standard Error: 0 .saturating_add(Weight::from_ref_time(101_566 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z as u64)) // Standard Error: 8
.saturating_add(Weight::from_ref_time(1_559 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(2 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))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(43_149_000 as u64)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(97_000 as u64).saturating_mul(s as u64))
// Standard Error: 0
.saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(3 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
// Storage: Multisig Multisigs (r:1 w:1)
/// The range of component `s` is `[3, 100]`. /// The range of component `s` is `[3, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_approve(s: u32, z: u32, ) -> Weight { fn as_multi_approve(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(29_142_000 as u64) // Minimum execution time: 40_013 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(28_889_358 as u64)
.saturating_add(Weight::from_ref_time(107_000 as u64).saturating_mul(s as u64)) // Standard Error: 846
// Standard Error: 0 .saturating_add(Weight::from_ref_time(117_565 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z as u64)) // Standard Error: 8
.saturating_add(Weight::from_ref_time(1_480 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(44_799_000 as u64)
// Standard Error: 2_000
.saturating_add(Weight::from_ref_time(96_000 as u64).saturating_mul(s as u64))
// Standard Error: 0
.saturating_add(Weight::from_ref_time(2_000 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: Multisig Calls (r:1 w:1)
// Storage: System Account (r:1 w:1) // Storage: System Account (r:1 w:1)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_complete(s: u32, z: u32, ) -> Weight { fn as_multi_complete(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(54_815_000 as u64) // Minimum execution time: 52_880 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(41_398_334 as u64)
.saturating_add(Weight::from_ref_time(131_000 as u64).saturating_mul(s as u64)) // Standard Error: 760
// Standard Error: 0 .saturating_add(Weight::from_ref_time(143_103 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(z as u64)) // Standard Error: 7
.saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(Weight::from_ref_time(1_485 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().writes(3 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: Multisig Multisigs (r:1 w:1)
// Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn approve_as_multi_create(s: u32, ) -> Weight { fn approve_as_multi_create(s: u32, ) -> Weight {
Weight::from_ref_time(37_558_000 as u64) // Minimum execution time: 34_872 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(37_363_593 as u64)
.saturating_add(Weight::from_ref_time(110_000 as u64).saturating_mul(s as u64)) // Standard Error: 1_144
.saturating_add(Weight::from_ref_time(125_451 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().reads(2 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))
} }
// Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Multisigs (r:1 w:1)
// Storage: Multisig Calls (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn approve_as_multi_approve(s: u32, ) -> Weight { fn approve_as_multi_approve(s: u32, ) -> Weight {
Weight::from_ref_time(26_926_000 as u64) // Minimum execution time: 25_288 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(26_822_824 as u64)
.saturating_add(Weight::from_ref_time(125_000 as u64).saturating_mul(s as u64)) // Standard Error: 705
.saturating_add(Weight::from_ref_time(128_964 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(64_260_000 as u64)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(151_000 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: Multisig Multisigs (r:1 w:1)
// Storage: Multisig Calls (r:1 w:1)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn cancel_as_multi(s: u32, ) -> Weight { fn cancel_as_multi(s: u32, ) -> Weight {
Weight::from_ref_time(53_920_000 as u64) // Minimum execution time: 34_669 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(36_953_098 as u64)
.saturating_add(Weight::from_ref_time(122_000 as u64).saturating_mul(s as u64)) // Standard Error: 944
.saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(Weight::from_ref_time(132_676 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
} }
} }
@@ -9,7 +9,7 @@ description = "Statemint parachain runtime"
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] }
hex-literal = { version = "0.3.4", optional = true } hex-literal = { version = "0.3.4", optional = true }
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
smallvec = "1.10.0" smallvec = "1.10.0"
# Substrate # Substrate
@@ -108,7 +108,7 @@ try-runtime = [
"cumulus-pallet-xcmp-queue/try-runtime", "cumulus-pallet-xcmp-queue/try-runtime",
"frame-executive/try-runtime", "frame-executive/try-runtime",
"frame-system/try-runtime", "frame-system/try-runtime",
"frame-try-runtime", "frame-try-runtime/try-runtime",
"pallet-asset-tx-payment/try-runtime", "pallet-asset-tx-payment/try-runtime",
"pallet-assets/try-runtime", "pallet-assets/try-runtime",
"pallet-aura/try-runtime", "pallet-aura/try-runtime",
@@ -280,7 +280,7 @@ parameter_types! {
pub const DepositBase: Balance = deposit(1, 88); pub const DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes. // Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = deposit(0, 32); pub const DepositFactor: Balance = deposit(0, 32);
pub const MaxSignatories: u16 = 100; pub const MaxSignatories: u32 = 100;
} }
impl pallet_multisig::Config for Runtime { impl pallet_multisig::Config for Runtime {
@@ -17,22 +17,21 @@
//! Autogenerated weights for `pallet_multisig` //! Autogenerated weights for `pallet_multisig`
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-09-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! DATE: 2022-10-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024 //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemint-dev"), DB CACHE: 1024
// Executed Command: // Executed Command:
// ./artifacts/polkadot-parachain // ./target/production/polkadot-parachain
// benchmark // benchmark
// pallet // pallet
// --chain=statemint-dev // --chain=statemint-dev
// --execution=wasm // --execution=wasm
// --wasm-execution=compiled // --wasm-execution=compiled
// --pallet=pallet_multisig // --pallet=pallet_multisig
// --extrinsic=* // --extrinsic=
// --steps=50 // --steps=50
// --repeat=20 // --repeat=20
// --json
// --header=./file_header.txt // --header=./file_header.txt
// --output=./parachains/runtimes/assets/statemint/src/weights/pallet_multisig.rs // --output=./parachains/runtimes/assets/statemint/src/weights/pallet_multisig.rs
@@ -40,7 +39,7 @@
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
use frame_support::{traits::Get, weights::{Weight}}; use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData; use sp_std::marker::PhantomData;
/// Weight functions for `pallet_multisig`. /// Weight functions for `pallet_multisig`.
@@ -48,115 +47,81 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_threshold_1(z: u32, ) -> Weight { fn as_multi_threshold_1(z: u32, ) -> Weight {
Weight::from_ref_time(21_264_000 as u64) // Minimum execution time: 20_538 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(21_429_260 as u64)
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z as u64)) // Standard Error: 10
.saturating_add(Weight::from_ref_time(398 as u64).saturating_mul(z as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Multisigs (r:1 w:1)
// Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_create(s: u32, z: u32, ) -> Weight { fn as_multi_create(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(40_726_000 as u64) // Minimum execution time: 49_619 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(39_692_148 as u64)
.saturating_add(Weight::from_ref_time(100_000 as u64).saturating_mul(s as u64)) // Standard Error: 795
// Standard Error: 0 .saturating_add(Weight::from_ref_time(107_929 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z as u64)) // Standard Error: 7
.saturating_add(Weight::from_ref_time(1_563 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(2 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))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(42_052_000 as u64)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(109_000 as u64).saturating_mul(s as u64))
// Standard Error: 0
.saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(3 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
// Storage: Multisig Multisigs (r:1 w:1)
/// The range of component `s` is `[3, 100]`. /// The range of component `s` is `[3, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_approve(s: u32, z: u32, ) -> Weight { fn as_multi_approve(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(29_056_000 as u64) // Minimum execution time: 39_162 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(27_925_170 as u64)
.saturating_add(Weight::from_ref_time(112_000 as u64).saturating_mul(s as u64)) // Standard Error: 771
// Standard Error: 0 .saturating_add(Weight::from_ref_time(125_006 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z as u64)) // Standard Error: 7
.saturating_add(Weight::from_ref_time(1_587 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(44_006_000 as u64)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(106_000 as u64).saturating_mul(s as u64))
// Standard Error: 0
.saturating_add(Weight::from_ref_time(2_000 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: Multisig Calls (r:1 w:1)
// Storage: System Account (r:1 w:1) // Storage: System Account (r:1 w:1)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_complete(s: u32, z: u32, ) -> Weight { fn as_multi_complete(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(53_470_000 as u64) // Minimum execution time: 54_676 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(42_343_658 as u64)
.saturating_add(Weight::from_ref_time(136_000 as u64).saturating_mul(s as u64)) // Standard Error: 915
// Standard Error: 0 .saturating_add(Weight::from_ref_time(143_916 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(z as u64)) // Standard Error: 8
.saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(Weight::from_ref_time(1_486 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().writes(3 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: Multisig Multisigs (r:1 w:1)
// Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn approve_as_multi_create(s: u32, ) -> Weight { fn approve_as_multi_create(s: u32, ) -> Weight {
Weight::from_ref_time(36_826_000 as u64) // Minimum execution time: 34_863 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(37_816_741 as u64)
.saturating_add(Weight::from_ref_time(125_000 as u64).saturating_mul(s as u64)) // Standard Error: 1_209
.saturating_add(Weight::from_ref_time(126_254 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().reads(2 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))
} }
// Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Multisigs (r:1 w:1)
// Storage: Multisig Calls (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn approve_as_multi_approve(s: u32, ) -> Weight { fn approve_as_multi_approve(s: u32, ) -> Weight {
Weight::from_ref_time(26_801_000 as u64) // Minimum execution time: 25_841 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(27_329_266 as u64)
.saturating_add(Weight::from_ref_time(126_000 as u64).saturating_mul(s as u64)) // Standard Error: 667
.saturating_add(Weight::from_ref_time(126_214 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(67_374_000 as u64)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(152_000 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: Multisig Multisigs (r:1 w:1)
// Storage: Multisig Calls (r:1 w:1)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn cancel_as_multi(s: u32, ) -> Weight { fn cancel_as_multi(s: u32, ) -> Weight {
Weight::from_ref_time(54_556_000 as u64) // Minimum execution time: 34_887 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(37_482_449 as u64)
.saturating_add(Weight::from_ref_time(125_000 as u64).saturating_mul(s as u64)) // Standard Error: 1_063
.saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(Weight::from_ref_time(132_406 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
} }
} }
@@ -9,7 +9,7 @@ description = "Westend variant of Statemint parachain runtime"
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] }
hex-literal = { version = "0.3.4", optional = true } hex-literal = { version = "0.3.4", optional = true }
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
smallvec = "1.10.0" smallvec = "1.10.0"
# Substrate # Substrate
@@ -108,7 +108,7 @@ try-runtime = [
"cumulus-pallet-xcmp-queue/try-runtime", "cumulus-pallet-xcmp-queue/try-runtime",
"frame-executive/try-runtime", "frame-executive/try-runtime",
"frame-system/try-runtime", "frame-system/try-runtime",
"frame-try-runtime", "frame-try-runtime/try-runtime",
"pallet-asset-tx-payment/try-runtime", "pallet-asset-tx-payment/try-runtime",
"pallet-assets/try-runtime", "pallet-assets/try-runtime",
"pallet-aura/try-runtime", "pallet-aura/try-runtime",
@@ -245,7 +245,7 @@ parameter_types! {
pub const DepositBase: Balance = deposit(1, 88); pub const DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes. // Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = deposit(0, 32); pub const DepositFactor: Balance = deposit(0, 32);
pub const MaxSignatories: u16 = 100; pub const MaxSignatories: u32 = 100;
} }
impl pallet_multisig::Config for Runtime { impl pallet_multisig::Config for Runtime {
@@ -17,22 +17,21 @@
//! Autogenerated weights for `pallet_multisig` //! Autogenerated weights for `pallet_multisig`
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-09-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! DATE: 2022-10-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024 //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024
// Executed Command: // Executed Command:
// ./artifacts/polkadot-parachain // ./target/production/polkadot-parachain
// benchmark // benchmark
// pallet // pallet
// --chain=westmint-dev // --chain=westmint-dev
// --execution=wasm // --execution=wasm
// --wasm-execution=compiled // --wasm-execution=compiled
// --pallet=pallet_multisig // --pallet=pallet_multisig
// --extrinsic=* // --extrinsic=
// --steps=50 // --steps=50
// --repeat=20 // --repeat=20
// --json
// --header=./file_header.txt // --header=./file_header.txt
// --output=./parachains/runtimes/assets/westmint/src/weights/pallet_multisig.rs // --output=./parachains/runtimes/assets/westmint/src/weights/pallet_multisig.rs
@@ -40,7 +39,7 @@
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
use frame_support::{traits::Get, weights::{Weight}}; use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData; use sp_std::marker::PhantomData;
/// Weight functions for `pallet_multisig`. /// Weight functions for `pallet_multisig`.
@@ -48,115 +47,81 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_threshold_1(z: u32, ) -> Weight { fn as_multi_threshold_1(z: u32, ) -> Weight {
Weight::from_ref_time(21_180_000 as u64) // Minimum execution time: 21_175 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(21_415_507 as u64)
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z as u64)) // Standard Error: 2
.saturating_add(Weight::from_ref_time(535 as u64).saturating_mul(z as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Multisigs (r:1 w:1)
// Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_create(s: u32, z: u32, ) -> Weight { fn as_multi_create(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(40_188_000 as u64) // Minimum execution time: 50_848 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(38_951_816 as u64)
.saturating_add(Weight::from_ref_time(97_000 as u64).saturating_mul(s as u64)) // Standard Error: 591
// Standard Error: 0 .saturating_add(Weight::from_ref_time(129_854 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z 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().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(42_835_000 as u64)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(93_000 as u64).saturating_mul(s as u64))
// Standard Error: 0
.saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(3 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
// Storage: Multisig Multisigs (r:1 w:1)
/// The range of component `s` is `[3, 100]`. /// The range of component `s` is `[3, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_approve(s: u32, z: u32, ) -> Weight { fn as_multi_approve(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(29_996_000 as u64) // Minimum execution time: 38_966 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(28_246_168 as u64)
.saturating_add(Weight::from_ref_time(101_000 as u64).saturating_mul(s as u64)) // Standard Error: 854
// Standard Error: 0 .saturating_add(Weight::from_ref_time(120_269 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z as u64)) // Standard Error: 8
.saturating_add(Weight::from_ref_time(1_559 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(43_306_000 as u64)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(104_000 as u64).saturating_mul(s as u64))
// Standard Error: 0
.saturating_add(Weight::from_ref_time(2_000 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: Multisig Calls (r:1 w:1)
// Storage: System Account (r:1 w:1) // Storage: System Account (r:1 w:1)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_complete(s: u32, z: u32, ) -> Weight { fn as_multi_complete(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(54_041_000 as u64) // Minimum execution time: 53_624 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(41_648_270 as u64)
.saturating_add(Weight::from_ref_time(124_000 as u64).saturating_mul(s as u64)) // Standard Error: 899
// Standard Error: 0 .saturating_add(Weight::from_ref_time(146_173 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(z as u64)) // Standard Error: 8
.saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(Weight::from_ref_time(1_506 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().writes(3 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: Multisig Multisigs (r:1 w:1)
// Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn approve_as_multi_create(s: u32, ) -> Weight { fn approve_as_multi_create(s: u32, ) -> Weight {
Weight::from_ref_time(35_967_000 as u64) // Minimum execution time: 34_216 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(37_335_151 as u64)
.saturating_add(Weight::from_ref_time(129_000 as u64).saturating_mul(s as u64)) // Standard Error: 1_250
.saturating_add(Weight::from_ref_time(127_478 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().reads(2 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))
} }
// Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Multisigs (r:1 w:1)
// Storage: Multisig Calls (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn approve_as_multi_approve(s: u32, ) -> Weight { fn approve_as_multi_approve(s: u32, ) -> Weight {
Weight::from_ref_time(26_289_000 as u64) // Minimum execution time: 25_017 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(26_893_486 as u64)
.saturating_add(Weight::from_ref_time(127_000 as u64).saturating_mul(s as u64)) // Standard Error: 769
.saturating_add(Weight::from_ref_time(129_806 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(64_336_000 as u64)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(151_000 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: Multisig Multisigs (r:1 w:1)
// Storage: Multisig Calls (r:1 w:1)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn cancel_as_multi(s: u32, ) -> Weight { fn cancel_as_multi(s: u32, ) -> Weight {
Weight::from_ref_time(53_361_000 as u64) // Minimum execution time: 34_833 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(37_327_112 as u64)
.saturating_add(Weight::from_ref_time(128_000 as u64).saturating_mul(s as u64)) // Standard Error: 1_050
.saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(Weight::from_ref_time(132_018 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
} }
} }
@@ -9,7 +9,7 @@ description = "Polkadot Collectives Parachain Runtime"
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] }
hex-literal = { version = "0.3.4", optional = true } hex-literal = { version = "0.3.4", optional = true }
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
smallvec = "1.10.0" smallvec = "1.10.0"
# Substrate # Substrate
@@ -104,7 +104,7 @@ try-runtime = [
"cumulus-pallet-xcmp-queue/try-runtime", "cumulus-pallet-xcmp-queue/try-runtime",
"frame-executive/try-runtime", "frame-executive/try-runtime",
"frame-system/try-runtime", "frame-system/try-runtime",
"frame-try-runtime", "frame-try-runtime/try-runtime",
"pallet-alliance/try-runtime", "pallet-alliance/try-runtime",
"pallet-aura/try-runtime", "pallet-aura/try-runtime",
"pallet-authorship/try-runtime", "pallet-authorship/try-runtime",
@@ -239,7 +239,7 @@ impl pallet_multisig::Config for Runtime {
type Currency = Balances; type Currency = Balances;
type DepositBase = DepositBase; type DepositBase = DepositBase;
type DepositFactor = DepositFactor; type DepositFactor = DepositFactor;
type MaxSignatories = ConstU16<100>; type MaxSignatories = ConstU32<100>;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>; type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
} }
@@ -17,24 +17,23 @@
//! Autogenerated weights for `pallet_multisig` //! Autogenerated weights for `pallet_multisig`
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-07-11, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! DATE: 2022-10-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024 //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("collectives-polkadot-dev"), DB CACHE: 1024
// Executed Command: // Executed Command:
// ./artifacts/polkadot-parachain // ./target/production/polkadot-parachain
// benchmark // benchmark
// pallet // pallet
// --chain=collectives-polkadot-dev // --chain=collectives-polkadot-dev
// --execution=wasm // --execution=wasm
// --wasm-execution=compiled // --wasm-execution=compiled
// --pallet=pallet_multisig // --pallet=pallet_multisig
// --extrinsic=* // --extrinsic=
// --steps=50 // --steps=50
// --repeat=20 // --repeat=20
// --json
// --header=./file_header.txt // --header=./file_header.txt
// --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights // --output=./parachains/runtimes/collectives/collectives-polkadot/src/weights/pallet_multisig.rs
#![cfg_attr(rustfmt, rustfmt_skip)] #![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)] #![allow(unused_parens)]
@@ -48,115 +47,81 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_threshold_1(z: u32, ) -> Weight { fn as_multi_threshold_1(z: u32, ) -> Weight {
Weight::from_ref_time(17_905_000 as u64) // Minimum execution time: 20_960 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(21_224_051 as u64)
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z as u64)) // Standard Error: 2
.saturating_add(Weight::from_ref_time(562 as u64).saturating_mul(z as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Multisigs (r:1 w:1)
// Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_create(s: u32, z: u32, ) -> Weight { fn as_multi_create(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(34_787_000 as u64) // Minimum execution time: 49_994 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(38_168_401 as u64)
.saturating_add(Weight::from_ref_time(105_000 as u64).saturating_mul(s as u64)) // Standard Error: 639
// Standard Error: 0 .saturating_add(Weight::from_ref_time(128_549 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z as u64)) // Standard Error: 6
.saturating_add(Weight::from_ref_time(1_496 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(2 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))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(38_845_000 as u64)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(75_000 as u64).saturating_mul(s as u64))
// Standard Error: 0
.saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(3 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
// Storage: Multisig Multisigs (r:1 w:1)
/// The range of component `s` is `[3, 100]`. /// The range of component `s` is `[3, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_approve(s: u32, z: u32, ) -> Weight { fn as_multi_approve(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(25_600_000 as u64) // Minimum execution time: 38_218 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(27_858_769 as u64)
.saturating_add(Weight::from_ref_time(76_000 as u64).saturating_mul(s as u64)) // Standard Error: 787
// Standard Error: 0 .saturating_add(Weight::from_ref_time(125_710 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(1_000 as u64).saturating_mul(z as u64)) // Standard Error: 7
.saturating_add(Weight::from_ref_time(1_500 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(36_944_000 as u64)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(95_000 as u64).saturating_mul(s as u64))
// Standard Error: 0
.saturating_add(Weight::from_ref_time(2_000 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: Multisig Calls (r:1 w:1)
// Storage: System Account (r:1 w:1) // Storage: System Account (r:1 w:1)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
/// The range of component `z` is `[0, 10000]`. /// The range of component `z` is `[0, 10000]`.
fn as_multi_complete(s: u32, z: u32, ) -> Weight { fn as_multi_complete(s: u32, z: u32, ) -> Weight {
Weight::from_ref_time(46_014_000 as u64) // Minimum execution time: 52_270 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(39_676_905 as u64)
.saturating_add(Weight::from_ref_time(126_000 as u64).saturating_mul(s as u64)) // Standard Error: 921
// Standard Error: 0 .saturating_add(Weight::from_ref_time(149_819 as u64).saturating_mul(s as u64))
.saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(z as u64)) // Standard Error: 9
.saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(Weight::from_ref_time(1_580 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().writes(3 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: Multisig Multisigs (r:1 w:1)
// Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn approve_as_multi_create(s: u32, ) -> Weight { fn approve_as_multi_create(s: u32, ) -> Weight {
Weight::from_ref_time(31_616_000 as u64) // Minimum execution time: 33_994 nanoseconds.
// Standard Error: 1_000 Weight::from_ref_time(36_875_310 as u64)
.saturating_add(Weight::from_ref_time(117_000 as u64).saturating_mul(s as u64)) // Standard Error: 1_099
.saturating_add(Weight::from_ref_time(129_680 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().reads(2 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))
} }
// Storage: Multisig Multisigs (r:1 w:1) // Storage: Multisig Multisigs (r:1 w:1)
// Storage: Multisig Calls (r:1 w:0)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn approve_as_multi_approve(s: u32, ) -> Weight { fn approve_as_multi_approve(s: u32, ) -> Weight {
Weight::from_ref_time(20_862_000 as u64) // Minimum execution time: 24_546 nanoseconds.
// Standard Error: 0 Weight::from_ref_time(26_469_862 as u64)
.saturating_add(Weight::from_ref_time(109_000 as u64).saturating_mul(s as u64)) // Standard Error: 882
.saturating_add(Weight::from_ref_time(127_818 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64))
} }
// Storage: Multisig Multisigs (r:1 w:1) // 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 {
Weight::from_ref_time(64_311_000 as u64)
// Standard Error: 1_000
.saturating_add(Weight::from_ref_time(164_000 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: Multisig Multisigs (r:1 w:1)
// Storage: Multisig Calls (r:1 w:1)
/// The range of component `s` is `[2, 100]`. /// The range of component `s` is `[2, 100]`.
fn cancel_as_multi(s: u32, ) -> Weight { fn cancel_as_multi(s: u32, ) -> Weight {
Weight::from_ref_time(51_181_000 as u64) // Minimum execution time: 33_795 nanoseconds.
// Standard Error: 2_000 Weight::from_ref_time(36_427_405 as u64)
.saturating_add(Weight::from_ref_time(110_000 as u64).saturating_mul(s as u64)) // Standard Error: 994
.saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(Weight::from_ref_time(139_272 as u64).saturating_mul(s as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
} }
} }
@@ -14,7 +14,7 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
hex-literal = { version = "0.3.4", optional = true } hex-literal = { version = "0.3.4", optional = true }
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
smallvec = "1.10.0" smallvec = "1.10.0"
# Substrate # Substrate
@@ -47,9 +47,8 @@ pallet-transaction-payment = { git = "https://github.com/paritytech/substrate",
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-utility = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-sudo = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-contracts = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-contracts = { git = "https://github.com/paritytech/substrate", default-features = false, features = ["unstable-interface"], branch = "master" }
pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-contracts-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
# Polkadot # Polkadot
kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" } kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
@@ -93,7 +92,6 @@ std = [
"pallet-balances/std", "pallet-balances/std",
"pallet-collator-selection/std", "pallet-collator-selection/std",
"pallet-contracts-primitives/std", "pallet-contracts-primitives/std",
"pallet-contracts-runtime-api/std",
"pallet-contracts/std", "pallet-contracts/std",
"pallet-multisig/std", "pallet-multisig/std",
"pallet-randomness-collective-flip/std", "pallet-randomness-collective-flip/std",
@@ -133,12 +131,6 @@ std = [
"cumulus-primitives-utility/std", "cumulus-primitives-utility/std",
] ]
# Make contract callable functions marked as __unstable__ available. Do not enable
# on live chains as those are subject to change.
contracts-unstable-interface = [
"pallet-contracts/unstable-interface"
]
runtime-benchmarks = [ runtime-benchmarks = [
"hex-literal", "hex-literal",
"frame-benchmarking/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks",
@@ -165,7 +157,7 @@ try-runtime = [
"cumulus-pallet-xcmp-queue/try-runtime", "cumulus-pallet-xcmp-queue/try-runtime",
"frame-executive/try-runtime", "frame-executive/try-runtime",
"frame-system/try-runtime", "frame-system/try-runtime",
"frame-try-runtime", "frame-try-runtime/try-runtime",
"pallet-aura/try-runtime", "pallet-aura/try-runtime",
"pallet-authorship/try-runtime", "pallet-authorship/try-runtime",
"pallet-balances/try-runtime", "pallet-balances/try-runtime",
@@ -9,7 +9,7 @@ use frame_support::{
}; };
use pallet_contracts::{ use pallet_contracts::{
weights::{SubstrateWeight, WeightInfo}, weights::{SubstrateWeight, WeightInfo},
Config, DefaultAddressGenerator, DefaultContractAccessWeight, Frame, Schedule, Config, DefaultAddressGenerator, Frame, Schedule,
}; };
pub use parachains_common::AVERAGE_ON_INITIALIZE_RATIO; pub use parachains_common::AVERAGE_ON_INITIALIZE_RATIO;
@@ -55,7 +55,6 @@ impl Config for Runtime {
type Schedule = MySchedule; type Schedule = MySchedule;
type CallStack = [Frame<Self>; 31]; type CallStack = [Frame<Self>; 31];
type AddressGenerator = DefaultAddressGenerator; type AddressGenerator = DefaultAddressGenerator;
type ContractAccessWeight = DefaultContractAccessWeight<RuntimeBlockWeights>;
type MaxCodeLen = ConstU32<{ 128 * 1024 }>; type MaxCodeLen = ConstU32<{ 128 * 1024 }>;
type MaxStorageKeyLen = ConstU32<128>; type MaxStorageKeyLen = ConstU32<128>;
} }
@@ -58,7 +58,8 @@ use frame_system::limits::{BlockLength, BlockWeights};
pub use parachains_common as common; pub use parachains_common as common;
use parachains_common::{ use parachains_common::{
impls::DealWithFees, opaque, AccountId, BlockNumber, Hash, Header, Index, Signature, impls::DealWithFees, opaque, AccountId, BlockNumber, Hash, Header, Index, Signature,
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, AVERAGE_ON_INITIALIZE_RATIO, MAXIMUM_BLOCK_WEIGHT, MINUTES, NORMAL_DISPATCH_RATIO,
SLOT_DURATION,
}; };
pub use parachains_common::{AuraId, Balance}; pub use parachains_common::{AuraId, Balance};
use xcm_config::CollatorSelectionUpdateOrigin; use xcm_config::CollatorSelectionUpdateOrigin;
@@ -234,7 +235,7 @@ impl pallet_multisig::Config for Runtime {
type Currency = Balances; type Currency = Balances;
type DepositBase = DepositBase; type DepositBase = DepositBase;
type DepositFactor = DepositFactor; type DepositFactor = DepositFactor;
type MaxSignatories = ConstU16<100>; type MaxSignatories = ConstU32<100>;
type WeightInfo = pallet_multisig::weights::SubstrateWeight<Runtime>; type WeightInfo = pallet_multisig::weights::SubstrateWeight<Runtime>;
} }
@@ -269,7 +270,7 @@ impl parachain_info::Config for Runtime {}
impl cumulus_pallet_aura_ext::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {}
parameter_types! { parameter_types! {
pub const Period: u32 = 6 * HOURS; pub const Period: u32 = 10 * MINUTES;
pub const Offset: u32 = 0; pub const Offset: u32 = 0;
} }
@@ -303,7 +304,7 @@ impl pallet_collator_selection::Config for Runtime {
type UpdateOrigin = CollatorSelectionUpdateOrigin; type UpdateOrigin = CollatorSelectionUpdateOrigin;
type PotId = PotId; type PotId = PotId;
type MaxCandidates = ConstU32<1000>; type MaxCandidates = ConstU32<1000>;
type MinCandidates = ConstU32<5>; type MinCandidates = ConstU32<0>;
type MaxInvulnerables = ConstU32<100>; type MaxInvulnerables = ConstU32<100>;
// should be a multiple of session or things will get inconsistent // should be a multiple of session or things will get inconsistent
type KickThreshold = Period; type KickThreshold = Period;
@@ -505,41 +506,42 @@ impl_runtime_apis! {
} }
} }
impl pallet_contracts_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash> impl pallet_contracts::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash> for Runtime {
for Runtime
{
fn call( fn call(
origin: AccountId, origin: AccountId,
dest: AccountId, dest: AccountId,
value: Balance, value: Balance,
gas_limit: u64, gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>, storage_deposit_limit: Option<Balance>,
input_data: Vec<u8>, input_data: Vec<u8>,
) -> pallet_contracts_primitives::ContractExecResult<Balance> { ) -> pallet_contracts_primitives::ContractExecResult<Balance> {
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_call( Contracts::bare_call(
origin, origin,
dest, dest,
value, value,
Weight::from_ref_time(gas_limit), gas_limit,
storage_deposit_limit, storage_deposit_limit,
input_data, input_data,
contracts::CONTRACTS_DEBUG_OUTPUT, contracts::CONTRACTS_DEBUG_OUTPUT,
pallet_contracts::Determinism::Deterministic,
) )
} }
fn instantiate( fn instantiate(
origin: AccountId, origin: AccountId,
value: Balance, value: Balance,
gas_limit: u64, gas_limit: Option<Weight>,
storage_deposit_limit: Option<Balance>, storage_deposit_limit: Option<Balance>,
code: pallet_contracts_primitives::Code<Hash>, code: pallet_contracts_primitives::Code<Hash>,
data: Vec<u8>, data: Vec<u8>,
salt: Vec<u8>, salt: Vec<u8>,
) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, Balance> { ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, Balance> {
let gas_limit = gas_limit.unwrap_or(RuntimeBlockWeights::get().max_block);
Contracts::bare_instantiate( Contracts::bare_instantiate(
origin, origin,
value, value,
Weight::from_ref_time(gas_limit), gas_limit,
storage_deposit_limit, storage_deposit_limit,
code, code,
data, data,
@@ -552,8 +554,14 @@ impl pallet_contracts_runtime_api::ContractsApi<Block, AccountId, Balance, Block
origin: AccountId, origin: AccountId,
code: Vec<u8>, code: Vec<u8>,
storage_deposit_limit: Option<Balance>, storage_deposit_limit: Option<Balance>,
determinism: pallet_contracts::Determinism,
) -> pallet_contracts_primitives::CodeUploadResult<Hash, Balance> { ) -> pallet_contracts_primitives::CodeUploadResult<Hash, Balance> {
Contracts::bare_upload_code(origin, code, storage_deposit_limit) Contracts::bare_upload_code(
origin,
code,
storage_deposit_limit,
determinism,
)
} }
fn get_storage( fn get_storage(
@@ -6,7 +6,7 @@ edition = "2021"
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
# Substrate # Substrate
frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -85,7 +85,8 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
/// by Operational extrinsics. /// by Operational extrinsics.
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// We allow for .5 seconds of compute with a 12 second average block time. /// We allow for .5 seconds of compute with a 12 second average block time.
const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.saturating_div(2) const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND
.saturating_div(2)
.set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64); .set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64);
parameter_types! { parameter_types! {
@@ -6,7 +6,7 @@ edition = "2021"
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
# Substrate # Substrate
frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -68,5 +68,5 @@ std = [
] ]
try-runtime = [ try-runtime = [
"frame-executive/try-runtime", "frame-executive/try-runtime",
"frame-try-runtime", "frame-try-runtime/try-runtime",
] ]
@@ -92,7 +92,8 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
/// by Operational extrinsics. /// by Operational extrinsics.
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// We allow for .5 seconds of compute with a 12 second average block time. /// We allow for .5 seconds of compute with a 12 second average block time.
const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.saturating_div(2) const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND
.saturating_div(2)
.set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64); .set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64);
parameter_types! { parameter_types! {
@@ -18,7 +18,7 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
hex-literal = { version = "0.3.4", optional = true } hex-literal = { version = "0.3.4", optional = true }
log = { version = "0.4.16", default-features = false } log = { version = "0.4.16", default-features = false }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
smallvec = "1.10.0" smallvec = "1.10.0"
# Substrate # Substrate
@@ -150,7 +150,7 @@ try-runtime = [
"cumulus-pallet-xcmp-queue/try-runtime", "cumulus-pallet-xcmp-queue/try-runtime",
"frame-executive/try-runtime", "frame-executive/try-runtime",
"frame-system/try-runtime", "frame-system/try-runtime",
"frame-try-runtime", "frame-try-runtime/try-runtime",
"pallet-aura/try-runtime", "pallet-aura/try-runtime",
"pallet-authorship/try-runtime", "pallet-authorship/try-runtime",
"pallet-balances/try-runtime", "pallet-balances/try-runtime",
@@ -230,7 +230,8 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// We allow for 0.5 of a second of compute with a 12 second average block time. /// We allow for 0.5 of a second of compute with a 12 second average block time.
const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.saturating_div(2) const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND
.saturating_div(2)
.set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64); .set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64);
/// The version information used to identify this runtime when compiled natively. /// The version information used to identify this runtime when compiled natively.
@@ -7,7 +7,7 @@ description = "Simple runtime used by the rococo parachain(s)"
[dependencies] [dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
# Substrate # Substrate
frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } frame-executive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -135,7 +135,8 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
/// by Operational extrinsics. /// by Operational extrinsics.
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// We allow for .5 seconds of compute with a 12 second average block time. /// We allow for .5 seconds of compute with a 12 second average block time.
const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND.saturating_div(2) const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND
.saturating_div(2)
.set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64); .set_proof_size(cumulus_primitives_core::relay_chain::v2::MAX_POV_SIZE as u64);
parameter_types! { parameter_types! {
+6 -4
View File
@@ -7,8 +7,8 @@ edition = "2021"
description = "Runs a polkadot parachain node which could be a collator." description = "Runs a polkadot parachain node which could be a collator."
[dependencies] [dependencies]
async-trait = "0.1.57" async-trait = "0.1.58"
clap = { version = "3.2.22", features = ["derive", "deprecated"] } clap = { version = "4.0.17", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.0.0" } codec = { package = "parity-scale-codec", version = "3.0.0" }
futures = "0.3.24" futures = "0.3.24"
hex-literal = "0.3.4" hex-literal = "0.3.4"
@@ -60,7 +60,7 @@ sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch =
sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-serializer = { git = "https://github.com/paritytech/substrate", branch = "master" } sp-serializer = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master" } try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" } frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -83,6 +83,7 @@ cumulus-primitives-parachain-inherent = { path = "../primitives/parachain-inhere
cumulus-relay-chain-interface = { path = "../client/relay-chain-interface" } cumulus-relay-chain-interface = { path = "../client/relay-chain-interface" }
cumulus-relay-chain-inprocess-interface = { path = "../client/relay-chain-inprocess-interface" } cumulus-relay-chain-inprocess-interface = { path = "../client/relay-chain-inprocess-interface" }
cumulus-relay-chain-rpc-interface = { path = "../client/relay-chain-rpc-interface" } cumulus-relay-chain-rpc-interface = { path = "../client/relay-chain-rpc-interface" }
cumulus-relay-chain-minimal-node = { path = "../client/relay-chain-minimal-node" }
[build-dependencies] [build-dependencies]
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -91,7 +92,7 @@ substrate-build-script-utils = { git = "https://github.com/paritytech/substrate"
assert_cmd = "2.0" assert_cmd = "2.0"
nix = "0.25" nix = "0.25"
tempfile = "3.3.0" tempfile = "3.3.0"
tokio = { version = "1.21.1", features = ["macros", "time", "parking_lot"] } tokio = { version = "1.21.2", features = ["macros", "time", "parking_lot"] }
wait-timeout = "0.2" wait-timeout = "0.2"
# purge_chain_works works with rococo-local and needs to allow this # purge_chain_works works with rococo-local and needs to allow this
polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master", features = ["rococo-native"] } polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "master", features = ["rococo-native"] }
@@ -109,4 +110,5 @@ try-runtime = [
"statemine-runtime/try-runtime", "statemine-runtime/try-runtime",
"westmint-runtime/try-runtime", "westmint-runtime/try-runtime",
"shell-runtime/try-runtime", "shell-runtime/try-runtime",
"try-runtime-cli/try-runtime",
] ]
+12 -7
View File
@@ -20,7 +20,7 @@ use std::path::PathBuf;
#[derive(Debug, clap::Subcommand)] #[derive(Debug, clap::Subcommand)]
pub enum Subcommand { pub enum Subcommand {
/// Key management CLI utilities /// Key management CLI utilities
#[clap(subcommand)] #[command(subcommand)]
Key(sc_cli::KeySubcommand), Key(sc_cli::KeySubcommand),
/// Build a chain specification. /// Build a chain specification.
@@ -52,24 +52,29 @@ pub enum Subcommand {
/// Sub-commands concerned with benchmarking. /// Sub-commands concerned with benchmarking.
/// The pallet benchmarking moved to the `pallet` sub-command. /// The pallet benchmarking moved to the `pallet` sub-command.
#[clap(subcommand)] #[command(subcommand)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd), Benchmark(frame_benchmarking_cli::BenchmarkCmd),
/// Try some testing command against a specified runtime state. /// Try some testing command against a specified runtime state.
#[cfg(feature = "try-runtime")]
TryRuntime(try_runtime_cli::TryRuntimeCmd), TryRuntime(try_runtime_cli::TryRuntimeCmd),
/// Errors since the binary was not build with `--features try-runtime`.
#[cfg(not(feature = "try-runtime"))]
TryRuntime,
} }
#[derive(Debug, clap::Parser)] #[derive(Debug, clap::Parser)]
#[clap( #[command(
propagate_version = true, propagate_version = true,
args_conflicts_with_subcommands = true, args_conflicts_with_subcommands = true,
subcommand_negates_reqs = true subcommand_negates_reqs = true
)] )]
pub struct Cli { pub struct Cli {
#[clap(subcommand)] #[command(subcommand)]
pub subcommand: Option<Subcommand>, pub subcommand: Option<Subcommand>,
#[clap(flatten)] #[command(flatten)]
pub run: cumulus_client_cli::RunCmd, pub run: cumulus_client_cli::RunCmd,
/// Disable automatic hardware benchmarks. /// Disable automatic hardware benchmarks.
@@ -79,11 +84,11 @@ pub struct Cli {
/// ///
/// The results are then printed out in the logs, and also sent as part of /// The results are then printed out in the logs, and also sent as part of
/// telemetry, if telemetry is enabled. /// telemetry, if telemetry is enabled.
#[clap(long)] #[arg(long)]
pub no_hardware_benchmarks: bool, pub no_hardware_benchmarks: bool,
/// Relay chain arguments /// Relay chain arguments
#[clap(raw = true, conflicts_with = "relay-chain-rpc-url")] #[arg(raw = true)]
pub relaychain_args: Vec<String>, pub relaychain_args: Vec<String>,
} }
+42 -37
View File
@@ -18,24 +18,21 @@ use crate::{
chain_spec, chain_spec,
cli::{Cli, RelayChainCli, Subcommand}, cli::{Cli, RelayChainCli, Subcommand},
service::{ service::{
new_partial, Block, CollectivesPolkadotRuntimeExecutor, ShellRuntimeExecutor, new_partial, Block, CollectivesPolkadotRuntimeExecutor, StatemineRuntimeExecutor,
StatemineRuntimeExecutor, StatemintRuntimeExecutor, WestmintRuntimeExecutor, StatemintRuntimeExecutor, WestmintRuntimeExecutor,
}, },
}; };
use codec::Encode; use codec::Encode;
use cumulus_client_cli::generate_genesis_block; use cumulus_client_cli::generate_genesis_block;
use cumulus_primitives_core::ParaId; use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};
use log::info; use log::{info, warn};
use parachains_common::{AuraId, StatemintAuraId}; use parachains_common::{AuraId, StatemintAuraId};
use sc_cli::{ use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli, NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
}; };
use sc_service::{ use sc_service::config::{BasePath, PrometheusConfig};
config::{BasePath, PrometheusConfig},
TaskManager,
};
use sp_core::hexdisplay::HexDisplay; use sp_core::hexdisplay::HexDisplay;
use sp_runtime::traits::{AccountIdConversion, Block as BlockT}; use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
use std::{net::SocketAddr, path::PathBuf}; use std::{net::SocketAddr, path::PathBuf};
@@ -597,41 +594,45 @@ pub fn run() -> Result<()> {
_ => Err("Benchmarking sub-command unsupported".into()), _ => Err("Benchmarking sub-command unsupported".into()),
} }
}, },
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => { Some(Subcommand::TryRuntime(cmd)) => {
if cfg!(feature = "try-runtime") { // grab the task manager.
// grab the task manager. let runner = cli.create_runner(cmd)?;
let runner = cli.create_runner(cmd)?; let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry);
let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry); let task_manager =
let task_manager = sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry)
TaskManager::new(runner.config().tokio_handle.clone(), *registry) .map_err(|e| format!("Error: {:?}", e))?;
.map_err(|e| format!("Error: {:?}", e))?;
match runner.config().chain_spec.runtime() { match runner.config().chain_spec.runtime() {
Runtime::Statemine => runner.async_run(|config| { Runtime::Statemine => runner.async_run(|config| {
Ok((cmd.run::<Block, StatemineRuntimeExecutor>(config), task_manager)) Ok((cmd.run::<Block, StatemineRuntimeExecutor>(config), task_manager))
}),
Runtime::Westmint => runner.async_run(|config| {
Ok((cmd.run::<Block, WestmintRuntimeExecutor>(config), task_manager))
}),
Runtime::Statemint => runner.async_run(|config| {
Ok((cmd.run::<Block, StatemintRuntimeExecutor>(config), task_manager))
}),
Runtime::CollectivesPolkadot | Runtime::CollectivesWestend =>
runner.async_run(|config| {
Ok((
cmd.run::<Block, CollectivesPolkadotRuntimeExecutor>(config),
task_manager,
))
}), }),
Runtime::Westmint => runner.async_run(|config| { Runtime::Shell => runner.async_run(|config| {
Ok((cmd.run::<Block, WestmintRuntimeExecutor>(config), task_manager)) Ok((
}), cmd.run::<Block, crate::service::ShellRuntimeExecutor>(config),
Runtime::Statemint => runner.async_run(|config| { task_manager,
Ok((cmd.run::<Block, StatemintRuntimeExecutor>(config), task_manager)) ))
}), }),
Runtime::CollectivesPolkadot | Runtime::CollectivesWestend => _ => Err("Chain doesn't support try-runtime".into()),
runner.async_run(|config| {
Ok((
cmd.run::<Block, CollectivesPolkadotRuntimeExecutor>(config),
task_manager,
))
}),
Runtime::Shell => runner.async_run(|config| {
Ok((cmd.run::<Block, ShellRuntimeExecutor>(config), task_manager))
}),
_ => Err("Chain doesn't support try-runtime".into()),
}
} else {
Err("Try-runtime must be enabled by `--features try-runtime`.".into())
} }
}, },
#[cfg(not(feature = "try-runtime"))]
Some(Subcommand::TryRuntime) => Err("Try-runtime was not enabled when building the node. \
You can enable it with `--features try-runtime`."
.into()),
Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?), Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?),
None => { None => {
let runner = cli.create_runner(&cli.run.normalize())?; let runner = cli.create_runner(&cli.run.normalize())?;
@@ -678,6 +679,10 @@ pub fn run() -> Result<()> {
info!("Parachain genesis state: {}", genesis_state); info!("Parachain genesis state: {}", genesis_state);
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
if collator_options.relay_chain_rpc_url.is_some() && cli.relaychain_args.len() > 0 {
warn!("Detected relay chain node arguments together with --relay-chain-rpc-url. This command starts a minimal Polkadot node that only uses a network-related subset of all relay chain CLI options.");
}
match config.chain_spec.runtime() { match config.chain_spec.runtime() {
Runtime::Statemint => crate::service::start_generic_aura_node::< Runtime::Statemint => crate::service::start_generic_aura_node::<
statemint_runtime::RuntimeApi, statemint_runtime::RuntimeApi,
+163 -246
View File
@@ -18,7 +18,7 @@ use codec::Codec;
use cumulus_client_cli::CollatorOptions; use cumulus_client_cli::CollatorOptions;
use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion}; use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};
use cumulus_client_consensus_common::{ use cumulus_client_consensus_common::{
ParachainBlockImport, ParachainCandidate, ParachainConsensus, ParachainBlockImport as TParachainBlockImport, ParachainCandidate, ParachainConsensus,
}; };
use cumulus_client_network::BlockAnnounceValidator; use cumulus_client_network::BlockAnnounceValidator;
use cumulus_client_service::{ use cumulus_client_service::{
@@ -30,7 +30,7 @@ use cumulus_primitives_core::{
}; };
use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain; use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult}; use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};
use cumulus_relay_chain_rpc_interface::{create_client_and_start_worker, RelayChainRpcInterface}; use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node;
use polkadot_service::CollatorPair; use polkadot_service::CollatorPair;
use sp_core::Pair; use sp_core::Pair;
@@ -69,6 +69,12 @@ type HostFunctions = sp_io::SubstrateHostFunctions;
type HostFunctions = type HostFunctions =
(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions); (sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions);
type ParachainClient<RuntimeApi> = TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>;
type ParachainBackend = TFullBackend<Block>;
type ParachainBlockImport<RuntimeApi> = TParachainBlockImport<Arc<ParachainClient<RuntimeApi>>>;
/// Native executor instance. /// Native executor instance.
pub struct ShellRuntimeExecutor; pub struct ShellRuntimeExecutor;
@@ -153,45 +159,34 @@ pub fn new_partial<RuntimeApi, BIQ>(
build_import_queue: BIQ, build_import_queue: BIQ,
) -> Result< ) -> Result<
PartialComponents< PartialComponents<
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>, ParachainClient<RuntimeApi>,
TFullBackend<Block>, ParachainBackend,
(), (),
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<Block, ParachainClient<RuntimeApi>>,
Block, sc_transaction_pool::FullPool<Block, ParachainClient<RuntimeApi>>,
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>, (ParachainBlockImport<RuntimeApi>, Option<Telemetry>, Option<TelemetryWorkerHandle>),
>,
sc_transaction_pool::FullPool<
Block,
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>,
(Option<Telemetry>, Option<TelemetryWorkerHandle>),
>, >,
sc_service::Error, sc_service::Error,
> >
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>> RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block> + sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block> + sp_session::SessionKeys<Block>
+ sp_api::ApiExt< + sp_api::ApiExt<
Block, Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>, StateBackend = sc_client_api::StateBackendFor<ParachainBackend, Block>,
> + sp_offchain::OffchainWorkerApi<Block> > + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block>, + sp_block_builder::BlockBuilder<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<ParachainBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
BIQ: FnOnce( BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>, Arc<ParachainClient<RuntimeApi>>,
ParachainBlockImport<RuntimeApi>,
&Configuration, &Configuration,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<Block, ParachainClient<RuntimeApi>>,
Block,
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>,
sc_service::Error, sc_service::Error,
>, >,
{ {
@@ -237,8 +232,11 @@ where
client.clone(), client.clone(),
); );
let block_import = ParachainBlockImport::new(client.clone());
let import_queue = build_import_queue( let import_queue = build_import_queue(
client.clone(), client.clone(),
block_import.clone(),
config, config,
telemetry.as_ref().map(|telemetry| telemetry.handle()), telemetry.as_ref().map(|telemetry| telemetry.handle()),
&task_manager, &task_manager,
@@ -252,7 +250,7 @@ where
task_manager, task_manager,
transaction_pool, transaction_pool,
select_chain: (), select_chain: (),
other: (telemetry, telemetry_worker_handle), other: (block_import, telemetry, telemetry_worker_handle),
}; };
Ok(params) Ok(params)
@@ -267,10 +265,8 @@ async fn build_relay_chain_interface(
hwbench: Option<sc_sysinfo::HwBench>, hwbench: Option<sc_sysinfo::HwBench>,
) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> { ) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> {
match collator_options.relay_chain_rpc_url { match collator_options.relay_chain_rpc_url {
Some(relay_chain_url) => { Some(relay_chain_url) =>
let client = create_client_and_start_worker(relay_chain_url, task_manager).await?; build_minimal_relay_chain_node(polkadot_config, task_manager, relay_chain_url).await,
Ok((Arc::new(RelayChainRpcInterface::new(client)) as Arc<_>, None))
},
None => build_inprocess_relay_chain( None => build_inprocess_relay_chain(
polkadot_config, polkadot_config,
parachain_config, parachain_config,
@@ -289,59 +285,44 @@ async fn start_shell_node_impl<RuntimeApi, RB, BIQ, BIC>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
id: ParaId, para_id: ParaId,
rpc_ext_builder: RB, rpc_ext_builder: RB,
build_import_queue: BIQ, build_import_queue: BIQ,
build_consensus: BIC, build_consensus: BIC,
hwbench: Option<sc_sysinfo::HwBench>, hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient<RuntimeApi>>)>
TaskManager,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
)>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>> RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block> + sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block> + sp_session::SessionKeys<Block>
+ sp_api::ApiExt< + sp_api::ApiExt<
Block, Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>, StateBackend = sc_client_api::StateBackendFor<ParachainBackend, Block>,
> + sp_offchain::OffchainWorkerApi<Block> > + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block> + sp_block_builder::BlockBuilder<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block>, + cumulus_primitives_core::CollectCollationInfo<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<ParachainBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
RB: Fn( RB: Fn(Arc<ParachainClient<RuntimeApi>>) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>
+ Send
+ 'static, + 'static,
BIQ: FnOnce( BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>, Arc<ParachainClient<RuntimeApi>>,
ParachainBlockImport<RuntimeApi>,
&Configuration, &Configuration,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<Block, ParachainClient<RuntimeApi>>,
Block,
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>,
sc_service::Error, sc_service::Error,
>, >,
BIC: FnOnce( BIC: FnOnce(
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>, Arc<ParachainClient<RuntimeApi>>,
ParachainBlockImport<RuntimeApi>,
Option<&Registry>, Option<&Registry>,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
Arc<dyn RelayChainInterface>, Arc<dyn RelayChainInterface>,
Arc< Arc<sc_transaction_pool::FullPool<Block, ParachainClient<RuntimeApi>>>,
sc_transaction_pool::FullPool<
Block,
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>,
>,
Arc<NetworkService<Block, Hash>>, Arc<NetworkService<Block, Hash>>,
SyncCryptoStorePtr, SyncCryptoStorePtr,
bool, bool,
@@ -350,7 +331,7 @@ where
let parachain_config = prepare_node_config(parachain_config); let parachain_config = prepare_node_config(parachain_config);
let params = new_partial::<RuntimeApi, BIQ>(&parachain_config, build_import_queue)?; let params = new_partial::<RuntimeApi, BIQ>(&parachain_config, build_import_queue)?;
let (mut telemetry, telemetry_worker_handle) = params.other; let (block_import, mut telemetry, telemetry_worker_handle) = params.other;
let client = params.client.clone(); let client = params.client.clone();
let backend = params.backend.clone(); let backend = params.backend.clone();
@@ -371,7 +352,8 @@ where
s => s.to_string().into(), s => s.to_string().into(),
})?; })?;
let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id); let block_announce_validator =
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
let force_authoring = parachain_config.force_authoring; let force_authoring = parachain_config.force_authoring;
let validator = parachain_config.role.is_authority(); let validator = parachain_config.role.is_authority();
@@ -431,6 +413,7 @@ where
if validator { if validator {
let parachain_consensus = build_consensus( let parachain_consensus = build_consensus(
client.clone(), client.clone(),
block_import,
prometheus_registry.as_ref(), prometheus_registry.as_ref(),
telemetry.as_ref().map(|t| t.handle()), telemetry.as_ref().map(|t| t.handle()),
&task_manager, &task_manager,
@@ -444,7 +427,7 @@ where
let spawner = task_manager.spawn_handle(); let spawner = task_manager.spawn_handle();
let params = StartCollatorParams { let params = StartCollatorParams {
para_id: id, para_id,
block_status: client.clone(), block_status: client.clone(),
announce_block, announce_block,
client: client.clone(), client: client.clone(),
@@ -463,11 +446,10 @@ where
client: client.clone(), client: client.clone(),
announce_block, announce_block,
task_manager: &mut task_manager, task_manager: &mut task_manager,
para_id: id, para_id,
relay_chain_interface, relay_chain_interface,
relay_chain_slot_duration, relay_chain_slot_duration,
import_queue, import_queue,
collator_options,
}; };
start_full_node(params)?; start_full_node(params)?;
@@ -486,61 +468,45 @@ async fn start_node_impl<RuntimeApi, RB, BIQ, BIC>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
id: ParaId, para_id: ParaId,
_rpc_ext_builder: RB, _rpc_ext_builder: RB,
build_import_queue: BIQ, build_import_queue: BIQ,
build_consensus: BIC, build_consensus: BIC,
hwbench: Option<sc_sysinfo::HwBench>, hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient<RuntimeApi>>)>
TaskManager,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
)>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>> RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block> + sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block> + sp_session::SessionKeys<Block>
+ sp_api::ApiExt< + sp_api::ApiExt<
Block, Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>, StateBackend = sc_client_api::StateBackendFor<ParachainBackend, Block>,
> + sp_offchain::OffchainWorkerApi<Block> > + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block> + sp_block_builder::BlockBuilder<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block> + cumulus_primitives_core::CollectCollationInfo<Block>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance> + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>, + frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<ParachainBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
RB: Fn( RB: Fn(Arc<ParachainClient<RuntimeApi>>) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>
+ Send
+ 'static,
BIQ: FnOnce( BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>, Arc<ParachainClient<RuntimeApi>>,
&Configuration, ParachainBlockImport<RuntimeApi>,
Option<TelemetryHandle>, &Configuration,
&TaskManager, Option<TelemetryHandle>,
) -> Result< &TaskManager,
sc_consensus::DefaultImportQueue< ) -> Result<
Block, sc_consensus::DefaultImportQueue<Block, ParachainClient<RuntimeApi>>,
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>, sc_service::Error,
>, >,
sc_service::Error,
> + 'static,
BIC: FnOnce( BIC: FnOnce(
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>, Arc<ParachainClient<RuntimeApi>>,
ParachainBlockImport<RuntimeApi>,
Option<&Registry>, Option<&Registry>,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
Arc<dyn RelayChainInterface>, Arc<dyn RelayChainInterface>,
Arc< Arc<sc_transaction_pool::FullPool<Block, ParachainClient<RuntimeApi>>>,
sc_transaction_pool::FullPool<
Block,
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>,
>,
Arc<NetworkService<Block, Hash>>, Arc<NetworkService<Block, Hash>>,
SyncCryptoStorePtr, SyncCryptoStorePtr,
bool, bool,
@@ -549,7 +515,7 @@ where
let parachain_config = prepare_node_config(parachain_config); let parachain_config = prepare_node_config(parachain_config);
let params = new_partial::<RuntimeApi, BIQ>(&parachain_config, build_import_queue)?; let params = new_partial::<RuntimeApi, BIQ>(&parachain_config, build_import_queue)?;
let (mut telemetry, telemetry_worker_handle) = params.other; let (block_import, mut telemetry, telemetry_worker_handle) = params.other;
let client = params.client.clone(); let client = params.client.clone();
let backend = params.backend.clone(); let backend = params.backend.clone();
@@ -569,7 +535,8 @@ where
s => s.to_string().into(), s => s.to_string().into(),
})?; })?;
let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id); let block_announce_validator =
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
let force_authoring = parachain_config.force_authoring; let force_authoring = parachain_config.force_authoring;
let validator = parachain_config.role.is_authority(); let validator = parachain_config.role.is_authority();
@@ -641,6 +608,7 @@ where
if validator { if validator {
let parachain_consensus = build_consensus( let parachain_consensus = build_consensus(
client.clone(), client.clone(),
block_import,
prometheus_registry.as_ref(), prometheus_registry.as_ref(),
telemetry.as_ref().map(|t| t.handle()), telemetry.as_ref().map(|t| t.handle()),
&task_manager, &task_manager,
@@ -654,7 +622,7 @@ where
let spawner = task_manager.spawn_handle(); let spawner = task_manager.spawn_handle();
let params = StartCollatorParams { let params = StartCollatorParams {
para_id: id, para_id,
block_status: client.clone(), block_status: client.clone(),
announce_block, announce_block,
client: client.clone(), client: client.clone(),
@@ -673,11 +641,10 @@ where
client: client.clone(), client: client.clone(),
announce_block, announce_block,
task_manager: &mut task_manager, task_manager: &mut task_manager,
para_id: id, para_id,
relay_chain_interface, relay_chain_interface,
relay_chain_slot_duration, relay_chain_slot_duration,
import_queue, import_queue,
collator_options,
}; };
start_full_node(params)?; start_full_node(params)?;
@@ -690,17 +657,13 @@ where
/// Build the import queue for the rococo parachain runtime. /// Build the import queue for the rococo parachain runtime.
pub fn rococo_parachain_build_import_queue( pub fn rococo_parachain_build_import_queue(
client: Arc< client: Arc<ParachainClient<rococo_parachain_runtime::RuntimeApi>>,
TFullClient<Block, rococo_parachain_runtime::RuntimeApi, WasmExecutor<HostFunctions>>, block_import: ParachainBlockImport<rococo_parachain_runtime::RuntimeApi>,
>,
config: &Configuration, config: &Configuration,
telemetry: Option<TelemetryHandle>, telemetry: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<Block, ParachainClient<rococo_parachain_runtime::RuntimeApi>>,
Block,
TFullClient<Block, rococo_parachain_runtime::RuntimeApi, WasmExecutor<HostFunctions>>,
>,
sc_service::Error, sc_service::Error,
> { > {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
@@ -713,7 +676,7 @@ pub fn rococo_parachain_build_import_queue(
_, _,
_, _,
>(cumulus_client_consensus_aura::ImportQueueParams { >(cumulus_client_consensus_aura::ImportQueueParams {
block_import: client.clone(), block_import,
client, client,
create_inherent_data_providers: move |_, _| async move { create_inherent_data_providers: move |_, _| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
@@ -738,20 +701,21 @@ pub async fn start_rococo_parachain_node(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
id: ParaId, para_id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>, hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc<TFullClient<Block, rococo_parachain_runtime::RuntimeApi, WasmExecutor<HostFunctions>>>, Arc<ParachainClient<rococo_parachain_runtime::RuntimeApi>>,
)> { )> {
start_node_impl::<rococo_parachain_runtime::RuntimeApi, _, _, _>( start_node_impl::<rococo_parachain_runtime::RuntimeApi, _, _, _>(
parachain_config, parachain_config,
polkadot_config, polkadot_config,
collator_options, collator_options,
id, para_id,
|_| Ok(RpcModule::new(())), |_| Ok(RpcModule::new(())),
rococo_parachain_build_import_queue, rococo_parachain_build_import_queue,
|client, |client,
block_import,
prometheus_registry, prometheus_registry,
telemetry, telemetry,
task_manager, task_manager,
@@ -782,7 +746,7 @@ pub async fn start_rococo_parachain_node(
relay_parent, relay_parent,
&relay_chain_interface, &relay_chain_interface,
&validation_data, &validation_data,
id, para_id,
).await; ).await;
let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
@@ -802,7 +766,7 @@ pub async fn start_rococo_parachain_node(
Ok((slot, timestamp, parachain_inherent)) Ok((slot, timestamp, parachain_inherent))
} }
}, },
block_import: client.clone(), block_import,
para_client: client, para_client: client,
backoff_authoring_blocks: Option::<()>::None, backoff_authoring_blocks: Option::<()>::None,
sync_oracle, sync_oracle,
@@ -824,35 +788,27 @@ pub async fn start_rococo_parachain_node(
/// Build the import queue for the shell runtime. /// Build the import queue for the shell runtime.
pub fn shell_build_import_queue<RuntimeApi>( pub fn shell_build_import_queue<RuntimeApi>(
client: Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>, client: Arc<ParachainClient<RuntimeApi>>,
block_import: ParachainBlockImport<RuntimeApi>,
config: &Configuration, config: &Configuration,
_: Option<TelemetryHandle>, _: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<sc_consensus::DefaultImportQueue<Block, ParachainClient<RuntimeApi>>, sc_service::Error>
sc_consensus::DefaultImportQueue<
Block,
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>,
sc_service::Error,
>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>> RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block> + sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block> + sp_session::SessionKeys<Block>
+ sp_api::ApiExt< + sp_api::ApiExt<
Block, Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>, StateBackend = sc_client_api::StateBackendFor<ParachainBackend, Block>,
> + sp_offchain::OffchainWorkerApi<Block> > + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block>, + sp_block_builder::BlockBuilder<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<ParachainBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
{ {
cumulus_client_consensus_relay_chain::import_queue( cumulus_client_consensus_relay_chain::import_queue(
client.clone(), client.clone(),
client, block_import,
|_, _| async { Ok(()) }, |_, _| async { Ok(()) },
&task_manager.spawn_essential_handle(), &task_manager.spawn_essential_handle(),
config.prometheus_registry(), config.prometheus_registry(),
@@ -865,36 +821,31 @@ pub async fn start_shell_node<RuntimeApi>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
id: ParaId, para_id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>, hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient<RuntimeApi>>)>
TaskManager,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
)>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>> RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block> + sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block> + sp_session::SessionKeys<Block>
+ sp_api::ApiExt< + sp_api::ApiExt<
Block, Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>, StateBackend = sc_client_api::StateBackendFor<ParachainBackend, Block>,
> + sp_offchain::OffchainWorkerApi<Block> > + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block> + sp_block_builder::BlockBuilder<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block>, + cumulus_primitives_core::CollectCollationInfo<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<ParachainBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
{ {
start_shell_node_impl::<RuntimeApi, _, _, _>( start_shell_node_impl::<RuntimeApi, _, _, _>(
parachain_config, parachain_config,
polkadot_config, polkadot_config,
collator_options, collator_options,
id, para_id,
|_| Ok(RpcModule::new(())), |_| Ok(RpcModule::new(())),
shell_build_import_queue, shell_build_import_queue,
|client, |client,
block_import,
prometheus_registry, prometheus_registry,
telemetry, telemetry,
task_manager, task_manager,
@@ -905,7 +856,7 @@ where
_| { _| {
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
task_manager.spawn_handle(), task_manager.spawn_handle(),
client.clone(), client,
transaction_pool, transaction_pool,
prometheus_registry, prometheus_registry,
telemetry, telemetry,
@@ -913,9 +864,9 @@ where
Ok(cumulus_client_consensus_relay_chain::build_relay_chain_consensus( Ok(cumulus_client_consensus_relay_chain::build_relay_chain_consensus(
cumulus_client_consensus_relay_chain::BuildRelayChainConsensusParams { cumulus_client_consensus_relay_chain::BuildRelayChainConsensusParams {
para_id: id, para_id,
proposer_factory, proposer_factory,
block_import: client, block_import,
relay_chain_interface: relay_chain_interface.clone(), relay_chain_interface: relay_chain_interface.clone(),
create_inherent_data_providers: move |_, (relay_parent, validation_data)| { create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
let relay_chain_interface = relay_chain_interface.clone(); let relay_chain_interface = relay_chain_interface.clone();
@@ -925,7 +876,7 @@ where
relay_parent, relay_parent,
&relay_chain_interface, &relay_chain_interface,
&validation_data, &validation_data,
id, para_id,
).await; ).await;
let parachain_inherent = parachain_inherent.ok_or_else(|| { let parachain_inherent = parachain_inherent.ok_or_else(|| {
Box::<dyn std::error::Error + Send + Sync>::from( Box::<dyn std::error::Error + Send + Sync>::from(
@@ -1052,32 +1003,24 @@ where
/// Build the import queue for Statemint and other Aura-based runtimes. /// Build the import queue for Statemint and other Aura-based runtimes.
pub fn aura_build_import_queue<RuntimeApi, AuraId: AppKey>( pub fn aura_build_import_queue<RuntimeApi, AuraId: AppKey>(
client: Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>, client: Arc<ParachainClient<RuntimeApi>>,
block_import: ParachainBlockImport<RuntimeApi>,
config: &Configuration, config: &Configuration,
telemetry_handle: Option<TelemetryHandle>, telemetry_handle: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<sc_consensus::DefaultImportQueue<Block, ParachainClient<RuntimeApi>>, sc_service::Error>
sc_consensus::DefaultImportQueue<
Block,
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>,
sc_service::Error,
>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>> RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block> + sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block> + sp_session::SessionKeys<Block>
+ sp_api::ApiExt< + sp_api::ApiExt<
Block, Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>, StateBackend = sc_client_api::StateBackendFor<ParachainBackend, Block>,
> + sp_offchain::OffchainWorkerApi<Block> > + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block> + sp_block_builder::BlockBuilder<Block>
+ sp_consensus_aura::AuraApi<Block, <<AuraId as AppKey>::Pair as Pair>::Public>, + sp_consensus_aura::AuraApi<Block, <<AuraId as AppKey>::Pair as Pair>::Public>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<ParachainBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
<<AuraId as AppKey>::Pair as Pair>::Signature: <<AuraId as AppKey>::Pair as Pair>::Signature:
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec, TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
{ {
@@ -1086,23 +1029,25 @@ where
let aura_verifier = move || { let aura_verifier = move || {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client2).unwrap(); let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client2).unwrap();
Box::new(cumulus_client_consensus_aura::build_verifier::<<AuraId as AppKey>::Pair, _, _>( Box::new(
cumulus_client_consensus_aura::BuildVerifierParams { cumulus_client_consensus_aura::build_verifier::<<AuraId as AppKey>::Pair, _, _, _>(
client: client2.clone(), cumulus_client_consensus_aura::BuildVerifierParams {
create_inherent_data_providers: move |_, _| async move { client: client2.clone(),
let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); create_inherent_data_providers: move |_, _| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
let slot = let slot =
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
*timestamp, *timestamp,
slot_duration, slot_duration,
); );
Ok((slot, timestamp)) Ok((slot, timestamp))
},
telemetry: telemetry_handle,
}, },
telemetry: telemetry_handle, ),
}, ) as Box<_>
)) as Box<_>
}; };
let relay_chain_verifier = let relay_chain_verifier =
@@ -1118,13 +1063,7 @@ where
let registry = config.prometheus_registry(); let registry = config.prometheus_registry();
let spawner = task_manager.spawn_essential_handle(); let spawner = task_manager.spawn_essential_handle();
Ok(BasicQueue::new( Ok(BasicQueue::new(verifier, Box::new(block_import), None, &spawner, registry))
verifier,
Box::new(ParachainBlockImport::new(client)),
None,
&spawner,
registry,
))
} }
/// Start an aura powered parachain node. /// Start an aura powered parachain node.
@@ -1133,30 +1072,24 @@ pub async fn start_generic_aura_node<RuntimeApi, AuraId: AppKey>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
id: ParaId, para_id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>, hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient<RuntimeApi>>)>
TaskManager,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
)>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>> RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block> + sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block> + sp_session::SessionKeys<Block>
+ sp_api::ApiExt< + sp_api::ApiExt<
Block, Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>, StateBackend = sc_client_api::StateBackendFor<ParachainBackend, Block>,
> + sp_offchain::OffchainWorkerApi<Block> > + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block> + sp_block_builder::BlockBuilder<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block> + cumulus_primitives_core::CollectCollationInfo<Block>
+ sp_consensus_aura::AuraApi<Block, <<AuraId as AppKey>::Pair as Pair>::Public> + sp_consensus_aura::AuraApi<Block, <<AuraId as AppKey>::Pair as Pair>::Public>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance> + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>, + frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<ParachainBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
<<AuraId as AppKey>::Pair as Pair>::Signature: <<AuraId as AppKey>::Pair as Pair>::Signature:
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec, TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
{ {
@@ -1164,10 +1097,11 @@ where
parachain_config, parachain_config,
polkadot_config, polkadot_config,
collator_options, collator_options,
id, para_id,
|_| Ok(RpcModule::new(())), |_| Ok(RpcModule::new(())),
aura_build_import_queue::<_, AuraId>, aura_build_import_queue::<_, AuraId>,
|client, |client,
block_import,
prometheus_registry, prometheus_registry,
telemetry, telemetry,
task_manager, task_manager,
@@ -1176,8 +1110,9 @@ where
sync_oracle, sync_oracle,
keystore, keystore,
force_authoring| { force_authoring| {
let client2 = client.clone();
let spawn_handle = task_manager.spawn_handle(); let spawn_handle = task_manager.spawn_handle();
let client2 = client.clone();
let block_import2 = block_import.clone();
let transaction_pool2 = transaction_pool.clone(); let transaction_pool2 = transaction_pool.clone();
let telemetry2 = telemetry.clone(); let telemetry2 = telemetry.clone();
let prometheus_registry2 = prometheus_registry.map(|r| (*r).clone()); let prometheus_registry2 = prometheus_registry.map(|r| (*r).clone());
@@ -1206,7 +1141,7 @@ where
relay_parent, relay_parent,
&relay_chain_for_aura, &relay_chain_for_aura,
&validation_data, &validation_data,
id, para_id,
).await; ).await;
let timestamp = let timestamp =
@@ -1228,8 +1163,8 @@ where
Ok((slot, timestamp, parachain_inherent)) Ok((slot, timestamp, parachain_inherent))
} }
}, },
block_import: client2.clone(), block_import: block_import2,
para_client: client2.clone(), para_client: client2,
backoff_authoring_blocks: Option::<()>::None, backoff_authoring_blocks: Option::<()>::None,
sync_oracle, sync_oracle,
keystore, keystore,
@@ -1255,9 +1190,9 @@ where
let relay_chain_consensus = let relay_chain_consensus =
cumulus_client_consensus_relay_chain::build_relay_chain_consensus( cumulus_client_consensus_relay_chain::build_relay_chain_consensus(
cumulus_client_consensus_relay_chain::BuildRelayChainConsensusParams { cumulus_client_consensus_relay_chain::BuildRelayChainConsensusParams {
para_id: id, para_id,
proposer_factory, proposer_factory,
block_import: client.clone(), block_import,
relay_chain_interface: relay_chain_interface.clone(), relay_chain_interface: relay_chain_interface.clone(),
create_inherent_data_providers: create_inherent_data_providers:
move |_, (relay_parent, validation_data)| { move |_, (relay_parent, validation_data)| {
@@ -1268,7 +1203,7 @@ where
relay_parent, relay_parent,
&relay_chain_interface, &relay_chain_interface,
&validation_data, &validation_data,
id, para_id,
).await; ).await;
let parachain_inherent = let parachain_inherent =
parachain_inherent.ok_or_else(|| { parachain_inherent.ok_or_else(|| {
@@ -1301,61 +1236,45 @@ async fn start_contracts_rococo_node_impl<RuntimeApi, RB, BIQ, BIC>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
id: ParaId, para_id: ParaId,
_rpc_ext_builder: RB, _rpc_ext_builder: RB,
build_import_queue: BIQ, build_import_queue: BIQ,
build_consensus: BIC, build_consensus: BIC,
hwbench: Option<sc_sysinfo::HwBench>, hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient<RuntimeApi>>)>
TaskManager,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
)>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>> RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
+ Send
+ Sync
+ 'static,
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
+ sp_api::Metadata<Block> + sp_api::Metadata<Block>
+ sp_session::SessionKeys<Block> + sp_session::SessionKeys<Block>
+ sp_api::ApiExt< + sp_api::ApiExt<
Block, Block,
StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>, StateBackend = sc_client_api::StateBackendFor<ParachainBackend, Block>,
> + sp_offchain::OffchainWorkerApi<Block> > + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block> + sp_block_builder::BlockBuilder<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block> + cumulus_primitives_core::CollectCollationInfo<Block>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance> + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>, + frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<ParachainBackend, Block>: sp_api::StateBackend<BlakeTwo256>,
RB: Fn( RB: Fn(Arc<ParachainClient<RuntimeApi>>) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>,
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>
+ Send
+ 'static,
BIQ: FnOnce( BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>, Arc<ParachainClient<RuntimeApi>>,
&Configuration, ParachainBlockImport<RuntimeApi>,
Option<TelemetryHandle>, &Configuration,
&TaskManager, Option<TelemetryHandle>,
) -> Result< &TaskManager,
sc_consensus::DefaultImportQueue< ) -> Result<
Block, sc_consensus::DefaultImportQueue<Block, ParachainClient<RuntimeApi>>,
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>, sc_service::Error,
>, >,
sc_service::Error,
> + 'static,
BIC: FnOnce( BIC: FnOnce(
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>, Arc<ParachainClient<RuntimeApi>>,
ParachainBlockImport<RuntimeApi>,
Option<&Registry>, Option<&Registry>,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
Arc<dyn RelayChainInterface>, Arc<dyn RelayChainInterface>,
Arc< Arc<sc_transaction_pool::FullPool<Block, ParachainClient<RuntimeApi>>>,
sc_transaction_pool::FullPool<
Block,
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
>,
>,
Arc<NetworkService<Block, Hash>>, Arc<NetworkService<Block, Hash>>,
SyncCryptoStorePtr, SyncCryptoStorePtr,
bool, bool,
@@ -1364,7 +1283,7 @@ where
let parachain_config = prepare_node_config(parachain_config); let parachain_config = prepare_node_config(parachain_config);
let params = new_partial::<RuntimeApi, BIQ>(&parachain_config, build_import_queue)?; let params = new_partial::<RuntimeApi, BIQ>(&parachain_config, build_import_queue)?;
let (mut telemetry, telemetry_worker_handle) = params.other; let (block_import, mut telemetry, telemetry_worker_handle) = params.other;
let client = params.client.clone(); let client = params.client.clone();
let backend = params.backend.clone(); let backend = params.backend.clone();
@@ -1384,7 +1303,8 @@ where
s => s.to_string().into(), s => s.to_string().into(),
})?; })?;
let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id); let block_announce_validator =
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
let force_authoring = parachain_config.force_authoring; let force_authoring = parachain_config.force_authoring;
let validator = parachain_config.role.is_authority(); let validator = parachain_config.role.is_authority();
@@ -1456,6 +1376,7 @@ where
if validator { if validator {
let parachain_consensus = build_consensus( let parachain_consensus = build_consensus(
client.clone(), client.clone(),
block_import,
prometheus_registry.as_ref(), prometheus_registry.as_ref(),
telemetry.as_ref().map(|t| t.handle()), telemetry.as_ref().map(|t| t.handle()),
&task_manager, &task_manager,
@@ -1469,7 +1390,7 @@ where
let spawner = task_manager.spawn_handle(); let spawner = task_manager.spawn_handle();
let params = StartCollatorParams { let params = StartCollatorParams {
para_id: id, para_id,
block_status: client.clone(), block_status: client.clone(),
announce_block, announce_block,
client: client.clone(), client: client.clone(),
@@ -1488,11 +1409,10 @@ where
client: client.clone(), client: client.clone(),
announce_block, announce_block,
task_manager: &mut task_manager, task_manager: &mut task_manager,
para_id: id, para_id,
relay_chain_interface, relay_chain_interface,
relay_chain_slot_duration, relay_chain_slot_duration,
import_queue, import_queue,
collator_options,
}; };
start_full_node(params)?; start_full_node(params)?;
@@ -1505,17 +1425,13 @@ where
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
pub fn contracts_rococo_build_import_queue( pub fn contracts_rococo_build_import_queue(
client: Arc< client: Arc<ParachainClient<contracts_rococo_runtime::RuntimeApi>>,
TFullClient<Block, contracts_rococo_runtime::RuntimeApi, WasmExecutor<HostFunctions>>, block_import: ParachainBlockImport<contracts_rococo_runtime::RuntimeApi>,
>,
config: &Configuration, config: &Configuration,
telemetry: Option<TelemetryHandle>, telemetry: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<Block, ParachainClient<contracts_rococo_runtime::RuntimeApi>>,
Block,
TFullClient<Block, contracts_rococo_runtime::RuntimeApi, WasmExecutor<HostFunctions>>,
>,
sc_service::Error, sc_service::Error,
> { > {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
@@ -1528,7 +1444,7 @@ pub fn contracts_rococo_build_import_queue(
_, _,
_, _,
>(cumulus_client_consensus_aura::ImportQueueParams { >(cumulus_client_consensus_aura::ImportQueueParams {
block_import: client.clone(), block_import,
client, client,
create_inherent_data_providers: move |_, _| async move { create_inherent_data_providers: move |_, _| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
@@ -1553,20 +1469,21 @@ pub async fn start_contracts_rococo_node(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
collator_options: CollatorOptions, collator_options: CollatorOptions,
id: ParaId, para_id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>, hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc<TFullClient<Block, contracts_rococo_runtime::RuntimeApi, WasmExecutor<HostFunctions>>>, Arc<ParachainClient<contracts_rococo_runtime::RuntimeApi>>,
)> { )> {
start_contracts_rococo_node_impl::<contracts_rococo_runtime::RuntimeApi, _, _, _>( start_contracts_rococo_node_impl::<contracts_rococo_runtime::RuntimeApi, _, _, _>(
parachain_config, parachain_config,
polkadot_config, polkadot_config,
collator_options, collator_options,
id, para_id,
|_| Ok(RpcModule::new(())), |_| Ok(RpcModule::new(())),
contracts_rococo_build_import_queue, contracts_rococo_build_import_queue,
|client, |client,
block_import,
prometheus_registry, prometheus_registry,
telemetry, telemetry,
task_manager, task_manager,
@@ -1596,7 +1513,7 @@ pub async fn start_contracts_rococo_node(
relay_parent, relay_parent,
&relay_chain_interface, &relay_chain_interface,
&validation_data, &validation_data,
id, para_id,
).await; ).await;
let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
@@ -1616,7 +1533,7 @@ pub async fn start_contracts_rococo_node(
Ok((slot, timestamp, parachain_inherent)) Ok((slot, timestamp, parachain_inherent))
} }
}, },
block_import: client.clone(), block_import,
para_client: client, para_client: client,
backoff_authoring_blocks: Option::<()>::None, backoff_authoring_blocks: Option::<()>::None,
sync_oracle, sync_oracle,
+3 -3
View File
@@ -5,10 +5,10 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021" edition = "2021"
[dependencies] [dependencies]
async-trait = { version = "0.1.57", optional = true } async-trait = { version = "0.1.58", optional = true }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ "derive" ] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ "derive" ] }
scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } scale-info = { version = "2.3.0", default-features = false, features = ["derive"] }
tracing = { version = "0.1.36", optional = true } tracing = { version = "0.1.37", optional = true }
# Substrate # Substrate
sc-client-api = { git = "https://github.com/paritytech/substrate", optional = true, branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", optional = true, branch = "master" }
+2 -3
View File
@@ -20,7 +20,6 @@ use cumulus_primitives_core::{
relay_chain, InboundDownwardMessage, InboundHrmpMessage, ParaId, PersistedValidationData, relay_chain, InboundDownwardMessage, InboundHrmpMessage, ParaId, PersistedValidationData,
}; };
use sc_client_api::{Backend, StorageProvider}; use sc_client_api::{Backend, StorageProvider};
use sp_api::BlockId;
use sp_core::twox_128; use sp_core::twox_128;
use sp_inherents::{InherentData, InherentDataProvider}; use sp_inherents::{InherentData, InherentDataProvider};
use sp_runtime::traits::Block; use sp_runtime::traits::Block;
@@ -116,7 +115,7 @@ impl MockXcmConfig {
) -> Self { ) -> Self {
let starting_dmq_mqc_head = client let starting_dmq_mqc_head = client
.storage( .storage(
&BlockId::Hash(parent_block), &parent_block,
&sp_storage::StorageKey( &sp_storage::StorageKey(
[twox_128(&parachain_system_name.0), twox_128(b"LastDmqMqcHead")] [twox_128(&parachain_system_name.0), twox_128(b"LastDmqMqcHead")]
.concat() .concat()
@@ -131,7 +130,7 @@ impl MockXcmConfig {
let starting_hrmp_mqc_heads = client let starting_hrmp_mqc_heads = client
.storage( .storage(
&BlockId::Hash(parent_block), &parent_block,
&sp_storage::StorageKey( &sp_storage::StorageKey(
[twox_128(&parachain_system_name.0), twox_128(b"LastHrmpMqcHeads")] [twox_128(&parachain_system_name.0), twox_128(b"LastHrmpMqcHeads")]
.concat() .concat()

Some files were not shown because too many files have changed in this diff Show More