diff --git a/.github/actions/README.md b/.github/actions/README.md index 5f841416ea..6619940bed 100644 --- a/.github/actions/README.md +++ b/.github/actions/README.md @@ -1,49 +1,5 @@ This directory gathers useful actions for Github pipelines. -## `restore-cache` -This action restores and saves cache dedicated for Rust builds -(in particular we keep Cargo files, target directories and make use of sccache). - -### Usage -Sample usage: -```yaml -steps: -- uses: Cardinal-Cryptography/github-actions/restore-cache@cache-v1 - -- run: cargo build - -- uses: Cardinal-Cryptography/github-actions/post-cache@v1 -``` - -For building packages excluded from main workspace, you can add corresponding input parameter: -```yaml -steps: -- uses: Cardinal-Cryptography/github-actions/restore-cache@cache-v1 - with: - cargo-targets: | - excluded_package_1/target/ - aux_tool/excluded_package_2/target/ -``` - -### Notes - -**Note:** Currently we only support runners using `ubuntu:latest` image. - -**Note:** Requires calling `post-cache` action to stop sccache server. - -**Note:** There is a problem with using `cargo clippy` with `sccache` - check: https://github.com/mozilla/sccache/issues/966. -Effectively, you have to override environment variables like this: -```shell -export RUSTC_WRAPPER="" -export RUSTC_WORKSPACE_WRAPPER=sccache -cargo clippy -``` - ---- - -## `post-cache` -Stops sccache server. Use together with `restore-cache`. - --- ## `run-e2e-test` diff --git a/.github/actions/cleanup-workspace/action.yml b/.github/actions/cleanup-workspace/action.yml index 45f042703d..d10b82f770 100644 --- a/.github/actions/cleanup-workspace/action.yml +++ b/.github/actions/cleanup-workspace/action.yml @@ -1,3 +1,4 @@ +--- name: Clean runner workspace description: Removes all the files from the runner working directory diff --git a/.github/actions/destroy-feature-environment/action.yml b/.github/actions/destroy-feature-environment/action.yml index 5f6e3a915c..5b20972934 100644 --- a/.github/actions/destroy-feature-environment/action.yml +++ b/.github/actions/destroy-feature-environment/action.yml @@ -1,3 +1,4 @@ +--- name: 'Destroy Feature Environment' description: 'Action used for feature environment deletion' @@ -19,9 +20,6 @@ outputs: deployment-name: description: 'Output with a deployment name for working with deployments' value: ${{ steps.get_branch.outputs.branch_name }} - - - runs: using: "composite" steps: @@ -75,15 +73,19 @@ runs: ARGOCD_URL: argocd.dev.azero.dev run: | ## Install argocd CLI tool - curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/download/v2.3.3/argocd-linux-amd64 + curl -sSL -o argocd \ + https://github.com/argoproj/argo-cd/releases/download/v2.3.3/argocd-linux-amd64 chmod +x argocd && mv argocd /usr/local/bin/ - /usr/local/bin/argocd app get fe-root-application --hard-refresh --auth-token ${{ inputs.argo-sync-user-token }} --server ${{ env.ARGOCD_URL }} - /usr/local/bin/argocd app wait fe-root-application --auth-token ${{ inputs.argo-sync-user-token }} --server ${{ env.ARGOCD_URL }} + /usr/local/bin/argocd app get fe-root-application --hard-refresh \ + --auth-token ${{ inputs.argo-sync-user-token }} --server ${{ env.ARGOCD_URL }} + /usr/local/bin/argocd app wait fe-root-application --auth-token \ + ${{ inputs.argo-sync-user-token }} --server ${{ env.ARGOCD_URL }} - name: Clean S3 storage shell: bash env: BRANCH_NAME: ${{ steps.get_branch.outputs.branch_name }} run: | - aws s3 rm --recursive s3://fe-alephzero-devnet-eu-central-1-keys-bucket/fe-${{ env.BRANCH_NAME }} \ No newline at end of file + aws s3 rm --recursive \ + s3://fe-alephzero-devnet-eu-central-1-keys-bucket/fe-${{ env.BRANCH_NAME }} diff --git a/.github/actions/get-branch/action.yaml b/.github/actions/get-branch/action.yaml index 5d1d8b38dc..e679aa5b7a 100644 --- a/.github/actions/get-branch/action.yaml +++ b/.github/actions/get-branch/action.yaml @@ -1,3 +1,4 @@ +--- name: Get branch details description: Gets branch name and commit SHA @@ -25,5 +26,6 @@ runs: HEAD_REF: ${{ github.head_ref || github.ref }} run: | echo "##[set-output name=branch_name;]$(echo ${HEAD_REF#refs/heads/} | tr / -)" - echo "##[set-output name=branch_appname;]$(printf ${HEAD_REF#refs/heads/} | tr / - | tr '[:upper:]' '[:lower:]' | tr -c '[a-z0-9-.]' '-')" + echo "##[set-output name=branch_appname;]$(printf ${HEAD_REF#refs/heads/} \ + | tr / - | tr '[:upper:]' '[:lower:]' | tr -c '[a-z0-9-.]' '-')" echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" diff --git a/.github/actions/post-cache/action.yml b/.github/actions/post-cache/action.yml deleted file mode 100644 index b615bcc82b..0000000000 --- a/.github/actions/post-cache/action.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: "Rust cache cleanup" -description: | - Run this at the end of your workflow if you're running `rust-cache`. - -runs: - using: "composite" - steps: - - name: Prune unused packages from cargo cache - uses: actions-rs/cargo@v1 - with: - command: cache - args: clean-unref - - - name: Prune sources from cargo cache - uses: actions-rs/cargo@v1 - with: - command: cache - args: --autoclean - - - name: Stop sccache server - run: sccache --stop-server || true - shell: bash diff --git a/.github/actions/restore-cache/action.yml b/.github/actions/restore-cache/action.yml deleted file mode 100644 index 9141c8c93f..0000000000 --- a/.github/actions/restore-cache/action.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: "Restore rust cache" -description: | - Restore/save rust caches. - - This action combines 3 caches: - - 1. The ~/.cargo cache - 2. The ./target cache - 3. The sccache cache along with starting the sccache server - - All caches are keyed with cache-version along with a hash of all Cargo.lock files in the project. As a fallback they - take the newest cache with any hash of Cargo.lock files to rebuild from a partial cache in case of a Cargo.lock change. - -inputs: - cache-version: - description: "String indicating the version of the caches, change it to clean caches." - required: false - default: "v1" - target-key: - description: > - If you have multiple workflows that generate different contents of the target directory, then you can set this key - differently for them, so that they don't interfere with each other. - required: false - default: "" - cargo-key: - description: > - If you have multiple workflows that generate different contents of the ~/.cargo directory, then you can set this key - differently for them, so that they don't interfere with each other. - required: false - default: "" - sccache-version: - description: "Version number of sccache to use." - required: false - default: v0.3.0 - sccache-size: - description: "Size specifier for scache's cache" - required: false - default: "1G" - cargo-targets: - description: "Additional directories to include in the target cache" - required: false - default: "" - -runs: - using: "composite" - - steps: - - name: Restore cargo cache - uses: actions/cache@v3 - env: - SEGMENT_DOWNLOAD_TIMEOUT_MIN: "10" - with: - path: | - ~/.cargo - key: ${{ runner.os }}-cargo-${{ inputs.cargo-key }}-${{ inputs.cache-version }}-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-${{ inputs.cargo-key }}-${{ inputs.cache-version }} - - - name: Restore target cache - uses: actions/cache@v3 - with: - path: | - target - ${{ inputs.cargo-targets }} - key: ${{ runner.os }}-target-${{ inputs.target-key }}-${{ inputs.cache-version }}-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-target-${{ inputs.target-key }}-${{ inputs.cache-version }} - - - name: Install sccache for ubuntu-20.04 - shell: bash - run: | - LINK=https://github.com/mozilla/sccache/releases/download - SCCACHE_FILE=sccache-${{ inputs.sccache-version }}-x86_64-unknown-linux-musl - - mkdir -p $HOME/.local/bin - curl -L "$LINK/${{ inputs.sccache-version }}/$SCCACHE_FILE.tar.gz" | tar xz - mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache - chmod +x $HOME/.local/bin/sccache - - echo "$HOME/.local/bin" >> $GITHUB_PATH - - - name: Restore sccache - uses: actions/cache@v3 - with: - path: /home/runner/.cache/sccache - key: ${{ runner.os }}-sccache-${{ inputs.target-key }}-${{ inputs.cache-version }}-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-sccache-${{ inputs.target-key }}-${{ inputs.cache-version }} - - - name: Start sccache server - env: - SCCACHE_CACHE_SIZE: ${{ inputs.sccache-size }} - shell: bash - run: sccache --start-server - - - name: Set RUSTC_WRAPPER - shell: bash - run: | - echo "RUSTC_WRAPPER=$HOME/.local/bin/sccache" >> $GITHUB_ENV - - - name: Install cargo-cache - uses: actions-rs/cargo@v1 - with: - command: install - args: cargo-cache diff --git a/.github/actions/run-e2e-test/action.yml b/.github/actions/run-e2e-test/action.yml index 751acaadc7..f157b1efb3 100644 --- a/.github/actions/run-e2e-test/action.yml +++ b/.github/actions/run-e2e-test/action.yml @@ -1,3 +1,4 @@ +--- name: 'Run e2e test' description: 'Run single e2e test.' @@ -62,7 +63,11 @@ runs: - name: Run consensus party shell: bash - run: NODE_IMAGE=${{ inputs.node-image }} DOCKER_COMPOSE=${{ inputs.compose-file }} ./.github/scripts/run_consensus.sh -m ${{ inputs.min-validator-count }} -n ${{ inputs.node-count }} + run: | + NODE_IMAGE=${{ inputs.node-image }} \ + DOCKER_COMPOSE=${{ inputs.compose-file }} \ + ./.github/scripts/run_consensus.sh \ + -m ${{ inputs.min-validator-count }} -n ${{ inputs.node-count }} - name: Sleep shell: bash @@ -95,7 +100,7 @@ runs: RESERVED_SEATS="${{ inputs.reserved-seats }}" NON_RESERVED_SEATS="${{ inputs.non-reserved-seats }}" - + if [[ -n "${RANDOMIZED}" ]]; then ARGS+=(-r "${RANDOMIZED}") fi @@ -128,4 +133,6 @@ runs: - name: Run finalization e2e test if: inputs.follow-up-finalization-check == 'true' shell: bash - run: ./.github/scripts/run_e2e_test.sh -t finalization::finalization -m "${{ inputs.min-validator-count }}" + run: | + ./.github/scripts/run_e2e_test.sh \ + -t finalization::finalization -m "${{ inputs.min-validator-count }}" diff --git a/.github/actions/slack-notification/action.yml b/.github/actions/slack-notification/action.yml index bd4bc072a8..d87ef6aca4 100644 --- a/.github/actions/slack-notification/action.yml +++ b/.github/actions/slack-notification/action.yml @@ -1,6 +1,8 @@ +--- name: 'Send Slack notifiction' -description: 'Action used to send Slack notifications about workflow status in channel specified in SLACK_WEBHOOK' - +description: | + Action used to send Slack notifications about workflow status in channel specified in + SLACK_WEBHOOK inputs: notify-on: description: "Choose when Slack messages should be sent" diff --git a/.github/scripts/docker-compose.no_quorum_without_old.override.yml b/.github/scripts/docker-compose.no_quorum_without_old.override.yml index 47369bd581..7cf2e29ca1 100644 --- a/.github/scripts/docker-compose.no_quorum_without_old.override.yml +++ b/.github/scripts/docker-compose.no_quorum_without_old.override.yml @@ -1,3 +1,4 @@ +--- services: Node0: environment: diff --git a/.github/workflows/build-and-push-cliain.yaml b/.github/workflows/build-and-push-cliain.yaml index 5e05a604b3..9930c59a4a 100644 --- a/.github/workflows/build-and-push-cliain.yaml +++ b/.github/workflows/build-and-push-cliain.yaml @@ -1,9 +1,11 @@ +--- name: Build and push cliain docker image on: push: paths: - 'bin/cliain/**' + - .github/workflows/build-and-push-cliain.yaml workflow_dispatch: jobs: @@ -47,7 +49,9 @@ jobs: - name: Build and push latest docker image id: build-image env: - RELEASE_IMAGE: public.ecr.aws/p6e8q1z1/cliain:${{ steps.get_branch.outputs.branch_name == 'main' && 'latest' || steps.get_branch.outputs.branch_name }} + RELEASE_IMAGE: > + public.ecr.aws/p6e8q1z1/cliain:${{ steps.get_branch.outputs.branch_name == 'main' + && 'latest' || steps.get_branch.outputs.branch_name }} uses: docker/build-push-action@v2 with: context: ./bin/cliain diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml index af24cdbdef..2a864d2e99 100644 --- a/.github/workflows/build-docs.yaml +++ b/.github/workflows/build-docs.yaml @@ -1,8 +1,12 @@ +--- # this workflow builds rustdoc for aleph-node crates name: build-docs on: - push: + pull_request: + paths: + - 'aleph-client/**' + - .github/workflows/build-docs.yaml jobs: build-aleph-client-docs: diff --git a/.github/workflows/build-node-and-runtime.yml b/.github/workflows/build-node-and-runtime.yml index 52de31dd48..b6fb4a383f 100644 --- a/.github/workflows/build-node-and-runtime.yml +++ b/.github/workflows/build-node-and-runtime.yml @@ -1,3 +1,4 @@ +--- name: Build aleph-node and aleph-runtime on: @@ -61,7 +62,9 @@ jobs: - name: S3 CI MAINNET | Configure AWS credentials - if: env.SECRETS_AWS_MAINNET_ACCESS_KEY_ID != '' && env.SECRETS_AWS_MAINNET_SECRET_ACCESS_KEY != '' + if: > + env.SECRETS_AWS_MAINNET_ACCESS_KEY_ID != '' && + env.SECRETS_AWS_MAINNET_SECRET_ACCESS_KEY != '' uses: aws-actions/configure-aws-credentials@v1 env: AWS_ACCESS_KEY_ID: "" @@ -75,11 +78,14 @@ jobs: aws-region: ${{ env.AWS_REGION }} - name: S3 CI MAINNET | Copy release binary to S3 bucket - if: env.SECRETS_AWS_MAINNET_ACCESS_KEY_ID != '' && env.SECRETS_AWS_MAINNET_SECRET_ACCESS_KEY != '' + if: > + env.SECRETS_AWS_MAINNET_ACCESS_KEY_ID != '' && + env.SECRETS_AWS_MAINNET_SECRET_ACCESS_KEY != '' shell: bash env: BINARY_DIR: target/production BINARY_FILE: aleph-node + # yamllint disable-line rule:line-length S3BUCKET_URL: s3://${{ secrets.CI_MAINNET_S3BUCKET_NAME }}/builds/aleph-node/commits/${{ steps.get_branch.outputs.sha_short }}/aleph-node S3BUCKET_FILE: aleph-node-${{ steps.get_branch.outputs.sha_short }}.tar.gz run: | @@ -87,11 +93,14 @@ jobs: aws s3 cp ${{ env.S3BUCKET_FILE }} ${{ env.S3BUCKET_URL }}/${{ env.S3BUCKET_FILE }} - name: S3 CI MAINNET | Copy release runtime to S3 bucket - if: env.SECRETS_AWS_MAINNET_ACCESS_KEY_ID != '' && env.SECRETS_AWS_MAINNET_SECRET_ACCESS_KEY != '' + if: > + env.SECRETS_AWS_MAINNET_ACCESS_KEY_ID != '' && + env.SECRETS_AWS_MAINNET_SECRET_ACCESS_KEY != '' shell: bash env: BINARY_DIR: target/production/wbuild/aleph-runtime BINARY_FILE: aleph_runtime.compact.wasm + # yamllint disable-line rule:line-length S3BUCKET_URL: s3://${{ secrets.CI_MAINNET_S3BUCKET_NAME }}/builds/aleph-node/commits/${{ steps.get_branch.outputs.sha_short }}/aleph-runtime S3BUCKET_FILE: aleph-runtime-${{ steps.get_branch.outputs.sha_short }}.tar.gz run: | @@ -100,7 +109,9 @@ jobs: - name: Build test binary - run: cargo build --release -p aleph-node --features "short_session enable_treasury_proposals only_legacy" + run: | + cargo build --release -p aleph-node \ + --features "short_session enable_treasury_proposals only_legacy" - name: Upload test binary uses: actions/upload-artifact@v2 @@ -119,11 +130,14 @@ jobs: retention-days: 7 - name: S3 CI MAINNET | Copy test binary to S3 bucket - if: env.SECRETS_AWS_MAINNET_ACCESS_KEY_ID != '' && env.SECRETS_AWS_MAINNET_SECRET_ACCESS_KEY != '' + if: > + env.SECRETS_AWS_MAINNET_ACCESS_KEY_ID != '' && + env.SECRETS_AWS_MAINNET_SECRET_ACCESS_KEY != '' shell: bash env: BINARY_DIR: target/release BINARY_FILE: aleph-node + # yamllint disable-line rule:line-length S3BUCKET_URL: s3://${{ secrets.CI_MAINNET_S3BUCKET_NAME }}/builds/aleph-node/commits/${{ steps.get_branch.outputs.sha_short }}/aleph-test-node S3BUCKET_FILE: aleph-test-node-${{ steps.get_branch.outputs.sha_short }}.tar.gz run: | @@ -131,11 +145,14 @@ jobs: aws s3 cp ${{ env.S3BUCKET_FILE }} ${{ env.S3BUCKET_URL }}/${{ env.S3BUCKET_FILE }} - name: S3 CI MAINNET | Copy test runtime to S3 bucket - if: env.SECRETS_AWS_MAINNET_ACCESS_KEY_ID != '' && env.SECRETS_AWS_MAINNET_SECRET_ACCESS_KEY != '' + if: > + env.SECRETS_AWS_MAINNET_ACCESS_KEY_ID != '' && + env.SECRETS_AWS_MAINNET_SECRET_ACCESS_KEY != '' shell: bash env: BINARY_DIR: target/release/wbuild/aleph-runtime BINARY_FILE: aleph_runtime.compact.wasm + # yamllint disable-line rule:line-length S3BUCKET_URL: s3://${{ secrets.CI_MAINNET_S3BUCKET_NAME }}/builds/aleph-node/commits/${{ steps.get_branch.outputs.sha_short }}/aleph-test-runtime S3BUCKET_FILE: aleph-test-runtime-${{ steps.get_branch.outputs.sha_short }}.tar.gz run: | diff --git a/.github/workflows/build-send-postsync-hook-runtime-image.yml b/.github/workflows/build-send-postsync-hook-runtime-image.yml index e2253bb80d..f17132dfbc 100644 --- a/.github/workflows/build-send-postsync-hook-runtime-image.yml +++ b/.github/workflows/build-send-postsync-hook-runtime-image.yml @@ -1,3 +1,4 @@ +--- name: Build, send and deploy postsync hook image. on: @@ -8,6 +9,7 @@ on: paths: - 'bin/cliain/**' - 'docker-runtime-hook/**' + - .github/workflows/build-send-postsync-hook-runtime-image.yml concurrency: group: ${{ github.ref }}-${{ github.workflow }} @@ -47,7 +49,8 @@ jobs: - name: Build runtime-update-hook run: | - docker build -f docker-runtime-hook/Dockerfile . -t runtime-update-hook:${{ steps.vars.outputs.sha_short }} + docker build -f docker-runtime-hook/Dockerfile . \ + -t runtime-update-hook:${{ steps.vars.outputs.sha_short }} - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 @@ -69,7 +72,8 @@ jobs: - name: Push postsync hook current Image to Public ECR env: CURRENT_IMAGE: runtime-update-hook:${{ steps.vars.outputs.sha_short }} - ECR_PUSH_IMAGE: public.ecr.aws/p6e8q1z1/runtime-update-hook:${{ steps.vars.outputs.sha_short }} + ECR_PUSH_IMAGE: + public.ecr.aws/p6e8q1z1/runtime-update-hook:${{ steps.vars.outputs.sha_short }} ECR_LATEST: public.ecr.aws/p6e8q1z1/runtime-update-hook:latest run: | docker tag ${{ env.CURRENT_IMAGE }} ${{ env.ECR_PUSH_IMAGE }} @@ -92,7 +96,8 @@ jobs: - name: Update postsync hook docker image env: - RELEASE_IMAGE: public.ecr.aws/p6e8q1z1/runtime-update-hook:${{ steps.vars.outputs.sha_short }} + RELEASE_IMAGE: + public.ecr.aws/p6e8q1z1/runtime-update-hook:${{ steps.vars.outputs.sha_short }} REGIONS_AWS: 'eu-central-1' run: | # Deploy new image version for postsync hook diff --git a/.github/workflows/check-excluded-packages.yml b/.github/workflows/check-excluded-packages.yml index 40de1f91c8..1ab9af9739 100644 --- a/.github/workflows/check-excluded-packages.yml +++ b/.github/workflows/check-excluded-packages.yml @@ -1,14 +1,19 @@ +--- name: Check excluded packages on: pull_request: - branches: - - '**' - push: - paths-ignore: - - '*.md' - branches: - - main + paths: + - 'flooder/**' + - 'e2e-tests/**' + - 'aleph-client/**' + - 'fork-off/**' + - 'bin/cliain/**' + - 'benches/**' + - 'contracts/**' + # TODO this package needs to be moved to /bin + - 'scripts/synthetic-network/synthetic-link/**' + - .github/workflows/check-excluded-packages.yml concurrency: group: ${{ github.ref }}-${{ github.workflow }} diff --git a/.github/workflows/contracts-deploy.yml b/.github/workflows/contracts-deploy.yml index d43988de97..c7f87e6cb8 100644 --- a/.github/workflows/contracts-deploy.yml +++ b/.github/workflows/contracts-deploy.yml @@ -1,3 +1,4 @@ +--- name: contracts-e2e-tests-and-deploy on: @@ -17,7 +18,11 @@ env: jobs: build_and_deploy_contracts: name: Deploy contracts on feature environment - if: (github.event_name == 'push' && github.ref_name == 'benjamin') || (github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == '[AZERO] DEPLOY-CONTRACTS') + if: > + (github.event_name == 'push' && github.ref_name == 'benjamin') || + (github.event_name == 'pull_request' && + github.event.action == 'labeled' && + github.event.label.name == '[AZERO] DEPLOY-CONTRACTS') runs-on: ubuntu-20.04 steps: - name: Checkout repo @@ -26,7 +31,8 @@ jobs: - name: Check if environment is reachable shell: bash run: | - source contracts/env/${{ env.CONTRACTS_ENVFILE }} && HOSTPORT=${NODE/wss:\/\//} && nc -zvw5 ${HOSTPORT/:*/} ${HOSTPORT/*:/} + source contracts/env/${{ env.CONTRACTS_ENVFILE }} && \ + HOSTPORT=${NODE/wss:\/\//} && nc -zvw5 ${HOSTPORT/:*/} ${HOSTPORT/*:/} - name: Get branch name and commit SHA id: get_branch @@ -50,11 +56,14 @@ jobs: - name: Install binaryen shell: bash + # yamllint disable rule:line-length run: | - wget https://github.com/WebAssembly/binaryen/releases/download/version_110/binaryen-version_110-x86_64-linux.tar.gz -O /tmp/binaryen-version_110-x86_64-linux.tar.gz + wget https://github.com/WebAssembly/binaryen/releases/download/version_110/binaryen-version_110-x86_64-linux.tar.gz \ + -O /tmp/binaryen-version_110-x86_64-linux.tar.gz tar -zxvf /tmp/binaryen-version_110-x86_64-linux.tar.gz -C /tmp sudo chmod +x /tmp/binaryen-version_110/bin/* sudo cp -rf /tmp/binaryen-version_110/* /usr/ + # yamllint enable rule:line-length - name: Install node uses: actions/setup-node@v3 @@ -98,8 +107,10 @@ jobs: - name: Copy addresses.json file from S3 bucket shell: bash + # yamllint disable rule:line-length run: | aws s3 cp s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/addresses.json contracts/addresses.json + # yamllint enable rule:line-length - name: Copy metadata.json files from S3 bucket shell: bash @@ -107,7 +118,8 @@ jobs: DOWNLOAD_TMP_DIR: downloaded_metadata run: | mkdir -p $DOWNLOAD_TMP_DIR - aws s3 sync --exclude '*' --include '*metadata.json' s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/ ./$DOWNLOAD_TMP_DIR/ + aws s3 sync --exclude '*' --include '*metadata.json' \ + s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/ ./$DOWNLOAD_TMP_DIR/ for i in `find $DOWNLOAD_TMP_DIR -name "metadata.json" | awk -F/ '{print $2}'`; do \ mkdir -p contracts/$i/target/ink; \ cp $DOWNLOAD_TMP_DIR/$i/metadata.json contracts/$i/target/ink/metadata.json; \ @@ -128,25 +140,30 @@ jobs: - name: Copy metadata.json and addresses.json files onto S3 bucket shell: bash run: | - aws s3 cp contracts/addresses.json s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/addresses.json + aws s3 cp contracts/addresses.json \ + s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/addresses.json for i in `find contracts -name "metadata.json" | awk -F/ '{print $2}'`; do \ - aws s3 cp contracts/"$i"/target/ink/metadata.json s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/"$i"/metadata.json; \ + aws s3 cp contracts/"$i"/target/ink/metadata.json \ + s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/"$i"/metadata.json; \ done echo -n "${{ steps.get_branch.outputs.sha_short }}" > commit_sha.txt - aws s3 cp commit_sha.txt s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/commit_sha.txt + aws s3 cp commit_sha.txt \ + s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/commit_sha.txt source contracts/env/${{ env.CONTRACTS_ENVFILE }} && echo -n "$NODE" > env_NODE.txt - aws s3 cp env_NODE.txt s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/env_NODE.txt + aws s3 cp env_NODE.txt \ + s3://${{ secrets.CI_S3BUCKET_NAME }}/${{ env.S3BUCKET_PATH }}/env_NODE.txt - name: Rename metadata and addresses JSON files to artifact upload shell: bash run: | cp contracts/addresses.json addresses.${{ env.CONTRACTS_ENVFILE }}.json for i in `find contracts -name "metadata.json" | awk -F/ '{print $2}'`; do \ - cp contracts/"$i"/target/ink/metadata.json metadata_"$i".${{ env.CONTRACTS_ENVFILE }}.json; \ + cp contracts/"$i"/target/ink/metadata.json \ + metadata_"$i".${{ env.CONTRACTS_ENVFILE }}.json; \ done - name: Upload artifact with contract addresses @@ -167,7 +184,9 @@ jobs: - name: Remove deploy label if present uses: actions-ecosystem/action-remove-labels@v1.3.0 - if: github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, '[AZERO] DEPLOY-CONTRACTS') + if: > + github.event_name == 'pull_request' && + contains( github.event.pull_request.labels.*.name, '[AZERO] DEPLOY-CONTRACTS') with: labels: '[AZERO] DEPLOY-CONTRACTS' github_token: ${{ secrets.CI_GH_TOKEN }} diff --git a/.github/workflows/deploy-feature-envs.yaml b/.github/workflows/deploy-feature-envs.yaml index 88248c76a3..16d05eea50 100644 --- a/.github/workflows/deploy-feature-envs.yaml +++ b/.github/workflows/deploy-feature-envs.yaml @@ -1,3 +1,4 @@ +--- name: Deploy Feature Environment on: @@ -28,13 +29,17 @@ env: jobs: ## After that job run, artefact with aleph-node is created with name: aleph-release-node build_aleph_node_binary: - if: (github.event.label.name == '[AZERO] DEPLOY-FEATURE-ENV') || (github.event.label.name == '[AZERO] DEPLOY-HOT-FEATURE-ENV') + if: > + (github.event.label.name == '[AZERO] DEPLOY-FEATURE-ENV') || + (github.event.label.name == '[AZERO] DEPLOY-HOT-FEATURE-ENV') name: Build runtime and aleph-node binary artefacts uses: ./.github/workflows/build-node-and-runtime.yml secrets: inherit push_pr_image: - if: (github.event.label.name == '[AZERO] DEPLOY-FEATURE-ENV') || (github.event.label.name == '[AZERO] DEPLOY-HOT-FEATURE-ENV') + if: > + (github.event.label.name == '[AZERO] DEPLOY-FEATURE-ENV') || + (github.event.label.name == '[AZERO] DEPLOY-HOT-FEATURE-ENV') needs: [build_aleph_node_binary] name: Build, prepare and push aleph-node image from PR to ECR runs-on: ubuntu-20.04 @@ -54,12 +59,14 @@ jobs: - name: Build docker image with PR aleph-node binary env: - IMAGE_TAG: ${{ env.FE_IMAGETAG_PREFIX }}${{ steps.get_branch.outputs.branch_imagetag_full }} + IMAGE_TAG: + ${{ env.FE_IMAGETAG_PREFIX }}${{ steps.get_branch.outputs.branch_imagetag_full }} run: | chmod +x target/release/aleph-node ls -alh target/release/ ls -alh ./docker/ - docker build --tag ${{ env.FE_ALEPHNODE_REGISTRY }}:${{ env.IMAGE_TAG }} -f ./docker/Dockerfile . + docker build --tag ${{ env.FE_ALEPHNODE_REGISTRY }}:${{ env.IMAGE_TAG }} \ + -f ./docker/Dockerfile . - name: Login to ECR uses: docker/login-action@v1 @@ -70,13 +77,16 @@ jobs: - name: Push FE aleph-node image to the feature-env-aleph-node registry env: - IMAGE_TAG: ${{ env.FE_IMAGETAG_PREFIX }}${{ steps.get_branch.outputs.branch_imagetag_full }} + IMAGE_TAG: + ${{ env.FE_IMAGETAG_PREFIX }}${{ steps.get_branch.outputs.branch_imagetag_full }} run: | docker push ${{ env.FE_ALEPHNODE_REGISTRY }}:${{ env.IMAGE_TAG }} deploy_feature_env: - if: (github.event.label.name == '[AZERO] DEPLOY-FEATURE-ENV') || (github.event.label.name == '[AZERO] DEPLOY-HOT-FEATURE-ENV') + if: > + (github.event.label.name == '[AZERO] DEPLOY-FEATURE-ENV') || + (github.event.label.name == '[AZERO] DEPLOY-HOT-FEATURE-ENV') name: Deploy feature environment based on the PR runs-on: ubuntu-20.04 outputs: @@ -132,8 +142,11 @@ jobs: env: BRANCH_NAME: ${{ steps.get_branch.outputs.branch_name }} CHAIN_ID: a0fenet + # yamllint disable rule:line-length run: | - COMMIT_ID=$(curl -s -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_version"}' ${{ env.RPC_TESTNET_URL }} | jq -r '.result' | cut -d "-" -f 2 | head -c 7) + COMMIT_ID=$(curl -s -H "Content-Type: application/json" \ + -d '{"id":1, "jsonrpc":"2.0", "method": "system_version"}' ${{ env.RPC_TESTNET_URL }} \ + | jq -r '.result' | cut -d "-" -f 2 | head -c 7) echo $COMMIT_ID TESTNET_IMAGE="${{ env.PUBLIC_ALEPHNODE_REGISTRY }}:$COMMIT_ID" @@ -141,29 +154,43 @@ jobs: aws s3 cp s3://${{ env.FE_KEYS_S3BUCKET }}/data data --recursive # rename validator paths - declare -A NAMES=([aleph-node-validator-0]=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY [aleph-node-validator-1]=5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty [aleph-node-validator-2]=5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y [aleph-node-validator-3]=5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy [aleph-node-validator-4]=5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw) + declare -A \ + NAMES=([aleph-node-validator-0]=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \ + [aleph-node-validator-1]=5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty \ + [aleph-node-validator-2]=5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y \ + [aleph-node-validator-3]=5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy \ + [aleph-node-validator-4]=5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw) for NAME in "${!NAMES[@]}"; do mv -v data/$NAME data/${NAMES[$NAME]} done # Generate chainspec skeleton, it will reuse keys from the synced keystore - docker run -v $(pwd)/data:/data --env RUST_BACKTRACE=1 --entrypoint "/usr/local/bin/aleph-node" $TESTNET_IMAGE bootstrap-chain --raw --base-path /data --chain-id $CHAIN_ID --account-ids 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy,5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw --sudo-account-id 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY --faucet-account-id 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY > chainspec.json - - # Generate chainspec from skeleton - # docker run -v $(pwd):/app --env RUST_LOG=info ${{ env.FORKOFF_IMAGE }} --ws-rpc-endpoint=${{ env.WSS_TESTNET_URL }} --initial-spec-path=chainspec.skeleton.json --combined-spec-path=chainspec.json - #--storage-keep-state=Aura,Aleph,Sudo,Staking,Session,Elections,Balances - - aws s3 cp chainspec.json s3://${{ env.FE_KEYS_S3BUCKET }}/${{ env.FE_KEYS_S3PATH_PREFIX }}${{ env.BRANCH_NAME }}/chainspec.json - aws s3 cp s3://${{ env.FE_KEYS_S3BUCKET }}/data/ s3://${{ env.FE_KEYS_S3BUCKET }}/${{ env.FE_KEYS_S3PATH_PREFIX }}${{ env.BRANCH_NAME }}/data/ --recursive + docker run -v $(pwd)/data:/data --env RUST_BACKTRACE=1 \ + --entrypoint "/usr/local/bin/aleph-node" $TESTNET_IMAGE bootstrap-chain --raw \ + --base-path /data --chain-id $CHAIN_ID \ + --account-ids 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy,5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw \ + --sudo-account-id 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \ + --faucet-account-id 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY > chainspec.json + + aws s3 cp chainspec.json \ + s3://${{ env.FE_KEYS_S3BUCKET }}/${{ env.FE_KEYS_S3PATH_PREFIX }}${{ env.BRANCH_NAME }}/chainspec.json + aws s3 cp \ + s3://${{ env.FE_KEYS_S3BUCKET }}/data/ \ + s3://${{ env.FE_KEYS_S3BUCKET }}/${{ env.FE_KEYS_S3PATH_PREFIX }}${{ env.BRANCH_NAME }}/data/ \ + --recursive + # yamllint enable rule:line-length - name: Build chainspec for Hotnet FE and send it to S3 if: contains( github.event.pull_request.labels.*.name, env.LABEL_DEPLOY_HOT) env: BRANCH_NAME: ${{ steps.get_branch.outputs.branch_name }} CHAIN_ID: a0fenet + # yamllint disable rule:line-length run: | - SYSTEM_VERSION=$(curl -s -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_version"}' ${{ env.RPC_MAINNET_URL }} | jq -r '.result') + SYSTEM_VERSION=$(curl -s -H "Content-Type: application/json" \ + -d '{"id":1, "jsonrpc":"2.0", "method": "system_version"}' ${{ env.RPC_MAINNET_URL }} \ + | jq -r '.result') SUFFIX="-x86_64-linux-gnu" LONG_COMMIT_ID=${SYSTEM_VERSION/%$SUFFIX} COMMIT_ID=${LONG_COMMIT_ID: -7} @@ -174,21 +201,34 @@ jobs: aws s3 cp s3://${{ env.FE_KEYS_S3BUCKET }}/data data --recursive # rename validator paths - declare -A NAMES=([aleph-node-validator-0]=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY [aleph-node-validator-1]=5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty [aleph-node-validator-2]=5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y [aleph-node-validator-3]=5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy [aleph-node-validator-4]=5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw) + declare -A \ + NAMES=([aleph-node-validator-0]=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY \ + [aleph-node-validator-1]=5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty \ + [aleph-node-validator-2]=5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y \ + [aleph-node-validator-3]=5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy \ + [aleph-node-validator-4]=5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw) for NAME in "${!NAMES[@]}"; do mv -v data/$NAME data/${NAMES[$NAME]} done # Generate chainspec skeleton, it will reuse keys from the synced keystore - docker run -v $(pwd)/data:/data --env RUST_BACKTRACE=1 --entrypoint "/usr/local/bin/aleph-node" $MAINNET_IMAGE bootstrap-chain --raw --base-path /data --chain-id $CHAIN_ID --account-ids 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy,5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw --sudo-account-id 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY > chainspec.json + docker run -v $(pwd)/data:/data --env RUST_BACKTRACE=1 \ + --entrypoint "/usr/local/bin/aleph-node" $MAINNET_IMAGE bootstrap-chain --raw \ + --base-path /data --chain-id $CHAIN_ID \ + --account-ids 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY,5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty,5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y,5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy,5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw \ + --sudo-account-id 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY > chainspec.json # Generate chainspec from skeleton # docker run -v $(pwd):/app --env RUST_LOG=info ${{ env.FORKOFF_IMAGE }} --ws-rpc-endpoint=${{ env.RPC_MAINNET_URL }} --initial-spec-path=chainspec.skeleton.json --combined-spec-path=chainspec.json - - aws s3 cp chainspec.json s3://${{ env.FE_KEYS_S3BUCKET }}/${{ env.FE_KEYS_S3PATH_PREFIX }}${{ env.BRANCH_NAME }}/chainspec.json - aws s3 cp s3://${{ env.FE_KEYS_S3BUCKET }}/data/ s3://${{ env.FE_KEYS_S3BUCKET }}/${{ env.FE_KEYS_S3PATH_PREFIX }}${{ env.BRANCH_NAME }}/data/ --recursive - + aws s3 cp \ + chainspec.json \ + s3://${{ env.FE_KEYS_S3BUCKET }}/${{ env.FE_KEYS_S3PATH_PREFIX }}${{ env.BRANCH_NAME }}/chainspec.json + aws s3 cp \ + s3://${{ env.FE_KEYS_S3BUCKET }}/data/ \ + s3://${{ env.FE_KEYS_S3BUCKET }}/${{ env.FE_KEYS_S3PATH_PREFIX }}${{ env.BRANCH_NAME }}/data/ \ + --recursive + # yamllint enable rule:line-length - name: GIT | Checkout aleph-apps repo uses: actions/checkout@master @@ -207,19 +247,35 @@ jobs: CREATE_HOOK: false run: | # Set up envs - COMMIT_ID=$(curl -s -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_version"}' ${{ env.RPC_TESTNET_URL }} | jq -r '.result' | cut -d "-" -f 2 | head -c 7) + COMMIT_ID=$(curl -s -H "Content-Type: application/json" \ + -d '{"id":1, "jsonrpc":"2.0", "method": "system_version"}' ${{ env.RPC_TESTNET_URL }} \ + | jq -r '.result' | cut -d "-" -f 2 | head -c 7) TESTNET_IMAGE="${{ env.PUBLIC_ALEPHNODE_REGISTRY_ESCAPED }}:$COMMIT_ID" ALEPH_PATH=$(pwd) # Create application manifest from template - sed "s/APP_NAME/${{ env.APP_NAME }}/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/app-template/app-template.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/APP_NAME/${{ env.APP_NAME }}/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/app-template/app-template.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - sed "s/CREATE_HOOK/${{ env.CREATE_HOOK }}/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/CREATE_HOOK/${{ env.CREATE_HOOK }}/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && \ + mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - sed "s/NAMESPACE/${{ env.NAMESPACE }}/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/NAMESPACE/${{ env.NAMESPACE }}/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && \ + mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - sed "s/NODE_IMAGE/$TESTNET_IMAGE/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/NODE_IMAGE/$TESTNET_IMAGE/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && \ + mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - name: Start mainnet image on feature environment if: contains( github.event.pull_request.labels.*.name, env.LABEL_DEPLOY_HOT) @@ -230,7 +286,9 @@ jobs: CREATE_HOOK: false run: | # Set up envs - SYSTEM_VERSION=$(curl -s -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_version"}' ${{ env.RPC_MAINNET_URL }} | jq -r '.result') + SYSTEM_VERSION=$(curl -s -H "Content-Type: application/json" \ + -d '{"id":1, "jsonrpc":"2.0", "method": "system_version"}' ${{ env.RPC_MAINNET_URL }} | \ + jq -r '.result') SUFFIX="-x86_64-linux-gnu" LONG_COMMIT_ID=${SYSTEM_VERSION/%$SUFFIX} COMMIT_ID=${LONG_COMMIT_ID: -7} @@ -239,13 +297,27 @@ jobs: # Create application manifest from template - sed "s/APP_NAME/${{ env.APP_NAME }}/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/app-template/app-template.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/APP_NAME/${{ env.APP_NAME }}/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/app-template/app-template.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - sed "s/CREATE_HOOK/${{ env.CREATE_HOOK }}/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/CREATE_HOOK/${{ env.CREATE_HOOK }}/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && \ + mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - sed "s/NAMESPACE/${{ env.NAMESPACE }}/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/NAMESPACE/${{ env.NAMESPACE }}/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && \ + mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - sed "s/NODE_IMAGE/$MAINNET_IMAGE/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/NODE_IMAGE/$MAINNET_IMAGE/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && \ + mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - name: GIT | Commit changes to aleph-apps repository. uses: EndBug/add-and-commit@v5.1.0 @@ -266,15 +338,19 @@ jobs: ARGOCD_URL: argocd.dev.azero.dev run: | ## Install argocd CLI tool - curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/download/v2.3.3/argocd-linux-amd64 + curl -sSL -o argocd \ + https://github.com/argoproj/argo-cd/releases/download/v2.3.3/argocd-linux-amd64 chmod +x argocd && mv argocd /usr/local/bin/ ## Sync argo to start deployment - /usr/local/bin/argocd app get fe-root-application --hard-refresh --auth-token ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} + /usr/local/bin/argocd app get fe-root-application --hard-refresh --auth-token \ + ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} ## Wait for the app to be deployed - /usr/local/bin/argocd app wait fe-root-application --auth-token ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} - /usr/local/bin/argocd app wait ${{ env.APP_NAME }} --auth-token ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} + /usr/local/bin/argocd app wait fe-root-application --auth-token \ + ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} + /usr/local/bin/argocd app wait ${{ env.APP_NAME }} --auth-token \ + ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} - name: Wait for the testnet aleph-node binary to accept some blocks uses: juliangruber/sleep-action@v1.0.1 @@ -282,8 +358,10 @@ jobs: time: 5m update_feature_env_image: - if: (github.event.label.name == '[AZERO] DEPLOY-FEATURE-ENV') || (github.event.label.name == '[AZERO] DEPLOY-HOT-FEATURE-ENV') - needs: [push_pr_image,deploy_feature_env] + if: > + (github.event.label.name == '[AZERO] DEPLOY-FEATURE-ENV') || + (github.event.label.name == '[AZERO] DEPLOY-HOT-FEATURE-ENV') + needs: [push_pr_image, deploy_feature_env] name: Update feature environment to the latest PR aleph-node image runs-on: ubuntu-20.04 steps: @@ -304,7 +382,8 @@ jobs: - name: Update feature environment to the latest PR image env: - IMAGE_TAG: ${{ env.FE_IMAGETAG_PREFIX }}${{ steps.get_branch.outputs.branch_imagetag_full }} + IMAGE_TAG: + ${{ env.FE_IMAGETAG_PREFIX }}${{ steps.get_branch.outputs.branch_imagetag_full }} APP_NAME: ${{ env.FE_APP_PREFIX }}${{ steps.get_branch.outputs.branch_appname }} ARGOCD_URL: argocd.dev.azero.dev NAMESPACE: ${{ env.FE_APP_PREFIX }}${{ steps.get_branch.outputs.branch_appname }} @@ -314,24 +393,41 @@ jobs: PR_IMAGE="${{ env.FE_ALEPHNODE_REGISTRY_ESCAPED }}\:${{ env.IMAGE_TAG }}" ALEPH_PATH=$(pwd) - sed "s/APP_NAME/${{ env.APP_NAME }}/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/app-template/app-template.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/APP_NAME/${{ env.APP_NAME }}/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/app-template/app-template.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - sed "s/CREATE_HOOK/${{ env.CREATE_HOOK }}/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/CREATE_HOOK/${{ env.CREATE_HOOK }}/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && \ + mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - sed "s/NAMESPACE/${{ env.NAMESPACE }}/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/NAMESPACE/${{ env.NAMESPACE }}/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && \ + mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - sed "s/NODE_IMAGE/$PR_IMAGE/g" $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml + sed "s/NODE_IMAGE/$PR_IMAGE/g" \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml > \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp && \ + mv $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml.temp \ + $ALEPH_PATH/aleph-apps/argocd/overlays/devnet/fe-apps/${{ env.APP_NAME }}.yaml - name: GIT | Commit changes to aleph-apps repository. uses: EndBug/add-and-commit@v5.1.0 env: - IMAGE_TAG: ${{ env.FE_IMAGETAG_PREFIX }}${{ steps.get_branch.outputs.branch_imagetag_full }} + IMAGE_TAG: + ${{ env.FE_IMAGETAG_PREFIX }}${{ steps.get_branch.outputs.branch_imagetag_full }} APP_NAME: ${{ env.FE_APP_PREFIX }}${{ steps.get_branch.outputs.branch_appname }} GITHUB_TOKEN: ${{ secrets.CI_GH_TOKEN }} with: author_name: AlephZero Automation author_email: alephzero@10clouds.com - message: "Image changed for the feature environment to: ${{ env.FE_ALEPHNODE_REGISTRY }}:${{ env.IMAGE_TAG }}" + message: + "Image changed for the feature environment to: + ${{ env.FE_ALEPHNODE_REGISTRY }}:${{ env.IMAGE_TAG }}" add: "*.yaml" cwd: "aleph-apps" branch: main @@ -342,15 +438,19 @@ jobs: ARGOCD_URL: argocd.dev.azero.dev run: | ## Install argocd CLI tool - curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/download/v2.3.3/argocd-linux-amd64 + curl -sSL -o argocd \ + https://github.com/argoproj/argo-cd/releases/download/v2.3.3/argocd-linux-amd64 chmod +x argocd && mv argocd /usr/local/bin/ ## Sync argo to start deployment - /usr/local/bin/argocd app get fe-root-application --hard-refresh --auth-token ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} + /usr/local/bin/argocd app get fe-root-application --hard-refresh \ + --auth-token ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} ## Wait for the app to be deployed - /usr/local/bin/argocd app wait fe-root-application --auth-token ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} - /usr/local/bin/argocd app wait ${{ env.APP_NAME }} --auth-token ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} + /usr/local/bin/argocd app wait fe-root-application \ + --auth-token ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} + /usr/local/bin/argocd app wait ${{ env.APP_NAME }} \ + --auth-token ${{ secrets.ARGO_SYNC_USER_TOKEN }} --server ${{ env.ARGOCD_URL }} - name: Remove testnet deployment request label if exists if: contains( github.event.pull_request.labels.*.name, env.LABEL_DEPLOY) @@ -388,6 +488,7 @@ jobs: status: ${{ job.status }} env: ${{ steps.get_branch.outputs.branch_name }} deployment_id: ${{ needs.deploy_feature_env.outputs.deployment-id }} + # yamllint disable-line rule:line-length env_url: https://dev.azero.dev/?rpc=wss%3A%2F%2Fws-${{ env.FE_APP_PREFIX }}${{ steps.get_branch.outputs.branch_appname }}.dev.azero.dev#/explorer ref: ${{ github.head_ref }} @@ -450,7 +551,10 @@ jobs: environment: ${{ steps.delete_fe.outputs.deployment-name }} destroy_feature_env_on_close: - if: (github.event.action == 'closed' && !contains( github.event.pull_request.labels.*.name, 'DESTROYED') && contains( github.event.pull_request.labels.*.name, 'DEPLOYED')) + if: > + github.event.action == 'closed' && + !contains(github.event.pull_request.labels.*.name, 'DESTROYED') && + contains(github.event.pull_request.labels.*.name, 'DEPLOYED') name: Destroy feature env when PR closed runs-on: ubuntu-20.04 steps: diff --git a/.github/workflows/deploy-mainnet.yml b/.github/workflows/deploy-mainnet.yml index b984fb29d6..fcca47550f 100644 --- a/.github/workflows/deploy-mainnet.yml +++ b/.github/workflows/deploy-mainnet.yml @@ -1,3 +1,4 @@ +--- name: Deploy to Mainnet on: @@ -13,7 +14,7 @@ jobs: runs-on: ubuntu-20.04 environment: 'mainnet' env: - AWS_REGION: us-east-1 # this region is used by all public ECR repos + AWS_REGION: us-east-1 # this region is used by all public ECR repos steps: - name: GIT | Checkout uses: actions/checkout@v2 @@ -62,7 +63,8 @@ jobs: - name: Tag and push image of Mainnet to DockerHub env: MAINNET_IMAGE: public.ecr.aws/p6e8q1z1/aleph-node:${{ steps.vars.outputs.branch }} - DOCKERHUB_MAINNET_IMAGE: cardinalcryptography/aleph-zero:mainnet-${{ steps.vars.outputs.branch }} + DOCKERHUB_MAINNET_IMAGE: + cardinalcryptography/aleph-zero:mainnet-${{ steps.vars.outputs.branch }} DOCKERHUB_MAINNET_LATEST_IMAGE: cardinalcryptography/aleph-zero:mainnet-latest run: | echo "FROM ${{ env.MAINNET_IMAGE }}" > Dockerfile.dockerhub @@ -84,6 +86,7 @@ jobs: - name: S3 CI | Download release runtime from S3 bucket shell: bash env: + # yamllint disable-line rule:line-length S3BUCKET_URL: s3://${{ secrets.CI_MAINNET_S3BUCKET_NAME }}/builds/aleph-node/commits/${{ steps.vars.outputs.sha_short }}/aleph-runtime S3BUCKET_FILE: aleph-runtime-${{ steps.vars.outputs.sha_short }}.tar.gz run: | @@ -119,11 +122,13 @@ jobs: for i in "${region_array[@]}"; do # Deploy new image version for archivist cd ${aleph_path}/aleph-apps/aleph-node-archivists/overlays/mainnet/${i} - kustomize edit set image "aleph-node-archivist-image-placeholder=${{ env.MAINNET_IMAGE }}" + kustomize edit set image \ + "aleph-node-archivist-image-placeholder=${{ env.MAINNET_IMAGE }}" # Deploy new image version for validator cd ${aleph_path}/aleph-apps/aleph-node-validators/overlays/mainnet/${i} - kustomize edit set image "aleph-node-validator-image-placeholder=${{ env.MAINNET_IMAGE }}" + kustomize edit set image \ + "aleph-node-validator-image-placeholder=${{ env.MAINNET_IMAGE }}" done - name: GIT | Commit changes to aleph-apps repository. diff --git a/.github/workflows/deploy-testnet.yml b/.github/workflows/deploy-testnet.yml index 8c3a740c70..eb152991e2 100644 --- a/.github/workflows/deploy-testnet.yml +++ b/.github/workflows/deploy-testnet.yml @@ -1,3 +1,4 @@ +--- name: Deploy to Testnet on: @@ -11,10 +12,10 @@ jobs: deploy-testnet: name: Deploy new aleph-node image to Testnet EKS runs-on: ubuntu-20.04 - environment: + environment: name: testnet env: - AWS_REGION: us-east-1 # this region is used by all public ECR repos + AWS_REGION: us-east-1 # this region is used by all public ECR repos steps: - name: GIT | Checkout uses: actions/checkout@v2 @@ -46,10 +47,12 @@ jobs: DEVNET_IMAGE: public.ecr.aws/p6e8q1z1/aleph-node:${{ steps.vars.outputs.sha_short }} TESTNET_IMAGE: public.ecr.aws/p6e8q1z1/aleph-node:${{ steps.vars.outputs.branch }} run: | - export image_not_exist=$(docker manifest inspect ${{ env.DEVNET_IMAGE }} &> /dev/null ; echo $?) + export image_not_exist=$(docker manifest inspect ${{ env.DEVNET_IMAGE }} \ + &> /dev/null ; echo $?) if [ $image_not_exist -eq 1 ]; then - echo "::error title=Wrong docker image tag::Docker image ${{ env.DEVNET_IMAGE }} doesn't exist" + echo "::error title=Wrong docker image tag::Docker image ${{ env.DEVNET_IMAGE }} \ + doesn't exist" exit 1 else docker pull ${{ env.DEVNET_IMAGE }} @@ -67,7 +70,8 @@ jobs: - name: Tag and push image of Testnet to DockerHub env: TESTNET_IMAGE: public.ecr.aws/p6e8q1z1/aleph-node:${{ steps.vars.outputs.branch }} - DOCKERHUB_TESTNET_IMAGE: cardinalcryptography/aleph-zero:testnet-${{ steps.vars.outputs.branch }} + DOCKERHUB_TESTNET_IMAGE: + cardinalcryptography/aleph-zero:testnet-${{ steps.vars.outputs.branch }} DOCKERHUB_TESTNET_LATEST_IMAGE: cardinalcryptography/aleph-zero:testnet-latest run: | echo "FROM ${{ env.TESTNET_IMAGE }}" > Dockerfile.dockerhub @@ -80,6 +84,7 @@ jobs: - name: S3 CI | Download release runtime from S3 bucket shell: bash env: + # yamllint disable-line rule:line-length S3BUCKET_URL: s3://${{ secrets.CI_MAINNET_S3BUCKET_NAME }}/builds/aleph-node/commits/${{ steps.vars.outputs.sha_short }}/aleph-runtime S3BUCKET_FILE: aleph-runtime-${{ steps.vars.outputs.sha_short }}.tar.gz run: | @@ -115,11 +120,13 @@ jobs: for i in "${region_array[@]}"; do # Deploy new image version for archivist cd ${aleph_path}/aleph-apps/aleph-node-archivists/overlays/testnet/${i} - kustomize edit set image "aleph-node-archivist-image-placeholder=${{ env.TESTNET_IMAGE }}" + kustomize edit set image \ + "aleph-node-archivist-image-placeholder=${{ env.TESTNET_IMAGE }}" # Deploy new image version for validator cd ${aleph_path}/aleph-apps/aleph-node-validators/overlays/testnet/${i} - kustomize edit set image "aleph-node-validator-image-placeholder=${{ env.TESTNET_IMAGE }}" + kustomize edit set image \ + "aleph-node-validator-image-placeholder=${{ env.TESTNET_IMAGE }}" done - name: GIT | Commit changes to aleph-apps repository. @@ -127,7 +134,8 @@ jobs: with: author_name: AlephZero Automation author_email: alephzero@10clouds.com - message: "Updating Testnet docker image tag for pre-release: ${{ steps.vars.outputs.branch }}" + message: + "Updating Testnet docker image tag for pre-release: ${{ steps.vars.outputs.branch }}" add: "*.yaml" cwd: "aleph-apps" branch: testnet diff --git a/.github/workflows/deploy-to-devnet.yml b/.github/workflows/deploy-to-devnet.yml index 9687480835..6938f7833e 100644 --- a/.github/workflows/deploy-to-devnet.yml +++ b/.github/workflows/deploy-to-devnet.yml @@ -1,3 +1,4 @@ +--- name: Deploy to Devnet # This workflow performs automatic deployment of aleph-node to the Devnet environment @@ -59,7 +60,17 @@ jobs: #!/bin/bash aws s3 cp s3://alephzero-devnet-eu-central-1-keys-bucket/data data --recursive # rename validator paths - declare -A NAMES=([aleph-node-validator-0]=5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH [aleph-node-validator-1]=5GBNeWRhZc2jXu7D55rBimKYDk8PGk8itRYFTPfC8RJLKG5o [aleph-node-validator-2]=5Dfis6XL8J2P6JHUnUtArnFWndn62SydeP8ee8sG2ky9nfm9 [aleph-node-validator-3]=5F4H97f7nQovyrbiq4ZetaaviNwThSVcFobcA5aGab6167dK [aleph-node-validator-4]=5DiDShBWa1fQx6gLzpf3SFBhMinCoyvHM1BWjPNsmXS8hkrW [aleph-node-validator-5]=5EFb84yH9tpcFuiKUcsmdoF7xeeY3ajG1ZLQimxQoFt9HMKR [aleph-node-validator-6]=5DZLHESsfGrJ5YzT3HuRPXsSNb589xQ4Unubh1mYLodzKdVY [aleph-node-validator-7]=5GHJzqvG6tXnngCpG7B12qjUvbo5e4e9z8Xjidk3CQZHxTPZ [aleph-node-validator-8]=5CUnSsgAyLND3bxxnfNhgWXSe9Wn676JzLpGLgyJv858qhoX [aleph-node-validator-9]=5CVKn7HAZW1Ky4r7Vkgsr7VEW88C2sHgUNDiwHY9Ct2hjU8q) + declare -A \ + NAMES=([aleph-node-validator-0]=5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH \ + [aleph-node-validator-1]=5GBNeWRhZc2jXu7D55rBimKYDk8PGk8itRYFTPfC8RJLKG5o \ + [aleph-node-validator-2]=5Dfis6XL8J2P6JHUnUtArnFWndn62SydeP8ee8sG2ky9nfm9 \ + [aleph-node-validator-3]=5F4H97f7nQovyrbiq4ZetaaviNwThSVcFobcA5aGab6167dK \ + [aleph-node-validator-4]=5DiDShBWa1fQx6gLzpf3SFBhMinCoyvHM1BWjPNsmXS8hkrW \ + [aleph-node-validator-5]=5EFb84yH9tpcFuiKUcsmdoF7xeeY3ajG1ZLQimxQoFt9HMKR \ + [aleph-node-validator-6]=5DZLHESsfGrJ5YzT3HuRPXsSNb589xQ4Unubh1mYLodzKdVY \ + [aleph-node-validator-7]=5GHJzqvG6tXnngCpG7B12qjUvbo5e4e9z8Xjidk3CQZHxTPZ \ + [aleph-node-validator-8]=5CUnSsgAyLND3bxxnfNhgWXSe9Wn676JzLpGLgyJv858qhoX \ + [aleph-node-validator-9]=5CVKn7HAZW1Ky4r7Vkgsr7VEW88C2sHgUNDiwHY9Ct2hjU8q) for NAME in "${!NAMES[@]}"; do mv -v data/$NAME data/${NAMES[$NAME]} done @@ -68,11 +79,17 @@ jobs: env: RELEASE_TAG: ${{ steps.vars.outputs.sha_short }} + # yamllint disable rule:line-length run: | #!/bin/bash aws s3 cp s3://alephzero-devnet-eu-central-1-keys-bucket/data data --recursive - docker run -i -v $(pwd)/data:/data --env RUST_BACKTRACE=1 --entrypoint "/usr/local/bin/aleph-node" public.ecr.aws/p6e8q1z1/aleph-node:${RELEASE_TAG} bootstrap-chain --raw --base-path /data --chain-id a0dnet1 --account-ids 5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH,5GBNeWRhZc2jXu7D55rBimKYDk8PGk8itRYFTPfC8RJLKG5o,5Dfis6XL8J2P6JHUnUtArnFWndn62SydeP8ee8sG2ky9nfm9,5F4H97f7nQovyrbiq4ZetaaviNwThSVcFobcA5aGab6167dK,5DiDShBWa1fQx6gLzpf3SFBhMinCoyvHM1BWjPNsmXS8hkrW,5EFb84yH9tpcFuiKUcsmdoF7xeeY3ajG1ZLQimxQoFt9HMKR,5DZLHESsfGrJ5YzT3HuRPXsSNb589xQ4Unubh1mYLodzKdVY,5GHJzqvG6tXnngCpG7B12qjUvbo5e4e9z8Xjidk3CQZHxTPZ,5CUnSsgAyLND3bxxnfNhgWXSe9Wn676JzLpGLgyJv858qhoX,5CVKn7HAZW1Ky4r7Vkgsr7VEW88C2sHgUNDiwHY9Ct2hjU8q --sudo-account-id 5F4SvwaUEQubiqkPF8YnRfcN77cLsT2DfG4vFeQmSXNjR7hD > chainspec.json + docker run -i -v $(pwd)/data:/data --env RUST_BACKTRACE=1 --entrypoint \ + "/usr/local/bin/aleph-node" public.ecr.aws/p6e8q1z1/aleph-node:${RELEASE_TAG} \ + bootstrap-chain --raw --base-path /data --chain-id a0dnet1 \ + --account-ids 5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH,5GBNeWRhZc2jXu7D55rBimKYDk8PGk8itRYFTPfC8RJLKG5o,5Dfis6XL8J2P6JHUnUtArnFWndn62SydeP8ee8sG2ky9nfm9,5F4H97f7nQovyrbiq4ZetaaviNwThSVcFobcA5aGab6167dK,5DiDShBWa1fQx6gLzpf3SFBhMinCoyvHM1BWjPNsmXS8hkrW,5EFb84yH9tpcFuiKUcsmdoF7xeeY3ajG1ZLQimxQoFt9HMKR,5DZLHESsfGrJ5YzT3HuRPXsSNb589xQ4Unubh1mYLodzKdVY,5GHJzqvG6tXnngCpG7B12qjUvbo5e4e9z8Xjidk3CQZHxTPZ,5CUnSsgAyLND3bxxnfNhgWXSe9Wn676JzLpGLgyJv858qhoX,5CVKn7HAZW1Ky4r7Vkgsr7VEW88C2sHgUNDiwHY9Ct2hjU8q \ + --sudo-account-id 5F4SvwaUEQubiqkPF8YnRfcN77cLsT2DfG4vFeQmSXNjR7hD > chainspec.json aws s3 cp chainspec.json s3://alephzero-devnet-eu-central-1-keys-bucket/chainspec.json + # yamllint enable rule:line-length - name: Stop and purge db Devnet run: | @@ -89,7 +106,8 @@ jobs: #!/bin/bash cd aleph-apps/aleph-node-validators/overlays/devnet/eu-central-1 - kustomize edit set image "aleph-node-validator-image-placeholder=public.ecr.aws/p6e8q1z1/aleph-node:${RELEASE_TAG}" + kustomize edit set image \ + "aleph-node-validator-image-placeholder=public.ecr.aws/p6e8q1z1/aleph-node:${RELEASE_TAG}" kustomize build . | kubectl apply -f - sleep 2 kubectl rollout status --watch --timeout=3600s statefulset/aleph-node-validator -n devnet diff --git a/.github/workflows/e2e-tests-main-devnet.yml b/.github/workflows/e2e-tests-main-devnet.yml index a1d2565562..ca289ed9a4 100644 --- a/.github/workflows/e2e-tests-main-devnet.yml +++ b/.github/workflows/e2e-tests-main-devnet.yml @@ -1,20 +1,23 @@ +--- name: e2e-tests-main-devnet on: pull_request: paths-ignore: - - '*.md' + - 'fork-off/**' + - 'flooder/**' branches: - benjamin - main - - "release-*" + - 'release-*' push: paths-ignore: - - '*.md' + - 'fork-off/**' + - 'flooder/**' branches: - benjamin - main - - "release-*" + - 'release-*' workflow_dispatch: concurrency: @@ -137,7 +140,8 @@ jobs: run: | cd e2e-tests/ rm -f target/release/deps/aleph_e2e_client* - cp $(cargo test --no-run --release --message-format=json | jq -r .executable | grep aleph_e2e_client) target/release/aleph-e2e-client + cp $(cargo test --no-run --release --message-format=json | jq -r .executable | \ + grep aleph_e2e_client) target/release/aleph-e2e-client docker build --tag aleph-e2e-client:latest -f Dockerfile . docker save -o aleph-e2e-client.tar aleph-e2e-client:latest @@ -153,7 +157,8 @@ jobs: needs: [build-test-docker] name: Checks if runtime file in aleph-client is up-to-date # disabling this check as it causes troubles - # this should be reworked to sth like https://github.com/paritytech/subxt/blob/master/examples/examples/metadata_compatibility.rs + # this should be reworked to sth like + # https://github.com/paritytech/subxt/blob/master/examples/examples/metadata_compatibility.rs if: false runs-on: ubuntu-20.04 steps: @@ -170,7 +175,9 @@ jobs: run: | cd aleph-client docker pull public.ecr.aws/p6e8q1z1/subxt-client-integration:latest - docker run --rm --network host --mount type=bind,source="$(pwd)/..",target=/subxt/aleph-node public.ecr.aws/p6e8q1z1/subxt-client-integration:latest + docker run --rm --network host \ + --mount type=bind,source="$(pwd)/..",target=/subxt/aleph-node \ + public.ecr.aws/p6e8q1z1/subxt-client-integration:latest run-e2e-finalization-test: needs: [build-test-docker, build-test-client] @@ -493,7 +500,7 @@ jobs: timeout-minutes: 15 run-e2e-permissionless-ban: - needs: [ build-test-docker, build-test-client ] + needs: [build-test-docker, build-test-client] name: Run permissionless ban test runs-on: ubuntu-20.04 steps: @@ -555,87 +562,6 @@ jobs: test-case: button timeout-minutes: 60 -# The tests below were written under the assumption that nonfinalized blocks are being produced, they need a rewrite before being reenabled. -# TODO(A0-1644): Reenable these tests. -# run-e2e-failing-version-upgrade: -# needs: [build-test-docker, build-test-client] -# name: Run basic (failing) version-upgrade test -# runs-on: ubuntu-20.04 -# steps: -# - name: Checkout source code -# uses: actions/checkout@v2 -# -# - name: Run e2e test -# uses: ./.github/actions/run-e2e-test -# with: -# test-case: doomed_version_upgrade -# env: -# OVERRIDE_DOCKER_COMPOSE: ./.github/scripts/docker-compose.no_quorum_without_old.override.yml -# UPGRADE_VERSION: 1 -# UPGRADE_SESSION: 3 -# UPGRADE_FINALIZATION_WAIT_SESSIONS: 2 -# ONLY_LEGACY: true -# timeout-minutes: 10 -# run-e2e-version-upgrade-catchup: -# needs: [build-test-docker, build-cliain-image] -# name: Run series of tests where some of the nodes need to do version-upgrade during catch-up -# runs-on: ubuntu-20.04 -# strategy: -# matrix: -# include: -# - nodes: "Node1" -# ports: "9934" -# ext_status: "finalized" -# upgrade_before_disable: "true" -# -# - nodes: "Node1" -# ports: "9934" -# ext_status: "finalized" -# upgrade_before_disable: "false" -# -# - nodes: "Node1:Node2" -# ports: "9934:9935" -# ext_status: "in-block" -# upgrade_before_disable: "true" -# -# - nodes: "Node1:Node2" -# ports: "9934:9935" -# ext_status: "in-block" -# upgrade_before_disable: "false" -# steps: -# - name: Checkout source code -# uses: actions/checkout@v2 -# -# - name: Download artifact with docker image for aleph-node -# uses: actions/download-artifact@v2 -# with: -# name: aleph-test-docker -# -# - name: Load node docker image -# shell: bash -# run: docker load -i aleph-node.tar -# -# - name: Download artifact with docker image for cliain -# uses: actions/download-artifact@v2 -# with: -# name: cliain-docker -# -# - name: Load cliain docker image -# shell: bash -# run: docker load -i cliain.tar -# -# - name: Call catchup_test.sh -# timeout-minutes: 10 -# env: -# UPGRADE_BLOCK: 31 -# NODES: ${{ matrix.nodes }} -# PORTS: ${{ matrix.ports }} -# EXT_STATUS: ${{ matrix.ext_status }} -# UPGRADE_BEFORE_DISABLE: ${{ matrix.upgrade_before_disable }} -# DOCKER_COMPOSE: docker/docker-compose.bridged.yml -# run: | -# ./scripts/catchup_version_upgrade_test.sh - run-e2e-finality-version-change: needs: [build-test-docker, build-test-client] name: Run finality version change test @@ -658,7 +584,6 @@ jobs: secrets: inherit check-e2e-test-suite-completion: -# run-e2e-authorities-are-staking, # run-e2e-failing-version-upgrade, # run-e2e-version-upgrade-catchup, needs: [ @@ -692,8 +617,8 @@ jobs: name: Check e2e test suite completion runs-on: ubuntu-20.04 steps: - - name: All e2e tests completed - run: echo "All e2e tests completed." + - name: All e2e tests completed + run: echo "All e2e tests completed." push-image: needs: [check-e2e-test-suite-completion] @@ -746,7 +671,8 @@ jobs: CURRENT_IMAGE: aleph-node ECR_PUSH_IMAGE: public.ecr.aws/p6e8q1z1/aleph-node run: | - docker tag ${{ env.CURRENT_IMAGE }} ${{ env.ECR_PUSH_IMAGE }}:${{ steps.vars.outputs.sha_short }} + docker tag ${{ env.CURRENT_IMAGE }} \ + ${{ env.ECR_PUSH_IMAGE }}:${{ steps.vars.outputs.sha_short }} docker tag ${{ env.CURRENT_IMAGE }} ${{ env.ECR_PUSH_IMAGE }}:latest docker push ${{ env.ECR_PUSH_IMAGE }}:${{ steps.vars.outputs.sha_short }} docker push ${{ env.ECR_PUSH_IMAGE }}:latest @@ -832,7 +758,7 @@ jobs: build-new-runtime-and-try_runtime: name: Build new runtime and try_runtime tool - needs: [ check-runtime-change ] + needs: [check-runtime-change] # Disbled check, reenable once we fix the issue with try-runtime test # if: ${{ needs.check-runtime-change.outputs.runtime-updated != 0 }} if: ${{ false }} @@ -874,7 +800,7 @@ jobs: test-runtime-update: name: Test runtime update with try-runtime tool runs-on: self-hosted - needs: [ build-new-runtime-and-try_runtime ] + needs: [build-new-runtime-and-try_runtime] steps: - name: Checkout source code uses: actions/checkout@v3 diff --git a/.github/workflows/nightly-pipeline.yaml b/.github/workflows/nightly-pipeline.yaml index 5356c26b1c..b775743f38 100644 --- a/.github/workflows/nightly-pipeline.yaml +++ b/.github/workflows/nightly-pipeline.yaml @@ -1,8 +1,9 @@ +--- name: Nightly pipeline on: schedule: - - cron: '00 23 * * *' + - cron: '00 23 * * *' concurrency: group: "${{ github.ref }}-${{ github.workflow }}-nightly" @@ -125,7 +126,8 @@ jobs: run: | cd e2e-tests/ rm -f target/release/deps/aleph_e2e_client* - cp $(cargo test --no-run --release --message-format=json | jq -r .executable | grep aleph_e2e_client) target/release/aleph-e2e-client + cp $(cargo test --no-run --release --message-format=json | jq -r .executable \ + | grep aleph_e2e_client) target/release/aleph-e2e-client docker build --tag aleph-e2e-client:latest -f Dockerfile . docker save -o aleph-e2e-client.tar aleph-e2e-client:latest diff --git a/.github/workflows/push-foundation-repo.yml b/.github/workflows/push-foundation-repo.yml index 5632c8487e..05666b33cb 100644 --- a/.github/workflows/push-foundation-repo.yml +++ b/.github/workflows/push-foundation-repo.yml @@ -1,17 +1,21 @@ +--- name: Sync Cardinal-Cryptography repo with Aleph-Zero-Foundation repo on: push: branches: - main - - release-** + - 'release-*' tags: - - r-* + - 'r-*' jobs: sync-main: runs-on: ubuntu-20.04 - if: github.repository == 'Cardinal-Cryptography/aleph-node' && startsWith(github.ref, 'refs/heads/') && github.ref_name == 'main' + if: > + github.repository == 'Cardinal-Cryptography/aleph-node' && + startsWith(github.ref, 'refs/heads/') && + github.ref_name == 'main' steps: - name: Checkout uses: actions/checkout@v3 @@ -20,12 +24,16 @@ jobs: token: ${{ secrets.SYNCAZF }} - name: Push to Aleph-Zero-Foundation + # yamllint disable-line rule:line-length run: git push https://x-access-token:${{ secrets.SYNCAZF }}@github.com/aleph-zero-foundation/aleph-node.git sync-release-branch: runs-on: ubuntu-20.04 - if: github.repository == 'Cardinal-Cryptography/aleph-node' && startsWith(github.ref, 'refs/heads/') && startsWith(github.ref_name, 'release-') + if: > + github.repository == 'Cardinal-Cryptography/aleph-node' && + startsWith(github.ref, 'refs/heads/') && + startsWith(github.ref_name, 'release-') steps: - name: GIT | Checkout uses: actions/checkout@v3 @@ -43,8 +51,12 @@ jobs: echo sha_short=$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT - name: Push to Aleph-Zero-Foundation + # yamllint disable rule:line-length run: | - git push 'https://x-access-token:${{ secrets.SYNCAZF }}@github.com/aleph-zero-foundation/aleph-node.git' ${{ steps.get_branch.outputs.branch_name }}:${{ steps.get_branch.outputs.branch_name }} + git push \ + 'https://x-access-token:${{ secrets.SYNCAZF }}@github.com/aleph-zero-foundation/aleph-node.git' \ + ${{ steps.get_branch.outputs.branch_name }}:${{ steps.get_branch.outputs.branch_name }} + # yamllint disable rule:line-length sync-release-tag: diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index d84ae3b03d..1ed35403ed 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -1,14 +1,14 @@ +--- name: unit-tests on: pull_request: - branches: - - '**' - push: paths-ignore: - - '*.md' + - 'fork-off/**' + - 'flooder/**' + push: branches: - - main + - 'release-*' concurrency: group: ${{ github.ref }}-${{ github.workflow }} diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml new file mode 100644 index 0000000000..bb99ae0d8d --- /dev/null +++ b/.github/workflows/yaml-lint.yml @@ -0,0 +1,30 @@ +--- +name: GH Action YAML linter + +on: + pull_request: + paths: + - '.github/**.yml' + - '.github/**.yaml' + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + main: + name: YAML Lint + runs-on: ubuntu-20.04 + steps: + - name: GIT | Checkout source code + uses: actions/checkout@v3 + with: + repository: Cardinal-Cryptography/aleph-node + token: ${{ secrets.CI_GH_TOKEN }} + + - name: LINT | Execute yaml-lint + uses: ibiqlik/action-yamllint@v3.1.1 + with: + strict: true + file_or_dir: .github + config_file: .yamllint diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000000..e53f35d245 --- /dev/null +++ b/.yamllint @@ -0,0 +1,57 @@ +--- +extends: default + +rules: + braces: + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + brackets: + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + colons: + max-spaces-before: 0 + max-spaces-after: 1 + commas: + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: + level: warning + require-starting-space: true + min-spaces-from-content: 2 + comments-indentation: disable + document-end: disable + document-start: enable + empty-lines: + max: 2 + max-start: 1 + max-end: 1 + empty-values: + forbid-in-block-mappings: false + forbid-in-flow-mappings: false + hyphens: + max-spaces-after: 1 + indentation: + spaces: consistent + indent-sequences: true + check-multi-line-strings: false + key-duplicates: enable + key-ordering: disable + line-length: + max: 100 + level: error + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: false + new-line-at-end-of-file: enable + new-lines: + type: unix + trailing-spaces: enable + truthy: + allowed-values: + - "true" + - "false" + check-keys: false diff --git a/aleph-client/Cargo.lock b/aleph-client/Cargo.lock index 49d117c46e..b3182d694d 100644 --- a/aleph-client/Cargo.lock +++ b/aleph-client/Cargo.lock @@ -140,19 +140,18 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "async-lock" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" +checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" dependencies = [ "event-listener", - "futures-lite", ] [[package]] name = "async-trait" -version = "0.1.64" +version = "0.1.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" +checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" dependencies = [ "proc-macro2", "quote", @@ -206,9 +205,9 @@ checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] name = "base64ct" -version = "1.5.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "beef" @@ -278,9 +277,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array 0.14.6", ] @@ -390,9 +389,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cec318a675afcb6a1ea1d4340e2d377e56e47c266f28043ceccbf4412ddfdd3b" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "contract-metadata" @@ -559,9 +558,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" +checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72" dependencies = [ "cc", "cxxbridge-flags", @@ -571,9 +570,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" +checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613" dependencies = [ "cc", "codespan-reporting", @@ -586,15 +585,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" +checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97" [[package]] name = "cxxbridge-macro" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" +checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" dependencies = [ "proc-macro2", "quote", @@ -603,9 +602,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ "darling_core", "darling_macro", @@ -613,9 +612,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", @@ -627,9 +626,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core", "quote", @@ -703,7 +702,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "crypto-common", "subtle", ] @@ -737,9 +736,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9b0705efd4599c15a38151f4721f7bc388306f61084d3bfd50bd07fbca5cb60" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecdsa" @@ -867,15 +866,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - [[package]] name = "ff" version = "0.12.1" @@ -928,7 +918,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "bitflags", "frame-metadata", @@ -960,7 +950,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "Inflector", "cfg-expr", @@ -975,7 +965,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -987,7 +977,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "proc-macro2", "quote", @@ -1049,21 +1039,6 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" -[[package]] -name = "futures-lite" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - [[package]] name = "futures-macro" version = "0.3.26" @@ -1185,9 +1160,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" dependencies = [ "bytes", "fnv", @@ -1554,15 +1529,6 @@ dependencies = [ "syn", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "integer-sqrt" version = "0.1.5" @@ -1589,9 +1555,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "joinery" @@ -1726,9 +1692,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "libm" @@ -1955,15 +1921,6 @@ dependencies = [ "nom", ] -[[package]] -name = "nom8" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" -dependencies = [ - "memchr", -] - [[package]] name = "num-bigint" version = "0.4.3" @@ -2074,7 +2031,7 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "pallet-contracts-primitives" version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "bitflags", "parity-scale-codec", @@ -2142,12 +2099,6 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" -[[package]] -name = "parking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" - [[package]] name = "parking_lot" version = "0.12.1" @@ -2173,9 +2124,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "pbkdf2" @@ -2288,9 +2239,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", "toml_edit", @@ -2445,18 +2396,18 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c78fb8c9293bcd48ef6fce7b4ca950ceaf21210de6e105a883ee280c0f7b9ed" +checksum = "a9af2cf09ef80e610097515e80095b7f76660a92743c4185aff5406cd5ce3dd5" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f9c0c92af03644e4806106281fe2e068ac5bc0ae74a707266d06ea27bccee5f" +checksum = "9c501201393982e275433bc55de7d6ae6f00e7699cd5572c5b57581cd69c881b" dependencies = [ "proc-macro2", "quote", @@ -2594,9 +2545,9 @@ checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "scale-bits" @@ -2710,9 +2661,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sct" @@ -2941,9 +2892,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -2967,7 +2918,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "hash-db", "log", @@ -2985,7 +2936,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "blake2", "proc-macro-crate", @@ -3011,7 +2962,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "parity-scale-codec", "scale-info", @@ -3054,7 +3005,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "integer-sqrt", "num-traits", @@ -3129,7 +3080,7 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "array-bytes", "base58", @@ -3230,7 +3181,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "blake2", "byteorder", @@ -3259,7 +3210,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "proc-macro2", "quote", @@ -3281,7 +3232,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "proc-macro2", "quote", @@ -3314,7 +3265,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "environmental", "parity-scale-codec", @@ -3337,7 +3288,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -3378,7 +3329,7 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "bytes", "ed25519", @@ -3446,7 +3397,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "async-trait", "futures", @@ -3490,7 +3441,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "backtrace", "lazy_static", @@ -3535,7 +3486,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "either", "hash256-std-hasher", @@ -3599,7 +3550,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -3649,7 +3600,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "Inflector", "proc-macro-crate", @@ -3674,7 +3625,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "parity-scale-codec", "scale-info", @@ -3709,7 +3660,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "hash-db", "log", @@ -3756,7 +3707,7 @@ checksum = "cf3fd4c1d304be101e6ebbafd3d4be9a37b320c970ef4e8df188b16873981c93" [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" [[package]] name = "sp-std" @@ -3781,7 +3732,7 @@ dependencies = [ [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3821,7 +3772,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "parity-scale-codec", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", @@ -3870,7 +3821,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "ahash 0.8.3", "hash-db", @@ -3917,7 +3868,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3934,7 +3885,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -3958,7 +3909,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "impl-trait-for-tuples", "log", @@ -4002,7 +3953,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" +source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#0d25bff2ff35d900a27efc93538d8b9d291f7381" dependencies = [ "parity-scale-codec", "scale-info", @@ -4217,18 +4168,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", @@ -4300,9 +4251,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.25.0" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" dependencies = [ "autocfg", "bytes", @@ -4313,7 +4264,7 @@ dependencies = [ "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -4355,19 +4306,19 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" [[package]] name = "toml_edit" -version = "0.18.1" +version = "0.19.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b" +checksum = "9a1eb0622d28f4b9c90adc4ea4b2b46b47663fde9ac5fafcb14a1369d5508825" dependencies = [ "indexmap", - "nom8", "toml_datetime", + "winnow", ] [[package]] @@ -4518,15 +4469,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -4579,12 +4530,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "want" version = "0.3.0" @@ -5009,6 +4954,15 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +[[package]] +name = "winnow" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee7b2c67f962bf5042bfd8b6a916178df33a26eec343ae064cb8e069f638fa6f" +dependencies = [ + "memchr", +] + [[package]] name = "wyz" version = "0.5.1" diff --git a/e2e-tests/Cargo.lock b/e2e-tests/Cargo.lock index b898b1f71a..a09eac32ef 100644 --- a/e2e-tests/Cargo.lock +++ b/e2e-tests/Cargo.lock @@ -1131,7 +1131,7 @@ dependencies = [ "paste", "scale-info", "serde", - "sp-api 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-api", "sp-application-crypto 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", @@ -1199,14 +1199,14 @@ dependencies = [ "scale-info", "serde", "smallvec", - "sp-api 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-api", "sp-arithmetic 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-core-hashing-proc-macro 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-core-hashing-proc-macro", "sp-inherents", "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", "sp-state-machine 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-tracing 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", @@ -1265,7 +1265,7 @@ dependencies = [ "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-version 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-version", "sp-weights 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] @@ -2609,7 +2609,7 @@ dependencies = [ "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] @@ -2629,7 +2629,7 @@ dependencies = [ "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-session", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-trie 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] @@ -2652,7 +2652,7 @@ dependencies = [ "sp-application-crypto 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] @@ -2883,12 +2883,12 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-api 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-application-crypto 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", + "sp-api", + "sp-application-crypto 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", + "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] [[package]] @@ -3719,31 +3719,13 @@ dependencies = [ "hash-db", "log", "parity-scale-codec", - "sp-api-proc-macro 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-api-proc-macro", "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-state-machine 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-trie 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-version 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "thiserror", -] - -[[package]] -name = "sp-api" -version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "hash-db", - "log", - "parity-scale-codec", - "sp-api-proc-macro 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-state-machine 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-trie 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-version 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", + "sp-version", "thiserror", ] @@ -3759,18 +3741,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-api-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "blake2", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "sp-application-crypto" version = "7.0.0" @@ -3798,19 +3768,6 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-application-crypto" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "sp-arithmetic" version = "6.0.0" @@ -3841,20 +3798,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "sp-arithmetic" -version = "6.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", - "scale-info", - "serde", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "static_assertions", -] - [[package]] name = "sp-core" version = "7.0.0" @@ -3943,48 +3886,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "sp-core" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "array-bytes", - "base58", - "bitflags", - "blake2", - "dyn-clonable", - "ed25519-zebra", - "futures", - "hash-db", - "hash256-std-hasher", - "impl-serde", - "lazy_static", - "libsecp256k1", - "log", - "merlin", - "parity-scale-codec", - "parking_lot", - "primitive-types", - "rand 0.8.5", - "regex", - "scale-info", - "schnorrkel", - "secp256k1 0.24.3", - "secrecy", - "serde", - "sp-core-hashing 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-debug-derive 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-externalities 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime-interface 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-storage 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "ss58-registry", - "substrate-bip39", - "thiserror", - "tiny-bip39 1.0.0", - "zeroize", -] - [[package]] name = "sp-core-hashing" version = "5.0.0" @@ -4014,20 +3915,6 @@ dependencies = [ "twox-hash", ] -[[package]] -name = "sp-core-hashing" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "blake2", - "byteorder", - "digest 0.10.6", - "sha2 0.10.6", - "sha3", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "twox-hash", -] - [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" @@ -4039,17 +3926,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-core-hashing-proc-macro" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "proc-macro2", - "quote", - "sp-core-hashing 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "syn", -] - [[package]] name = "sp-debug-derive" version = "5.0.0" @@ -4071,16 +3947,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-debug-derive" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "sp-externalities" version = "0.13.0" @@ -4104,17 +3970,6 @@ dependencies = [ "sp-storage 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-externalities" -version = "0.13.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "environmental", - "parity-scale-codec", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-storage 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "sp-inherents" version = "4.0.0-dev" @@ -4181,31 +4036,6 @@ dependencies = [ "tracing-core", ] -[[package]] -name = "sp-io" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "bytes", - "ed25519", - "ed25519-dalek", - "futures", - "libsecp256k1", - "log", - "parity-scale-codec", - "secp256k1 0.24.3", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-externalities 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-keystore 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime-interface 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-state-machine 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-tracing 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-trie 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "tracing", - "tracing-core", -] - [[package]] name = "sp-keystore" version = "0.13.0" @@ -4239,22 +4069,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "sp-keystore" -version = "0.13.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "async-trait", - "futures", - "merlin", - "parity-scale-codec", - "parking_lot", - "schnorrkel", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-externalities 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "thiserror", -] - [[package]] name = "sp-npos-elections" version = "4.0.0-dev" @@ -4290,16 +4104,6 @@ dependencies = [ "regex", ] -[[package]] -name = "sp-panic-handler" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "backtrace", - "lazy_static", - "regex", -] - [[package]] name = "sp-runtime" version = "7.0.0" @@ -4346,28 +4150,6 @@ dependencies = [ "sp-weights 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-runtime" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "either", - "hash256-std-hasher", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "paste", - "rand 0.8.5", - "scale-info", - "serde", - "sp-application-crypto 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-arithmetic 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-io 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-weights 4.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "sp-runtime-interface" version = "7.0.0" @@ -4405,24 +4187,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "sp-runtime-interface" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "bytes", - "impl-trait-for-tuples", - "parity-scale-codec", - "primitive-types", - "sp-externalities 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime-interface-proc-macro 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-storage 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-tracing 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-wasm-interface 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "static_assertions", -] - [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" @@ -4448,18 +4212,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-runtime-interface-proc-macro" -version = "6.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "Inflector", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "sp-session" version = "4.0.0-dev" @@ -4467,10 +4219,10 @@ source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=alep dependencies = [ "parity-scale-codec", "scale-info", - "sp-api 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-api", "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-staking 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-staking", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] @@ -4486,18 +4238,6 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-staking" -version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "parity-scale-codec", - "scale-info", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "sp-state-machine" version = "0.13.0" @@ -4541,26 +4281,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "sp-state-machine" -version = "0.13.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "hash-db", - "log", - "parity-scale-codec", - "parking_lot", - "rand 0.8.5", - "smallvec", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-externalities 0.13.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-panic-handler 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-trie 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "thiserror", - "tracing", -] - [[package]] name = "sp-std" version = "5.0.0" @@ -4572,11 +4292,6 @@ name = "sp-std" version = "5.0.0" source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38#85ce0f97d013118e17921af98cbc34ed00ec80e3" -[[package]] -name = "sp-std" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" - [[package]] name = "sp-storage" version = "7.0.0" @@ -4604,19 +4319,6 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-storage" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "ref-cast", - "serde", - "sp-debug-derive 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "sp-timestamp" version = "4.0.0-dev" @@ -4657,18 +4359,6 @@ dependencies = [ "tracing-subscriber", ] -[[package]] -name = "sp-tracing" -version = "6.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "parity-scale-codec", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "tracing", - "tracing-core", - "tracing-subscriber", -] - [[package]] name = "sp-trie" version = "7.0.0" @@ -4716,29 +4406,6 @@ dependencies = [ "trie-root", ] -[[package]] -name = "sp-trie" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "ahash 0.8.3", - "hash-db", - "hashbrown 0.12.3", - "lazy_static", - "memory-db 0.31.0", - "nohash-hasher", - "parity-scale-codec", - "parking_lot", - "scale-info", - "schnellru", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "thiserror", - "tracing", - "trie-db", - "trie-root", -] - [[package]] name = "sp-version" version = "5.0.0" @@ -4749,27 +4416,10 @@ dependencies = [ "parity-wasm", "scale-info", "serde", - "sp-core-hashing-proc-macro 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", + "sp-core-hashing-proc-macro", "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "sp-version-proc-macro 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", - "thiserror", -] - -[[package]] -name = "sp-version" -version = "5.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "parity-wasm", - "scale-info", - "serde", - "sp-core-hashing-proc-macro 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-runtime 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-version-proc-macro 4.0.0-dev (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", + "sp-version-proc-macro", "thiserror", ] @@ -4784,17 +4434,6 @@ dependencies = [ "syn", ] -[[package]] -name = "sp-version-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "parity-scale-codec", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "sp-wasm-interface" version = "7.0.0" @@ -4821,19 +4460,6 @@ dependencies = [ "wasmtime", ] -[[package]] -name = "sp-wasm-interface" -version = "7.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "wasmi", - "wasmtime", -] - [[package]] name = "sp-weights" version = "4.0.0" @@ -4866,21 +4492,6 @@ dependencies = [ "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=aleph-v0.9.38)", ] -[[package]] -name = "sp-weights" -version = "4.0.0" -source = "git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38#140608987761992352ba19e9e0883f5cb8bd6d2a" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde", - "smallvec", - "sp-arithmetic 6.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-core 7.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-debug-derive 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", - "sp-std 5.0.0 (git+https://github.com/Cardinal-Cryptography/substrate.git?branch=wip-v0.9.38)", -] - [[package]] name = "spin" version = "0.5.2" diff --git a/e2e-tests/src/config.rs b/e2e-tests/src/config.rs index 6c81087569..80d8838b3d 100644 --- a/e2e-tests/src/config.rs +++ b/e2e-tests/src/config.rs @@ -26,12 +26,12 @@ static GLOBAL_CONFIG: Lazy = Lazy::new(|| { upgrade_session: get_env("UPGRADE_SESSION"), upgrade_finalization_wait_sessions: get_env("UPGRADE_FINALIZATION_WAIT_SESSIONS"), adder: get_env("ADDER"), + adder_metadata: get_env("ADDER_METADATA"), back_to_the_future: get_env("BACK_TO_THE_FUTURE"), early_bird_special: get_env("EARLY_BIRD_SPECIAL"), the_pressiah_cometh: get_env("THE_PRESSIAH_COMETH"), wrapped_azero: get_env("WRAPPED_AZERO"), simple_dex: get_env("SIMPLE_DEX"), - adder_metadata: get_env("ADDER_METADATA"), button_game_metadata: get_env("BUTTON_GAME_METADATA"), marketplace_metadata: get_env("MARKETPLACE_METADATA"), reward_token_metadata: get_env("REWARD_TOKEN_METADATA"), diff --git a/e2e-tests/src/test/button_game/mod.rs b/e2e-tests/src/test/button_game/mod.rs index 812d2bf0ff..de9df2d59a 100644 --- a/e2e-tests/src/test/button_game/mod.rs +++ b/e2e-tests/src/test/button_game/mod.rs @@ -472,7 +472,7 @@ async fn button_game_play( ); info!("Waiting before pressing again"); - sleep(Duration::from_secs(5)).await; + sleep(Duration::from_secs(10)).await; button.press(&sign(&conn, player)).await?; let event = assert_recv_id(&mut events, "ButtonPressed").await; diff --git a/finality-aleph/src/sync/data.rs b/finality-aleph/src/sync/data.rs index 3d6e3eee1b..dc0a91a852 100644 --- a/finality-aleph/src/sync/data.rs +++ b/finality-aleph/src/sync/data.rs @@ -27,6 +27,48 @@ impl State { } } +/// Additional information about the branch connecting the top finalized block +/// with a given one. All the variants are exhaustive and exclusive due to the +/// properties of the `Forest` structure. +#[derive(Clone, Debug, Encode, Decode, PartialEq, Eq)] +pub enum BranchKnowledge { + /// ID of the oldest known ancestor if none of them are imported. + /// It must be different from the, imported by definition, root. + LowestId(BlockIdFor), + /// ID of the top imported ancestor if any of them is imported. + /// Since imported vertices are connected to the root, the oldest known + /// ancestor is, implicitly, the root. + TopImported(BlockIdFor), +} + +/// Request content. +#[derive(Clone, Debug, Encode, Decode)] +pub struct Request { + target_id: BlockIdFor, + branch_knowledge: BranchKnowledge, + state: State, +} + +impl Request { + pub fn new( + target_id: BlockIdFor, + branch_knowledge: BranchKnowledge, + state: State, + ) -> Self { + Self { + target_id, + branch_knowledge, + state, + } + } +} + +impl Request { + pub fn state(&self) -> &State { + &self.state + } +} + /// Data to be sent over the network. #[derive(Clone, Debug, Encode, Decode)] pub enum NetworkData { @@ -34,10 +76,13 @@ pub enum NetworkData { /// send what we are missing, and sometines just use the justifications to update their own /// state. StateBroadcast(State), - /// A series of justifications, sent to a node that is clearly behind. - Justifications(Vec, State), + /// Response to a state broadcast. Contains at most two justifications that the peer will + /// understand. + StateBroadcastResponse(J::Unverified, Option), /// An explicit request for data, potentially a lot of it. - Request(BlockIdFor, State), + Request(Request), + /// Response to the request for data. Currently consists only of justifications. + RequestResponse(Vec), } /// Version wrapper around the network data. diff --git a/finality-aleph/src/sync/forest/mod.rs b/finality-aleph/src/sync/forest/mod.rs index c0648debca..3cbcd0a326 100644 --- a/finality-aleph/src/sync/forest/mod.rs +++ b/finality-aleph/src/sync/forest/mod.rs @@ -3,7 +3,9 @@ use std::collections::{ HashMap, HashSet, }; -use crate::sync::{BlockIdFor, BlockIdentifier, Header, Justification, PeerId}; +use crate::sync::{ + data::BranchKnowledge, BlockIdFor, BlockIdentifier, Header, Justification, PeerId, +}; mod vertex; @@ -23,15 +25,23 @@ enum VertexHandle<'a, I: PeerId, J: Justification> { Candidate(OccupiedEntry<'a, BlockIdFor, VertexWithChildren>), } -/// Our interest in a block referred to by a vertex, including the information about whom we expect to have the block. +/// Information required to prepare a request for block. +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct RequestInfo { + know_most: HashSet, + branch_knowledge: BranchKnowledge, +} + +/// Our interest in a block referred to by a vertex, +/// including all the information required to prepare a request. #[derive(Clone, PartialEq, Eq, Debug)] -pub enum Interest { +pub enum Interest { /// We are not interested in this block. Uninterested, /// We would like to have this block. - Required(HashSet), + Required(RequestInfo), /// We would like to have this block and its the highest on its branch. - TopRequired(HashSet), + TopRequired(RequestInfo), } /// What can go wrong when inserting data into the forest. @@ -69,6 +79,7 @@ const MAX_DEPTH: u32 = 1800; pub struct Forest { vertices: HashMap, VertexWithChildren>, top_required: HashSet>, + justified_blocks: HashMap>, root_id: BlockIdFor, root_children: HashSet>, compost_bin: HashSet>, @@ -79,6 +90,7 @@ impl Forest { Self { vertices: HashMap::new(), top_required: HashSet::new(), + justified_blocks: HashMap::new(), root_id: highest_justified, root_children: HashSet::new(), compost_bin: HashSet::new(), @@ -224,9 +236,9 @@ impl Forest { } } - /// Updates the vertex related to the provided header marking it as imported. Returns whether - /// it is now finalizable, or errors when it's impossible to do consistently. - pub fn update_body(&mut self, header: &J::Header) -> Result { + /// Updates the vertex related to the provided header marking it as imported. + /// Returns errors when it's impossible to do consistently. + pub fn update_body(&mut self, header: &J::Header) -> Result<(), Error> { use VertexHandle::*; let (id, parent_id) = self.process_header(header)?; self.update_header(header, None, false)?; @@ -240,41 +252,46 @@ impl Forest { Unknown(_) | HopelessFork | BelowMinimal => return Err(Error::IncorrectParentState), } match self.get_mut(&id) { - Candidate(mut entry) => Ok(entry.get_mut().vertex.insert_body(parent_id.clone())), + Candidate(mut entry) => { + let vertex = &mut entry.get_mut().vertex; + vertex.insert_body(parent_id.clone()); + if vertex.justified_block() { + self.justified_blocks.insert(id.number(), id.clone()); + } + Ok(()) + } _ => Err(Error::IncorrectVertexState), } } - /// Updates the provided justification, returns whether either finalization is now possible or - /// the vertex became a new top required. + /// Updates the provided justification. + /// Returns whether the vertex became a new top required. pub fn update_justification( &mut self, justification: J, holder: Option, - ) -> Result { + ) -> Result { use JustificationAddResult::*; let (id, parent_id) = self.process_header(justification.header())?; self.update_header(justification.header(), None, false)?; match self.get_mut(&id) { VertexHandle::Candidate(mut entry) => { - match entry.get_mut().vertex.insert_justification( - parent_id.clone(), - justification, - holder, - ) { - Noop => Ok(Noop), + let vertex = &mut entry.get_mut().vertex; + match vertex.insert_justification(parent_id.clone(), justification, holder) { + Noop => Ok(false), Required => { self.top_required.insert(id.clone()); self.set_required(&parent_id); - Ok(Required) + Ok(true) } Finalizable => { self.top_required.remove(&id); - Ok(Finalizable) + self.justified_blocks.insert(id.number(), id.clone()); + Ok(false) } } } - _ => Ok(Noop), + _ => Ok(false), } } @@ -289,52 +306,102 @@ impl Forest { self.prune(&id); } self.compost_bin.retain(|k| k.number() > level); + self.justified_blocks.retain(|k, _| k > &level); } /// Attempt to finalize one block, returns the correct justification if successful. - pub fn try_finalize(&mut self) -> Option { - for child_id in self.root_children.clone().into_iter() { - if let Some(VertexWithChildren { vertex, children }) = self.vertices.remove(&child_id) { + pub fn try_finalize(&mut self, number: &u32) -> Option { + // cached as ready + if let Some(id) = self.justified_blocks.get(number) { + if let Some(VertexWithChildren { vertex, children }) = self.vertices.remove(id) { match vertex.ready() { + // ready indeed Ok(justification) => { - self.root_id = child_id; + self.root_id = id.clone(); self.root_children = children; self.prune_level(self.root_id.number()); return Some(justification); } - Err(vertex) => { - self.vertices - .insert(child_id, VertexWithChildren { vertex, children }); - } + Err(_vertex) => panic!("Block sync justified_blocks cache corrupted, please restart the Node and contact the developers"), } } } None } - /// How much interest we have for the block. - pub fn state(&mut self, id: &BlockIdFor) -> Interest { + /// Returns the BranchKnowledge regarding the given block id, + /// or None if there is no branch at all. + fn branch_knowledge(&mut self, mut id: BlockIdFor) -> Option> { + use VertexHandle::*; + // traverse ancestors till we reach something imported or a parentless vertex + loop { + match self.get_mut(&id) { + Candidate(entry) => { + // first encounter of an imported ancestor, return it + if entry.get().vertex.imported() { + return Some(BranchKnowledge::TopImported(id)); + } + // try update current id to parent_id + match entry.get().vertex.parent().cloned() { + // it has a parent, continue + Some(parent_id) => id = parent_id, + // does not have parent, thus is the lowest known, + // and is not imported (a Candidate is not the HighestFinalized), + // return it + None => return Some(BranchKnowledge::LowestId(id)), + }; + } + // we've reached the root, hence this is the top imported ancestor, return it + HighestFinalized => { + return Some(BranchKnowledge::TopImported(id)); + } + // either we don't know the requested id, or it will never connect to the root, + // return None + HopelessFork | BelowMinimal | Unknown(_) => return None, + }; + } + } + + /// Prepare additional info required to create a request for the block. + /// Returns `None` if we're not interested in the block. + fn prepare_request_info(&mut self, id: &BlockIdFor) -> Option> { + use VertexHandle::Candidate; match self.get_mut(id) { - VertexHandle::Candidate(entry) => { - let vertex = &entry.get().vertex; - let know_most = vertex.know_most().clone(); - match vertex.required() { - true => match self.top_required.contains(id) { - true => Interest::TopRequired(know_most), - false => Interest::Required(know_most), - }, - false => Interest::Uninterested, + Candidate(entry) => { + // request only required blocks + if !&entry.get().vertex.required() { + return None; } + let know_most = entry.get().vertex.know_most().clone(); + // should always return Some, as the branch of a Candidate always exists + self.branch_knowledge(id.clone()) + .map(|branch_knowledge| RequestInfo { + know_most, + branch_knowledge, + }) } - _ => Interest::Uninterested, + // request only Candidates + _ => None, + } + } + + /// How much interest we have for the block. + pub fn state(&mut self, id: &BlockIdFor) -> Interest { + match self.prepare_request_info(id) { + Some(request_info) => match self.top_required.contains(id) { + true => Interest::TopRequired(request_info), + false => Interest::Required(request_info), + }, + None => Interest::Uninterested, } } } #[cfg(test)] mod tests { - use super::{Error, Forest, Interest::*, JustificationAddResult, MAX_DEPTH}; + use super::{Error, Forest, Interest::*, MAX_DEPTH}; use crate::sync::{ + data::BranchKnowledge::*, mock::{MockHeader, MockJustification, MockPeerId}, Header, Justification, }; @@ -350,7 +417,7 @@ mod tests { #[test] fn initially_empty() { let (initial_header, mut forest) = setup(); - assert!(forest.try_finalize().is_none()); + assert!(forest.try_finalize(&1).is_none()); assert_eq!(forest.state(&initial_header.id()), Uninterested); } @@ -362,7 +429,7 @@ mod tests { assert!(!forest .update_block_identifier(&child.id(), Some(peer_id), false) .expect("it's not too high")); - assert!(forest.try_finalize().is_none()); + assert!(forest.try_finalize(&1).is_none()); assert_eq!(forest.state(&child.id()), Uninterested); } @@ -374,9 +441,9 @@ mod tests { assert!(forest .update_block_identifier(&child.id(), Some(peer_id), true) .expect("it's not too high")); - assert!(forest.try_finalize().is_none()); + assert!(forest.try_finalize(&1).is_none()); match forest.state(&child.id()) { - TopRequired(holders) => assert!(holders.contains(&peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } assert!(!forest @@ -406,7 +473,7 @@ mod tests { assert!(!forest .update_header(&child, Some(peer_id), false) .expect("header was correct")); - assert!(forest.try_finalize().is_none()); + assert!(forest.try_finalize(&1).is_none()); assert_eq!(forest.state(&child.id()), Uninterested); } @@ -418,9 +485,9 @@ mod tests { assert!(forest .update_header(&child, Some(peer_id), true) .expect("header was correct")); - assert!(forest.try_finalize().is_none()); + assert!(forest.try_finalize(&1).is_none()); match forest.state(&child.id()) { - TopRequired(holders) => assert!(holders.contains(&peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } assert!(!forest @@ -444,15 +511,12 @@ mod tests { let (initial_header, mut forest) = setup(); let child = MockJustification::for_header(initial_header.random_child()); let peer_id = rand::random(); - assert_eq!( - forest - .update_justification(child.clone(), Some(peer_id)) - .expect("header was correct"), - JustificationAddResult::Required - ); - assert!(forest.try_finalize().is_none()); + assert!(forest + .update_justification(child.clone(), Some(peer_id)) + .expect("header was correct")); + assert!(forest.try_finalize(&1).is_none()); match forest.state(&child.header().id()) { - TopRequired(holders) => assert!(holders.contains(&peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } } @@ -472,8 +536,8 @@ mod tests { fn accepts_first_body() { let (initial_header, mut forest) = setup(); let child = initial_header.random_child(); - assert!(!forest.update_body(&child).expect("header was correct")); - assert!(forest.try_finalize().is_none()); + forest.update_body(&child).expect("header was correct"); + assert!(forest.try_finalize(&1).is_none()); assert_eq!(forest.state(&child.id()), Uninterested); } @@ -489,7 +553,7 @@ mod tests { forest.update_body(&grandchild), Err(Error::ParentNotImported) ); - assert!(forest.try_finalize().is_none()); + assert!(forest.try_finalize(&1).is_none()); assert_eq!(forest.state(&child.id()), Uninterested); assert_eq!(forest.state(&grandchild.id()), Uninterested); } @@ -499,21 +563,18 @@ mod tests { let (initial_header, mut forest) = setup(); let child = MockJustification::for_header(initial_header.random_child()); let peer_id = rand::random(); - assert_eq!( - forest - .update_justification(child.clone(), Some(peer_id)) - .expect("header was correct"), - JustificationAddResult::Required - ); - assert!(forest.try_finalize().is_none()); + assert!(forest + .update_justification(child.clone(), Some(peer_id)) + .expect("header was correct")); + assert!(forest.try_finalize(&1).is_none()); match forest.state(&child.header().id()) { - TopRequired(holders) => assert!(holders.contains(&peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } - assert!(forest + forest .update_body(child.header()) - .expect("header was correct")); - assert_eq!(forest.try_finalize().expect("the block is ready"), child); + .expect("header was correct"); + assert_eq!(forest.try_finalize(&1).expect("the block is ready"), child); } #[test] @@ -527,19 +588,16 @@ mod tests { .update_header(&fork_child, Some(fork_peer_id), true) .expect("header was correct")); match forest.state(&fork_child.id()) { - TopRequired(holders) => assert!(holders.contains(&fork_peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&fork_peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } - assert_eq!( - forest - .update_justification(child.clone(), Some(peer_id)) - .expect("header was correct"), - JustificationAddResult::Required - ); assert!(forest - .update_body(child.header()) + .update_justification(child.clone(), Some(peer_id)) .expect("header was correct")); - assert_eq!(forest.try_finalize().expect("the block is ready"), child); + forest + .update_body(child.header()) + .expect("header was correct"); + assert_eq!(forest.try_finalize(&1).expect("the block is ready"), child); assert_eq!(forest.state(&fork_child.id()), Uninterested); assert!(!forest .update_header(&fork_child, Some(fork_peer_id), true) @@ -556,22 +614,19 @@ mod tests { .update_header(header, Some(peer_id), true) .expect("header was correct")); match forest.state(&header.id()) { - TopRequired(holders) => assert!(holders.contains(&peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } } let child = MockJustification::for_header(initial_header.random_child()); let peer_id = rand::random(); - assert_eq!( - forest - .update_justification(child.clone(), Some(peer_id)) - .expect("header was correct"), - JustificationAddResult::Required - ); assert!(forest - .update_body(child.header()) + .update_justification(child.clone(), Some(peer_id)) .expect("header was correct")); - assert_eq!(forest.try_finalize().expect("the block is ready"), child); + forest + .update_body(child.header()) + .expect("header was correct"); + assert_eq!(forest.try_finalize(&1).expect("the block is ready"), child); for header in fork_branch { assert_eq!(forest.state(&header.id()), Uninterested); } @@ -587,7 +642,7 @@ mod tests { .update_header(header, Some(peer_id), true) .expect("header was correct")); match forest.state(&header.id()) { - TopRequired(holders) => assert!(holders.contains(&peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } let header = &branch[1]; @@ -602,7 +657,7 @@ mod tests { .update_header(header, Some(peer_id), true) .expect("header was correct")); match forest.state(&header.id()) { - TopRequired(holders) => assert!(holders.contains(&peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } let header = &branch[2]; @@ -616,6 +671,66 @@ mod tests { assert!(matches!(forest.state(&branch[3].id()), TopRequired(_))); } + #[test] + fn finds_ancestors() { + let (initial_header, mut forest) = setup(); + let branch: Vec<_> = initial_header.random_branch().take(4).collect(); + let header = &branch[0]; + let peer_id = rand::random(); + assert!(!forest + .update_header(header, Some(peer_id), false) + .expect("header was correct")); + assert_eq!(forest.state(&header.id()), Uninterested); + // skip branch[1] + let header = &branch[2]; + let peer_id = rand::random(); + assert!(!forest + .update_header(header, Some(peer_id), false) + .expect("header was correct")); + assert_eq!(forest.state(&header.id()), Uninterested); + let header = &branch[3]; + let peer_id = rand::random(); + assert!(forest + .update_header(header, Some(peer_id), true) + .expect("header was correct")); + match forest.state(&header.id()) { + TopRequired(request_info) => { + assert!(request_info.know_most.contains(&peer_id)); + // we only know parent from branch[2], namely branch[1] + assert_eq!(request_info.branch_knowledge, LowestId(branch[1].id())); + } + other_state => panic!("Expected top required, got {:?}.", other_state), + } + // fill the gap + let header = &branch[1]; + let peer_id = rand::random(); + assert!(!forest + .update_header(header, Some(peer_id), false) + .expect("header was correct")); + for header in branch.iter().take(3) { + assert!(matches!(forest.state(&header.id()), Required(_))); + } + match forest.state(&branch[3].id()) { + TopRequired(request_info) => { + // now we know all ancestors + assert_eq!( + request_info.branch_knowledge, + TopImported(initial_header.id()) + ); + } + other_state => panic!("Expected top required, got {:?}.", other_state), + } + forest.update_body(&branch[0]).expect("should import"); + forest.update_body(&branch[1]).expect("should import"); + match forest.state(&branch[3].id()) { + TopRequired(request_info) => { + // we know all ancestors, three blocks were imported + assert_eq!(request_info.branch_knowledge, TopImported(branch[1].id())); + } + other_state => panic!("Expected top required, got {:?}.", other_state), + } + } + const HUGE_BRANCH_LENGTH: usize = MAX_DEPTH as usize; #[test] @@ -628,28 +743,65 @@ mod tests { .collect(); for justification in &justifications { let peer_id = rand::random(); - assert_eq!( - forest - .update_justification(justification.clone(), Some(peer_id)) - .expect("header was correct"), - JustificationAddResult::Required - ); + assert!(forest + .update_justification(justification.clone(), Some(peer_id)) + .expect("header was correct")); match forest.state(&justification.header().id()) { - TopRequired(holders) => assert!(holders.contains(&peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } - assert!(forest + forest .update_body(justification.header()) - .expect("header was correct")); + .expect("header was correct"); } - for justification in justifications { + for (number, justification) in justifications.into_iter().enumerate() { assert_eq!( - forest.try_finalize().expect("the block is ready"), + forest + .try_finalize(&(number as u32 + 1)) + .expect("the block is ready"), justification ); } } + #[test] + fn finalizes_huge_branch_with_justification_holes() { + let (initial_header, mut forest) = setup(); + let justifications: Vec<_> = initial_header + .random_branch() + .map(MockJustification::for_header) + .take(HUGE_BRANCH_LENGTH) + .enumerate() + .collect(); + for (number, justification) in &justifications { + if number.is_power_of_two() { + let peer_id = rand::random(); + assert!(forest + .update_justification(justification.clone(), Some(peer_id)) + .expect("header was correct")); + match forest.state(&justification.header().id()) { + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), + other_state => panic!("Expected top required, got {:?}.", other_state), + } + } + forest + .update_body(justification.header()) + .expect("header was correct"); + } + for (number, justification) in justifications.into_iter() { + if number.is_power_of_two() { + assert_eq!( + forest + .try_finalize(&(number as u32 + 1)) + .expect("the block is ready"), + justification + ); + } else { + assert!(forest.try_finalize(&(number as u32 + 1)).is_none()); + } + } + } + #[test] fn prunes_huge_branch() { let (initial_header, mut forest) = setup(); @@ -662,29 +814,26 @@ mod tests { assert!(forest .update_header(header, Some(peer_id), true) .expect("header was correct")); - assert!(forest.try_finalize().is_none()); + assert!(forest.try_finalize(&1).is_none()); match forest.state(&header.id()) { - TopRequired(holders) => assert!(holders.contains(&peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } } let child = MockJustification::for_header(initial_header.random_child()); let peer_id = rand::random(); - assert_eq!( - forest - .update_justification(child.clone(), Some(peer_id)) - .expect("header was correct"), - JustificationAddResult::Required - ); - assert!(forest.try_finalize().is_none()); + assert!(forest + .update_justification(child.clone(), Some(peer_id)) + .expect("header was correct")); + assert!(forest.try_finalize(&1).is_none()); match forest.state(&child.header().id()) { - TopRequired(holders) => assert!(holders.contains(&peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } - assert!(forest + forest .update_body(child.header()) - .expect("header was correct")); - assert_eq!(forest.try_finalize().expect("the block is ready"), child); + .expect("header was correct"); + assert_eq!(forest.try_finalize(&1).expect("the block is ready"), child); for header in &fork { assert_eq!(forest.state(&header.id()), Uninterested); } @@ -710,7 +859,7 @@ mod tests { .update_header(header, Some(peer_id), true) .expect("header was correct")); match forest.state(&header.id()) { - TopRequired(holders) => assert!(holders.contains(&peer_id)), + TopRequired(request_info) => assert!(request_info.know_most.contains(&peer_id)), other_state => panic!("Expected top required, got {:?}.", other_state), } for header in branch.iter().take(HUGE_BRANCH_LENGTH - 1) { diff --git a/finality-aleph/src/sync/forest/vertex.rs b/finality-aleph/src/sync/forest/vertex.rs index 7d26d66bdc..062ee6e058 100644 --- a/finality-aleph/src/sync/forest/vertex.rs +++ b/finality-aleph/src/sync/forest/vertex.rs @@ -79,6 +79,14 @@ impl Vertex { ) } + /// Whether the vertex represents imported justified block. + pub fn justified_block(&self) -> bool { + matches!( + self.inner, + InnerVertex::Justification { imported: true, .. } + ) + } + /// Deconstructs the vertex into a justification if it is ready to be imported, /// i.e. the related block has already been imported, otherwise returns it. pub fn ready(self) -> Result { diff --git a/finality-aleph/src/sync/handler.rs b/finality-aleph/src/sync/handler.rs index 7641d84098..1fc8f17b33 100644 --- a/finality-aleph/src/sync/handler.rs +++ b/finality-aleph/src/sync/handler.rs @@ -1,19 +1,15 @@ use crate::{ session::{last_block_of_session, session_id_from_block_num, SessionId, SessionPeriod}, sync::{ - data::{NetworkData, State}, - forest::{Error as ForestError, Forest, JustificationAddResult}, + data::{NetworkData, Request, State}, + forest::{Error as ForestError, Forest}, BlockIdFor, BlockIdentifier, ChainStatus, Finalizer, Header, Justification, PeerId, Verifier, }, }; -/// How many justifications we will send at most in response to a broadcast. -const MAX_SMALL_JUSTIFICATION_BATCH: u32 = 10; -// Silly workaround to make range matching actually work... -const MAX_SMALL_JUSTIFICATION_BATCH_PLUS_ONE: u32 = MAX_SMALL_JUSTIFICATION_BATCH + 1; /// How many justifications we will send at most in response to an explicit query. -const MAX_JUSTIFICATION_BATCH: u32 = 100; +const MAX_JUSTIFICATION_BATCH: usize = 100; /// Handler for data incoming from the network. pub struct Handler, V: Verifier, F: Finalizer> @@ -42,8 +38,18 @@ impl SyncActions { SyncActions::Noop } - fn response(response: NetworkData) -> Self { - SyncActions::Response(response) + fn state_broadcast_response( + justification: J::Unverified, + other_justification: Option, + ) -> Self { + SyncActions::Response(NetworkData::StateBroadcastResponse( + justification, + other_justification, + )) + } + + fn request_response(justifications: Vec) -> Self { + SyncActions::Response(NetworkData::RequestResponse(justifications)) } fn task(id: BlockIdFor) -> Self { @@ -95,130 +101,57 @@ impl, V: Verifier, F: Finaliz }) } - fn large_justification_batch_from( - &self, - id: BlockIdFor, - ) -> Result, Error> { - use Error::*; - let mut result = Vec::with_capacity(MAX_SMALL_JUSTIFICATION_BATCH as usize); - let mut number = id.number() + 1; - let top_finalized_number = self + fn try_finalize(&mut self) -> Result<(), Error> { + let mut number = self .chain_status .top_finalized() - .map_err(ChainStatus)? + .map_err(Error::ChainStatus)? .header() .id() - .number(); - while result.len() < MAX_JUSTIFICATION_BATCH as usize && number <= top_finalized_number { - number = match self - .chain_status - .finalized_at(number) - .map_err(ChainStatus)? - { - Some(justification) => { - result.push(justification.into_unverified()); - number + 1 - } - // We might skip all blocks of a session if we are missing a justification, but - // this will happen only for sessions where we don't have all the justifications. - // The last block of a session was always guaranteed to contain a justification, so - // we only share that one. It can be missing only if the last block is above the - // top finalized, in which case this will break the loop. - None => last_block_of_session( - session_id_from_block_num(number, self.period), - self.period, - ), - } - } - Ok(NetworkData::Justifications(result, self.state()?)) - } - - fn small_justification_batch_from( - &self, - id: BlockIdFor, - ) -> Result, Error> { - let mut result = Vec::with_capacity(MAX_SMALL_JUSTIFICATION_BATCH as usize); - let mut number = id.number() + 1; - while result.len() < MAX_SMALL_JUSTIFICATION_BATCH as usize { - match self - .chain_status - .finalized_at(number) - .map_err(Error::ChainStatus)? - { - Some(justification) => result.push(justification.into_unverified()), - None => break, + .number() + + 1; + loop { + while let Some(justification) = self.forest.try_finalize(&number) { + self.finalizer + .finalize(justification) + .map_err(Error::Finalizer)?; + number += 1; } - number += 1; - } - Ok(NetworkData::Justifications(result, self.state()?)) - } - - fn top_understandable_for( - &self, - id: BlockIdFor, - ) -> Result, Error> { - use Error::*; - let block_session = session_id_from_block_num(id.number(), self.period); - let understandable_session = SessionId(block_session.0 + 1); - let last_understandable_block_number = - last_block_of_session(understandable_session, self.period); - match self - .chain_status - .finalized_at(last_understandable_block_number) - .map_err(ChainStatus)? - { - Some(justification) => Ok(NetworkData::Justifications( - vec![justification.into_unverified()], - self.state()?, - )), - None => { - let justification = self.chain_status.top_finalized().map_err(ChainStatus)?; - match justification.header().id().number() <= last_understandable_block_number { - true => Ok(NetworkData::Justifications( - vec![justification.into_unverified()], - self.state()?, - )), - false => Err(Error::MissingJustification), + number = + last_block_of_session(session_id_from_block_num(number, self.period), self.period); + match self.forest.try_finalize(&number) { + Some(justification) => { + self.finalizer + .finalize(justification) + .map_err(Error::Finalizer)?; + number += 1; } - } + None => return Ok(()), + }; } } - fn try_finalize(&mut self) -> Result<(), Error> { - while let Some(justification) = self.forest.try_finalize() { - self.finalizer - .finalize(justification) - .map_err(Error::Finalizer)?; - } - Ok(()) - } - fn handle_verified_justification( &mut self, justification: J, peer: I, ) -> Result, Error> { - use JustificationAddResult::*; let id = justification.header().id(); - match self + let action = match self .forest .update_justification(justification, Some(peer))? { - Noop => Ok(SyncActions::noop()), - Required => Ok(SyncActions::task(id)), - Finalizable => { - self.try_finalize()?; - Ok(SyncActions::noop()) - } - } + true => Ok(SyncActions::task(id)), + false => Ok(SyncActions::noop()), + }; + self.try_finalize()?; + action } /// Inform the handler that a block has been imported. pub fn block_imported(&mut self, header: J::Header) -> Result<(), Error> { - match self.forest.update_body(&header)? { - true => self.try_finalize(), - false => Ok(()), - } + self.forest.update_body(&header)?; + self.try_finalize() } /// Handle a request for potentially substantial amounts of data. @@ -227,18 +160,47 @@ impl, V: Verifier, F: Finaliz /// blocks. pub fn handle_request( &mut self, - _requested_id: BlockIdFor, - state: State, + request: Request, ) -> Result, Error> { - let remote_top_id = self + let mut number = self .verifier - .verify(state.top_justification()) + .verify(request.state().top_justification()) .map_err(Error::Verifier)? .header() - .id(); - Ok(SyncActions::response( - self.large_justification_batch_from(remote_top_id)?, - )) + .id() + .number() + + 1; + let mut justifications = vec![]; + while justifications.len() < MAX_JUSTIFICATION_BATCH { + match self + .chain_status + .finalized_at(number) + .map_err(Error::ChainStatus)? + { + Some(justification) => { + justifications.push(justification.into_unverified()); + number += 1; + } + None => { + number = last_block_of_session( + session_id_from_block_num(number, self.period), + self.period, + ); + match self + .chain_status + .finalized_at(number) + .map_err(Error::ChainStatus)? + { + Some(justification) => { + justifications.push(justification.into_unverified()); + number += 1; + } + None => break, + }; + } + } + } + Ok(SyncActions::request_response(justifications)) } /// Handle a single justification. @@ -254,6 +216,19 @@ impl, V: Verifier, F: Finaliz self.handle_verified_justification(justification, peer) } + fn last_justification_unverified( + &self, + session: SessionId, + ) -> Result> { + use Error::*; + Ok(self + .chain_status + .finalized_at(last_block_of_session(session, self.period)) + .map_err(ChainStatus)? + .ok_or(MissingJustification)? + .into_unverified()) + } + /// Handle a state broadcast returning the actions we should take in response. pub fn handle_state( &mut self, @@ -265,22 +240,34 @@ impl, V: Verifier, F: Finaliz .verifier .verify(state.top_justification()) .map_err(Verifier)?; + let remote_top_number = remote_top.header().id().number(); let local_top = self.chain_status.top_finalized().map_err(ChainStatus)?; - match local_top - .header() - .id() - .number() - .checked_sub(remote_top.header().id().number()) - { - // If we are just one behind then normal broadcasts should remedy the situation. - Some(0..=1) => Ok(SyncActions::noop()), - Some(2..=MAX_SMALL_JUSTIFICATION_BATCH) => Ok(SyncActions::response( - self.small_justification_batch_from(remote_top.header().id())?, + let local_top_number = local_top.header().id().number(); + let remote_session = session_id_from_block_num(remote_top_number, self.period); + let local_session = session_id_from_block_num(local_top_number, self.period); + match local_session.0.checked_sub(remote_session.0) { + // remote session number larger than ours, we can try to import the justification + None => self.handle_verified_justification(remote_top, peer), + // same session + Some(0) => match remote_top_number >= local_top_number { + // remote top justification higher than ours, we can import the justification + true => self.handle_verified_justification(remote_top, peer), + // remote top justification lower than ours, we can send a response + false => Ok(SyncActions::state_broadcast_response( + local_top.into_unverified(), + None, + )), + }, + // remote lags one session behind + Some(1) => Ok(SyncActions::state_broadcast_response( + self.last_justification_unverified(remote_session)?, + Some(local_top.into_unverified()), )), - Some(MAX_SMALL_JUSTIFICATION_BATCH_PLUS_ONE..) => Ok(SyncActions::response( - self.top_understandable_for(remote_top.header().id())?, + // remote lags multiple sessions behind + Some(2..) => Ok(SyncActions::state_broadcast_response( + self.last_justification_unverified(remote_session)?, + Some(self.last_justification_unverified(SessionId(remote_session.0 + 1))?), )), - None => self.handle_verified_justification(remote_top, peer), } } @@ -300,9 +287,9 @@ mod tests { use super::{Handler, SyncActions}; use crate::{ sync::{ - data::NetworkData, + data::{BranchKnowledge::*, NetworkData, Request}, mock::{Backend, MockHeader, MockJustification, MockPeerId, MockVerifier}, - ChainStatus, Header, Justification, + BlockIdentifier, ChainStatus, Header, Justification, }, SessionPeriod, }; @@ -312,7 +299,7 @@ mod tests { const SESSION_PERIOD: usize = 20; fn setup() -> (MockHandler, Backend, impl Send) { - let (backend, _keep) = Backend::setup(); + let (backend, _keep) = Backend::setup(SESSION_PERIOD); let verifier = MockVerifier {}; let handler = Handler::new( backend.clone(), @@ -379,14 +366,17 @@ mod tests { } #[test] - fn handles_state_with_small_difference() { + fn handles_state_with_large_difference() { let (mut handler, backend, _keep) = setup(); let initial_state = handler.state().expect("state works"); let peer = rand::random(); - for justification in import_branch(&backend, 5) + let justifications: Vec = import_branch(&backend, 43) .into_iter() .map(MockJustification::for_header) - { + .collect(); + let last_from_first_session = justifications[18].clone().into_unverified(); + let last_from_second_session = justifications[38].clone().into_unverified(); + for justification in justifications.into_iter() { handler .block_imported(justification.header().clone()) .expect("importing in order"); @@ -398,8 +388,12 @@ mod tests { .handle_state(initial_state, peer) .expect("correct justification") { - SyncActions::Response(NetworkData::Justifications(justifications, _)) => { - assert_eq!(justifications.len(), 5) + SyncActions::Response(NetworkData::StateBroadcastResponse( + justification, + maybe_justification, + )) => { + assert_eq!(justification, last_from_first_session); + assert_eq!(maybe_justification, Some(last_from_second_session)); } other_action => panic!( "expected a response with justifications, got {:?}", @@ -409,15 +403,17 @@ mod tests { } #[test] - fn handles_state_with_large_difference() { + fn handles_state_with_medium_difference() { let (mut handler, backend, _keep) = setup(); let initial_state = handler.state().expect("state works"); let peer = rand::random(); - let justifications: Vec<_> = import_branch(&backend, 500) + let justifications: Vec = import_branch(&backend, 23) .into_iter() .map(MockJustification::for_header) .collect(); - for justification in &justifications { + let last_from_first_session = justifications[18].clone().into_unverified(); + let top = justifications[22].clone().into_unverified(); + for justification in justifications.into_iter() { handler .block_imported(justification.header().clone()) .expect("importing in order"); @@ -429,12 +425,12 @@ mod tests { .handle_state(initial_state, peer) .expect("correct justification") { - SyncActions::Response(NetworkData::Justifications(sent_justifications, _)) => { - assert_eq!(sent_justifications.len(), 1); - assert_eq!( - sent_justifications[0].header().id(), - justifications[SESSION_PERIOD * 2 - 2].header().id() - ); + SyncActions::Response(NetworkData::StateBroadcastResponse( + justification, + maybe_justification, + )) => { + assert_eq!(justification, last_from_first_session); + assert_eq!(maybe_justification, Some(top)); } other_action => panic!( "expected a response with justifications, got {:?}", @@ -444,15 +440,16 @@ mod tests { } #[test] - fn handles_request() { + fn handles_state_with_small_difference() { let (mut handler, backend, _keep) = setup(); let initial_state = handler.state().expect("state works"); let peer = rand::random(); - let justifications: Vec<_> = import_branch(&backend, 500) + let justifications: Vec = import_branch(&backend, 13) .into_iter() .map(MockJustification::for_header) .collect(); - for justification in &justifications { + let top = justifications[12].clone().into_unverified(); + for justification in justifications.into_iter() { handler .block_imported(justification.header().clone()) .expect("importing in order"); @@ -460,13 +457,56 @@ mod tests { .handle_justification(justification.clone().into_unverified(), peer) .expect("correct justification"); } - // currently ignored, so picking a random one - let requested_id = justifications[43].header().id(); match handler - .handle_request(requested_id, initial_state) - .expect("correct request") + .handle_state(initial_state, peer) + .expect("correct justification") { - SyncActions::Response(NetworkData::Justifications(sent_justifications, _)) => { + SyncActions::Response(NetworkData::StateBroadcastResponse( + justification, + maybe_justification, + )) => { + assert_eq!(justification, top); + assert!(maybe_justification.is_none()); + } + other_action => panic!( + "expected a response with justifications, got {:?}", + other_action + ), + } + } + + #[test] + fn handles_request() { + let (mut handler, backend, _keep) = setup(); + let initial_state = handler.state().expect("state works"); + let peer = rand::random(); + let mut justifications: Vec<_> = import_branch(&backend, 500) + .into_iter() + .map(MockJustification::for_header) + .collect(); + for justification in &justifications { + let number = justification.header().id().number(); + handler + .block_imported(justification.header().clone()) + .expect("importing in order"); + // skip some justifications, but always keep the last of the session + // justifications right before the last will be skipped in response + if number % 20 < 10 || number % 20 > 14 { + handler + .handle_justification(justification.clone().into_unverified(), peer) + .expect("correct justification"); + } + } + // currently ignored, so picking a random one + let requested_id = justifications[43].header().id(); + let request = Request::new(requested_id.clone(), LowestId(requested_id), initial_state); + // filter justifications, these are supposed to be included in the response + justifications.retain(|j| { + let number = j.header().id().number(); + number % 20 < 10 || number % 20 == 19 + }); + match handler.handle_request(request).expect("correct request") { + SyncActions::Response(NetworkData::RequestResponse(sent_justifications)) => { assert_eq!(sent_justifications.len(), 100); for (sent_justification, justification) in sent_justifications.iter().zip(justifications) diff --git a/finality-aleph/src/sync/mock/backend.rs b/finality-aleph/src/sync/mock/backend.rs index 65325c607c..edae29c22c 100644 --- a/finality-aleph/src/sync/mock/backend.rs +++ b/finality-aleph/src/sync/mock/backend.rs @@ -38,6 +38,7 @@ impl MockBlock { #[derive(Clone, Debug)] struct BackendStorage { + session_period: u32, blockchain: HashMap, finalized: Vec, best_block: MockIdentifier, @@ -72,13 +73,16 @@ fn is_predecessor( } impl Backend { - pub fn setup() -> (Self, impl ChainStatusNotifier) { + pub fn setup(session_period: usize) -> (Self, impl ChainStatusNotifier) { let (notification_sender, notification_receiver) = mpsc::unbounded(); - (Backend::new(notification_sender), notification_receiver) + ( + Backend::new(notification_sender, session_period as u32), + notification_receiver, + ) } - fn new(notification_sender: UnboundedSender) -> Self { + fn new(notification_sender: UnboundedSender, session_period: u32) -> Self { let header = MockHeader::random_parentless(0); let id = header.id(); @@ -88,6 +92,7 @@ impl Backend { }; let storage = Arc::new(Mutex::new(BackendStorage { + session_period, blockchain: HashMap::from([(id.clone(), block)]), finalized: vec![id.clone()], best_block: id.clone(), @@ -175,24 +180,11 @@ impl Finalizer for Backend { let header = justification.header(); let parent_id = match justification.header().parent_id() { Some(id) => id, - None => panic!("finalizing block without a parent: {:?}", header), + None => panic!("finalizing block without specified parent: {:?}", header), }; - let parent_block = match storage.blockchain.get(&parent_id) { - Some(block) => block, - None => panic!("finalizing block without an imported parent: {:?}", header), - }; - - if parent_block.justification.is_none() { - panic!("finalizing block without a finalized parent: {:?}", header); - } - - if &parent_id != storage.finalized.last().expect("there is a top finalized") { - panic!( - "finalizing block whose parent is not top finalized: {:?}. Top is {:?}", - header, - storage.finalized.last().expect("there is a top finalized") - ); + if storage.blockchain.get(&parent_id).is_none() { + panic!("finalizing block without imported parent: {:?}", header) } let id = justification.header().id(); @@ -202,6 +194,21 @@ impl Finalizer for Backend { }; block.finalize(justification); + + // Check if the previous block was finalized, or this is the last block of the current + // session + let allowed_numbers = match storage.finalized.last() { + Some(id) => [ + id.number + 1, + id.number + storage.session_period + - (id.number + 1).rem_euclid(storage.session_period), + ], + None => [0, storage.session_period - 1], + }; + if !allowed_numbers.contains(&id.number) { + panic!("finalizing a block that is not a child of top finalized (round {:?}), nor the last of a session (round {:?}): round {:?}", allowed_numbers[0], allowed_numbers[1], id.number); + } + storage.finalized.push(id.clone()); // In case finalization changes best block, we set best block, to top finalized. // Whenever a new import happens, best block will update anyway.